From: Ben Pfaff Date: Thu, 1 Jan 2009 22:42:10 +0000 (-0800) Subject: vswitchd: Add support for untagged VLAN ports in VLAN 0. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a92a5b6a6c50992ff9f30d1c970381bbe54a942;p=openvswitch vswitchd: Add support for untagged VLAN ports in VLAN 0. --- diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index c19e2cbf..447a8819 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -115,7 +115,7 @@ struct mirror { struct port { struct bridge *bridge; size_t port_idx; - int vlan; /* 0=trunk port, otherwise a 12-bit VLAN ID. */ + int vlan; /* -1=trunk port, else a 12-bit VLAN ID. */ unsigned long *trunks; /* Trunked VLANs, if 'vlan' == 0. */ const char *name; @@ -1262,8 +1262,8 @@ set_dst(struct ft_dst *p, const struct flow *flow, const struct port *in_port, const struct port *out_port, tag_type *tags) { - p->vlan = (out_port->vlan ? OFP_VLAN_NONE - : in_port->vlan ? in_port->vlan + p->vlan = (out_port->vlan >= 0 ? OFP_VLAN_NONE + : in_port->vlan >= 0 ? in_port->vlan : ntohs(flow->dl_vlan)); return choose_output_iface(out_port, flow, &p->dp_ifidx, tags); } @@ -1366,7 +1366,7 @@ dst_is_duplicate(const struct ft_dst *dsts, size_t n_dsts, static bool port_trunks_vlan(const struct port *port, uint16_t vlan) { - return !port->vlan && bitmap_is_set(port->trunks, vlan); + return port->vlan < 0 && bitmap_is_set(port->trunks, vlan); } static bool @@ -1415,7 +1415,7 @@ compose_dsts(const struct bridge *br, const struct flow *flow, uint16_t vlan, && set_dst(dst, flow, in_port, port, tags) && !dst_is_duplicate(dsts, dst - dsts, dst)) { - if (!port->vlan) { + if (port->vlan < 0) { dst->vlan = m->out_vlan; } if (dst->dp_ifidx == ntohs(flow->in_port)) { @@ -1588,7 +1588,7 @@ process_flow(struct bridge *br, const struct flow *flow, if (vlan == OFP_VLAN_NONE) { vlan = 0; } - if (in_port->vlan) { + if (in_port->vlan >= 0) { if (vlan) { /* XXX support double tagging? */ if (pkt->buf) { @@ -2211,7 +2211,7 @@ port_create(struct bridge *br, const char *name) port = xcalloc(1, sizeof *port); port->bridge = br; port->port_idx = br->n_ports; - port->vlan = 0; + port->vlan = -1; port->trunks = NULL; port->name = xstrdup(name); port->active_iface = -1; @@ -2281,14 +2281,12 @@ port_reconfigure(struct port *port) } /* Get VLAN tag. */ - vlan = 0; + vlan = -1; if (cfg_has("vlan.%s.tag", port->name)) { if (!bonded) { vlan = cfg_get_vlan(0, "vlan.%s.tag", port->name); if (vlan >= 0 && vlan <= 4095) { VLOG_DBG("port %s: assigning VLAN tag %d", port->name, vlan); - } else { - vlan = 0; } } else { /* It's possible that bonded, VLAN-tagged ports make sense. Maybe @@ -2304,7 +2302,7 @@ port_reconfigure(struct port *port) /* Get trunked VLANs. */ trunks = NULL; - if (!vlan) { + if (vlan < 0) { size_t n_trunks, n_errors; size_t i; diff --git a/vswitchd/vswitchd.conf.5 b/vswitchd/vswitchd.conf.5 index 06721a46..121cb545 100644 --- a/vswitchd/vswitchd.conf.5 +++ b/vswitchd/vswitchd.conf.5 @@ -108,7 +108,7 @@ carries VLANs 1, 2, and 3: .PP A bridge port may be configured with an implicit, untagged VLAN. Define key -\fBvlan.\fIport\fB.tag\fR to an integer value \fIvid\fR between 1 and +\fBvlan.\fIport\fB.tag\fR to an integer value \fIvid\fR between 0 and 4095, inclusive, to designate the named \fIport\fR as a member of 802.1Q VLAN \fIvid\fR. When \fIport\fR is assigned a VLAN tag this way, frames arriving on trunk ports will be forwarded to \fIport\fR @@ -117,6 +117,9 @@ other VLAN ports will be forwarded to \fIport\fR only if their \fIvid\fR values are equal. Frames forwarded to \fIport\fR will not have an 802.1Q header. .PP +When \fIvid\fR is 0, frames arriving on trunk ports without an 802.1Q +VLAN header will also be forwarded to \fIport\fR. +.PP When a frame with a 802.1Q header that indicates a nonzero VLAN is received on an implicit VLAN port, it is discarded. .PP