X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=vswitchd%2Fbridge.c;h=d1e24d0eeaaeba8c376cf63be5bb99dd269e40c5;hb=7beaa082d7f422dda337780d6dd457b9a5ffe7d5;hp=dbce59a32d50177a6cc6f58d8b2fdc96ea498351;hpb=b4f4b737f901a43eba962bec2280b52b95ad10d5;p=openvswitch diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index dbce59a3..d1e24d0e 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -36,6 +36,7 @@ #include "meta-flow.h" #include "netdev.h" #include "ofp-print.h" +#include "ofp-util.h" #include "ofpbuf.h" #include "ofproto/ofproto.h" #include "poll-loop.h" @@ -227,6 +228,8 @@ static void mirror_refresh_stats(struct mirror *); static void iface_configure_lacp(struct iface *, struct lacp_slave_settings *); static bool iface_create(struct bridge *, struct if_cfg *, int ofp_port); +static bool iface_is_internal(const struct ovsrec_interface *iface, + const struct ovsrec_bridge *br); static const char *iface_get_type(const struct ovsrec_interface *, const struct ovsrec_bridge *); static void iface_destroy(struct iface *); @@ -812,6 +815,18 @@ bridge_configure_datapath_id(struct bridge *br) free(dpid_string); } +/* Returns a bitmap of "enum ofputil_protocol"s that are allowed for use with + * 'br'. */ +static uint32_t +bridge_get_allowed_versions(struct bridge *br) +{ + if (!br->cfg->n_protocols) + return 0; + + return ofputil_versions_from_strings(br->cfg->protocols, + br->cfg->n_protocols); +} + /* Set NetFlow configuration on 'br'. */ static void bridge_configure_netflow(struct bridge *br) @@ -1347,7 +1362,8 @@ iface_do_create(const struct bridge *br, br->name, iface_cfg->name, *ofp_portp); } - if (port_cfg->vlan_mode && !strcmp(port_cfg->vlan_mode, "splinter")) { + if ((port_cfg->vlan_mode && !strcmp(port_cfg->vlan_mode, "splinter")) + || iface_is_internal(iface_cfg, br->cfg)) { netdev_turn_flags_on(netdev, NETDEV_UP, true); } @@ -2797,7 +2813,8 @@ bridge_configure_remotes(struct bridge *br, n_ocs++; } - ofproto_set_controllers(br->ofproto, ocs, n_ocs, 0); + ofproto_set_controllers(br->ofproto, ocs, n_ocs, + bridge_get_allowed_versions(br)); free(ocs[0].target); /* From bridge_ofproto_controller_for_mgmt(). */ free(ocs); @@ -3135,6 +3152,14 @@ port_is_synthetic(const struct port *port) /* Interface functions. */ +static bool +iface_is_internal(const struct ovsrec_interface *iface, + const struct ovsrec_bridge *br) +{ + /* The local port and "internal" ports are always "internal". */ + return !strcmp(iface->type, "internal") || !strcmp(iface->name, br->name); +} + /* Returns the correct network device type for interface 'iface' in bridge * 'br'. */ static const char * @@ -3146,7 +3171,7 @@ iface_get_type(const struct ovsrec_interface *iface, /* The local port always has type "internal". Other ports take * their type from the database and default to "system" if none is * specified. */ - if (!strcmp(iface->name, br->name)) { + if (iface_is_internal(iface, br)) { type = "internal"; } else { type = iface->type[0] ? iface->type : "system";