From mboxrd@z Thu Jan 1 00:00:00 1970 From: William Tu Subject: [PATCH bpf-next] bpf: clear the ip_tunnel_info. Date: Tue, 24 Apr 2018 23:46:59 -0700 Message-ID: <1524638819-31626-1-git-send-email-u9012063@gmail.com> To: netdev@vger.kernel.org Return-path: Received: from mail-pg0-f65.google.com ([74.125.83.65]:40298 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751285AbeDYGr3 (ORCPT ); Wed, 25 Apr 2018 02:47:29 -0400 Received: by mail-pg0-f65.google.com with SMTP id e9so12634673pgr.7 for ; Tue, 24 Apr 2018 23:47:29 -0700 (PDT) Received: from sc9-mailhost3.vmware.com (c-73-231-16-221.hsd1.ca.comcast.net. [73.231.16.221]) by smtp.gmail.com with ESMTPSA id 142sm18692845pgg.86.2018.04.24.23.47.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 24 Apr 2018 23:47:27 -0700 (PDT) Sender: netdev-owner@vger.kernel.org List-ID: The percpu metadata_dst might carry the stale ip_tunnel_info and cause incorrect behavior. When mixing tests using ipv4/ipv6 bpf vxlan and geneve tunnel, the ipv6 tunnel info incorrectly uses ipv4's src ip addr as its ipv6 src address, because the previous tunnel info does not clean up. The patch zeros the fields in ip_tunnel_info. Signed-off-by: William Tu Reported-by: Yifeng Sun --- net/core/filter.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/core/filter.c b/net/core/filter.c index 8e45c6c7ab08..d3781daa26ab 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -3281,6 +3281,7 @@ BPF_CALL_4(bpf_skb_set_tunnel_key, struct sk_buff *, skb, skb_dst_set(skb, (struct dst_entry *) md); info = &md->u.tun_info; + memset(info, 0, sizeof(*info)); info->mode = IP_TUNNEL_INFO_TX; info->key.tun_flags = TUNNEL_KEY | TUNNEL_CSUM | TUNNEL_NOCACHE; -- 2.7.4