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. */
+ /* 'mirrors' is a bit-mask of candidates for mirroring. Iterate through
+ * the candidates, adding the ones that really should be mirrored to
+ * 'used_mirrors', as long as some candidates remain. */
+ mirror_mask_t used_mirrors = 0;
while (mirrors) {
const unsigned long *vlans;
mirror_mask_t dup_mirrors;
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
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