diff mbox series

[net-next,2/3] bpf: allow disabling tunnel csum for ipv6

Message ID 1512170770-7866-3-git-send-email-u9012063@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show
Series add ip6 gre and gretap collect_md mode | expand

Commit Message

William Tu Dec. 1, 2017, 11:26 p.m. UTC
Before the patch, BPF_F_ZERO_CSUM_TX can be used only for ipv4 tunnel.
With introduction of ip6gretap collect_md mode, the flag should be also
supported for ipv6.

Signed-off-by: William Tu <u9012063@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
---
 net/core/filter.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Daniel Borkmann Dec. 4, 2017, 8:33 a.m. UTC | #1
Hi William,

On 12/02/2017 12:26 AM, William Tu wrote:
> Before the patch, BPF_F_ZERO_CSUM_TX can be used only for ipv4 tunnel.
> With introduction of ip6gretap collect_md mode, the flag should be also
> supported for ipv6.
> 
> Signed-off-by: William Tu <u9012063@gmail.com>
> Cc: Daniel Borkmann <daniel@iogearbox.net>
> ---
>  net/core/filter.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 6a85e67fafce..8ec5a504eb28 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -3026,10 +3026,11 @@ BPF_CALL_4(bpf_skb_set_tunnel_key, struct sk_buff *, skb,
>  				  IPV6_FLOWLABEL_MASK;
>  	} else {
>  		info->key.u.ipv4.dst = cpu_to_be32(from->remote_ipv4);
> -		if (flags & BPF_F_ZERO_CSUM_TX)
> -			info->key.tun_flags &= ~TUNNEL_CSUM;
>  	}
>  
> +	if (flags & BPF_F_ZERO_CSUM_TX)
> +		info->key.tun_flags &= ~TUNNEL_CSUM;
> +

Looks fine to me. One minor request from my side:

Could you move the check right below the 'flags & BPF_F_DONT_FRAGMENT'
test in bpf_skb_set_tunnel_key(), so common tun_flags handling is
logically together. With that change done, please add my ack:

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

Thanks,
Daniel
diff mbox series

Patch

diff --git a/net/core/filter.c b/net/core/filter.c
index 6a85e67fafce..8ec5a504eb28 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3026,10 +3026,11 @@  BPF_CALL_4(bpf_skb_set_tunnel_key, struct sk_buff *, skb,
 				  IPV6_FLOWLABEL_MASK;
 	} else {
 		info->key.u.ipv4.dst = cpu_to_be32(from->remote_ipv4);
-		if (flags & BPF_F_ZERO_CSUM_TX)
-			info->key.tun_flags &= ~TUNNEL_CSUM;
 	}
 
+	if (flags & BPF_F_ZERO_CSUM_TX)
+		info->key.tun_flags &= ~TUNNEL_CSUM;
+
 	return 0;
 }