From patchwork Mon Jul 18 15:54: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: 12921411 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 967AAC43334 for ; Mon, 18 Jul 2022 15:54:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235065AbiGRPyL (ORCPT ); Mon, 18 Jul 2022 11:54:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235205AbiGRPyJ (ORCPT ); Mon, 18 Jul 2022 11:54:09 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0342B1C0 for ; Mon, 18 Jul 2022 08:54:07 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id a5so17670072wrx.12 for ; Mon, 18 Jul 2022 08:54: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=jNOFWD6EWX/ilMsSDswwTAqMX/p75CHGacwLg212UIA=; b=pKtudd//N5O7taLzY08jZ7HXjO6PCiCDHPliOFecVIv+sDNVX+AyJXAt/6nVGWR3is h+5RS73wR/3i/YG9yUJP4MlWwILmmRLvFGYsbvV1bGEVmLsgG0dFPiTivgqQbrA5J/dj vz9nobADF59If0/0wLD3+bRNzsmUzoHY4tVVK6axeQEeWRnB29unNbiCvT6LRjrg4/XD r2Qmp+8Y3xniLm5gUt15YoYUdCMKzD4Q5Wv6Ypijmx2hfxFKFjfE9QKTGTxlV5II4ISs IGrp3E0Kud1q2XcoPE1EkOvofIn7GSpKJu83K6sxd/w3JMrHHHGGXOw2PChNqqDO1Ysz 95tA== 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=lQSPKyYDoHa99B4VOxBuXfoivnQccRMB0UUTzyBdHE9EO7Y2FgzgszSqa2Gqj1xxgB TKnH/WaDjNtV16H0NJOvq4K+VLPxCPrdOQcXI+j8Fn8DcbQ+d67wnctAxKr6XRENW3oi yhyXiBrVQFAl1eJEWm4Qc0a+jUAxCBstQexc+/IYlJxnLjoo0HBXcM/UvHHRBSLdjYe0 ZjHBqfeao+Mse9sUwFOuNyn91Pa1GA0WghDBI++dV9jt8STFwLs51LvWQMtFTpSo3juW ZnzUVplGh543tTVjB7SVv2sw+Q2kBiNnx49WGEqnWoroUqDExsFh9/Radz3Vx7RVL/EI VBOw== X-Gm-Message-State: AJIora/kbZzQAG419/7xVnakVSJk7AjwP/njOJul63HYfA6FKnpgtDXP BfYMPIVt8aKTXaYknDFfvzT3ZivOPBrtBnk= X-Google-Smtp-Source: AGRyM1tuUbXkTHmwSeQpNvkpX+9RV2rNX0WnzUhlbbdeXGqZ5TcgzBxdsITPDnCaw3Rv47uHxqm1Rw== X-Received: by 2002:a05:6000:1446:b0:21d:cfe1:67a0 with SMTP id v6-20020a056000144600b0021dcfe167a0mr13565811wrx.91.1658159646328; Mon, 18 Jul 2022 08:54:06 -0700 (PDT) Received: from Mem (2a01cb088160fc006422ad4f4c265774.ipv6.abo.wanadoo.fr. [2a01:cb08:8160:fc00:6422:ad4f:4c26:5774]) by smtp.gmail.com with ESMTPSA id h7-20020adffd47000000b0021d650e4df4sm11230963wrs.87.2022.07.18.08.54.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 08:54:06 -0700 (PDT) Date: Mon, 18 Jul 2022 17:54: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 , Yonghong Song Subject: [PATCH bpf v2 1/5] ip_tunnels: Add new flow flags field to ip_tunnel_key Message-ID: <457f79e53a6b9f0921561bc796a49e917d131635.1658159533.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 Mon Jul 18 15:54:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Chaignon X-Patchwork-Id: 12921412 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 3DD7FC433EF for ; Mon, 18 Jul 2022 15:54:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234874AbiGRPyl (ORCPT ); Mon, 18 Jul 2022 11:54:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230174AbiGRPyk (ORCPT ); Mon, 18 Jul 2022 11:54:40 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EFE56465 for ; Mon, 18 Jul 2022 08:54:39 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id h17so17760403wrx.0 for ; Mon, 18 Jul 2022 08:54:39 -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=Hjg6zXcEQgOffoS5EbAyXFRdrHTBt8cuUBdNpDQuLu8=; b=PZksptx3+NBk5ZyL6GQ+yxZxy9duMMDrFpXIL9zZRaT0/bytPnl7QjqsRsKqHcMlow YSl89MFIZ7mhtufhlAsHmCC9UJOc7r321CaVIC9fZ5UDd3/x0821/aB/R6JjqMKERvrt +tfbYR0mxpuP8yBEBosG49MP4Y0kW93KB//R+lL7etBCE+6Msu2wTxqcmxwLBNp2zF80 6urk+WvTrA8MT06hP8DAmRlarb1GgW5M3+Y255VbVXSPsyjiacBtayH5OwzBMLOqTl6+ vlOiUFcyK2SH1g0QYElzgKKB0DeQRN+3FaWuCeSBs+lKeryMtr9HPXVNQ5gPBauS3s/k gWVg== 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=Hjg6zXcEQgOffoS5EbAyXFRdrHTBt8cuUBdNpDQuLu8=; b=7YfTHvmMqohz3ecSJIriDDcEbVJp8ZxjeKc8BTG39X/1s7Js46TA5WznLF2HOEuMOV It2BIsiU555iShgjBf4G70eJUp9WScQDWQkCfmy13uaCh3SdbIqCZt4slINiZinVM5me NwcKBXpx/x6Yh8SSeRNW4Q9EKBivEd+rSN2vJMGcGhgnkKdFWZK9RmuVpxHhHq08TJR9 yVUSlhD8cJbJDypWTc+QnboBCKcC8MAB11eY6As7ygR31ofFHvDx+E0JJRGvI/0iuKoC o71T1VMrqvxFirauX5Ejc7RPw4Tj9wSbEohuVBd+Sl/9pln11j09XmGecRo+ejWrNSVS xohg== X-Gm-Message-State: AJIora+kANjsKAASCCEo6P7BtUkfxQ4t+1Hlkro/S70qnYOxPPwSSL+t VdoeEkQzP2jrBtHoW4XKcLBa X-Google-Smtp-Source: AGRyM1tVUB88glHB+N94rkUZ9NVX49f78EhwHmz1TqKArqTmnqYKPeAiPOHDHkonueXQF3LHjvOxbA== X-Received: by 2002:adf:f1d0:0:b0:21d:9c0d:9b5 with SMTP id z16-20020adff1d0000000b0021d9c0d09b5mr22670127wro.689.1658159678091; Mon, 18 Jul 2022 08:54:38 -0700 (PDT) Received: from Mem (2a01cb088160fc006422ad4f4c265774.ipv6.abo.wanadoo.fr. [2a01:cb08:8160:fc00:6422:ad4f:4c26:5774]) by smtp.gmail.com with ESMTPSA id 7-20020a05600c264700b003a31c4f6f74sm3873962wmy.32.2022.07.18.08.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 08:54:37 -0700 (PDT) Date: Mon, 18 Jul 2022 17:54:36 +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 , Yonghong Song Subject: [PATCH bpf v2 2/5] vxlan: Use ip_tunnel_key flow flags in route lookups Message-ID: <0e0e26155df4e63def5e863b725d10c95d850995.1658159533.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 IPv4 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 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 265d4a0245e7..6991bf7c1cf0 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)) { @@ -2459,7 +2460,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 +2526,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 +2557,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); @@ -3061,7 +3063,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); From patchwork Mon Jul 18 15:54:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Chaignon X-Patchwork-Id: 12921413 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 1289FCCA479 for ; Mon, 18 Jul 2022 15:55:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235000AbiGRPzC (ORCPT ); Mon, 18 Jul 2022 11:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230174AbiGRPzB (ORCPT ); Mon, 18 Jul 2022 11:55:01 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42D5C2983E for ; Mon, 18 Jul 2022 08:55:00 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id a5so17674089wrx.12 for ; Mon, 18 Jul 2022 08:55:00 -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=mDb9whvWU3aIAljsROfD3VS/LVSIYuoUZ7vz5yEj+JA=; b=vOh9tiz7pU4joZzaooEQdjB/tWxraeC9px8ydo+Zmqpu/svNVGMX7YsCes47OzRRpe MoHVCNTEsMkKLATfWDJyvqRSMaJ1ZfoygRUs5DJw9n8MvrWfwM3pAL4PqLzmCoXNkzNW dNfQ5GdyogB/IqLOlemx6p1HUfbd51hZaA8Or4FAy7TU94zPc1bCstusDDDOKTS18Cee d0sErCsr7tqf2Uw/o5erWjR0F/czk5GrC220XYMUEok+z6OicSZESu+SUHJncmY5aNKi l5+t86zRFgYCLcFVnmZjC5mCD9K2sA160v62MRBYQTqpfz8ogIC8iSIvtZdFsWB0gOPX 1MNg== 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=mDb9whvWU3aIAljsROfD3VS/LVSIYuoUZ7vz5yEj+JA=; b=XgP/LWjMBI0QIkPR7eGnJ/2RN/T085rcXT5WvMftCscKfSk0S9Qme+Af1iAyuAa5OH 36f68OPOtTxc2xEuX7NW8HbmCgVuT0NEWjtMt4SSthAXuHoPLDphZ0P3piZaWmpn53LN LPRB6hDbb6/o9niP208uelSdVDPTpao4zjsh79zjd1PUhxKqnONJnQo6tg+KECVwxWe6 P/F0VKWg1YhVcdeyKSEqG/s/EVLG5cTtuYfQvIsNa+iqFfTbek4CQQucARocDJBD1suV uWPZPbb9xvpn/RuB+1gF9Fk42qAJM/XnzinV/8/h+X8/tP/M7qv9SXW+zE+6QkKcQR+g 7tPQ== X-Gm-Message-State: AJIora9w9jOYOyX3z4TnufrFi7PYzD54m4jLbwxL8X+5DhWuQtB7CgQ8 zYbTn3y/vitabuEFmMdAs80G X-Google-Smtp-Source: AGRyM1twMDtcUqhsDm1D5PjPfYTk8J48S6lNCSgyxg6Bi/vBvQgWfob+8o0q1du/jnuOupvJ6cWY0A== X-Received: by 2002:a5d:5451:0:b0:21d:2295:6a05 with SMTP id w17-20020a5d5451000000b0021d22956a05mr23098167wrv.302.1658159698730; Mon, 18 Jul 2022 08:54:58 -0700 (PDT) Received: from Mem (2a01cb088160fc006422ad4f4c265774.ipv6.abo.wanadoo.fr. [2a01:cb08:8160:fc00:6422:ad4f:4c26:5774]) by smtp.gmail.com with ESMTPSA id h7-20020adffd47000000b0021d650e4df4sm11232724wrs.87.2022.07.18.08.54.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 08:54:58 -0700 (PDT) Date: Mon, 18 Jul 2022 17:54:56 +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 , Yonghong Song Subject: [PATCH bpf v2 3/5] geneve: Use ip_tunnel_key flow flags in route lookups Message-ID: <500695e5e5cfbfd94f37959c250e194aff88c7e1.1658159533.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 IPv4 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 | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index 2495a5719e1c..018d365f9deb 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) { From patchwork Mon Jul 18 15:55:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Chaignon X-Patchwork-Id: 12921414 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 9D980CCA479 for ; Mon, 18 Jul 2022 15:55:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235043AbiGRPzT (ORCPT ); Mon, 18 Jul 2022 11:55:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231567AbiGRPzS (ORCPT ); Mon, 18 Jul 2022 11:55:18 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B10E62983E for ; Mon, 18 Jul 2022 08:55:17 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id a11so1276784wmq.3 for ; Mon, 18 Jul 2022 08:55:17 -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=de65JHAf/8D+v+XVKW0OHlE0ON3UO9qmitW45Wit8Ow=; b=hGqSX7abQ7NhrJ6eyhq01svyHXt2Lh3ywrrs7P/5cPge/yyHiD3kNtIrgICmd681/E Li3fS2cP+Hs1yuzQz+USfl1w949Gs+gY5t+miRXZHCD3Wgxb71l+OYEQiNxpJdZcLihr U9x61EY3coMVjDCHUYGelxly9U7VInQ0meR5mEOf/h8uIyoSTvSRlRkfceIInRxTaQ/+ 9NUpv6+uZFh6fXjMnlwGRqQE5qJc7oaJH7ARPWcsjuv4h396ssHY9fWfu2vgOx74qkcY V8REQRc5BRJSpX1ZO6VVFjiGQ5MhiuzAJZQzmKuJaC5fEFaTK+iAZLJu1FE13fCSAyTl 64lA== 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=de65JHAf/8D+v+XVKW0OHlE0ON3UO9qmitW45Wit8Ow=; b=PA8Zjpa08zyhnpSpc2q23aJMwkNOYzcFH/YBL1El499RG73W14daAhbfYmgG0hc+uf N7g8t2fMbFR0chmlIs0fNj7mqBU5yvojnaRYEd8FQnv6rNW/Wcsl2+z4N/3T2HKlCekz 705+bT5JmlzNHm3cqnX9JSW4den0gLFVmNXB5Y+zY5wVBIbLTpF2umbPRAE6ChZKEHkz 7kv6xW04uFHYHvc+B5R07sOLBtA2LnEY9xe+ll4oWqP1TMmJGrfqvUZqe/k02AqVAt1I jud6jG18820vVYk3CLzGoMj6J8bb6SlP57sX2nlKnhVHc71joPSfNrDc+pKRAfB55ZOM 7W1Q== X-Gm-Message-State: AJIora8oUZXsP6rafsiJ9SKw6lih3OYoraUTo2fmS7DCFAN7s3/LUYDJ C+qwyJlSUcKjk5WcLdJWkvxm X-Google-Smtp-Source: AGRyM1tx74gyfosDpVh2rY6IrLw8ovxGL2+54lu3NJ2hQPlYrVd8+Q+pYQ8HxL6BaUASoSFjzvoG2Q== X-Received: by 2002:a05:600c:1986:b0:3a1:9fc4:b683 with SMTP id t6-20020a05600c198600b003a19fc4b683mr33717889wmq.72.1658159716205; Mon, 18 Jul 2022 08:55:16 -0700 (PDT) Received: from Mem (2a01cb088160fc006422ad4f4c265774.ipv6.abo.wanadoo.fr. [2a01:cb08:8160:fc00:6422:ad4f:4c26:5774]) by smtp.gmail.com with ESMTPSA id k15-20020a7bc30f000000b0039c54bb28f2sm15647436wmj.36.2022.07.18.08.55.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 08:55:15 -0700 (PDT) Date: Mon, 18 Jul 2022 17:55:14 +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 , Yonghong Song Subject: [PATCH bpf v2 4/5] bpf: Set flow flag to allow any source IP in bpf_tunnel_key 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 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..2e3dc9b8e612 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -4653,6 +4653,7 @@ BPF_CALL_4(bpf_skb_set_tunnel_key, struct sk_buff *, skb, } else { info->key.u.ipv4.dst = cpu_to_be32(from->remote_ipv4); info->key.u.ipv4.src = cpu_to_be32(from->local_ipv4); + info->key.flow_flags = FLOWI_FLAG_ANYSRC; } return 0; From patchwork Mon Jul 18 15:55:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Chaignon X-Patchwork-Id: 12921415 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 83D39C433EF for ; Mon, 18 Jul 2022 15:55:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235056AbiGRPzd (ORCPT ); Mon, 18 Jul 2022 11:55:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230174AbiGRPzc (ORCPT ); Mon, 18 Jul 2022 11:55:32 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A8642A41F for ; Mon, 18 Jul 2022 08:55:31 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id a5so17676396wrx.12 for ; Mon, 18 Jul 2022 08:55:31 -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=EXxkakBYHHMmV1resyEvWwZDbmjWsWVlSMwrmJMu+fyaOY1DJWzFfwrcxGt7evNn8T TkZYQPcBY4yXz6LWrNgh/tctKwzhj9EOrq2o58NA+f7fPwH/IAYkmw8uFCbRLLmqC36L afBwLwG9CTtHVVS6eG46ogvGj4yYjIcG/Wv4vddlurYvfEvM2v0MiLXoAj71GHjfPIqv ZDDGYrK1PGil1TBCkdYnFADTu7+opZpKg+aEKjFRSPynGkG+8zjpw7pm+jc54/73g5CS b0tvbSGoTslNE8gcOvqAMhYpLs1Igmml6RJEv6pm1utpg7tn8xROxqr5eWSLWRBDyEwE BElg== 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=rlxDsNL8hXOfV7TwKW2RTRtzPBP8wFDGOhBiQwgaitUUoYA2/Skzp03bE0A7Ba3ns+ R9CXHwzBTnmD1gqlPCQFq4OxyeJEeQsWWarlVjJ0YQUZ8MywyD71esNK+/xgNtf6z0nc pF041vPkKEfeXPxXp5/JH0iPvqrscTb1my6aTRQUeN+1Da93O5HOtcUC3gRNvyhsTtgt QrOggS3MZdNU8xpVXHEcm6es62TmXoIUj4hU+Zvo8qLPTvIWaU5Ci6zU8aBfx9BX/F9l 1rKIqBrzyujpF75Zqi7s0ZpOkpc0bHtkM6GLrlFlKORiWUXULZ4EOZsjqSVGQJZJ8YZU bE1w== X-Gm-Message-State: AJIora9PzKKTU493DZaTIY4LvDNWo7ItTTv4uaXT/7TMTw+lRkCE0WBK E88MbGHT0tUmW/N3S4OGvqiG X-Google-Smtp-Source: AGRyM1vwtfQ8ITTvIIUj9bCMNXMi61TsMC6zmPCQEUqTOUydZvpfUpu6N3bpglzrpzFDX+fvgOdHsA== X-Received: by 2002:adf:e6c1:0:b0:21d:6497:f819 with SMTP id y1-20020adfe6c1000000b0021d6497f819mr22250931wrm.243.1658159730971; Mon, 18 Jul 2022 08:55:30 -0700 (PDT) Received: from Mem (2a01cb088160fc006422ad4f4c265774.ipv6.abo.wanadoo.fr. [2a01:cb08:8160:fc00:6422:ad4f:4c26:5774]) by smtp.gmail.com with ESMTPSA id d14-20020adffd8e000000b0021d6a23fdf3sm11214824wrr.15.2022.07.18.08.55.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 08:55:30 -0700 (PDT) Date: Mon, 18 Jul 2022 17:55:28 +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 , Yonghong Song Subject: [PATCH bpf v2 5/5] selftests/bpf: Don't assign outer source IP to host Message-ID: <3509b3fb239bdb56d420f49f0abf8343d0063f83.1658159533.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");