ofproto-dpif-xlate: Rewrite mirroring to better fit flow translation.
authorBen Pfaff <blp@nicira.com>
Thu, 30 Jul 2015 00:00:49 +0000 (17:00 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 31 Jul 2015 22:14:37 +0000 (15:14 -0700)
commit7efbc3b7c4006caed79cc9afa799cd0f9b8f5d38
tree2465d5f2778f0a7af6f4661ceff8dc7c1b20c240
parentbef1403ec175fc195751d6162262baa5f063fa96
ofproto-dpif-xlate: Rewrite mirroring to better fit flow translation.

Until now, mirroring has been implemented by accumulating, across the whole
translation process, a set of mirrors that should receive a mirrored
packet.  After translation was complete, mirroring restored the original
version of the packet and sent that version to the mirrors.

That implementation was ugly for multiple reasons.  First, it means that
we have to keep a copy of the original packet (or its headers, actually),
which is expensive.  Second, it doesn't really make sense to mirror a
version of a packet that is different from the one originally output.
Third, it interacted with recirculation; mirroring needed to happen only
after recirculation was complete, but this was never properly implemented,
so that (I think) mirroring never happened for packets that were
recirculated.

This commit changes how mirroring works.  Now, a packet is mirrored at the
point in translation when it becomes eligible for it: for mirrors based on
ingress port, this is at ingress; for mirrors based on egress port, this
is at egress.  (Duplicates are dropped.)  Mirroring happens on the version
of the packet as it exists when it becomes eligible.  Finally, since
mirroring happens immediately, it interacts better with recirculation
(it still isn't perfect, since duplicate mirroring will occur if a packet
is eligible for mirroring both before and after recirculation; this is
not difficult to fix and an upcoming commit later in this series will do so).

Finally, this commit removes more code from xlate_actions() than it adds,
which in my opinion makes it easier to understand.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
ofproto/ofproto-dpif-xlate.c
tests/ofproto-dpif.at
vswitchd/vswitch.xml