Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
Signed-off-by: Han Zhou <[email protected]>
  • Loading branch information
hzhou8 committed Feb 27, 2024
1 parent 166ee41 commit 29a4d81
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions vswitchd/bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ static void bridge_delete_ofprotos(void);
static void bridge_delete_or_reconfigure_ports(struct bridge *);
static void bridge_del_ports(struct bridge *,
const struct shash *wanted_ports);
static void bridge_add_ports(struct bridge *,
static bool bridge_add_ports(struct bridge *,
const struct shash *wanted_ports);

static void bridge_configure_datapath_id(struct bridge *);
Expand Down Expand Up @@ -858,7 +858,7 @@ datapath_reconfigure(const struct ovsrec_open_vswitch *cfg)
}
}

static void
static bool
bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
{
struct sockaddr_in *managers;
Expand Down Expand Up @@ -943,8 +943,11 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)

config_ofproto_types(&ovs_cfg->other_config);

bool add_port_res = true;
HMAP_FOR_EACH (br, node, &all_bridges) {
bridge_add_ports(br, &br->wanted_ports);
if (!bridge_add_ports(br, &br->wanted_ports)) {
add_port_res = false;
}
shash_destroy(&br->wanted_ports);
}

Expand Down Expand Up @@ -1003,6 +1006,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
* narrow race window in which e.g. ofproto/trace will not recognize the
* new configuration (sometimes this causes unit test failures). */
bridge_run__();
return add_port_res;
}

/* Delete ofprotos which aren't configured or have the wrong type. Create
Expand Down Expand Up @@ -1197,11 +1201,12 @@ bridge_delete_or_reconfigure_ports(struct bridge *br)
sset_destroy(&ofproto_ports);
}

static void
static bool
bridge_add_ports__(struct bridge *br, const struct shash *wanted_ports,
bool with_requested_port)
{
struct shash_node *port_node;
int ret = true;

SHASH_FOR_EACH (port_node, wanted_ports) {
const struct ovsrec_port *port_cfg = port_node->data;
Expand All @@ -1215,24 +1220,26 @@ bridge_add_ports__(struct bridge *br, const struct shash *wanted_ports,
if ((requested_ofp_port != OFPP_NONE) == with_requested_port) {
struct iface *iface = iface_lookup(br, iface_cfg->name);

if (!iface) {
iface_create(br, iface_cfg, port_cfg);
if (!iface && !iface_create(br, iface_cfg, port_cfg)) {
ret = false;
}
}
}
}
return ret;
}

static void
static bool
bridge_add_ports(struct bridge *br, const struct shash *wanted_ports)
{
/* First add interfaces that request a particular port number. */
bridge_add_ports__(br, wanted_ports, true);
int ret1 = bridge_add_ports__(br, wanted_ports, true);

/* Then add interfaces that want automatic port number assignment.
* We add these afterward to avoid accidentally taking a specifically
* requested port number. */
bridge_add_ports__(br, wanted_ports, false);
int ret2 = bridge_add_ports__(br, wanted_ports, false);
return ret1 && ret2;
}

static void
Expand Down Expand Up @@ -3364,7 +3371,9 @@ bridge_run(void)

idl_seqno = ovsdb_idl_get_seqno(idl);
txn = ovsdb_idl_txn_create(idl);
bridge_reconfigure(cfg ? cfg : &null_cfg);
if (!bridge_reconfigure(cfg ? cfg : &null_cfg)) {
bridge_reconfigure(cfg ? cfg : &null_cfg);
}

if (cfg) {
ovsrec_open_vswitch_set_cur_cfg(cfg, cfg->next_cfg);
Expand Down

0 comments on commit 29a4d81

Please sign in to comment.