rstp: Add 'rstp-admin-p2p-mac' and 'rstp-admin-port-state' setters.
authorJarno Rajahalme <jrajahalme@nicira.com>
Fri, 14 Nov 2014 22:07:50 +0000 (14:07 -0800)
committerJarno Rajahalme <jrajahalme@nicira.com>
Fri, 14 Nov 2014 22:07:50 +0000 (14:07 -0800)
'rstp-admin-port-state' is the Administrative Bridge Port state
variable defined in the 802.1D-2004 standard.  It can be set to
include or exclude a port from the active topology by management
(section 7.4).

operPointToPointMAC and 'rstp-admin-p2p-mac' are a pair of parameters
that permit inspection of, and control over, the administrative and
operational state of the point-to-point status of the MAC entity by
the MAC Relay Entity.  adminPointToPointMAC can be set by management
and its value is reflected on operPointToPointMAC.

Signed-off-by: Daniele Venturino <daniele.venturino@m3s.it>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
lib/rstp-common.h
lib/rstp.c
lib/rstp.h
ofproto/ofproto-dpif.c
ofproto/ofproto.h
utilities/ovs-vsctl.8.in
vswitchd/bridge.c

index 587f88c..cd43079 100644 (file)
@@ -240,12 +240,6 @@ struct rstp_bpdu {
     uint8_t padding[7];
 });
 
