From 92cf817bad93a29079788ebbc233a8df0afca241 Mon Sep 17 00:00:00 2001 From: Alex Wang Date: Wed, 4 Sep 2013 15:21:15 -0700 Subject: [PATCH] ofproto-dpif-xlate: Fix confusion between "no stp port" and "stp port 0". Commit 9d189a50e (ofproto-dpif-xlate: Pull STP xlation into ofproto-dpif-xlate.) introduced the bug that considers 'stp_port_no' of 0 as stp disabled on the port. However 'stp_port_no' is actually the index of the stp struct's port array and ranges between [0, STP_MAX_PORTS). So the bug allows the blocked port keep transmitting packets and generates loop. This commit fixes this bug. Signed-off-by: Alex Wang Signed-off-by: Ben Pfaff --- ofproto/ofproto-dpif-xlate.c | 4 ++-- ofproto/ofproto-dpif.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index ef254d9d6..b276ecd86 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -121,7 +121,7 @@ struct xport { struct xport *peer; /* Patch port peer or null. */ enum ofputil_port_config config; /* OpenFlow port configuration. */ - int stp_port_no; /* STP port number or 0 if not in use. */ + int stp_port_no; /* STP port number or -1 if not in use. */ struct hmap skb_priorities; /* Map of 'skb_priority_to_dscp's. */ @@ -621,7 +621,7 @@ xport_lookup(const struct ofport_dpif *ofport) static struct stp_port * xport_get_stp_port(const struct xport *xport) { - return xport->xbridge->stp && xport->stp_port_no + return xport->xbridge->stp && xport->stp_port_no != -1 ? stp_get_port(xport->xbridge->stp, xport->stp_port_no) : NULL; } diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 0ce2ee046..e824891ee 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -821,7 +821,7 @@ type_run(const char *type) HMAP_FOR_EACH (ofport, up.hmap_node, &ofproto->up.ports) { int stp_port = ofport->stp_port ? stp_port_no(ofport->stp_port) - : 0; + : -1; xlate_ofport_set(ofproto, ofport->bundle, ofport, ofport->up.ofp_port, ofport->odp_port, ofport->up.netdev, ofport->cfm, -- 2.43.0