From 558e2cc58e16f6e3cee44926d69d385d84d42521 Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Tue, 20 Nov 2012 03:34:03 -0800 Subject: [PATCH] vswitchd: Make Interface's ofport a persistent column. Currently, the 'ofport' column in Interface table is ephemeral and is populated by vswitchd everytime it is started or when a new interface is created with vswitchd running. Making it persistent lets vswitchd try and assign the same ofport number to a particular interface across restarts. This is just a fallback option when 'ofport_request' column is empty. Signed-off-by: Gurucharan Shetty --- vswitchd/bridge.c | 15 +++++++++++---- vswitchd/vswitch.ovsschema | 7 +++---- vswitchd/vswitch.xml | 3 +++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 06d6366f..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); } @@ -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. */ diff --git a/vswitchd/vswitch.ovsschema b/vswitchd/vswitch.ovsschema index fd2bb4bf..293a11b3 100644 --- a/vswitchd/vswitch.ovsschema +++ b/vswitchd/vswitch.ovsschema @@ -1,6 +1,6 @@ {"name": "Open_vSwitch", - "version": "6.11.1", - "cksum": "2684374538 17324", + "version": "6.11.2", + "cksum": "2033079075 17296", "tables": { "Open_vSwitch": { "columns": { @@ -180,8 +180,7 @@ "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}, "ofport": { - "type": {"key": "integer", "min": 0, "max": 1}, - "ephemeral": true}, + "type": {"key": "integer", "min": 0, "max": 1}}, "ofport_request": { "type": { "key": {"type": "integer", diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index c9d0dc43..c2786a5c 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -1164,6 +1164,9 @@ port number for the OpenFlow ``local port''). If the interface cannot be added then Open vSwitch sets this column to -1.

+

When is not set, Open vSwitch picks + an appropriate value for this column and then tries to keep the value + constant across restarts.

-- 2.30.2