From 512f02d40587f4df648597b2aa878859d63b645e Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 19 Sep 2008 17:02:30 -0700 Subject: [PATCH] Get rid of per-port STP implemented bits, by reducing OFPP_MAX to 255. 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 | 3 +-- lib/learning-switch.c | 2 +- secchan/secchan.c | 17 ++++------------- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/include/openflow.h b/include/openflow.h index 632ac425c..c81cea3f9 100644 --- a/include/openflow.h +++ b/include/openflow.h @@ -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. */ }; diff --git a/lib/learning-switch.c b/lib/learning-switch.c index fedf73eec..25c2c5913 100644 --- a/lib/learning-switch.c +++ b/lib/learning-switch.c @@ -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); diff --git a/secchan/secchan.c b/secchan/secchan.c index 341e146c2..44f51d3ed 100644 --- a/secchan/secchan.c +++ b/secchan/secchan.c @@ -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); } -- 2.45.2