From 1a59abcd95e40f28fc6a3d88ec0d567a8a1b9c6b Mon Sep 17 00:00:00 2001 From: luqiuwen Date: Tue, 18 Jun 2019 18:20:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E8=A7=A3=E5=AF=86=E6=B5=81?= =?UTF-8?q?=E9=87=8F=E8=BD=AC=E5=8F=91=E4=B8=ADvlan=E5=A4=B4=E9=83=A8?= =?UTF-8?q?=E3=80=81IPv6=E5=A4=B4=E9=83=A8=E8=A2=AB=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/business/traffic-mirror/src/rebuild.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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;