Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19631431rwd; Wed, 28 Jun 2023 11:54:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ZORxO0ionqIZ8QxM/zDC1pTakpQG6Z8pTJx3RNQzzyaTxT03MmAcqtjBNdv0K7FB3YFL/ X-Received: by 2002:a17:903:489:b0:1b8:2adc:8358 with SMTP id jj9-20020a170903048900b001b82adc8358mr2454512plb.11.1687978441091; Wed, 28 Jun 2023 11:54:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687978441; cv=none; d=google.com; s=arc-20160816; b=jl51oTOrSkudd66gjw78DGOVdmn6fQvN1S7zIWqQWxfUhqmEclYeb7yJFR0ExdOQeS VVq65PvyaAytOZR6VMvgeaJEFihbpmOgangeXDoOW3Lp/gC44zVig0UU3TVO5SYPbZsb 2jfT/JRd18y/xoEzd9jp2y70cdqiDRnkFx1FBrbHT/odNu6XgfoOEwuozDWycyweO9VG zFv6AksNq4ahJKyqKVYTLh+Yw3MLD2quCPZ3nhvqgcs+LjoCf2JFW1SDUGJ/SgH43r/E RalrVGMzIfpxlALgiM8WxE2JTWq1nu10g1gMaHpGP/iDgoAkwGZd4kPrzhnBG25JCPWC V3EQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BL4ULAFej05+WRV13/0IUuXBJpcZCjd4OTT8VyAGeUo=; fh=O6BRKew07CxxKA7AhkGKWhvW1RveMnrsvQtRPUqj3W0=; b=fNNZiMnk8sbFdxQ0s2LSW9LrNyR9uGQ/k4NeO+ZgWBXY6P4MeUoQekDtqtZIhagoDV xtZwhZksgnzFf3AxMW7688fOO/AT+2QRdm++VWhZup/2DWKGdmMnUvwa+RTb63wUpOlW R49aJbePFoqLSur/H5fiv2P4PQLQ1UqZIiv1IMysiA0WeNcvhGNa5iUjINttynJDspA5 ksEnD2FikGO4uNQItqzXxK2IEb/vQSCchcWJcfOL7r12ZSAISzI1oPvSSCKeiS88q2o2 pC8QJT/mpj5Q67azJDzAfpLKEEhgMzkEAAMhgXWv2z1Xt0hYVXUf/Ysqh9RxoTsxtgym J4Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=md69R2XK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i11-20020a170902eb4b00b001b801bd7fbasi6326451pli.417.2023.06.28.11.53.48; Wed, 28 Jun 2023 11:54:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=md69R2XK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231382AbjF1SkV (ORCPT + 99 others); Wed, 28 Jun 2023 14:40:21 -0400 Received: from smtp-fw-80006.amazon.com ([99.78.197.217]:54882 "EHLO smtp-fw-80006.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbjF1SkT (ORCPT ); Wed, 28 Jun 2023 14:40:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1687977620; x=1719513620; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BL4ULAFej05+WRV13/0IUuXBJpcZCjd4OTT8VyAGeUo=; b=md69R2XKNtIInjnpodcnZ8ZCRoSl0TFUSxMBAnm0cudPbrsS7/PTXU4u K+PU8b/s2nIyom7cMzaFy+BQT1S6xCoHI+DbQs4ZToD9q9taXhaNuP9wG yfPU5h6TDJvVgBe3vELVjWFjI+iml6KDWvNL8Y0ntwCzpCVKCD3Eclx0t s=; X-IronPort-AV: E=Sophos;i="6.01,166,1684800000"; d="scan'208";a="223422365" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO email-inbound-relay-iad-1a-m6i4x-9fe6ad2f.us-east-1.amazon.com) ([10.25.36.210]) by smtp-border-fw-80006.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2023 18:40:16 +0000 Received: from EX19MTAUWB001.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-iad-1a-m6i4x-9fe6ad2f.us-east-1.amazon.com (Postfix) with ESMTPS id 1B2B7805E6; Wed, 28 Jun 2023 18:40:08 +0000 (UTC) Received: from EX19D004ANA001.ant.amazon.com (10.37.240.138) by EX19MTAUWB001.ant.amazon.com (10.250.64.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Wed, 28 Jun 2023 18:40:04 +0000 Received: from 88665a182662.ant.amazon.com.com (10.187.170.50) by EX19D004ANA001.ant.amazon.com (10.37.240.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Wed, 28 Jun 2023 18:39:59 +0000 From: Kuniyuki Iwashima To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH bpf-next v4 4/7] net: document inet[6]_lookup_reuseport sk_state requirements Date: Wed, 28 Jun 2023 11:39:50 -0700 Message-ID: <20230628183950.75449-1-kuniyu@amazon.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230613-so-reuseport-v4-4-4ece76708bba@isovalent.com> References: <20230613-so-reuseport-v4-4-4ece76708bba@isovalent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.187.170.50] X-ClientProxiedBy: EX19D041UWA003.ant.amazon.com (10.13.139.105) To EX19D004ANA001.ant.amazon.com (10.37.240.138) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lorenz Bauer Date: Wed, 28 Jun 2023 10:48:19 +0100 > The current implementation was extracted from inet[6]_lhash2_lookup > in commit 80b373f74f9e ("inet: Extract helper for selecting socket > from reuseport group") and commit 5df6531292b5 ("inet6: Extract helper > for selecting socket from reuseport group"). In the original context, > sk is always in TCP_LISTEN state and so did not have a separate check. > > Add documentation that specifies which sk_state are valid to pass to > the function. > > Signed-off-by: Lorenz Bauer Reviewed-by: Kuniyuki Iwashima 2 nit below. > --- > net/ipv4/inet_hashtables.c | 14 ++++++++++++++ > net/ipv6/inet6_hashtables.c | 14 ++++++++++++++ > 2 files changed, 28 insertions(+) > > diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c > index 352eb371c93b..ac927a635a6f 100644 > --- a/net/ipv4/inet_hashtables.c > +++ b/net/ipv4/inet_hashtables.c > @@ -335,6 +335,20 @@ static inline int compute_score(struct sock *sk, struct net *net, > > INDIRECT_CALLABLE_DECLARE(inet_ehashfn_t udp_ehashfn); > > +/** > + * inet_lookup_reuseport() - execute reuseport logic on AF_INET socket if necessary. > + * @net: network namespace. > + * @sk: AF_INET socket, must be in TCP_LISTEN state for TCP or TCP_CLOSE for UDP. > + * @skb: context for a potential SK_REUSEPORT program. > + * @doff: header offset. > + * @saddr: source address. > + * @sport: source port. > + * @daddr: destination address. > + * @hnum: destination port in host byte order. It seems you forgot to copy-and-paste the ehashfn description. ---8<--- + * @ehashfn: hash function used to generate the fallback hash. ---8<--- https://lore.kernel.org/all/20230613-so-reuseport-v3-4-907b4cbb7b99@isovalent.com/ > + * > + * Return: NULL if sk doesn't have SO_REUSEPORT set, otherwise a pointer to > + * the selected sock or an error. > + */ > struct sock *inet_lookup_reuseport(struct net *net, struct sock *sk, > struct sk_buff *skb, int doff, > __be32 saddr, __be16 sport, > diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c > index 3616225c89ef..d37602fabc00 100644 > --- a/net/ipv6/inet6_hashtables.c > +++ b/net/ipv6/inet6_hashtables.c > @@ -114,6 +114,20 @@ static inline int compute_score(struct sock *sk, struct net *net, > > INDIRECT_CALLABLE_DECLARE(inet6_ehashfn_t udp6_ehashfn); > > +/** > + * inet6_lookup_reuseport() - execute reuseport logic on AF_INET6 socket if necessary. > + * @net: network namespace. > + * @sk: AF_INET6 socket, must be in TCP_LISTEN state for TCP or TCP_CLOSE for UDP. > + * @skb: context for a potential SK_REUSEPORT program. > + * @doff: header offset. > + * @saddr: source address. > + * @sport: source port. > + * @daddr: destination address. > + * @hnum: destination port in host byte order. Same here. > + * > + * Return: NULL if sk doesn't have SO_REUSEPORT set, otherwise a pointer to > + * the selected sock or an error. > + */ > struct sock *inet6_lookup_reuseport(struct net *net, struct sock *sk, > struct sk_buff *skb, int doff, > const struct in6_addr *saddr, > > -- > 2.40.1