From 419d76711d09e6999c42d1bf8b3b01c91c48d4a8 Mon Sep 17 00:00:00 2001 From: Justin Pettit Date: Tue, 17 Mar 2009 17:35:00 -0700 Subject: [PATCH] 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. --- vswitchd/bridge.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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; -- 2.30.2