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;
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);
}
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
&& 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)) {
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) {
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;
}
/* 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
/* Get trunked VLANs. */
trunks = NULL;
- if (!vlan) {
+ if (vlan < 0) {
size_t n_trunks, n_errors;
size_t i;
.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
\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