Until now, OVS has accounted packets to mirrors even if the VLAN selection criteria did not match. This fixes the problem.
Reported-by: Shweta Seth <[email protected]> Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2018-December/047931.html Signed-off-by: Ben Pfaff <[email protected]> --- ofproto/ofproto-dpif-xlate.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 839fddd99fbe..8d17151a057e 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -2058,21 +2058,9 @@ mirror_packet(struct xlate_ctx *ctx, struct xbundle *xbundle, return; } - if (ctx->xin->resubmit_stats) { - mirror_update_stats(xbridge->mbridge, mirrors, - ctx->xin->resubmit_stats->n_packets, - ctx->xin->resubmit_stats->n_bytes); - } - if (ctx->xin->xcache) { - struct xc_entry *entry; - - entry = xlate_cache_add_entry(ctx->xin->xcache, XC_MIRROR); - entry->mirror.mbridge = mbridge_ref(xbridge->mbridge); - entry->mirror.mirrors = mirrors; - } - /* 'mirrors' is a bit-mask of candidates for mirroring. Iterate as long as * some candidates remain. */ + mirror_mask_t used_mirrors = 0; while (mirrors) { const unsigned long *vlans; mirror_mask_t dup_mirrors; @@ -2096,6 +2084,9 @@ mirror_packet(struct xlate_ctx *ctx, struct xbundle *xbundle, continue; } + /* We sent a packet to this mirror. */ + used_mirrors |= rightmost_1bit(mirrors); + /* Record the mirror, and the mirrors that output to the same * destination, so that we don't mirror to them again. This must be * done now to ensure that output_normal(), below, doesn't recursively @@ -2129,6 +2120,21 @@ mirror_packet(struct xlate_ctx *ctx, struct xbundle *xbundle, mirrors &= ~ctx->mirrors; ctx->mirror_snaplen = 0; } + + if (used_mirrors) { + if (ctx->xin->resubmit_stats) { + mirror_update_stats(xbridge->mbridge, used_mirrors, + ctx->xin->resubmit_stats->n_packets, + ctx->xin->resubmit_stats->n_bytes); + } + if (ctx->xin->xcache) { + struct xc_entry *entry; + + entry = xlate_cache_add_entry(ctx->xin->xcache, XC_MIRROR); + entry->mirror.mbridge = mbridge_ref(xbridge->mbridge); + entry->mirror.mirrors = used_mirrors; + } + } } static void -- 2.16.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
