diff --git a/plugin/business/traffic-mirror/src/rebuild.cpp b/plugin/business/traffic-mirror/src/rebuild.cpp index 5929f6c..11f8c41 100644 --- a/plugin/business/traffic-mirror/src/rebuild.cpp +++ b/plugin/business/traffic-mirror/src/rebuild.cpp @@ -230,15 +230,16 @@ static int ipv6_header_construct(unsigned char *buf, unsigned short carry_layer_ { struct ip6_hdr * ip6_hdr = (struct ip6_hdr *) buf; - ip6_hdr->ip6_vfc = ntohl(0x60000000U); ip6_hdr->ip6_flow = 0; ip6_hdr->ip6_plen = htons(carry_layer_len); ip6_hdr->ip6_nxt = protocol; ip6_hdr->ip6_hlim = 128; + ip6_hdr->ip6_vfc &= 0x0F; + ip6_hdr->ip6_vfc |= (6U << 4U); ip6_hdr->ip6_src = *src; ip6_hdr->ip6_dst = *dst; - return sizeof(ip6_hdr); + return sizeof(struct ip6_hdr); } static int ip_header_construct_by_stream_addr(struct tfe_stream_addr * addr, @@ -260,7 +261,7 @@ static int ip_header_construct_by_stream_addr(struct tfe_stream_addr * addr, return -1; } -static void ether_header_construct(unsigned char *buf, unsigned char *dst, +static void ether_header_construct_helper(unsigned char *buf, unsigned char *dst, unsigned char *src, unsigned short type) { struct ethhdr * eth_hdr = (struct ethhdr *) buf; @@ -282,7 +283,7 @@ static int ether_header_construct(struct traffic_mirror_ethdev * ethdev, char * unsigned int header_len = 0; unsigned int eth_protocol = vlan_tci > 0 ? ETH_P_8021Q : l3_protocol; - ether_header_construct((unsigned char *)buffer + header_len, + ether_header_construct_helper((unsigned char *)buffer + header_len, (unsigned char *)target_addr->ether_addr_octet, (unsigned char *)ethdev->local_ether_addr, eth_protocol); @@ -291,8 +292,8 @@ static int ether_header_construct(struct traffic_mirror_ethdev * ethdev, char * /* need to construct vlan header */ if (vlan_tci > 0) { - header_len += sizeof(struct vlan_hdr); vlan_tag_construct((unsigned char *)buffer + header_len, vlan_tci, l3_protocol); + header_len += sizeof(struct vlan_hdr); } return header_len;