This commit provides an option to enable or disable packet processing coming from the datapath.
This option is useful during Open vSwitch upgrades. Typically we want to restart openvswitch, add the openflow flows and then start packet processing. The next commit will use these commands in Open vSwitch startup scripts. Bug #16086. Signed-off-by: Gurucharan Shetty <gshe...@nicira.com> --- ofproto/ofproto.c | 5 +++++ vswitchd/ovs-vswitchd.8.in | 4 ++++ vswitchd/ovs-vswitchd.c | 26 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 262493e..b36a165 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -226,6 +226,8 @@ static struct shash init_ofp_ports = SHASH_INITIALIZER(&init_ofp_ports); static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); +extern bool packet_recv_enable; + /* Must be called to initialize the ofproto library. * * The caller may pass in 'iface_hints', which contains an shash of @@ -338,6 +340,9 @@ void ofproto_enumerate_types(struct sset *types) { size_t i; + if (!packet_recv_enable) { + return; + } for (i = 0; i < n_ofproto_classes; i++) { ofproto_classes[i]->enumerate_types(types); diff --git a/vswitchd/ovs-vswitchd.8.in b/vswitchd/ovs-vswitchd.8.in index 43c5d24..b078485 100644 --- a/vswitchd/ovs-vswitchd.8.in +++ b/vswitchd/ovs-vswitchd.8.in @@ -108,6 +108,10 @@ how to configure Open vSwitch. .SS "GENERAL COMMANDS" .IP "\fBexit\fR" Causes \fBovs\-vswitchd\fR to gracefully terminate. +.IP "\fBrecv\-enable\fR" +Enables \fBovs\-vswitchd\fR to start processing the packets from the datapath. +.IP "\fBrecv\-disable\fR" +Disables \fBovs\-vswitchd\fR from processing the packets from the datapath. .IP "\fBqos/show\fR \fIinterface\fR" Queries the kernel for Quality of Service configuration and statistics associated with the given \fIinterface\fR. diff --git a/vswitchd/ovs-vswitchd.c b/vswitchd/ovs-vswitchd.c index 78ebd31..67e44e0 100644 --- a/vswitchd/ovs-vswitchd.c +++ b/vswitchd/ovs-vswitchd.c @@ -59,7 +59,13 @@ VLOG_DEFINE_THIS_MODULE(vswitchd); * the kernel from paging any of its memory to disk. */ static bool want_mlockall; +/* If set (default), enables processing packets from the datapath. It can be + * set/unset through the unixctl recv-enable recv-disable commands. */ +bool packet_recv_enable = true; + static unixctl_cb_func ovs_vswitchd_exit; +static unixctl_cb_func ovs_vswitchd_recv_enable; +static unixctl_cb_func ovs_vswitchd_recv_disable; static char *parse_options(int argc, char *argv[], char **unixctl_path); static void usage(void) NO_RETURN; @@ -102,6 +108,10 @@ main(int argc, char *argv[]) exit(EXIT_FAILURE); } unixctl_command_register("exit", "", 0, 0, ovs_vswitchd_exit, &exiting); + unixctl_command_register("recv-enable", "", 0, 0, ovs_vswitchd_recv_enable, + NULL); + unixctl_command_register("recv-disable", "", 0, 0, + ovs_vswitchd_recv_disable, NULL); bridge_init(remote); free(remote); @@ -273,3 +283,19 @@ ovs_vswitchd_exit(struct unixctl_conn *conn, int argc OVS_UNUSED, *exiting = true; unixctl_command_reply(conn, NULL); } + +static void +ovs_vswitchd_recv_enable(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED) +{ + packet_recv_enable = true; + unixctl_command_reply(conn, NULL); +} + +static void +ovs_vswitchd_recv_disable(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED) +{ + packet_recv_enable = false; + unixctl_command_reply(conn, NULL); +} -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev