diff mbox series

[ovs-dev] Subject:[patch]netdev-native-tnl: strip padding bytes of inner L2.

Message ID tencent_10916C46893C31EB2F378981028EE45D8C0A@qq.com
State New
Headers show
Series [ovs-dev] Subject:[patch]netdev-native-tnl: strip padding bytes of inner L2. | expand

Commit Message

weili zhang Sept. 7, 2020, 11:51 a.m. UTC
From: Weili Zhang <305753229@qq.com>

We need strip the inner L2 padding bytes, before enapcasulate a packet.

Signed-off-by: Weili Zhang <305753229@qq.com>
---
 lib/netdev-native-tnl.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Gregory Rose Sept. 8, 2020, 4:46 p.m. UTC | #1
On 9/7/2020 4:51 AM, 305753229@qq.com wrote:
> From: Weili Zhang <305753229@qq.com>
> 
> We need strip the inner L2 padding bytes, before enapcasulate a packet.

Why?  What happens otherwise?

- Greg

> 
> Signed-off-by: Weili Zhang <305753229@qq.com>
> ---
>   lib/netdev-native-tnl.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
> index b89dfdd52..acfbb13c4 100644
> --- a/lib/netdev-native-tnl.c
> +++ b/lib/netdev-native-tnl.c
> @@ -149,11 +149,15 @@ void *
>   netdev_tnl_push_ip_header(struct dp_packet *packet,
>                  const void *header, int size, int *ip_tot_size)
>   {
> +    int padding = dp_packet_l2_pad_size(packet);
>       struct eth_header *eth;
>       struct ip_header *ip;
>       struct ovs_16aligned_ip6_hdr *ip6;
>   
>       eth = dp_packet_push_uninit(packet, size);
> +    if (padding) {
> +        dp_packet_set_size(packet, dp_packet_size(packet) - padding);
> +    }
>       *ip_tot_size = dp_packet_size(packet) - sizeof (struct eth_header);
>   
>       memcpy(eth, header, size);
>
diff mbox series

Patch

diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
index b89dfdd52..acfbb13c4 100644
--- a/lib/netdev-native-tnl.c
+++ b/lib/netdev-native-tnl.c
@@ -149,11 +149,15 @@  void *
 netdev_tnl_push_ip_header(struct dp_packet *packet,
                const void *header, int size, int *ip_tot_size)
 {
+    int padding = dp_packet_l2_pad_size(packet);
     struct eth_header *eth;
     struct ip_header *ip;
     struct ovs_16aligned_ip6_hdr *ip6;
 
     eth = dp_packet_push_uninit(packet, size);
+    if (padding) {
+        dp_packet_set_size(packet, dp_packet_size(packet) - padding);
+    }
     *ip_tot_size = dp_packet_size(packet) - sizeof (struct eth_header);
 
     memcpy(eth, header, size);