From 29a4d815e647ad311f240f977083f86ebb099ad0 Mon Sep 17 00:00:00 2001 From: Han Zhou Date: Mon, 26 Feb 2024 22:36:02 -0800 Subject: [PATCH] temp Signed-off-by: Han Zhou --- vswitchd/bridge.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 95a65fcdcd5..18d6fb5b76b 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -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 *); @@ -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; @@ -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); } @@ -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 @@ -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; @@ -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 @@ -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);