From patchwork Fri Jul 15 15:01:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Chaignon X-Patchwork-Id: 12919351 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39335C43334 for ; Fri, 15 Jul 2022 15:01:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231620AbiGOPBI (ORCPT ); Fri, 15 Jul 2022 11:01:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229599AbiGOPBH (ORCPT ); Fri, 15 Jul 2022 11:01:07 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D3967AC34 for ; Fri, 15 Jul 2022 08:01:06 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id d16so7067412wrv.10 for ; Fri, 15 Jul 2022 08:01:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=jNOFWD6EWX/ilMsSDswwTAqMX/p75CHGacwLg212UIA=; b=3x+YM7a1x4GZKfTQerXh3xdV/n3rhT4J5GK1vUMPEnBz8iShqUsnZix5jhRQLVemDW PtzfIeTHN3t0aobVk6DmRqbgXa7XCulj6gnPCuQ7NFokMqFtakrrQtYw6K6gFvzgF9nE cktRwa6/5neoX9aJtW90I4ck10X5JTmNLLnxcCnp8fQKfgL2PGzEoYuoycrw8L32Yhaj Uw4p7Y2CVNgzDippCnh7YAeNdIP71drh3G8qwU2EaU31Nsax4nNe45CgctIbjR5/NUWY CoMGiWfzeFpbEuaAhpzYCjq6VK6ALa8Uxbk1Uf+PW9hEWlJGNS8fcvq4b6FPcIY2Q4dV RN/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jNOFWD6EWX/ilMsSDswwTAqMX/p75CHGacwLg212UIA=; b=6osS+lyDVNsxbdgbWUcrhd/BQyVI4GMrR/utAVpZ0hqEkOrBIs/CuiwPEtmvZA/5tf QMQPucPUKrHo0ieJF/f95vAg6repvq33eosLk00SopUQZrieXkh/HlNLH60asgGT1Oag a+id8tzRPWDGfYFc6K996NVOVHUg3dvcyS+yHYWTFdNoBNWIDSZvWN7cbJLCfkyzKbOY JbpXY52dUOLqLbQsWKNRXFjQ1qkdRoadTwKiP0Si9x1gCoiy4FS0neibRc/iJQ8iAWG7 S3nrhJ1qCrsh8xLvbjT+nf9pZdyYXCUXX0bNH475UiHWZy+GWWcPJltP2dINZKCz0QRE R6Pg== X-Gm-Message-State: AJIora/0Y9/gpUhUyWLG+mimU5KjG4rUVnTqk7TBeNTxqJ07IatTm/1m EA0l506Pd9haEnmE4h6VxS4P X-Google-Smtp-Source: AGRyM1srnY/B9l9X6av7ND4wDeY38iSSKSh/7xiN/bXpISRK3guMjtmraKsZ8m5U0xWzZ7mfsCyioQ== X-Received: by 2002:adf:e702:0:b0:21d:6900:ea1c with SMTP id c2-20020adfe702000000b0021d6900ea1cmr12563421wrm.620.1657897264879; Fri, 15 Jul 2022 08:01:04 -0700 (PDT) Received: from Mem (2a01cb088160fc0095dc955fbebd15a0.ipv6.abo.wanadoo.fr. [2a01:cb08:8160:fc00:95dc:955f:bebd:15a0]) by smtp.gmail.com with ESMTPSA id r21-20020a05600c425500b003a2cf5eb900sm5292466wmm.40.2022.07.15.08.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 08:01:04 -0700 (PDT) Date: Fri, 15 Jul 2022 17:01:02 +0200 From: Paul Chaignon To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , John Fastabend , Kaixi Fan , Nikolay Aleksandrov Subject: [PATCH bpf 1/5] ip_tunnels: Add new flow flags field to ip_tunnel_key Message-ID: <457f79e53a6b9f0921561bc796a49e917d131635.1657895526.git.paul@isovalent.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net This commit extends the ip_tunnel_key struct with a new field for the flow flags, to pass them to the route lookups. This new field will be populated and used in subsequent commits. Signed-off-by: Paul Chaignon --- include/net/ip_tunnels.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index c24fa934221d..20f60d9da741 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h @@ -54,6 +54,7 @@ struct ip_tunnel_key { __be32 label; /* Flow Label for IPv6 */ __be16 tp_src; __be16 tp_dst; + __u8 flow_flags; }; /* Flags for ip_tunnel_info mode. */ From patchwork Fri Jul 15 15:01:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Chaignon X-Patchwork-Id: 12919352 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03431C433EF for ; Fri, 15 Jul 2022 15:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231660AbiGOPBk (ORCPT ); Fri, 15 Jul 2022 11:01:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231777AbiGOPBh (ORCPT ); Fri, 15 Jul 2022 11:01:37 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B7767B37E for ; Fri, 15 Jul 2022 08:01:36 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id f24-20020a1cc918000000b003a30178c022so3028654wmb.3 for ; Fri, 15 Jul 2022 08:01:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=sAK+1eDl4p0U2zzE18FluVyvJNB/v7GV3zwJU7RBeRY=; b=P2NNwW1NfFyPnKnRuP8E40Sf/lTLdvB7ei+BXITQfLU9BrgrfPZIzNRiM3uyiDGOgB 8FJB5XHkbVZTC5hDNNin6cNEXmvw+aFn5zjSblmCyTV4xe4r5nqtyl49Xpp8mSJW8vti lLRXZ0KNuLvZCMpHv8byvskZ1OvPHT4iHpzx4zsOiwqSKEhyYAumHv+0Fm5FHM2Sbxcs h7Vf2//ttRKFOLDJJac59TYCXlKhvra7JkgkY40b5S2/4lRXpkA1DRaH0ZiTQELO8G+H 2eXJDQ5RAJ6WrDQCpPtMkOdnizK79GYgIK1tp8i3JSROOKJRRnBLXIeezrqt1kIKDWJ+ uvpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=sAK+1eDl4p0U2zzE18FluVyvJNB/v7GV3zwJU7RBeRY=; b=ipZ1bWtVO9Pnbsujs8Omlo/98CixQ/NyppUUXQAGWDz2sg9gw4B4gjJbllDwO6nbe1 XZ6Q6QpTERrMM1Oz32OpsLyAh9zvRuJe760rH2L00s82ZKY0f1NhGwKLbTC8xNwIh0CA /TTFToxO43ZfxTQHKZmQOAAm08YXz6Z8z7xV69KBuGnZX/Efj1lNht1FT0djyCJPlK5E YRno4lhZQfPh4efu2BXtPLGhMmgQupUGhjipfW1a8K/9MCs8UuCQ2Wizg2dxNFVEVsbR C/VRrgRHwXbvmfFP5uWIsAdu7eMHouVH2wvMeL1RkfJdkQy7Tx11OdsraGkZ07Ezt6U3 Lfag== X-Gm-Message-State: AJIora+9HmtEmj26p7G8VX3uyJfrVDlXqxeL6q1NzL1hpSGokoa2fKGM Y16eyXjkGkGson5a+uIIXAFh X-Google-Smtp-Source: AGRyM1uSL1lHx/F3ktq2lj73s4yHTlYBZRt+SdeP0H4xYhCBXcmnFOx8ryPTt8YqsPNQWd7EYutjmA== X-Received: by 2002:a7b:c3d4:0:b0:3a3:ce7:7894 with SMTP id t20-20020a7bc3d4000000b003a30ce77894mr3445137wmj.134.1657897295216; Fri, 15 Jul 2022 08:01:35 -0700 (PDT) Received: from Mem (2a01cb088160fc0095dc955fbebd15a0.ipv6.abo.wanadoo.fr. [2a01:cb08:8160:fc00:95dc:955f:bebd:15a0]) by smtp.gmail.com with ESMTPSA id p19-20020a05600c359300b003a300452f7fsm7304955wmq.32.2022.07.15.08.01.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 08:01:34 -0700 (PDT) Date: Fri, 15 Jul 2022 17:01:33 +0200 From: Paul Chaignon To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , John Fastabend , Kaixi Fan , Nikolay Aleksandrov Subject: [PATCH bpf 2/5] vxlan: Use ip_tunnel_key flow flags in route lookups Message-ID: <40ddf5780215bd001604410682c42d132d8f01ed.1657895526.git.paul@isovalent.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Use the new ip_tunnel_key field with the flow flags in the route lookups for the encapsulated packet. This will be used by the bpf_skb_set_tunnel_key helper in a subsequent commit. Signed-off-by: Paul Chaignon --- drivers/net/vxlan/vxlan_core.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 265d4a0245e7..3c93cf5683be 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -2243,7 +2243,7 @@ static struct rtable *vxlan_get_route(struct vxlan_dev *vxlan, struct net_device struct vxlan_sock *sock4, struct sk_buff *skb, int oif, u8 tos, __be32 daddr, __be32 *saddr, __be16 dport, __be16 sport, - struct dst_cache *dst_cache, + __u8 flow_flags, struct dst_cache *dst_cache, const struct ip_tunnel_info *info) { bool use_cache = ip_tunnel_dst_cache_usable(skb, info); @@ -2270,6 +2270,7 @@ static struct rtable *vxlan_get_route(struct vxlan_dev *vxlan, struct net_device fl4.saddr = *saddr; fl4.fl4_dport = dport; fl4.fl4_sport = sport; + fl4.flowi4_flags = flow_flags; rt = ip_route_output_key(vxlan->net, &fl4); if (!IS_ERR(rt)) { @@ -2298,6 +2299,7 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan, const struct in6_addr *daddr, struct in6_addr *saddr, __be16 dport, __be16 sport, + __u8 flow_flags, struct dst_cache *dst_cache, const struct ip_tunnel_info *info) { @@ -2325,6 +2327,7 @@ static struct dst_entry *vxlan6_get_route(struct vxlan_dev *vxlan, fl6.flowi6_proto = IPPROTO_UDP; fl6.fl6_dport = dport; fl6.fl6_sport = sport; + fl6.flowi6_flags = flow_flags; ndst = ipv6_stub->ipv6_dst_lookup_flow(vxlan->net, sock6->sock->sk, &fl6, NULL); @@ -2459,7 +2462,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, unsigned int pkt_len = skb->len; __be16 src_port = 0, dst_port; struct dst_entry *ndst = NULL; - __u8 tos, ttl; + __u8 tos, ttl, flow_flags = 0; int ifindex; int err; u32 flags = vxlan->cfg.flags; @@ -2525,6 +2528,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, } dst = &remote_ip; dst_port = info->key.tp_dst ? : vxlan->cfg.dst_port; + flow_flags = info->key.flow_flags; vni = tunnel_id_to_key32(info->key.tun_id); ifindex = 0; dst_cache = &info->dst_cache; @@ -2555,7 +2559,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, rt = vxlan_get_route(vxlan, dev, sock4, skb, ifindex, tos, dst->sin.sin_addr.s_addr, &local_ip.sin.sin_addr.s_addr, - dst_port, src_port, + dst_port, src_port, flow_flags, dst_cache, info); if (IS_ERR(rt)) { err = PTR_ERR(rt); @@ -2628,7 +2632,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev, ndst = vxlan6_get_route(vxlan, dev, sock6, skb, ifindex, tos, label, &dst->sin6.sin6_addr, &local_ip.sin6.sin6_addr, - dst_port, src_port, + dst_port, src_port, flow_flags, dst_cache, info); if (IS_ERR(ndst)) { err = PTR_ERR(ndst); @@ -3061,7 +3065,8 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb) rt = vxlan_get_route(vxlan, dev, sock4, skb, 0, info->key.tos, info->key.u.ipv4.dst, &info->key.u.ipv4.src, dport, sport, - &info->dst_cache, info); + info->key.flow_flags, &info->dst_cache, + info); if (IS_ERR(rt)) return PTR_ERR(rt); ip_rt_put(rt); @@ -3073,7 +3078,8 @@ static int vxlan_fill_metadata_dst(struct net_device *dev, struct sk_buff *skb) ndst = vxlan6_get_route(vxlan, dev, sock6, skb, 0, info->key.tos, info->key.label, &info->key.u.ipv6.dst, &info->key.u.ipv6.src, dport, sport, - &info->dst_cache, info); + info->key.flow_flags, &info->dst_cache, + info); if (IS_ERR(ndst)) return PTR_ERR(ndst); dst_release(ndst); From patchwork Fri Jul 15 15:02:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Chaignon X-Patchwork-Id: 12919353 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41290C43334 for ; Fri, 15 Jul 2022 15:02:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231572AbiGOPCK (ORCPT ); Fri, 15 Jul 2022 11:02:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbiGOPCJ (ORCPT ); Fri, 15 Jul 2022 11:02:09 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08C567B343 for ; Fri, 15 Jul 2022 08:02:08 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id bk26so7072323wrb.11 for ; Fri, 15 Jul 2022 08:02:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=EfG5Vmq+7RCHk9EyoVnjhujw/dAMQt8Collt+KmmvH4=; b=QFTfrdiJHFKaAXOA62RvrMQndAbXWdmhfCiB7lsRilaC2qaRf1Vp4LtzBWOzUDZ/6n VRIy/bbKukUgrQEf4tx0c5qnbRhq9NtAi/drIdMqv/BuHaBIaOPswUFlFemm+27p6u1J r1dMOl6799ROCL1PykQ5V5XRR+EMwgKxAZZQeXrCMxN5f4rNB7mAWZvhgHD4pIxYsyuX +GsJ6AuoTTM1xauvpLNHyeA632xbPAu4ZVuQymk8NKT6apkN9xC99w3q+y5G2a1WhsYx x36XisUBDiVrjJA1VbdLG2s4F+vkWqLJF9eL2ODTMzHIgK5kBMWxhbHnWxo2ASBbo8vp C7HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=EfG5Vmq+7RCHk9EyoVnjhujw/dAMQt8Collt+KmmvH4=; b=LnG6Z+MJSHugZ1wZcQziR6seD42RgkmmQ6HBF9reqsaNa7bauzFfLymcOxPNZZF6NF YK4uXXHkUkC739/73idPEpdavUH7E5QWi27XfTVP0quQtzKnokusH81sfC7CuOeDfI3s 4ZwZoCwm4RiZXuBCU+A50YGelQZpF0o2ZlieBmZFE/ep9fChi3SLoll2z4nJ7Zvw+pEL 86ZIr3jzamj1qLxqfk59N+Z8qgwGKK3oxJnYU/n4ALcl5ZprLCbHV1sOIMcu5pRYpueC ob9y2mt8QAF9F1WqpjTOlLdLFGPgf5YT8HY7q9/K/8e6inrJf6YsYIBHZhdokKjhoHBq GzFA== X-Gm-Message-State: AJIora84WlcOnyrNgUg/MOieCkegKRgQynZo26S2hglpHnXUhRVIkK2u SfNAlSrfr8/eGsxIszRIo37u X-Google-Smtp-Source: AGRyM1uiWPsZlqGwGr10aVv9iT+usN6YgVKBc694CkBqReFG1w0nXt6th+MaUgLBF3Wr7GS/eXD9Jg== X-Received: by 2002:a05:6000:1841:b0:21d:b6ca:2e19 with SMTP id c1-20020a056000184100b0021db6ca2e19mr13219905wri.599.1657897326616; Fri, 15 Jul 2022 08:02:06 -0700 (PDT) Received: from Mem (2a01cb088160fc0095dc955fbebd15a0.ipv6.abo.wanadoo.fr. [2a01:cb08:8160:fc00:95dc:955f:bebd:15a0]) by smtp.gmail.com with ESMTPSA id bw3-20020a0560001f8300b0021d70a871cbsm3915090wrb.32.2022.07.15.08.02.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 08:02:06 -0700 (PDT) Date: Fri, 15 Jul 2022 17:02:04 +0200 From: Paul Chaignon To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , John Fastabend , Kaixi Fan , Nikolay Aleksandrov Subject: [PATCH bpf 3/5] geneve: Use ip_tunnel_key flow flags in route lookups Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Use the new ip_tunnel_key field with the flow flags in the route lookups for the encapsulated packet. This will be used by the bpf_skb_set_tunnel_key helper in the subsequent commit. Signed-off-by: Paul Chaignon --- drivers/net/geneve.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 2495a5719e1c..efad129ca8fd 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -815,6 +815,7 @@ static struct rtable *geneve_get_v4_rt(struct sk_buff *skb, fl4->saddr = info->key.u.ipv4.src; fl4->fl4_dport = dport; fl4->fl4_sport = sport; + fl4->flowi4_flags = info->key.flow_flags; tos = info->key.tos; if ((tos == 1) && !geneve->cfg.collect_md) { @@ -868,6 +869,7 @@ static struct dst_entry *geneve_get_v6_dst(struct sk_buff *skb, fl6->saddr = info->key.u.ipv6.src; fl6->fl6_dport = dport; fl6->fl6_sport = sport; + fl6->flowi6_flags = info->key.flow_flags; prio = info->key.tos; if ((prio == 1) && !geneve->cfg.collect_md) { From patchwork Fri Jul 15 15:02:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Chaignon X-Patchwork-Id: 12919354 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFA2DCCA47C for ; Fri, 15 Jul 2022 15:02:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231777AbiGOPCh (ORCPT ); Fri, 15 Jul 2022 11:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229510AbiGOPCg (ORCPT ); Fri, 15 Jul 2022 11:02:36 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6880B7AC35 for ; Fri, 15 Jul 2022 08:02:35 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id f24-20020a1cc918000000b003a30178c022so3030855wmb.3 for ; Fri, 15 Jul 2022 08:02:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tC3AjBr7xJY+R5Pdcv2ZD56l8Ldf9LSIpfukfebYliI=; b=lRbR00JlR3LaXkeZcjf0Vd1Fc1UMINH3PoEw21donNVr0xEvH89c41GX14LlCGUMuh 0Q8NWlSjCwiYKM6l3qmU22ZfIHJ/Ylud6AgrZGN1q0l58Sl/LoHVjcwF3YlfHH4vcJAH ACb3ea47ZmfWvyY5YSyBqE+Zz+qTZpdJk/ZIwAXlNU3OxKIUpLXCVhpByA/EbwwJYXHe OHL6IqHLALXJZIaSj93vIH2wgwrTxXD4j92PPKx0KItl80Pk6XHid0vNByybUTG78Iik VcaXLGq7w0uExTPrgzmQbK9hkrQMq5aOMIS2BuYEa+TkG+eEEGP6q+hScfMa6Kv7gLQE tFxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tC3AjBr7xJY+R5Pdcv2ZD56l8Ldf9LSIpfukfebYliI=; b=PqyZVOZXjSuKRRkfp8HH/aKtxv2w2eu2I2vkNy77BbXxfSqttkdQr0Us3s+ggl7gRO 9bW5m5ARMeO+LwqjJIPwy/IjWYH8TAXyd1D7e3Tw/y4gxwwtzc3R7MUupRcxDjJoKMMi OTW/UoEJ8OKvI2b2KNRnm9CMC8XHt/wd85wp41fDFGDNTwkGNpOhaBQqhkY626qRFTog qInFaGvLXpgVMjCIlFSNMBRIDCGG89nKM/1yavbmHl5lNhk/3pYC3ket5JWpnQxwjA8l fySECrb2YtbEQCfpsL5LAoVzVBlAciQmCb6WeXiQuJD2fhPw6wO9AJ8vMqIh6Fb1TUqG Ldlw== X-Gm-Message-State: AJIora/OvOCmMlQUvqn1bAuj5hQsOhWsHMd3sG/ImqvE4qHVQcZUf9s7 jiqzYkZBumnxgUVOp91FOt+F X-Google-Smtp-Source: AGRyM1un1zp0hlHPGaEnqQvaKTD2TO/+BIBIxyGRGpgSte2jWv4Y9qSe3scYJAxeL+liH65PYhb9mg== X-Received: by 2002:a05:600c:3506:b0:3a2:feb0:9f8e with SMTP id h6-20020a05600c350600b003a2feb09f8emr11720274wmq.42.1657897354033; Fri, 15 Jul 2022 08:02:34 -0700 (PDT) Received: from Mem (2a01cb088160fc0095dc955fbebd15a0.ipv6.abo.wanadoo.fr. [2a01:cb08:8160:fc00:95dc:955f:bebd:15a0]) by smtp.gmail.com with ESMTPSA id h7-20020adf9cc7000000b0021d8faf57d5sm4230299wre.74.2022.07.15.08.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 08:02:33 -0700 (PDT) Date: Fri, 15 Jul 2022 17:02:31 +0200 From: Paul Chaignon To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , John Fastabend , Kaixi Fan , Nikolay Aleksandrov Subject: [PATCH bpf 4/5] bpf: Set flow flag to allow any source IP in bpf_tunnel_key Message-ID: <627e34e78283b84c79db8945b05930b70eeaa925.1657895526.git.paul@isovalent.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Commit 26101f5ab6bd ("bpf: Add source ip in "struct bpf_tunnel_key"") added support for getting and setting the outer source IP of encapsulated packets via the bpf_skb_{get,set}_tunnel_key BPF helper. This change allows BPF programs to set any IP address as the source, including for example the IP address of a container running on the same host. In that last case, however, the encapsulated packets are dropped when looking up the route because the source IP address isn't assigned to any interface on the host. To avoid this, we need to set the FLOWI_FLAG_ANYSRC flag. Fixes: 26101f5ab6bd ("bpf: Add source ip in "struct bpf_tunnel_key"") Signed-off-by: Paul Chaignon --- net/core/filter.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/core/filter.c b/net/core/filter.c index 5d16d66727fc..6d9c800cdab9 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -4641,6 +4641,7 @@ BPF_CALL_4(bpf_skb_set_tunnel_key, struct sk_buff *, skb, info->key.tun_id = cpu_to_be64(from->tunnel_id); info->key.tos = from->tunnel_tos; info->key.ttl = from->tunnel_ttl; + info->key.flow_flags = FLOWI_FLAG_ANYSRC; if (flags & BPF_F_TUNINFO_IPV6) { info->mode |= IP_TUNNEL_INFO_IPV6; From patchwork Fri Jul 15 15:03:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Chaignon X-Patchwork-Id: 12919355 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43DDCCCA47C for ; Fri, 15 Jul 2022 15:03:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232086AbiGOPDH (ORCPT ); Fri, 15 Jul 2022 11:03:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231818AbiGOPDG (ORCPT ); Fri, 15 Jul 2022 11:03:06 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4722E7BE1C for ; Fri, 15 Jul 2022 08:03:05 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id v67-20020a1cac46000000b003a1888b9d36so5087108wme.0 for ; Fri, 15 Jul 2022 08:03:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=XUUk00/TjPArZ0mXnxJW0zloRPmWlYco9FTFKH+pLFQ=; b=OM2veA4WKKocg94uSF1SEQfSTNA2LhJAJG65r9TwBUUYIPrVGS9bTbmlVBq5H8Chs6 q4zE4j7bhIOMv8M78iqzAh/JOFCYkXOXJdqXgjRI0r4WMsMJHIFvPNRKfVsid2nCc1ZY xGicVm29OW9IcyMdD1qZFCU7kvIqCC12fmFuZEyNXKp0coqQr4GuMSy5cyn5Y3vlZ6M4 Agt+3OPG7swX/WCCdz+oqaY6AKdYEy39dCsOZlJ/miyoO3LR8DE6+zB9QxI+3sGMW3DT ACfb1wE6Cw23H89K7LdAO/tu8GQkgq1lrITaWmnGdoKOrUXt+iybOmRKXQ5/Tv0FOhal rfVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=XUUk00/TjPArZ0mXnxJW0zloRPmWlYco9FTFKH+pLFQ=; b=jPfdd+CSxTF6H+e6gfzoWYwPCtGnqZndckDUVTDR1b2mCu1ObWLWkZX+WO0NCS1pD4 V9AUQJxCcsxe4bxetk+HqxOHXCiCjAaCCZJNlzNMuv13+v8xqGO5iKBQaDnG71d/1x2p tSAF3BilN4ikbjNHXK+MCrtm+ZmBQwwTqiquho1ysBDNudYzoCX4Q6/ez9Ijtu+5U66a W5YwhfzmObKVE193M25TcVsLIRm2SjmAgUSfTcWZr9i+EZMDr3sVr+fDS5cIeIZvNOgW 0gCKPCCX7SvehwC58/sdQLEU9kyJYFZtms9DdycujNmF7dNKLyEPHboPn2r9KFdzIdjM 7qBQ== X-Gm-Message-State: AJIora8dLG9aOXaaGP4oa8r1fTAXsFCIgCHd1o80szRQwuSA73ZiUikd 0mZzfX9o7Qz50ExcPQTLS0sV X-Google-Smtp-Source: AGRyM1t9wJGmJtM3O73qbYDljCQWWCeJf3IDtfzo9kGuSiJRxvBVzfsLxAqqe6SEHC36NaBUyAquOQ== X-Received: by 2002:a05:600c:a03:b0:39e:4f0c:938c with SMTP id z3-20020a05600c0a0300b0039e4f0c938cmr14406450wmp.145.1657897383819; Fri, 15 Jul 2022 08:03:03 -0700 (PDT) Received: from Mem (2a01cb088160fc0095dc955fbebd15a0.ipv6.abo.wanadoo.fr. [2a01:cb08:8160:fc00:95dc:955f:bebd:15a0]) by smtp.gmail.com with ESMTPSA id d16-20020a05600c049000b0039c96b97359sm5355917wme.37.2022.07.15.08.03.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jul 2022 08:03:03 -0700 (PDT) Date: Fri, 15 Jul 2022 17:03:01 +0200 From: Paul Chaignon To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , John Fastabend , Kaixi Fan , Nikolay Aleksandrov Subject: [PATCH bpf 5/5] selftests/bpf: Don't assign outer source IP to host Message-ID: <8f04b8e911fcb8166ed964d4eb154a2e0586ca92.1657895526.git.paul@isovalent.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net The previous commit fixed a bug in the bpf_skb_set_tunnel_key helper to avoid dropping packets whose outer source IP address isn't assigned to a host interface. This commit changes the corresponding selftest to not assign the outer source IP address to an interface. With this change and without the bugfix, the ICMP echo packets sent as part of the test are dropped. Signed-off-by: Paul Chaignon --- tools/testing/selftests/bpf/prog_tests/test_tunnel.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/bpf/prog_tests/test_tunnel.c b/tools/testing/selftests/bpf/prog_tests/test_tunnel.c index 3bba4a2a0530..14ccb41a9f59 100644 --- a/tools/testing/selftests/bpf/prog_tests/test_tunnel.c +++ b/tools/testing/selftests/bpf/prog_tests/test_tunnel.c @@ -111,7 +111,6 @@ static int config_device(void) SYS("ip link add veth0 type veth peer name veth1"); SYS("ip link set veth0 netns at_ns0"); SYS("ip addr add " IP4_ADDR1_VETH1 "/24 dev veth1"); - SYS("ip addr add " IP4_ADDR2_VETH1 "/24 dev veth1"); SYS("ip link set dev veth1 up mtu 1500"); SYS("ip netns exec at_ns0 ip addr add " IP4_ADDR_VETH0 "/24 dev veth0"); SYS("ip netns exec at_ns0 ip link set dev veth0 up mtu 1500");