Get rid of per-port STP implemented bits, by reducing OFPP_MAX to 255.
authorBen Pfaff <blp@nicira.com>
Sat, 20 Sep 2008 00:02:30 +0000 (17:02 -0700)
committerBen Pfaff <blp@nicira.com>
Sat, 20 Sep 2008 00:07:47 +0000 (17:07 -0700)
802.1D Spanning Tree Protocol supports a maximum of 255 ports per bridge,
but OpenFlow supported 256, so 1 port had to not implement STP.  This
gets rid of the problem by reducing the maximum number of ports to 255.

include/openflow.h
lib/learning-switch.c
secchan/secchan.c

index 632ac42..c81cea3 100644 (file)
@@ -76,7 +76,7 @@
 /* Port numbering.  Physical ports are numbered starting from 0. */
 enum ofp_port {
     /* Maximum number of physical switch ports. */
-    OFPP_MAX = 0x100,
+    OFPP_MAX = 255,
 
     /* Fake output "ports". */
     OFPP_IN_PORT    = 0xfff8,  /* Send the packet out the input port.  This 
@@ -213,7 +213,6 @@ enum ofp_port_features {
     OFPPF_1GB_HD     = 1 << 4, /* 1 Gb half-duplex rate support. */
     OFPPF_1GB_FD     = 1 << 5, /* 1 Gb full-duplex rate support. */
     OFPPF_10GB_FD    = 1 << 6, /* 10 Gb full-duplex rate support. */
-    OFPPF_STP        = 1 << 7, /* 802.1D spanning tree supported on port. */
 };
 
 
index fedf73e..25c2c59 100644 (file)
@@ -291,7 +291,7 @@ static void
 process_phy_port(struct lswitch *sw, struct rconn *rconn,
                  const struct ofp_phy_port *opp)
 {
-    if (sw->capabilities & OFPC_STP && opp->features & ntohl(OFPPF_STP)) {
+    if (sw->capabilities & OFPC_STP && ntohs(opp->port_no) < OFPP_MAX) {
         uint32_t flags = ntohl(opp->flags);
         uint32_t new_flags = flags & ~(OFPPFL_NO_RECV | OFPPFL_NO_RECV_STP
                                        | OFPPFL_NO_FWD | OFPPFL_NO_PACKET_IN);
index 341e146..44f51d3 100644 (file)
@@ -1122,20 +1122,12 @@ send_bpdu(const void *bpdu, size_t bpdu_size, int port_no, void *stp_)
 static bool
 stp_is_port_supported(uint16_t port_no)
 {
-    /* STP only supports a maximum of 255 ports, one less than OpenFlow.  We
-     * don't support STP on OFPP_LOCAL, either.  */
+    /* We should be able to support STP on all possible OpenFlow physical
+     * ports.  (But we don't support STP on OFPP_LOCAL.)  */
+    BUILD_ASSERT_DECL(STP_MAX_PORTS >= OFPP_MAX);
     return port_no < STP_MAX_PORTS;
 }
 
-static void
-stp_edit_port_cb(struct ofp_phy_port *p, void *stp_ UNUSED)
-{
-    uint16_t port_no = ntohs(p->port_no);
-    if (stp_is_port_supported(port_no)) {
-        p->features |= htonl(OFPPF_STP);
-    }
-}
-
 static void
 stp_port_changed_cb(uint16_t port_no,
                     const struct ofp_phy_port *old,
@@ -1183,8 +1175,7 @@ stp_hook_create(const struct settings *s, struct port_watcher *pw,
     stp->remote_rconn = remote;
     stp->last_tick_256ths = time_256ths();
 
-    port_watcher_register_callback(pw, stp_edit_port_cb,
-                                   stp_port_changed_cb, stp);
+    port_watcher_register_callback(pw, NULL, stp_port_changed_cb, stp);
     return make_hook(stp_local_packet_cb, NULL,
                      stp_periodic_cb, stp_wait_cb, stp);
 }