From: Huanle Han Date: Wed, 15 Jul 2015 15:41:05 +0000 (+0800) Subject: ovs-appctl: register unixctl commands in the beginning X-Git-Tag: v2.4.0~33 X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fovs.git;a=commitdiff_plain;h=b25702bc920b14cb2bf7b832c6f14a1dc44d203b ovs-appctl: register unixctl commands in the beginning Some commands of ovs-appctl were lazily registered when first bridg or bfd was added. Before that, calling these commands raised a error("xxx is not a valid command"). The problem commangs included "bfd/...", "upcall/...","dpif/...","fdb/..." and so on. Fix this by moving the register into the "bridge_init" and "bridge_init_ofproto". All commands are registered at the moment ovs-vswitchd starts. Signed-off-by: Huanle Han Signed-off-by: Ben Pfaff --- diff --git a/lib/bfd.c b/lib/bfd.c index 92fdbd899..889c76eb2 100644 --- a/lib/bfd.c +++ b/lib/bfd.c @@ -329,6 +329,16 @@ bfd_get_status(const struct bfd *bfd, struct smap *smap) ovs_mutex_unlock(&mutex); } +void +bfd_init(void) +{ + unixctl_command_register("bfd/show", "[interface]", 0, 1, + bfd_unixctl_show, NULL); + unixctl_command_register("bfd/set-forwarding", + "[interface] normal|false|true", 1, 2, + bfd_unixctl_set_forwarding_override, NULL); +} + /* Initializes, destroys, or reconfigures the BFD session 'bfd' (named 'name'), * according to the database configuration contained in 'cfg'. Takes ownership * of 'bfd', which may be NULL. Returns a BFD object which may be used as a @@ -338,7 +348,6 @@ struct bfd * bfd_configure(struct bfd *bfd, const char *name, const struct smap *cfg, struct netdev *netdev) OVS_EXCLUDED(mutex) { - static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; static atomic_count udp_src = ATOMIC_COUNT_INIT(0); int decay_min_rx; @@ -350,15 +359,6 @@ bfd_configure(struct bfd *bfd, const char *name, const struct smap *cfg, struct in_addr in_addr; uint8_t ea[ETH_ADDR_LEN]; - if (ovsthread_once_start(&once)) { - unixctl_command_register("bfd/show", "[interface]", 0, 1, - bfd_unixctl_show, NULL); - unixctl_command_register("bfd/set-forwarding", - "[interface] normal|false|true", 1, 2, - bfd_unixctl_set_forwarding_override, NULL); - ovsthread_once_done(&once); - } - if (!cfg || !smap_get_bool(cfg, "enable", false)) { bfd_unref(bfd); return NULL; diff --git a/lib/bfd.h b/lib/bfd.h index 19d294f82..19da3a3f7 100644 --- a/lib/bfd.h +++ b/lib/bfd.h @@ -43,6 +43,7 @@ bool bfd_should_process_flow(const struct bfd *, const struct flow *, void bfd_process_packet(struct bfd *, const struct flow *, const struct dp_packet *); +void bfd_init(void); struct bfd *bfd_configure(struct bfd *, const char *name, const struct smap *smap, struct netdev *netdev); diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c index c39b5712e..4f607d6f3 100644 --- a/ofproto/ofproto-dpif-upcall.c +++ b/ofproto/ofproto-dpif-upcall.c @@ -304,12 +304,10 @@ static upcall_callback upcall_cb; static atomic_bool enable_megaflows = ATOMIC_VAR_INIT(true); static atomic_bool enable_ufid = ATOMIC_VAR_INIT(true); -struct udpif * -udpif_create(struct dpif_backer *backer, struct dpif *dpif) +void +udpif_init(void) { static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER; - struct udpif *udpif = xzalloc(sizeof *udpif); - if (ovsthread_once_start(&once)) { unixctl_command_register("upcall/show", "", 0, 0, upcall_unixctl_show, NULL); @@ -329,6 +327,12 @@ udpif_create(struct dpif_backer *backer, struct dpif *dpif) upcall_unixctl_purge, NULL); ovsthread_once_done(&once); } +} + +struct udpif * +udpif_create(struct dpif_backer *backer, struct dpif *dpif) +{ + struct udpif *udpif = xzalloc(sizeof *udpif); udpif->dpif = dpif; udpif->backer = backer; diff --git a/ofproto/ofproto-dpif-upcall.h b/ofproto/ofproto-dpif-upcall.h index ec19bd0f0..efa3cd190 100644 --- a/ofproto/ofproto-dpif-upcall.h +++ b/ofproto/ofproto-dpif-upcall.h @@ -28,6 +28,7 @@ struct simap; * them. Additionally, it's responsible for maintaining the datapath flow * table. */ +void udpif_init(void); struct udpif *udpif_create(struct dpif_backer *, struct dpif *); void udpif_run(struct udpif *udpif); void udpif_set_threads(struct udpif *, size_t n_handlers, diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 8575b1cfa..b08ea5d7c 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -443,6 +443,9 @@ init(const struct shash *iface_hints) shash_add(&init_ofp_ports, node->name, new_hint); } + + ofproto_unixctl_init(); + udpif_init(); } static void @@ -1256,8 +1259,6 @@ construct(struct ofproto *ofproto_) guarded_list_init(&ofproto->pins); - ofproto_unixctl_init(); - hmap_init(&ofproto->vlandev_map); hmap_init(&ofproto->realdev_vid_map); diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 42bbc9b67..6dda3cdba 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -379,6 +379,8 @@ ofproto_init(const struct shash *iface_hints) for (i = 0; i < n_ofproto_classes; i++) { ofproto_classes[i]->init(&init_ofp_ports); } + + ofproto_unixctl_init(); } /* 'type' should be a normalized datapath type, as returned by @@ -507,8 +509,6 @@ ofproto_create(const char *datapath_name, const char *datapath_type, *ofprotop = NULL; - ofproto_unixctl_init(); - datapath_type = ofproto_normalize_type(datapath_type); class = ofproto_class_find__(datapath_type); if (!class) { diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index d48cf7ff1..cecfad48b 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -473,6 +473,7 @@ bridge_init(const char *remote) lacp_init(); bond_init(); cfm_init(); + bfd_init(); ovs_numa_init(); stp_init(); lldp_init();