From patchwork Fri Aug 2 13:40:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13751554 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B69831E3CD5 for ; Fri, 2 Aug 2024 13:40:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722606038; cv=none; b=FNe4CfeRfCJ3kP8OaLKBxWlMbCcqspe0Z83b7LLapLL06rTzNKQ9dVKGUfgGfnXvu7JcnB06ezsjL8Lji4BeXJcrchdkxxRl33sCRuFKCY1tkpr/R4A/QOhsuOAh5DBPJaDhxYj/2UVB9/EacGmwmA8BHnly6pRTIKtkTEA+pO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722606038; c=relaxed/simple; bh=spCrNzbGkK8/+ZHqzp4os4fkptzalQRSmeVLbxdO8gk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=oEX1IW8ujY75Zoo63noCMwe/QVSbSjj1owiz+TSmuqiXSr1wXC01KoMTjesMNlbDCgyRYRC/GsXQb1A7u9jq7E2u+Jg/yCpsUYxbpz+1NQD1tjQuEkY43KsphLusDLeqnY3k2NuV2xak/bNPc8s5Q2rSq2cYb71TLh9CxjWjeig= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=IQ1hYnJU; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IQ1hYnJU" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-65194ea3d4dso157926357b3.0 for ; Fri, 02 Aug 2024 06:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722606035; x=1723210835; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=knorcKRv5dDMneA1GmD9DFCzjlihhkTLp7+wgFH0124=; b=IQ1hYnJUjxdP2c7IQzbkAja7JBHtkig9RbNYlzNAJW2Iz9yNoUTdRW5FtsrOXydktQ Lfc0vT4BVG8NeXjpIH3JrIPrqhCdkdcI8ygCiQ2KEeAKucjLQkk4Qg9lHU7bV05AHgBI sqB/8009co7Qno1eZwnynEiDPEf5HPrbWGBJ1lEK/np+Ihl0zAtHQlmu/Ow6RonwYo80 K8wzpwQHVOGXRTPPHdGBlkjKmuIZ1i1/dFJtIAVmsba56+K3aG/9lK0fLL7s/bXhs+Ja zCcSt9kxqw5rh6bhoZXJlznx3BJIwrW1itWU9jLclyqqz1I5ONd+np4LCq2q7M3CJEl0 6Fyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722606035; x=1723210835; 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=knorcKRv5dDMneA1GmD9DFCzjlihhkTLp7+wgFH0124=; b=a/ixeKR0Qtc0yuNfSllatRAXxxpfQidg/sVOUr53d7xPfFcJv7kbY2Dx81/NNyA/RK OyZSln95FYg23bERaKq03dYEOfPYjBfCTztd9sWWEOK6NLymBS6KsQTTeHQnU0djvELR gYwoLge5HZHJ5stK3r7BO0kFGCyGxImfC3IdB3FBC2nkyPLYcI9Ix/295lc5sCMMwYPU tXSWb5nsl/uTyE5xQZj/+KarlAW59MSFFggXPOrefonhmpBMDE7k59Uap7EWTBGZ4w9U T33mSGQJvE9+VrrgibKsk9gJSh5ZWKXV9jFpsNlyTEmv24NZJD3aaM2EiTpp5+Al2n5d GSTw== X-Forwarded-Encrypted: i=1; AJvYcCW3ZmRFoehxZ8f5rTAkppMLYVADrIwM/0kmSXe1DgEp4Y8dqpA4P9OHDwVdPKCWL27P5Yb5zxTqm9OgOmXNCbCmXM+alr9U X-Gm-Message-State: AOJu0YyuY7GkAuXkKPr5T6kteSXs8jM2YiTt1Ql7SpcLcoxXOGfp+iPN 5Nv5n7hlyDQzVe9bBrpBpMzyqKzM+wx0dpSLo+0mcsMkUGjKNTjLi/im92FG5ww4qzstXSxrkQ4 +j//MiFpd1w== X-Google-Smtp-Source: AGHT+IE1WPfQR5vYwR+Idb2act7F8DUd0LNET6m+S6Z412VYPAWgltoYchFsRh1KOJYzP7eg/i9sL6LX6lYTZQ== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6902:2b8b:b0:e05:eb99:5f84 with SMTP id 3f1490d57ef6-e0bde3656a2mr5785276.4.1722606035605; Fri, 02 Aug 2024 06:40:35 -0700 (PDT) Date: Fri, 2 Aug 2024 13:40:25 +0000 In-Reply-To: <20240802134029.3748005-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240802134029.3748005-1-edumazet@google.com> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog Message-ID: <20240802134029.3748005-2-edumazet@google.com> Subject: [PATCH net-next 1/5] inet: constify inet_sk_bound_dev_eq() net parameter From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: David Ahern , Willem de Bruijn , Tom Herbert , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org inet_sk_bound_dev_eq() and its callers do not modify the net structure. Signed-off-by: Eric Dumazet Reviewed-by: Simon Horman --- include/net/inet6_hashtables.h | 2 +- include/net/inet_hashtables.h | 2 +- include/net/inet_sock.h | 3 ++- net/ipv4/inet_hashtables.c | 2 +- net/ipv6/inet6_hashtables.c | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index 533a7337865a4308c073b30b69dae4dcf7e6b264..591cbf5e4d5f86375598b9622f616ac662b0fc4e 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h @@ -175,7 +175,7 @@ struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo, int inet6_hash(struct sock *sk); -static inline bool inet6_match(struct net *net, const struct sock *sk, +static inline bool inet6_match(const struct net *net, const struct sock *sk, const struct in6_addr *saddr, const struct in6_addr *daddr, const __portpair ports, diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 7f1b384587437d06834bde554edd8df983fd64a4..1cc8b7ca20a10c1b0c8a6b9a029e5f8b4a1e846d 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h @@ -351,7 +351,7 @@ static inline struct sock *inet_lookup_listener(struct net *net, ((__force __u64)(__be32)(__saddr))) #endif /* __BIG_ENDIAN */ -static inline bool inet_match(struct net *net, const struct sock *sk, +static inline bool inet_match(const struct net *net, const struct sock *sk, const __addrpair cookie, const __portpair ports, int dif, int sdif) { diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index f9ddd47dc4f8d989e1c966bf363ed846c0911639..394c3b66065e20d34594d6e2a2010c55bb457810 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h @@ -150,7 +150,8 @@ static inline bool inet_bound_dev_eq(bool l3mdev_accept, int bound_dev_if, return bound_dev_if == dif || bound_dev_if == sdif; } -static inline bool inet_sk_bound_dev_eq(struct net *net, int bound_dev_if, +static inline bool inet_sk_bound_dev_eq(const struct net *net, + int bound_dev_if, int dif, int sdif) { #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV) diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index 48d0d494185b19a5e7282ffb6b33051604c28c9f..3d913dbd028404b1a1bf4dc3f988133e4a1d52ec 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -310,7 +310,7 @@ inet_lhash2_bucket_sk(struct inet_hashinfo *h, struct sock *sk) return inet_lhash2_bucket(h, hash); } -static inline int compute_score(struct sock *sk, struct net *net, +static inline int compute_score(struct sock *sk, const struct net *net, const unsigned short hnum, const __be32 daddr, const int dif, const int sdif) { diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index 6db71bb1cd300a9a3d91a8d771db4521978bc5d6..f29f094e57a4a5da8b238246d437328569a165d3 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c @@ -89,7 +89,7 @@ struct sock *__inet6_lookup_established(struct net *net, } EXPORT_SYMBOL(__inet6_lookup_established); -static inline int compute_score(struct sock *sk, struct net *net, +static inline int compute_score(struct sock *sk, const struct net *net, const unsigned short hnum, const struct in6_addr *daddr, const int dif, const int sdif) From patchwork Fri Aug 2 13:40:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13751555 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f201.google.com (mail-qk1-f201.google.com [209.85.222.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DFD01E485B for ; Fri, 2 Aug 2024 13:40:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722606040; cv=none; b=BeOogsYGibwIZTJWPvfgnqZN0t90y4hW1l9Qe3Ry1hFW+m2TfKmSujAuYoHmu8k1C1bF5DbyljeUqEpz++yMYNbJ8A1mntEV3r6wFPDf9GPOS7kAtKWHOuKWv/zNOIakJwUxZenGRdrlo/YUkV0xAT/QdDef6ae04QLyjOAULoo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722606040; c=relaxed/simple; bh=tyyH640+l+MA9Jf+TfbxkFuk52tJt0TSRt9Ih56Xm5g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mBHd220lJJfmEX8PpE6hP6C0tcOBHa0njqYVOgevk9/M86V5jzNoFYs48IqI0C5KcpKkKhtDfcGOloAPNOZ0X/gE4FQ5sTPSw8Elz9T4S6XcyCkbMOGiWUEEh7V5R1vW7ID7k97QTvDQ1ihuAx2tPX1Vr6RrsRWNyymilScjlGI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=IJ5cUs/L; arc=none smtp.client-ip=209.85.222.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="IJ5cUs/L" Received: by mail-qk1-f201.google.com with SMTP id af79cd13be357-7a1d737f940so532616385a.0 for ; Fri, 02 Aug 2024 06:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722606037; x=1723210837; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=M7qOqghSjWdpJk3mrrs1cNVxDem0EoTuaZfvapvG15c=; b=IJ5cUs/LwMWmWnl+Hrw9mHcyFrXvpOBoNiolplj9gr7vdXBJM7RGRvmJWsZuD4qAZa dpheIgDhl7VmwV9ya6w9z37MDVE3RXYhMLfsVsZHfIdjKzIE1Ts1ii53yx0PoSdQobgN TCIvnk0Ggqxj3iRqw6DM4eTzVTsVhnUzDVhJ36KawYopZRPwOdtDErGfFLt8gdZJ8zQy br5EdWChJZ6OQ9PkDUH1ATbARST7ZNjs68N1vKn+AGhYI/9w0uSNvD8Ons7eyiMsTEUx LPZmdyLcmeUnK0+N8bzmCtxpztXXunn/HTC60lph5SRe6eYePlCu0UnYma3jHRXGnkpf TpTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722606037; x=1723210837; 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=M7qOqghSjWdpJk3mrrs1cNVxDem0EoTuaZfvapvG15c=; b=NtCO0UiIKbVUokK8XkyK2AJ+tO7Xj7DUiDlpu2TWn9hTHs0u58dR7nJyJB5q/gG/4c ArQp8VnYjNvmqNHj0bd/wsb/893JZRxwDOWafHmDhTeiTD3h5XUtez7LRk+nkhYNa39e pWPwYyjrvFAUlf/bWWDvVmovAJb8+k+Fw4JvqT2NxTVZopYTGqN3Kc3QadUvPtSr6oX9 NUzv8UuHnQaQ/BnrIOdTBrXkp9WgaOn0CX7Y5UIykNarI08xdInhZWIsgqjrXW+JQSvt dxKMazUsyK/ZOdTOvAzs7tptH+0Gz1V0XRIJmxvBge/3+CzeW5gLAbTLjzztet5MyhwL b9UQ== X-Forwarded-Encrypted: i=1; AJvYcCVcGuusJcvf6FeXMrE3G6qgbD4AKEcXfu/vFaj8BBn5ZrKYYAYJriiCN5QmxeG5c2E8CHTfAyaTsd+GRb89Qk2O/hYlC9Ia X-Gm-Message-State: AOJu0YzmNHZP7P1FP0rGxJVTPcEd4w/Hw/L0cfrTT/s8sI8O/fYW1hSc K/88/g4tGgaeVscclR5obJZM1pUaF/lL/G0dpXK7ERFGyNxPsnQ9JpKL0kDPTaNaP6R/OtgX8Vf MMDHiLPFLoA== X-Google-Smtp-Source: AGHT+IHwAirQoQmr05ThDsTs20/kDBKdUBxepURgxCYbnzaDf8IXPUuoc91xeq4j1N+s25ta90x5UHZ5OuwiSg== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6214:20aa:b0:6b5:db40:8dd1 with SMTP id 6a1803df08f44-6bb98509fa7mr1359286d6.0.1722606037229; Fri, 02 Aug 2024 06:40:37 -0700 (PDT) Date: Fri, 2 Aug 2024 13:40:26 +0000 In-Reply-To: <20240802134029.3748005-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240802134029.3748005-1-edumazet@google.com> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog Message-ID: <20240802134029.3748005-3-edumazet@google.com> Subject: [PATCH net-next 2/5] inet: constify 'struct net' parameter of various lookup helpers From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: David Ahern , Willem de Bruijn , Tom Herbert , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org Following helpers do not touch their struct net argument: - bpf_sk_lookup_run_v4() - inet_lookup_reuseport() - inet_lhash2_lookup() - inet_lookup_run_sk_lookup() - __inet_lookup_listener() - __inet_lookup_established() Signed-off-by: Eric Dumazet Reviewed-by: Simon Horman --- include/linux/filter.h | 2 +- include/net/inet_hashtables.h | 8 ++++---- net/ipv4/inet_hashtables.c | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/linux/filter.h b/include/linux/filter.h index b6672ff61407fc8dd56e4555e30f1a3c9dc238dc..4acd1da4dac623a0af53c3df888d42326189efcf 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -1616,7 +1616,7 @@ extern struct static_key_false bpf_sk_lookup_enabled; _all_pass || _selected_sk ? SK_PASS : SK_DROP; \ }) -static inline bool bpf_sk_lookup_run_v4(struct net *net, int protocol, +static inline bool bpf_sk_lookup_run_v4(const struct net *net, int protocol, const __be32 saddr, const __be16 sport, const __be32 daddr, const u16 dport, const int ifindex, struct sock **psk) diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 1cc8b7ca20a10c1b0c8a6b9a029e5f8b4a1e846d..5eea47f135a421ce8275d4cd83c5771b3f448e5c 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h @@ -304,7 +304,7 @@ int __inet_hash(struct sock *sk, struct sock *osk); int inet_hash(struct sock *sk); void inet_unhash(struct sock *sk); -struct sock *__inet_lookup_listener(struct net *net, +struct sock *__inet_lookup_listener(const struct net *net, struct inet_hashinfo *hashinfo, struct sk_buff *skb, int doff, const __be32 saddr, const __be16 sport, @@ -368,7 +368,7 @@ static inline bool inet_match(const struct net *net, const struct sock *sk, /* Sockets in TCP_CLOSE state are _always_ taken out of the hash, so we need * not check it for lookups anymore, thanks Alexey. -DaveM */ -struct sock *__inet_lookup_established(struct net *net, +struct sock *__inet_lookup_established(const struct net *net, struct inet_hashinfo *hashinfo, const __be32 saddr, const __be16 sport, const __be32 daddr, const u16 hnum, @@ -382,13 +382,13 @@ inet_ehashfn_t inet_ehashfn; INDIRECT_CALLABLE_DECLARE(inet_ehashfn_t udp_ehashfn); -struct sock *inet_lookup_reuseport(struct net *net, struct sock *sk, +struct sock *inet_lookup_reuseport(const struct net *net, struct sock *sk, struct sk_buff *skb, int doff, __be32 saddr, __be16 sport, __be32 daddr, unsigned short hnum, inet_ehashfn_t *ehashfn); -struct sock *inet_lookup_run_sk_lookup(struct net *net, +struct sock *inet_lookup_run_sk_lookup(const struct net *net, int protocol, struct sk_buff *skb, int doff, __be32 saddr, __be16 sport, diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c index 3d913dbd028404b1a1bf4dc3f988133e4a1d52ec..9bfcfd016e18275fb50fea8d77adc8a64fb12494 100644 --- a/net/ipv4/inet_hashtables.c +++ b/net/ipv4/inet_hashtables.c @@ -348,7 +348,7 @@ static inline int compute_score(struct sock *sk, const struct net *net, * 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 sock *inet_lookup_reuseport(const struct net *net, struct sock *sk, struct sk_buff *skb, int doff, __be32 saddr, __be16 sport, __be32 daddr, unsigned short hnum, @@ -374,7 +374,7 @@ EXPORT_SYMBOL_GPL(inet_lookup_reuseport); */ /* called with rcu_read_lock() : No refcount taken on the socket */ -static struct sock *inet_lhash2_lookup(struct net *net, +static struct sock *inet_lhash2_lookup(const struct net *net, struct inet_listen_hashbucket *ilb2, struct sk_buff *skb, int doff, const __be32 saddr, __be16 sport, @@ -401,7 +401,7 @@ static struct sock *inet_lhash2_lookup(struct net *net, return result; } -struct sock *inet_lookup_run_sk_lookup(struct net *net, +struct sock *inet_lookup_run_sk_lookup(const struct net *net, int protocol, struct sk_buff *skb, int doff, __be32 saddr, __be16 sport, @@ -423,7 +423,7 @@ struct sock *inet_lookup_run_sk_lookup(struct net *net, return sk; } -struct sock *__inet_lookup_listener(struct net *net, +struct sock *__inet_lookup_listener(const struct net *net, struct inet_hashinfo *hashinfo, struct sk_buff *skb, int doff, const __be32 saddr, __be16 sport, @@ -488,7 +488,7 @@ void sock_edemux(struct sk_buff *skb) } EXPORT_SYMBOL(sock_edemux); -struct sock *__inet_lookup_established(struct net *net, +struct sock *__inet_lookup_established(const struct net *net, struct inet_hashinfo *hashinfo, const __be32 saddr, const __be16 sport, const __be32 daddr, const u16 hnum, From patchwork Fri Aug 2 13:40:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13751556 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F9A31E486A for ; Fri, 2 Aug 2024 13:40:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722606041; cv=none; b=gZaDVI3T+PzoORo/JGivnyonTYzXTXbQYsUmGE3aTVYX41WnOOFMew4fO/1LtxyOLcMO0KZqe4DvztCwa8Tv7rhbv3/B4jgc+v3KcqANqN2OHVNA/Mhhp/nLpmbjhxdu8ghj0QvU39iW+qNk5bd9ieTVUK3xtUffqeneaxy6RQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722606041; c=relaxed/simple; bh=6zjoTz6EDwOEkjpOLaGGkURo9+ggn0TYjO+dqFmZZQ8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=X/yeKM0hpVSWiRbUepNhzWS3AuSaEhvLZ77FtBuEuPoRbl1tjssDVeMUtfwMORpBWrKSSCfB/4VxDWJ0MLhU6r+KRdqf1rDbItQZanGGA09YL9xT+sANfe86kjiX908wsa/4RtCunTePs68dHhKSsA1eSwfjmDEalNH3KaUbyXM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=tj5gCUii; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tj5gCUii" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-64b70c4a269so152871417b3.1 for ; Fri, 02 Aug 2024 06:40:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722606038; x=1723210838; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=b1y2ZM9IdEGayT9P3CUQeRyXf3F1RxpY5mc/K/Y+2Fs=; b=tj5gCUiipK3rG9quqlp02adUnPuXScnc3/K3o52xizGyGDti8fhTruxr9EbC5Jzd13 8gQ2MQOnImn91K2jit5I3zaQrMe7rwFKdg6OKlo/xRu+PKkhijwN7pV3RBxrHKa4cMqV aj7cTd5wa6aqstnu7ESXt7MH+U5QXz+hCCusU7NV973KkTAtdDxYo/EJUNFPPZa5NNus sCOE7vD9aHxwziUPRshThZFnOmghdjkbdK2DlD550CopEtTICEWp1NLHcc2caTM6SM3Y VV7S/dJ1qiJSBgFCACciP1gSONIcOutSHZyWcR8R1C3okjnpa8BQGcCmfbCb/R95zjpJ Rbrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722606038; x=1723210838; 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=b1y2ZM9IdEGayT9P3CUQeRyXf3F1RxpY5mc/K/Y+2Fs=; b=UDC4VQobVCLyme6MD5LDhzfwfsL0DHpX+6hjKtcUsjYdCckmnmfxX3mTwSW+xz6bP5 M9kLe6azx93a6pCUQZRyd1xv/WLLd9fl00UTVYSwYpVW/kxKt+bBnT3tg7o79UhJMrU2 /fuVsXElLMm/yxIl1faL8CBB7/SK6La5sTOa5Dm0h+0X8wqxvO11Ibqi+NapYEESwqkg Ym7qIYu1nx6HkdZ7OCAgLnAPNS8Rt6ochY8d/UwDBA9daWN6Ogo8LjCVh0JDOa5KdrK1 dKKeuqzbalG9kbmF1A4YfzdQSlnJ/t6qFGY1SvLWoxZ4WLJnxWcxaa3rIW9SDjVwiCaI uQpg== X-Forwarded-Encrypted: i=1; AJvYcCXkbxEF4NqcBPR+JyULrxQ+xmp4eIMmtXeVs/CzXrEj46qApvEYAgP+WwT4e+8AsVyeZOMzC3+NHwVpnbVmUUFVhSCZ1kO+ X-Gm-Message-State: AOJu0YxHReIzM/I0LmEEXuqwMXQB5cR3A1XDkVyaksQToyW655WAAbLI FZrGQpvyZxeLDPbkepPWTy2TPGtfuRcOmeMqRrjxIseTkzFEwVkr6uqhNMNk2r+UhPAUba6wrft kqwu1+iXJaQ== X-Google-Smtp-Source: AGHT+IE5em3Njm4+CpBPKTb/r5ILn9cSRFIzZZUWh5tLBpzSik2DSPeYShgeWGcBmxS26isB237cQZOqWtokcg== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6902:c0a:b0:e0b:5200:d93f with SMTP id 3f1490d57ef6-e0bde1fc85bmr5052276.3.1722606038519; Fri, 02 Aug 2024 06:40:38 -0700 (PDT) Date: Fri, 2 Aug 2024 13:40:27 +0000 In-Reply-To: <20240802134029.3748005-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240802134029.3748005-1-edumazet@google.com> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog Message-ID: <20240802134029.3748005-4-edumazet@google.com> Subject: [PATCH net-next 3/5] udp: constify 'struct net' parameter of socket lookups From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: David Ahern , Willem de Bruijn , Tom Herbert , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org Following helpers do not touch their 'struct net' argument. - udp_sk_bound_dev_eq() - udp4_lib_lookup() - __udp4_lib_lookup() Signed-off-by: Eric Dumazet Reviewed-by: Simon Horman --- include/net/udp.h | 10 ++++++---- net/ipv4/udp.c | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/net/udp.h b/include/net/udp.h index c4e05b14b648a4a98b67a8da5ed1e29f2413f35c..a0217e3cfe4f8c79d53479ce0bb8ad8fcd32e2a8 100644 --- a/include/net/udp.h +++ b/include/net/udp.h @@ -79,7 +79,8 @@ struct udp_table { extern struct udp_table udp_table; void udp_table_init(struct udp_table *, const char *); static inline struct udp_hslot *udp_hashslot(struct udp_table *table, - struct net *net, unsigned int num) + const struct net *net, + unsigned int num) { return &table->hash[udp_hashfn(net, num, table->mask)]; } @@ -245,7 +246,7 @@ static inline int udp_rqueue_get(struct sock *sk) return sk_rmem_alloc_get(sk) - READ_ONCE(udp_sk(sk)->forward_deficit); } -static inline bool udp_sk_bound_dev_eq(struct net *net, int bound_dev_if, +static inline bool udp_sk_bound_dev_eq(const struct net *net, int bound_dev_if, int dif, int sdif) { #if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV) @@ -296,9 +297,10 @@ int udp_lib_getsockopt(struct sock *sk, int level, int optname, int udp_lib_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, unsigned int optlen, int (*push_pending_frames)(struct sock *)); -struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, +struct sock *udp4_lib_lookup(const struct net *net, __be32 saddr, __be16 sport, __be32 daddr, __be16 dport, int dif); -struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, +struct sock *__udp4_lib_lookup(const struct net *net, __be32 saddr, + __be16 sport, __be32 daddr, __be16 dport, int dif, int sdif, struct udp_table *tbl, struct sk_buff *skb); struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb, diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 49c622e743e87fca17da555ef0a65bdb4aeed336..ddb86baaea6c87a9645f3baa6e4ab695cd539de4 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -365,7 +365,7 @@ int udp_v4_get_port(struct sock *sk, unsigned short snum) return udp_lib_get_port(sk, snum, hash2_nulladdr); } -static int compute_score(struct sock *sk, struct net *net, +static int compute_score(struct sock *sk, const struct net *net, __be32 saddr, __be16 sport, __be32 daddr, unsigned short hnum, int dif, int sdif) @@ -420,7 +420,7 @@ u32 udp_ehashfn(const struct net *net, const __be32 laddr, const __u16 lport, } /* called with rcu_read_lock() */ -static struct sock *udp4_lib_lookup2(struct net *net, +static struct sock *udp4_lib_lookup2(const struct net *net, __be32 saddr, __be16 sport, __be32 daddr, unsigned int hnum, int dif, int sdif, @@ -480,7 +480,7 @@ static struct sock *udp4_lib_lookup2(struct net *net, /* UDP is nearly always wildcards out the wazoo, it makes no sense to try * harder than this. -DaveM */ -struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, +struct sock *__udp4_lib_lookup(const struct net *net, __be32 saddr, __be16 sport, __be32 daddr, __be16 dport, int dif, int sdif, struct udp_table *udptable, struct sk_buff *skb) { @@ -561,7 +561,7 @@ struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb, * Does increment socket refcount. */ #if IS_ENABLED(CONFIG_NF_TPROXY_IPV4) || IS_ENABLED(CONFIG_NF_SOCKET_IPV4) -struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, +struct sock *udp4_lib_lookup(const struct net *net, __be32 saddr, __be16 sport, __be32 daddr, __be16 dport, int dif) { struct sock *sk; From patchwork Fri Aug 2 13:40:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13751557 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1ADC01E487A for ; Fri, 2 Aug 2024 13:40:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722606042; cv=none; b=sI6SbWUkevBSOea1918gbwus1/mlmfoX7x6cuBvECmzBrCZKd/QBdN7TSu3IrT5HYVPmjN/SLQyaf0tKhR8IioPn8MDuGpSxGXUnpMoztgMCvT9ToLsVrBof/xbUYfK5PH1BxJ8f0ZOIOgK3TnMCS7xp3GVjDYrnILFxw/dMUkM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722606042; c=relaxed/simple; bh=oakbWTV5o+pLzquEgcZMq85UtM4ha5ADS2ZoCMLBW/Q=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=ob3uAhgB5xFZ0RSVP7EKvtJVGNzVUqLR5FbWi+Itr2x69zabXX7FsX5rK8ci4tgbMyoLjC2u7n51WAZF56CLeaq9C7XISVkjSFmb2lf9zlKVugf2wsAEFcRe1OmacFjEhGv4+loAwvcPfDdlzNdtl21xu8GHSTq7fF56DnToMgE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=C/js/eHH; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="C/js/eHH" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-65194ea3d4dso157928657b3.0 for ; Fri, 02 Aug 2024 06:40:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722606040; x=1723210840; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=cfFRtvw9VqkxG0Z6iAul2+1bjV3z4oaLcZtN7mt/vC8=; b=C/js/eHHvnkRaZak1pwTu7to/Y7njRyt5goNj0YBLMkoujM2Awfpd1IX7Wj7IulMg0 FvDL8SzWYpIWbFFukehbe7PIgaX/wMmTvPtQMQIMARsiaRoZGahrs1CGWCi/5hAlU9Qg JSPxfHUEknfxZGC7sM8zB7SkqIGxwRrH3SFAtO2876iqYnp8GX4xcuwKz6vSvXCXDA8U YtSg7u7q0TT+13yBHCNEXyCTi7w+PVLd2JNkVlbuvIAsqw3Tt0jnyOfzK8Gl5FgbW46q 3N6otkRGZW5smB5BMv/TmpE0azzNEejR+HCym9LEsAk2AHRRhsjsYPwCcOSJN9O/K1eS veMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722606040; x=1723210840; 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=cfFRtvw9VqkxG0Z6iAul2+1bjV3z4oaLcZtN7mt/vC8=; b=gPky4PEzKwTkOZxwdZYSoJSgS2QAcPxCTdiCrf131f7M+YoLFdKRcIN/j2qnVyU97Z kwvecb4qEIGQu5LBiyqlPzooYpPhzPnwZ+xjhpzvDrQtiNJCmpvSvtbgnjZxwpEXKNZh U9ofURW7mV+hXx65fkvcrwzEMgkbgj+PbIcyz1Vz2H3YsLee1IPKaZww1rmmDyJj++mK QUK5+oQ90WW1ZFxY8BK79tT1BJdewbsCOY7qfTM2eAjKqaOWaBbaBNRURDbnk5FWcj04 aXAYIRl3h5u2klvXzHaAisNTkO/tZLG95IZLAf14DjOr0pUQQ2E87CF8mWLB2wzKY+al dW6w== X-Forwarded-Encrypted: i=1; AJvYcCXyPF30kOhtbI2TaeH5GuVj7fiHYRwJWFRYWSgqeOOz7UKOevenRbRjnVLedgnGW6sJmoWgm9o=@vger.kernel.org X-Gm-Message-State: AOJu0Yxp/KfKpZ1FO6pYaDooAD0Xb7NJ0P1lTImltadLLYyKmfW062F/ +EmsPmWpTccj8kfzrfXqHyj7ESNHfjHtblkoEOsE6s4m3NxXN/DtlSFRCuo/b8oq7WdPFhFfaar 5r8zVfpLUnA== X-Google-Smtp-Source: AGHT+IGbQAUsnOt8u/I/nNq2XzRJ5JUH0jCPHtdUNHodgmmeuVpXbORGWxAFHgyh7HuCrNPceBY5JjFCTa6Pfw== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:690c:112:b0:62c:fb55:aeab with SMTP id 00721157ae682-6896458f799mr2619147b3.8.1722606040020; Fri, 02 Aug 2024 06:40:40 -0700 (PDT) Date: Fri, 2 Aug 2024 13:40:28 +0000 In-Reply-To: <20240802134029.3748005-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240802134029.3748005-1-edumazet@google.com> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog Message-ID: <20240802134029.3748005-5-edumazet@google.com> Subject: [PATCH net-next 4/5] inet6: constify 'struct net' parameter of various lookup helpers From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: David Ahern , Willem de Bruijn , Tom Herbert , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org Following helpers do not touch their struct net argument: - bpf_sk_lookup_run_v6() - __inet6_lookup_established() - inet6_lookup_reuseport() - inet6_lookup_listener() - inet6_lookup_run_sk_lookup() - __inet6_lookup() - inet6_lookup() Signed-off-by: Eric Dumazet Reviewed-by: Simon Horman --- include/linux/filter.h | 2 +- include/net/inet6_hashtables.h | 12 ++++++------ net/ipv6/inet6_hashtables.c | 13 +++++++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/linux/filter.h b/include/linux/filter.h index 4acd1da4dac623a0af53c3df888d42326189efcf..64e1506fefb82e4adc1def9d007fdf88a88651c3 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -1653,7 +1653,7 @@ static inline bool bpf_sk_lookup_run_v4(const struct net *net, int protocol, } #if IS_ENABLED(CONFIG_IPV6) -static inline bool bpf_sk_lookup_run_v6(struct net *net, int protocol, +static inline bool bpf_sk_lookup_run_v6(const struct net *net, int protocol, const struct in6_addr *saddr, const __be16 sport, const struct in6_addr *daddr, diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index 591cbf5e4d5f86375598b9622f616ac662b0fc4e..74dd90ff5f129fe4c8adad67a642ae5070410518 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h @@ -40,7 +40,7 @@ static inline unsigned int __inet6_ehashfn(const u32 lhash, * * The sockhash lock must be held as a reader here. */ -struct sock *__inet6_lookup_established(struct net *net, +struct sock *__inet6_lookup_established(const struct net *net, struct inet_hashinfo *hashinfo, const struct in6_addr *saddr, const __be16 sport, @@ -56,7 +56,7 @@ inet6_ehashfn_t inet6_ehashfn; INDIRECT_CALLABLE_DECLARE(inet6_ehashfn_t udp6_ehashfn); -struct sock *inet6_lookup_reuseport(struct net *net, struct sock *sk, +struct sock *inet6_lookup_reuseport(const struct net *net, struct sock *sk, struct sk_buff *skb, int doff, const struct in6_addr *saddr, __be16 sport, @@ -64,7 +64,7 @@ struct sock *inet6_lookup_reuseport(struct net *net, struct sock *sk, unsigned short hnum, inet6_ehashfn_t *ehashfn); -struct sock *inet6_lookup_listener(struct net *net, +struct sock *inet6_lookup_listener(const struct net *net, struct inet_hashinfo *hashinfo, struct sk_buff *skb, int doff, const struct in6_addr *saddr, @@ -73,7 +73,7 @@ struct sock *inet6_lookup_listener(struct net *net, const unsigned short hnum, const int dif, const int sdif); -struct sock *inet6_lookup_run_sk_lookup(struct net *net, +struct sock *inet6_lookup_run_sk_lookup(const struct net *net, int protocol, struct sk_buff *skb, int doff, const struct in6_addr *saddr, @@ -82,7 +82,7 @@ struct sock *inet6_lookup_run_sk_lookup(struct net *net, const u16 hnum, const int dif, inet6_ehashfn_t *ehashfn); -static inline struct sock *__inet6_lookup(struct net *net, +static inline struct sock *__inet6_lookup(const struct net *net, struct inet_hashinfo *hashinfo, struct sk_buff *skb, int doff, const struct in6_addr *saddr, @@ -167,7 +167,7 @@ static inline struct sock *__inet6_lookup_skb(struct inet_hashinfo *hashinfo, iif, sdif, refcounted); } -struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo, +struct sock *inet6_lookup(const struct net *net, struct inet_hashinfo *hashinfo, struct sk_buff *skb, int doff, const struct in6_addr *saddr, const __be16 sport, const struct in6_addr *daddr, const __be16 dport, diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c index f29f094e57a4a5da8b238246d437328569a165d3..9ec05e354baa69d14e88da37f5a9fce11e874e35 100644 --- a/net/ipv6/inet6_hashtables.c +++ b/net/ipv6/inet6_hashtables.c @@ -46,7 +46,7 @@ EXPORT_SYMBOL_GPL(inet6_ehashfn); * * The sockhash lock must be held as a reader here. */ -struct sock *__inet6_lookup_established(struct net *net, +struct sock *__inet6_lookup_established(const struct net *net, struct inet_hashinfo *hashinfo, const struct in6_addr *saddr, const __be16 sport, @@ -126,7 +126,7 @@ static inline int compute_score(struct sock *sk, const struct net *net, * 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 sock *inet6_lookup_reuseport(const struct net *net, struct sock *sk, struct sk_buff *skb, int doff, const struct in6_addr *saddr, __be16 sport, @@ -147,7 +147,7 @@ struct sock *inet6_lookup_reuseport(struct net *net, struct sock *sk, EXPORT_SYMBOL_GPL(inet6_lookup_reuseport); /* called with rcu_read_lock() */ -static struct sock *inet6_lhash2_lookup(struct net *net, +static struct sock *inet6_lhash2_lookup(const struct net *net, struct inet_listen_hashbucket *ilb2, struct sk_buff *skb, int doff, const struct in6_addr *saddr, @@ -174,7 +174,7 @@ static struct sock *inet6_lhash2_lookup(struct net *net, return result; } -struct sock *inet6_lookup_run_sk_lookup(struct net *net, +struct sock *inet6_lookup_run_sk_lookup(const struct net *net, int protocol, struct sk_buff *skb, int doff, const struct in6_addr *saddr, @@ -199,7 +199,7 @@ struct sock *inet6_lookup_run_sk_lookup(struct net *net, } EXPORT_SYMBOL_GPL(inet6_lookup_run_sk_lookup); -struct sock *inet6_lookup_listener(struct net *net, +struct sock *inet6_lookup_listener(const struct net *net, struct inet_hashinfo *hashinfo, struct sk_buff *skb, int doff, const struct in6_addr *saddr, @@ -243,7 +243,8 @@ struct sock *inet6_lookup_listener(struct net *net, } EXPORT_SYMBOL_GPL(inet6_lookup_listener); -struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo, +struct sock *inet6_lookup(const struct net *net, + struct inet_hashinfo *hashinfo, struct sk_buff *skb, int doff, const struct in6_addr *saddr, const __be16 sport, const struct in6_addr *daddr, const __be16 dport, From patchwork Fri Aug 2 13:40:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13751558 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f201.google.com (mail-qt1-f201.google.com [209.85.160.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 196951E4EE8 for ; Fri, 2 Aug 2024 13:40:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722606044; cv=none; b=tMiHMeMMrrE8HrIS29xzoscVlEu3z/EBTqFJnuHPMbwOPhmi5Hx4GZFckmivCUd4dpjpUPi7hLo3KzNoEu/p6CtUut6A/S0t2v9U6O+0M+mQj9qI80WbBGfDCWDBdroo8QcroKR5FsDm+8w9OBjxd8CD7u1UjDqmwbfnVngGVYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722606044; c=relaxed/simple; bh=2Glza3dJ0RpAAgALc4nO1PaIqGZhs1DBn0m7rOkiRWM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=b1McUr7vmKttYgpM5AtfLiPdVG4HkoAUprJEn18EcOIpJCmaBPPJer7BesAlKjet4SJLNBYdLWq34s6kkXsvTlYv+EVgiKQLsbQ7ULhwEmTDJhQg9d1V8U8CMe3JoC6iIrOKeZnCW0Pasq9VFY8LCC5PaLaRq2WxtcR2PHxLNxo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Tva4QQl1; arc=none smtp.client-ip=209.85.160.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Tva4QQl1" Received: by mail-qt1-f201.google.com with SMTP id d75a77b69052e-44fe92a34d2so115218691cf.0 for ; Fri, 02 Aug 2024 06:40:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722606042; x=1723210842; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=iJCD9E0BGO+udSkWv5s+vPmVAmzrYKRy5J3lskBd7Ks=; b=Tva4QQl1CtSAsb981kzdTZdRDt59m6I4qzP+8DvVZwkcV0VovO2u9SoxL+qU7tE1q4 Xm0pde/qYatMH1jLAkivB2OgFP/LWNcj2kWBrHesQWe1y6sCD1vN9bfiyWWsS3JuYUO+ saoJR6H5fkdMJGyj6K7hqyPKNlMV52qHx1jTPqeecaYh018PhqB5g3WVwSUNWZt0pZ5M zP9x0EmYziY7998s6B24rKTsNTxgZxNLZkGQu+zZUu2SwvCI9Zq8lCqixyT5Z8eJdH7h sHuQj1E2g7zzZHOJN6eXAliaB961Q68ZEAVpsYSkra4WJOz22A1JQmysySPX/Jt3Bjg1 MHtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722606042; x=1723210842; 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=iJCD9E0BGO+udSkWv5s+vPmVAmzrYKRy5J3lskBd7Ks=; b=Gw9LWT84cwdotqwUGPaYi9NFgOPYT7SV01V9vqVVWBiTQEZdDAM/cix36FmKn/0+xS txhzuWV/mkmnP19N5v2sHejbDFmM2Ax6lYb/mllMo1Fu9CLEmLh7xMPEppFAOYhSrjIa C2if6lCsI6efYtQA5J+2GCfiBm1kbG7SqYXUCwObb7DuGKOaTyfe8QiE0O6z5Ib84Hat 5ZypV6gr9u4TTyP83bL5UlrLVAjUgdXkYAPjSWp58tqckjcGYF1DCIPrprcRk+QcUVl5 omupfKglT1R9GH4c2ByGW+Yv85bUHBb6RR5OcmyLykaND8FFfE78MigR8QPvhh0YLAs7 e4Tw== X-Forwarded-Encrypted: i=1; AJvYcCV4lcgf0JpPY7kxGBLXG5c1JorbnQCiSUirft5D81jnv+1+CmDSiscMLCZMQCcDBfnbT5Y66MAYRYeUTgM1PymrBUOZlowD X-Gm-Message-State: AOJu0Yz+cRtazOI3eWbJxqx798lFP/LX97uyelDDijhSZDZRpJXxCVWZ 8LyPnbJsA8AJFnNy8w49NahMsEv7XXgVkVkSDRsUl2TapItXDI95RMWAtYhTV+Jht3b+u+XM1+O LPMwBh1hQ5w== X-Google-Smtp-Source: AGHT+IEDJCUzzoiYtt79oMyQbnc5Pm8H8F1CQF+3+mnMyB7AtiHn4F8uyHVFjY4i/hc59DR5BmvVtOMXDbxf1A== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:622a:180f:b0:446:4a66:bf25 with SMTP id d75a77b69052e-451892cae76mr256931cf.11.1722606041828; Fri, 02 Aug 2024 06:40:41 -0700 (PDT) Date: Fri, 2 Aug 2024 13:40:29 +0000 In-Reply-To: <20240802134029.3748005-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240802134029.3748005-1-edumazet@google.com> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog Message-ID: <20240802134029.3748005-6-edumazet@google.com> Subject: [PATCH net-next 5/5] ipv6: udp: constify 'struct net' parameter of socket lookups From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: David Ahern , Willem de Bruijn , Tom Herbert , netdev@vger.kernel.org, eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org Following helpers do not touch their 'struct net' argument. - udp6_lib_lookup() - __udp6_lib_lookup() Signed-off-by: Eric Dumazet Reviewed-by: Simon Horman --- include/net/ipv6_stubs.h | 2 +- include/net/udp.h | 4 ++-- net/ipv6/udp.c | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/net/ipv6_stubs.h b/include/net/ipv6_stubs.h index 11cefd50704da8c6b81810fd45c54b243e9709cb..8a3465c8c2c5ce810ab2cd0b5008f63ee2aa0f37 100644 --- a/include/net/ipv6_stubs.h +++ b/include/net/ipv6_stubs.h @@ -82,7 +82,7 @@ extern const struct ipv6_stub *ipv6_stub __read_mostly; struct ipv6_bpf_stub { int (*inet6_bind)(struct sock *sk, struct sockaddr *uaddr, int addr_len, u32 flags); - struct sock *(*udp6_lib_lookup)(struct net *net, + struct sock *(*udp6_lib_lookup)(const struct net *net, const struct in6_addr *saddr, __be16 sport, const struct in6_addr *daddr, __be16 dport, int dif, int sdif, struct udp_table *tbl, diff --git a/include/net/udp.h b/include/net/udp.h index a0217e3cfe4f8c79d53479ce0bb8ad8fcd32e2a8..5ca53b1cec67472be861283290a1165f89a2ac5a 100644 --- a/include/net/udp.h +++ b/include/net/udp.h @@ -305,11 +305,11 @@ struct sock *__udp4_lib_lookup(const struct net *net, __be32 saddr, struct udp_table *tbl, struct sk_buff *skb); struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb, __be16 sport, __be16 dport); -struct sock *udp6_lib_lookup(struct net *net, +struct sock *udp6_lib_lookup(const struct net *net, const struct in6_addr *saddr, __be16 sport, const struct in6_addr *daddr, __be16 dport, int dif); -struct sock *__udp6_lib_lookup(struct net *net, +struct sock *__udp6_lib_lookup(const struct net *net, const struct in6_addr *saddr, __be16 sport, const struct in6_addr *daddr, __be16 dport, int dif, int sdif, struct udp_table *tbl, diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 6602a2e9cdb5324b6cd22d9c915455eb316779d8..52dfbb2ff1a80eb26dfb38598764dfaf2610ee84 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -114,7 +114,7 @@ void udp_v6_rehash(struct sock *sk) udp_lib_rehash(sk, new_hash); } -static int compute_score(struct sock *sk, struct net *net, +static int compute_score(struct sock *sk, const struct net *net, const struct in6_addr *saddr, __be16 sport, const struct in6_addr *daddr, unsigned short hnum, int dif, int sdif) @@ -160,7 +160,7 @@ static int compute_score(struct sock *sk, struct net *net, } /* called with rcu_read_lock() */ -static struct sock *udp6_lib_lookup2(struct net *net, +static struct sock *udp6_lib_lookup2(const struct net *net, const struct in6_addr *saddr, __be16 sport, const struct in6_addr *daddr, unsigned int hnum, int dif, int sdif, struct udp_hslot *hslot2, @@ -217,7 +217,7 @@ static struct sock *udp6_lib_lookup2(struct net *net, } /* rcu_read_lock() must be held */ -struct sock *__udp6_lib_lookup(struct net *net, +struct sock *__udp6_lib_lookup(const struct net *net, const struct in6_addr *saddr, __be16 sport, const struct in6_addr *daddr, __be16 dport, int dif, int sdif, struct udp_table *udptable, @@ -300,7 +300,7 @@ struct sock *udp6_lib_lookup_skb(const struct sk_buff *skb, * Does increment socket refcount. */ #if IS_ENABLED(CONFIG_NF_TPROXY_IPV6) || IS_ENABLED(CONFIG_NF_SOCKET_IPV6) -struct sock *udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport, +struct sock *udp6_lib_lookup(const struct net *net, const struct in6_addr *saddr, __be16 sport, const struct in6_addr *daddr, __be16 dport, int dif) { struct sock *sk;