~james-page/ubuntu/saucy/openvswitch/1.12-snapshot

« back to all changes in this revision

Viewing changes to utilities/ovs-ctl.in

  • Committer: James Page
  • Date: 2013-08-21 10:16:57 UTC
  • mfrom: (1.1.20)
  • Revision ID: james.page@canonical.com-20130821101657-3o0z0qeiv5zkwlzi
New upstream snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
## start ##
31
31
## ----- ##
32
32
 
33
 
insert_openvswitch_mod_if_required () {
 
33
insert_mod_if_required () {
34
34
    # If openvswitch is already loaded then we're done.
35
35
    test -e /sys/module/openvswitch -o -e /sys/module/openvswitch_mod && \
36
36
     return 0
52
52
    action "Inserting openvswitch module" modprobe openvswitch
53
53
}
54
54
 
55
 
insert_mod_if_required () {
56
 
    insert_openvswitch_mod_if_required || return 1
57
 
}
58
 
 
59
55
ovs_vsctl () {
60
56
    ovs-vsctl --no-wait "$@"
61
57
}
157
153
 
158
154
check_force_cores () {
159
155
    if test X"$FORCE_COREFILES" = Xyes; then
160
 
        ulimit -Sc 67108864
 
156
        ulimit -c 67108864
161
157
    fi
162
158
}
163
159
 
206
202
    fi
207
203
}
208
204
 
 
205
add_managers () {
 
206
    # Now that ovs-vswitchd has started and completed its initial
 
207
    # configuration, tell ovsdb-server to conenct to the remote managers.  We
 
208
    # used to do this at ovsdb-server startup time, but waiting for
 
209
    # ovs-vswitchd to finish configuring means that remote managers see less
 
210
    # churn in the database at startup or restart.  (For example, managers
 
211
    # won't briefly see empty datapath-id or ofport columns for records that
 
212
    # exist at startup.)
 
213
    action "Enabling remote OVSDB managers" \
 
214
        ovs-appctl -t ovsdb-server ovsdb-server/add-remote \
 
215
            db:Open_vSwitch,Open_vSwitch,manager_options
 
216
}
 
217
 
209
218
start_forwarding () {
210
219
    check_force_cores
211
220
 
215
224
        log_success_msg "ovs-vswitchd is already running"
216
225
    else
217
226
        # Increase the limit on the number of open file descriptors.
218
 
        # On Linux, ovs-vswitchd needs about one file descriptor per
219
 
        # switch port, so this allows a very large number of switch
220
 
        # ports.
221
 
        ulimit -n 5000
 
227
        # On Linux, ovs-vswitchd needs about three file descriptors
 
228
        # per bridge and one file descriptor per bridge port, so this
 
229
        # allows a very large number of bridges and ports.
 
230
        ulimit -n 7500
222
231
 
223
232
            # Start ovs-vswitchd.
224
233
            set ovs-vswitchd unix:"$DB_SOCK"
228
237
            fi
229
238
            start_daemon "$OVS_VSWITCHD_PRIORITY" "$OVS_VSWITCHD_WRAPPER" "$@"
230
239
    fi
231
 
 
232
 
    # Now that ovs-vswitchd has started and completed its initial
233
 
    # configuration, tell ovsdb-server to conenct to the remote managers.  We
234
 
    # used to do this at ovsdb-server startup time, but waiting for
235
 
    # ovs-vswitchd to finish configuring means that remote managers see less
236
 
    # churn in the database at startup or restart.  (For example, managers
237
 
    # won't briefly see empty datapath-id or ofport columns for records that
238
 
    # exist at startup.)
239
 
    action "Enabling remote OVSDB managers" \
240
 
        ovs-appctl -t ovsdb-server ovsdb-server/add-remote \
241
 
            db:Open_vSwitch,Open_vSwitch,manager_options
242
240
}
243
241
 
244
242
## ---- ##
308
306
        action "Restoring ofport values" "${script_ofports}"
309
307
}
310
308
 
 
309
flow_restore_wait () {
 
310
    ovs_vsctl set open_vswitch . other_config:flow-restore-wait="true"
 
311
}
 
312
 
 
313
flow_restore_complete () {
 
314
    ovs_vsctl --if-exists remove open_vswitch . other_config \
 
315
        flow-restore-wait="true"
 
316
}
 
317
 
311
318
restore_flows () {
312
319
    [ -x "${script_flows}" ] && \
313
320
        action "Restoring saved flows" "${script_flows}"
359
366
    else
360
367
        log_warning_msg "Failed to save configuration, not replacing kernel module"
361
368
        start_forwarding
 
369
        add_managers
362
370
        exit 1
363
371
    fi
364
372
    chmod +x "$script_interfaces"
374
382
        action "Removing openvswitch module" rmmod openvswitch
375
383
    fi
376
384
 
 
385
    # Start vswitchd by asking it to wait till flow restore is finished.
 
386
    flow_restore_wait
377
387
    start_forwarding
378
388
 
 
389
    # Restore saved flows and inform vswitchd that we are done.
379
390
    restore_flows
 
391
    flow_restore_complete
 
392
    add_managers
380
393
 
381
394
    restore_interfaces
382
395
 
418
431
    restore_ofports
419
432
 
420
433
    stop_forwarding
 
434
 
 
435
    # Start vswitchd by asking it to wait till flow restore is finished.
 
436
    flow_restore_wait
421
437
    start_forwarding
422
438
 
423
 
    # Restore the saved flows.
 
439
    # Restore saved flows and inform vswitchd that we are done.
424
440
    restore_flows
 
441
    flow_restore_complete
 
442
    add_managers
425
443
 
426
444
    # Restore the interfaces if required. Return true even if restore fails.
427
445
    restore_interfaces || true
668
686
    start)
669
687
        start_ovsdb
670
688
        start_forwarding
 
689
        add_managers
671
690
        ;;
672
691
    stop)
673
692
        stop_forwarding