From mboxrd@z Thu Jan 1 00:00:00 1970 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 88729C77B73 for ; Thu, 27 Apr 2023 18:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244490AbjD0SDo (ORCPT ); Thu, 27 Apr 2023 14:03:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjD0SDn (ORCPT ); Thu, 27 Apr 2023 14:03:43 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5968420A for ; Thu, 27 Apr 2023 11:03:42 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id d2e1a72fcca58-64115e69e1eso5304228b3a.0 for ; Thu, 27 Apr 2023 11:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682618622; x=1685210622; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=fh+piB/LEKCTLTDSFOcrpICMj5GtBDUbjH//IFYqtZc=; b=cbI3HrZ2S3Ue1P/yd267JGutYEFecBnHhGg5i+33d83UHEJlA8CCQPmWfb2C0/EoVp C2w7VZxiJGmtsZA0UpzavcDzybKtoSJnZo1Kzc1dnySm1o5oILW75z0fxqjUtdstrwde fjf8IO549GRnmnfuav7TUxJ0Dlmojy8OxDaP9e/AhfT5lcy2kHveC2HddiAGFMEIpaOC DcSq68UW5vaj9ixkmoCcmWCGyn5MaWhokB67KqjpUMI906P/d+x3roSv0u7dg+V7/BuV E8rcUo9gPGwlJYXlNjurjQ0pfSewt7Yhb8x5VsP1rVefebJijdIZTiXAT5bF1D22tYb4 aMJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682618622; x=1685210622; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fh+piB/LEKCTLTDSFOcrpICMj5GtBDUbjH//IFYqtZc=; b=P6PwiYKPEzPVzhE1hir2Kg2+MhrU/jvGROgIqfC83AIZsaSQHQHnA2VF2jxs2I2XxF Jc8D+fOe9q9xifOuSOk/uEyATPUr+/r1kbgdJBZh+YarjydovcxLPy6oOTQ0oNaQnGJ2 GL1kmeAmmbuH9YX8SUZmYX2A9LmvC2bRqeUjBIxB91pkaovq4Fsv3rZntXsvfWRNzOdh 6fz76SsK/XpKAZpk7lpT12tOK27A9uCT4n8kt/2iW0YB89wno9I3PX+J5rFYGcZBplDW N9TQViriS3q3bKkCYZExum9qvR61Li84cm6LRXjXIW+RcXU0k/tXOAEdK5lxB+DER+Eu AYtg== X-Gm-Message-State: AC+VfDx65LwONiIHBu/EniPmaubSuu3KAk/mNE3KGpfF954o9SRkOWNb 0+7VVd43CPLrW4zhcq5m0x8DrH8= X-Google-Smtp-Source: ACHHUZ4m5XBsE7zGA4Mdisw1N212Syt2mumgBcZVYtNSGwwcpqJvfmHMA1PTfBUBSVvnVbXfqQwl0kw= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a63:2843:0:b0:520:8b35:157d with SMTP id bs64-20020a632843000000b005208b35157dmr760782pgb.4.1682618622166; Thu, 27 Apr 2023 11:03:42 -0700 (PDT) Date: Thu, 27 Apr 2023 11:03:40 -0700 In-Reply-To: <20230426085122.376768-3-gilad9366@gmail.com> Mime-Version: 1.0 References: <20230426085122.376768-1-gilad9366@gmail.com> <20230426085122.376768-3-gilad9366@gmail.com> Message-ID: Subject: Re: [PATCH bpf,v3 2/4] bpf: Call __bpf_sk_lookup()/__bpf_skc_lookup() directly via TC hookpoint From: Stanislav Fomichev To: Gilad Sever Cc: dsahern@kernel.org, martin.lau@linux.dev, daniel@iogearbox.net, john.fastabend@gmail.com, ast@kernel.org, andrii@kernel.org, song@kernel.org, yhs@fb.com, kpsingh@kernel.org, haoluo@google.com, jolsa@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mykolal@fb.com, shuah@kernel.org, hawk@kernel.org, joe@wand.net.nz, eyal.birger@gmail.com, shmulik.ladkani@gmail.com, bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org On 04/26, Gilad Sever wrote: > skb->dev always exists in the tc flow. There is no need to use > bpf_skc_lookup(), bpf_sk_lookup() from this code path. > > This change facilitates fixing the tc flow to be VRF aware. > > Reviewed-by: Shmulik Ladkani > Reviewed-by: Eyal Birger > Signed-off-by: Gilad Sever Acked-by: Stanislav Fomichev > --- > net/core/filter.c | 24 ++++++++++++++++++------ > 1 file changed, 18 insertions(+), 6 deletions(-) > > diff --git a/net/core/filter.c b/net/core/filter.c > index 5910956f4e0d..f43f86fc1235 100644 > --- a/net/core/filter.c > +++ b/net/core/filter.c > @@ -6704,8 +6704,12 @@ static const struct bpf_func_proto bpf_sk_lookup_udp_proto = { > BPF_CALL_5(bpf_tc_skc_lookup_tcp, struct sk_buff *, skb, > struct bpf_sock_tuple *, tuple, u32, len, u64, netns_id, u64, flags) > { > - return (unsigned long)bpf_skc_lookup(skb, tuple, len, IPPROTO_TCP, > - netns_id, flags); > + struct net *caller_net = dev_net(skb->dev); > + int ifindex = skb->dev->ifindex; > + > + return (unsigned long)__bpf_skc_lookup(skb, tuple, len, caller_net, > + ifindex, IPPROTO_TCP, netns_id, > + flags); > } > > static const struct bpf_func_proto bpf_tc_skc_lookup_tcp_proto = { > @@ -6723,8 +6727,12 @@ static const struct bpf_func_proto bpf_tc_skc_lookup_tcp_proto = { > BPF_CALL_5(bpf_tc_sk_lookup_tcp, struct sk_buff *, skb, > struct bpf_sock_tuple *, tuple, u32, len, u64, netns_id, u64, flags) > { > - return (unsigned long)bpf_sk_lookup(skb, tuple, len, IPPROTO_TCP, > - netns_id, flags); > + struct net *caller_net = dev_net(skb->dev); > + int ifindex = skb->dev->ifindex; > + > + return (unsigned long)__bpf_sk_lookup(skb, tuple, len, caller_net, > + ifindex, IPPROTO_TCP, netns_id, > + flags); > } > > static const struct bpf_func_proto bpf_tc_sk_lookup_tcp_proto = { > @@ -6742,8 +6750,12 @@ static const struct bpf_func_proto bpf_tc_sk_lookup_tcp_proto = { > BPF_CALL_5(bpf_tc_sk_lookup_udp, struct sk_buff *, skb, > struct bpf_sock_tuple *, tuple, u32, len, u64, netns_id, u64, flags) > { > - return (unsigned long)bpf_sk_lookup(skb, tuple, len, IPPROTO_UDP, > - netns_id, flags); > + struct net *caller_net = dev_net(skb->dev); > + int ifindex = skb->dev->ifindex; > + > + return (unsigned long)__bpf_sk_lookup(skb, tuple, len, caller_net, > + ifindex, IPPROTO_UDP, netns_id, > + flags); > } > > static const struct bpf_func_proto bpf_tc_sk_lookup_udp_proto = { > -- > 2.34.1 >