/* 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
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. */
};
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);
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,
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);
}