From: Justin Pettit Date: Wed, 18 Mar 2009 00:35:00 +0000 (-0700) Subject: Fix mirroring when no selection criteria provided. (Bug #1112) X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=419d76711d09e6999c42d1bf8b3b01c91c48d4a8;p=openvswitch Fix mirroring when no selection criteria provided. (Bug #1112) Mirroring wouldn't occur when no selection criteria was provided. If a source/destination port or vlan were provided, mirroring would work as expected. This fixes that. --- diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 5f2c3e08..0429a6d1 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -2148,6 +2148,7 @@ mirror_reconfigure_one(struct mirror *m) size_t n_vlans; int *vlans; size_t i; + bool mirror_all_ports; /* Get output port. */ out_port_name = cfg_get_key(0, "mirror.%s.%s.output.port", @@ -2215,12 +2216,16 @@ mirror_reconfigure_one(struct mirror *m) m->out_port = out_port; m->out_vlan = out_vlan; + /* If no selection criteria have been given, mirror for all ports. */ + mirror_all_ports = (!m->src_ports.n) && (!m->dst_ports.n) && (!m->n_vlans); + /* Update ports. */ mirror_bit = MIRROR_MASK_C(1) << m->idx; for (i = 0; i < m->bridge->n_ports; i++) { struct port *port = m->bridge->ports[i]; - if (svec_contains(&m->src_ports, port->name) + if (mirror_all_ports + || svec_contains(&m->src_ports, port->name) || (m->n_vlans && (!port->vlan ? port_trunks_any_mirrored_vlan(m, port) @@ -2230,7 +2235,7 @@ mirror_reconfigure_one(struct mirror *m) port->src_mirrors &= ~mirror_bit; } - if (svec_contains(&m->dst_ports, port->name)) { + if (mirror_all_ports || svec_contains(&m->dst_ports, port->name)) { port->dst_mirrors |= mirror_bit; } else { port->dst_mirrors &= ~mirror_bit;