-enum rstp_admin_point_to_point_mac_state {
-    RSTP_ADMIN_P2P_MAC_FORCE_TRUE,
-    RSTP_ADMIN_P2P_MAC_FORCE_FALSE,
-    RSTP_ADMIN_P2P_MAC_FORCE_AUTO
-};
-
 enum rstp_info_is {
     INFO_IS_DISABLED,
     INFO_IS_RECEIVED,
index 0f96749..e457159 100644 (file)
@@ -110,6 +110,9 @@ static void rstp_port_set_admin_edge__(struct rstp_port *, bool admin_edge)
     OVS_REQUIRES(rstp_mutex);
 static void rstp_port_set_auto_edge__(struct rstp_port *, bool auto_edge)
     OVS_REQUIRES(rstp_mutex);
+static void rstp_port_set_admin_point_to_point_mac__(struct rstp_port *,
+        enum rstp_admin_point_to_point_mac_state admin_p2p_mac_state)
+    OVS_REQUIRES(rstp_mutex);
 static void rstp_port_set_mcheck__(struct rstp_port *, bool mcheck)
     OVS_REQUIRES(rstp_mutex);
 static void reinitialize_port__(struct rstp_port *p)
@@ -922,6 +925,9 @@ rstp_port_set_administrative_bridge_port__(struct rstp_port *p,
                                            uint8_t admin_port_state)
     OVS_REQUIRES(rstp_mutex)
 {
+    VLOG_DBG("%s, port %u: set RSTP port admin-port-state to %d",
+             p->rstp->name, p->port_number, admin_port_state);
+
     if (admin_port_state == RSTP_ADMIN_BRIDGE_PORT_STATE_DISABLED
         || admin_port_state == RSTP_ADMIN_BRIDGE_PORT_STATE_ENABLED) {
 
@@ -1120,6 +1126,38 @@ rstp_port_set_auto_edge__(struct rstp_port *port, bool auto_edge)
     }
 }
 
+/* Sets the port admin_point_to_point_mac parameter. */
+static void rstp_port_set_admin_point_to_point_mac__(struct rstp_port *port,
+        enum rstp_admin_point_to_point_mac_state admin_p2p_mac_state)
+    OVS_REQUIRES(rstp_mutex)
+{
+    VLOG_DBG("%s, port %u: set RSTP port admin-point-to-point-mac to %d",
+            port->rstp->name, port->port_number, admin_p2p_mac_state);
+
+    if (admin_p2p_mac_state == RSTP_ADMIN_P2P_MAC_FORCE_TRUE) {
+        port->admin_point_to_point_mac = admin_p2p_mac_state;
+        rstp_port_set_oper_point_to_point_mac__(port,
+                RSTP_OPER_P2P_MAC_STATE_ENABLED);
+    } else if (admin_p2p_mac_state == RSTP_ADMIN_P2P_MAC_FORCE_FALSE) {
+        port->admin_point_to_point_mac = admin_p2p_mac_state;
+        rstp_port_set_oper_point_to_point_mac__(port,
+                RSTP_OPER_P2P_MAC_STATE_DISABLED);
+    } else if (admin_p2p_mac_state == RSTP_ADMIN_P2P_MAC_AUTO) {
+        /* If adminPointToPointMAC is set to Auto, then the value of
+         * operPointToPointMAC is determined in accordance with the
+         * specific procedures defined for the MAC entity concerned, as
+         * defined in 6.5. If these procedures determine that the MAC
+         * entity is connected to a point-to-point LAN, then
+         * operPointToPointMAC is set TRUE; otherwise it is set FALSE.
+         * In the absence of a specific definition of how to determine
+         * whether the MAC is connected to a point-to-point LAN or not,
+         * the value of operPointToPointMAC shall be FALSE. */
+        port->admin_point_to_point_mac = admin_p2p_mac_state;
+        rstp_port_set_oper_point_to_point_mac__(
+            port, RSTP_OPER_P2P_MAC_STATE_DISABLED);
+    }
+}
+
 /* Sets the port mcheck parameter.
  * [17.19.13] May be set by management to force the Port Protocol Migration
  * state machine to transmit RST BPDUs for a MigrateTime (17.13.9) period, to
@@ -1289,7 +1327,8 @@ rstp_port_get_status(const struct rstp_port *p, uint16_t *id,
 void
 rstp_port_set(struct rstp_port *port, uint16_t port_num, int priority,
               uint32_t path_cost, bool is_admin_edge, bool is_auto_edge,
-              bool do_mcheck, void *aux)
+              enum rstp_admin_point_to_point_mac_state admin_p2p_mac_state,
+              bool admin_port_state, bool do_mcheck, void *aux)
     OVS_EXCLUDED(rstp_mutex)
 {
     ovs_mutex_lock(&rstp_mutex);
@@ -1299,6 +1338,8 @@ rstp_port_set(struct rstp_port *port, uint16_t port_num, int priority,
     rstp_port_set_path_cost__(port, path_cost);
     rstp_port_set_admin_edge__(port, is_admin_edge);
     rstp_port_set_auto_edge__(port, is_auto_edge);
+    rstp_port_set_admin_point_to_point_mac__(port, admin_p2p_mac_state);
+    rstp_port_set_administrative_bridge_port__(port, admin_port_state);
     rstp_port_set_mcheck__(port, do_mcheck);
     ovs_mutex_unlock(&rstp_mutex);
 }
index ccf8292..458aecf 100644 (file)
@@ -120,6 +120,12 @@ enum rstp_port_role {
     ROLE_DISABLED
 };
 
+enum rstp_admin_point_to_point_mac_state {
+    RSTP_ADMIN_P2P_MAC_FORCE_FALSE,
+    RSTP_ADMIN_P2P_MAC_FORCE_TRUE,
+    RSTP_ADMIN_P2P_MAC_AUTO
+};
+
 struct rstp;
 struct rstp_port;
 struct ofproto_rstp_settings;
@@ -211,7 +217,8 @@ uint32_t rstp_convert_speed_to_cost(unsigned int speed);
 
 void rstp_port_set(struct rstp_port *, uint16_t port_num, int priority,
                    uint32_t path_cost, bool is_admin_edge, bool is_auto_edge,
-                   bool do_mcheck, void *aux)
+                   enum rstp_admin_point_to_point_mac_state admin_p2p_mac_state,
+                   bool admin_port_state, bool do_mcheck, void *aux)
     OVS_EXCLUDED(rstp_mutex);
 
 enum rstp_state rstp_port_get_state(const struct rstp_port *)
index a056a63..3f034c8 100644 (file)
@@ -2433,7 +2433,9 @@ set_rstp_port(struct ofport *ofport_,
     }
 
     rstp_port_set(rp, s->port_num, s->priority, s->path_cost,
-                  s->admin_edge_port, s->auto_edge, s->mcheck, ofport);
+                  s->admin_edge_port, s->auto_edge,
+                  s->admin_p2p_mac_state, s->admin_port_state, s->mcheck,
+                  ofport);
     update_rstp_port_state(ofport);
     /* Synchronize operational status. */
     rstp_port_set_mac_operational(rp, ofport->may_enable);
index a17d1bc..261bc3b 100644 (file)
@@ -127,6 +127,8 @@ struct ofproto_port_rstp_settings {
     bool admin_edge_port;
     bool auto_edge;
     bool mcheck;
+    uint8_t admin_p2p_mac_state;
+    bool admin_port_state;
 };
 
 struct ofproto_stp_settings {
index 8cf13ae..ddb8410 100644 (file)
@@ -987,8 +987,8 @@ Set the multicast snooping table size \fBbr0\fR to 2048 entries:
 .B "ovs\-vsctl set Bridge br0 other_config:mcast-snooping-table-size=2048"
 .PP
 Disable flooding of unregistered multicast packets to all ports. When
-set to true, the switch will send unregistered multicast packets only
-to ports connected to multicast routers. When it is set to false, the
+set to \fBtrue\fR, the switch will send unregistered multicast packets only
+to ports connected to multicast routers. When it is set to \fBfalse\fR, the
 switch will send them to all ports. This command disables the flood of
 unregistered packets on bridge \fBbr0\fR.
 .IP
@@ -1043,15 +1043,15 @@ Set the bridge transmit hold count of \fBbr0\fR to 7 s. This value should be bet
 .IP
 .B "ovs\-vsctl set Bridge br0 other_config:rstp-transmit-hold-count=7"
 .PP
-Enable RSTP on the Port \fBeth0\fR.
+Enable RSTP on the Port \fBeth0\fR:
 .IP
 .B "ovs\-vsctl set Port eth0 other_config:rstp-enable=true"
 .PP
-Disable RSTP on the Port \fBeth0\fR.
+Disable RSTP on the Port \fBeth0\fR:
 .IP
 .B "ovs\-vsctl set Port eth0 other_config:rstp-enable=false"
 .PP
-Set the priority of port \fBeth0\fR to 20. The value must be specified in
+Set the priority of port \fBeth0\fR to 32. The value must be specified in
 decimal notation and should be a multiple of 16 (if not, it is rounded down to the
 nearest multiple of 16). The default priority value is 0x80 (128).
 .IP
@@ -1073,6 +1073,17 @@ Set the auto edge value of port \fBeth0\fR:
 .IP
 .B "ovs\-vsctl set Port eth0 other_config:rstp-port-auto-edge=true"
 .PP
+Set the admin point to point mac value of port \fBeth0\fR.  Acceptable
+values are 0 (force \fBfalse\fR), 1 (force \fBtrue\fR, the default value) or
+2 (\fBauto\fR).
+.IP
+.B "ovs\-vsctl set Port eth0 other_config:rstp-admin-p2p-mac=1"
+.PP
+Set the admin port state value of port \fBeth0\fR.  \fBtrue\fR is the
+default value.
+.IP
+.B "ovs\-vsctl set Port eth0 other_config:rstp-admin-port-state=false"
+.PP
 Set the mcheck value of port \fBeth0\fR:
 .IP
 .B "ovs\-vsctl set Port eth0 other_config:rstp-port-mcheck=true"
index f346522..fea273a 100644 (file)
@@ -1398,6 +1398,16 @@ port_configure_rstp(const struct ofproto *ofproto, struct port *port,
         port_s->priority = RSTP_DEFAULT_PORT_PRIORITY;
     }
 
+    config_str = smap_get(&port->cfg->other_config, "rstp-admin-p2p-mac");
+    if (config_str) {
+        port_s->admin_p2p_mac_state = strtoul(config_str, NULL, 0);
+    } else {
+        port_s->admin_p2p_mac_state = RSTP_ADMIN_P2P_MAC_FORCE_TRUE;
+    }
+
+    port_s->admin_port_state = smap_get_bool(&port->cfg->other_config,
+                                             "rstp-admin-port-state", true);
+
     port_s->admin_edge_port = smap_get_bool(&port->cfg->other_config,
                                             "rstp-port-admin-edge", false);
     port_s->auto_edge = smap_get_bool(&port->cfg->other_config,