All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit b25702bc authored by Huanle Han's avatar Huanle Han Committed by Ben Pfaff

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: default avatarHuanle Han <hanxueluo@gmail.com>
Signed-off-by: default avatarBen Pfaff <blp@nicira.com>
parent 951a9873
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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,
......
......@@ -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);
......
......@@ -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) {
......
......@@ -473,6 +473,7 @@ bridge_init(const char *remote)
lacp_init();
bond_init();
cfm_init();
bfd_init();
ovs_numa_init();
stp_init();
lldp_init();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment