X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=vswitchd%2Fbridge.c;h=e9a161676d01ccaf1c964c6da04b1ce37ee4eecd;hb=refs%2Fheads%2Fmanual;hp=d1e24d0eeaaeba8c376cf63be5bb99dd269e40c5;hpb=7beaa082d7f422dda337780d6dd457b9a5ffe7d5;p=openvswitch diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index d1e24d0e..e9a16167 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -247,6 +247,7 @@ static void iface_refresh_cfm_stats(struct iface *); static void iface_refresh_stats(struct iface *); static void iface_refresh_status(struct iface *); static bool iface_is_synthetic(const struct iface *); +static int64_t iface_pick_ofport(const struct ovsrec_interface *); /* Linux VLAN device support (e.g. "eth0.10" for VLAN 10.) * @@ -295,8 +296,7 @@ bridge_init_ofproto(const struct ovsrec_open_vswitch *cfg) iface_hint = xmalloc(sizeof *iface_hint); iface_hint->br_name = br_cfg->name; iface_hint->br_type = br_cfg->datapath_type; - iface_hint->ofp_port = if_cfg->n_ofport_request ? - *if_cfg->ofport_request : OFPP_NONE; + iface_hint->ofp_port = iface_pick_ofport(if_cfg); shash_add(&iface_hints, if_cfg->name, iface_hint); } @@ -1245,7 +1245,7 @@ bridge_refresh_one_ofp_port(struct bridge *br, * configured as the user requested, so we must destroy it. */ return false; } else { - /* It's the right type and configured correctly. keep it. */ + /* It's the right type and configured correctly. Keep it. */ iface_set_ofp_port(iface, ofp_port); return true; } @@ -1404,6 +1404,7 @@ iface_create(struct bridge *br, struct if_cfg *if_cfg, int ofp_port) error = iface_do_create(br, if_cfg, &ofp_port, &netdev); bridge_run_fast(); if (error) { + iface_set_ofport(iface_cfg, -1); iface_clear_db_record(iface_cfg); ok = false; goto done; @@ -2545,7 +2546,7 @@ bridge_queue_if_cfg(struct bridge *br, if_cfg->cfg = cfg; if_cfg->parent = parent; - if_cfg->ofport = cfg->n_ofport_request ? *cfg->ofport_request : OFPP_NONE; + if_cfg->ofport = iface_pick_ofport(cfg); hmap_insert(&br->if_cfg_todo, &if_cfg->hmap_node, hash_string(if_cfg->cfg->name, 0)); } @@ -3308,7 +3309,6 @@ static void iface_clear_db_record(const struct ovsrec_interface *if_cfg) { if (!ovsdb_idl_row_is_synthetic(&if_cfg->header_)) { - iface_set_ofport(if_cfg, -1); ovsrec_interface_set_status(if_cfg, NULL); ovsrec_interface_set_admin_state(if_cfg, NULL); ovsrec_interface_set_duplex(if_cfg, NULL); @@ -3478,6 +3478,13 @@ iface_is_synthetic(const struct iface *iface) return ovsdb_idl_row_is_synthetic(&iface->cfg->header_); } +static int64_t +iface_pick_ofport(const struct ovsrec_interface *cfg) +{ + int64_t ofport = cfg->n_ofport ? *cfg->ofport : OFPP_NONE; + return cfg->n_ofport_request ? *cfg->ofport_request : ofport; +} + /* Port mirroring. */