Skip to content

Commit

Permalink
closes-bug:#1420452 While mirroring the tunneled packet, tunnel headers
Browse files Browse the repository at this point in the history
are removed and ethernet header is added from Encap nh to ensure that
Mirroring application sees a regular ethernet packet. After IRB, the
packet can be L2 packet and might contain ethernet header in the Tunnel
payload. In this case, the ethernet header need not be added from Encap
NH. This functionality is added by verifying the type of NH.

Change-Id: I0797c9db5e25ac09d51ddd3cdb9b25c632b812b9
  • Loading branch information
divakardhar committed Apr 21, 2015
1 parent d86a053 commit 294d9cc
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions dp-core/vr_mirror.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ vr_mirror(struct vrouter *router, uint8_t mirror_id,
struct vr_pcap *pcap;
struct vr_mirror_entry *mirror;
struct vr_mirror_meta_entry *mme;
unsigned int captured_len;
unsigned int captured_len, clone_len = VR_MIRROR_PKT_HEAD_SPACE;
unsigned int mirror_md_len = 0;
unsigned char default_mme[2] = {0xff, 0x0};
void *mirror_md;
Expand All @@ -397,6 +397,7 @@ vr_mirror(struct vrouter *router, uint8_t mirror_id,
mirror_md = default_mme;
}

clone_len += mirror_md_len;
nh = mirror->mir_nh;
pkt = vr_pclone(pkt);
if (!pkt)
Expand All @@ -409,23 +410,28 @@ vr_mirror(struct vrouter *router, uint8_t mirror_id,
reset = true;
if (pkt->vp_if && pkt->vp_if->vif_type == VIF_TYPE_PHYSICAL) {
pkt_nh = pkt->vp_nh;
if (pkt_nh && pkt_nh->nh_type == NH_ENCAP && pkt_nh->nh_dev &&
pkt_nh->nh_dev->vif_set_rewrite && pkt_nh->nh_encap_len) {
if (pkt_nh && (pkt_nh->nh_flags & NH_FLAG_VALID) &&
(pkt_nh->nh_type == NH_ENCAP)) {

reset = false;
if (vr_pcow(pkt, VR_MIRROR_PKT_HEAD_SPACE + mirror_md_len +
pkt_nh->nh_encap_len))
if (pkt_nh->nh_family == AF_INET)
clone_len += pkt_nh->nh_encap_len;

if (vr_pcow(pkt, clone_len))
goto fail;

if (!pkt_nh->nh_dev->vif_set_rewrite(pkt_nh->nh_dev, pkt, fmd,

if (pkt_nh->nh_family == AF_INET) {
if (!pkt_nh->nh_dev->vif_set_rewrite(pkt_nh->nh_dev, pkt, fmd,
pkt_nh->nh_data, pkt_nh->nh_encap_len))
goto fail;
}
}
}

if (reset) {
vr_preset(pkt);
if (vr_pcow(pkt, VR_MIRROR_PKT_HEAD_SPACE + mirror_md_len))
if (vr_pcow(pkt, clone_len))
goto fail;
}

Expand Down

0 comments on commit 294d9cc

Please sign in to comment.