* [PATCH net-next 0/5] net: constify 'struct net' parameter of socket lookups
@ 2024-08-02 13:40 Eric Dumazet
2024-08-02 13:40 ` [PATCH net-next 1/5] inet: constify inet_sk_bound_dev_eq() net parameter Eric Dumazet
` (5 more replies)
0 siblings, 6 replies; 12+ messages in thread
From: Eric Dumazet @ 2024-08-02 13:40 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: David Ahern, Willem de Bruijn, Tom Herbert, netdev, eric.dumazet,
Eric Dumazet
We should keep const qualifiers whenever possible.
This series should remove the need for Tom patch in :
Link: https://lore.kernel.org/netdev/20240731172332.683815-2-tom@herbertland.com/
Eric Dumazet (5):
inet: constify inet_sk_bound_dev_eq() net parameter
inet: constify 'struct net' parameter of various lookup helpers
udp: constify 'struct net' parameter of socket lookups
inet6: constify 'struct net' parameter of various lookup helpers
ipv6: udp: constify 'struct net' parameter of socket lookups
include/linux/filter.h | 4 ++--
include/net/inet6_hashtables.h | 14 +++++++-------
include/net/inet_hashtables.h | 10 +++++-----
include/net/inet_sock.h | 3 ++-
include/net/ipv6_stubs.h | 2 +-
include/net/udp.h | 14 ++++++++------
net/ipv4/inet_hashtables.c | 12 ++++++------
net/ipv4/udp.c | 8 ++++----
net/ipv6/inet6_hashtables.c | 15 ++++++++-------
net/ipv6/udp.c | 8 ++++----
10 files changed, 47 insertions(+), 43 deletions(-)
--
2.46.0.rc2.264.g509ed76dc8-goog
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH net-next 1/5] inet: constify inet_sk_bound_dev_eq() net parameter
2024-08-02 13:40 [PATCH net-next 0/5] net: constify 'struct net' parameter of socket lookups Eric Dumazet
@ 2024-08-02 13:40 ` Eric Dumazet
2024-08-05 13:52 ` Simon Horman
2024-08-02 13:40 ` [PATCH net-next 2/5] inet: constify 'struct net' parameter of various lookup helpers Eric Dumazet
` (4 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Eric Dumazet @ 2024-08-02 13:40 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: David Ahern, Willem de Bruijn, Tom Herbert, netdev, eric.dumazet,
Eric Dumazet
inet_sk_bound_dev_eq() and its callers do not modify the net structure.
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
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)
--
2.46.0.rc2.264.g509ed76dc8-goog
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH net-next 2/5] inet: constify 'struct net' parameter of various lookup helpers
2024-08-02 13:40 [PATCH net-next 0/5] net: constify 'struct net' parameter of socket lookups Eric Dumazet
2024-08-02 13:40 ` [PATCH net-next 1/5] inet: constify inet_sk_bound_dev_eq() net parameter Eric Dumazet
@ 2024-08-02 13:40 ` Eric Dumazet
2024-08-05 13:52 ` Simon Horman
2024-08-02 13:40 ` [PATCH net-next 3/5] udp: constify 'struct net' parameter of socket lookups Eric Dumazet
` (3 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Eric Dumazet @ 2024-08-02 13:40 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: David Ahern, Willem de Bruijn, Tom Herbert, netdev, eric.dumazet,
Eric Dumazet
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 <edumazet@google.com>
---
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,
--
2.46.0.rc2.264.g509ed76dc8-goog
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH net-next 3/5] udp: constify 'struct net' parameter of socket lookups
2024-08-02 13:40 [PATCH net-next 0/5] net: constify 'struct net' parameter of socket lookups Eric Dumazet
2024-08-02 13:40 ` [PATCH net-next 1/5] inet: constify inet_sk_bound_dev_eq() net parameter Eric Dumazet
2024-08-02 13:40 ` [PATCH net-next 2/5] inet: constify 'struct net' parameter of various lookup helpers Eric Dumazet
@ 2024-08-02 13:40 ` Eric Dumazet
2024-08-05 13:53 ` Simon Horman
2024-08-02 13:40 ` [PATCH net-next 4/5] inet6: constify 'struct net' parameter of various lookup helpers Eric Dumazet
` (2 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Eric Dumazet @ 2024-08-02 13:40 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: David Ahern, Willem de Bruijn, Tom Herbert, netdev, eric.dumazet,
Eric Dumazet
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 <edumazet@google.com>
---
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;
--
2.46.0.rc2.264.g509ed76dc8-goog
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH net-next 4/5] inet6: constify 'struct net' parameter of various lookup helpers
2024-08-02 13:40 [PATCH net-next 0/5] net: constify 'struct net' parameter of socket lookups Eric Dumazet
` (2 preceding siblings ...)
2024-08-02 13:40 ` [PATCH net-next 3/5] udp: constify 'struct net' parameter of socket lookups Eric Dumazet
@ 2024-08-02 13:40 ` Eric Dumazet
2024-08-05 13:54 ` Simon Horman
2024-08-02 13:40 ` [PATCH net-next 5/5] ipv6: udp: constify 'struct net' parameter of socket lookups Eric Dumazet
2024-08-05 23:54 ` [PATCH net-next 0/5] net: " patchwork-bot+netdevbpf
5 siblings, 1 reply; 12+ messages in thread
From: Eric Dumazet @ 2024-08-02 13:40 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: David Ahern, Willem de Bruijn, Tom Herbert, netdev, eric.dumazet,
Eric Dumazet
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 <edumazet@google.com>
---
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,
--
2.46.0.rc2.264.g509ed76dc8-goog
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH net-next 5/5] ipv6: udp: constify 'struct net' parameter of socket lookups
2024-08-02 13:40 [PATCH net-next 0/5] net: constify 'struct net' parameter of socket lookups Eric Dumazet
` (3 preceding siblings ...)
2024-08-02 13:40 ` [PATCH net-next 4/5] inet6: constify 'struct net' parameter of various lookup helpers Eric Dumazet
@ 2024-08-02 13:40 ` Eric Dumazet
2024-08-05 13:54 ` Simon Horman
2024-08-05 23:54 ` [PATCH net-next 0/5] net: " patchwork-bot+netdevbpf
5 siblings, 1 reply; 12+ messages in thread
From: Eric Dumazet @ 2024-08-02 13:40 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski, Paolo Abeni
Cc: David Ahern, Willem de Bruijn, Tom Herbert, netdev, eric.dumazet,
Eric Dumazet
Following helpers do not touch their 'struct net' argument.
- udp6_lib_lookup()
- __udp6_lib_lookup()
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
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;
--
2.46.0.rc2.264.g509ed76dc8-goog
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 1/5] inet: constify inet_sk_bound_dev_eq() net parameter
2024-08-02 13:40 ` [PATCH net-next 1/5] inet: constify inet_sk_bound_dev_eq() net parameter Eric Dumazet
@ 2024-08-05 13:52 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2024-08-05 13:52 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, David Ahern,
Willem de Bruijn, Tom Herbert, netdev, eric.dumazet
On Fri, Aug 02, 2024 at 01:40:25PM +0000, Eric Dumazet wrote:
> inet_sk_bound_dev_eq() and its callers do not modify the net structure.
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 2/5] inet: constify 'struct net' parameter of various lookup helpers
2024-08-02 13:40 ` [PATCH net-next 2/5] inet: constify 'struct net' parameter of various lookup helpers Eric Dumazet
@ 2024-08-05 13:52 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2024-08-05 13:52 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, David Ahern,
Willem de Bruijn, Tom Herbert, netdev, eric.dumazet
On Fri, Aug 02, 2024 at 01:40:26PM +0000, Eric Dumazet wrote:
> 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 <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 3/5] udp: constify 'struct net' parameter of socket lookups
2024-08-02 13:40 ` [PATCH net-next 3/5] udp: constify 'struct net' parameter of socket lookups Eric Dumazet
@ 2024-08-05 13:53 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2024-08-05 13:53 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, David Ahern,
Willem de Bruijn, Tom Herbert, netdev, eric.dumazet
On Fri, Aug 02, 2024 at 01:40:27PM +0000, Eric Dumazet wrote:
> 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 <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 4/5] inet6: constify 'struct net' parameter of various lookup helpers
2024-08-02 13:40 ` [PATCH net-next 4/5] inet6: constify 'struct net' parameter of various lookup helpers Eric Dumazet
@ 2024-08-05 13:54 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2024-08-05 13:54 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, David Ahern,
Willem de Bruijn, Tom Herbert, netdev, eric.dumazet
On Fri, Aug 02, 2024 at 01:40:28PM +0000, Eric Dumazet wrote:
> 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 <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 5/5] ipv6: udp: constify 'struct net' parameter of socket lookups
2024-08-02 13:40 ` [PATCH net-next 5/5] ipv6: udp: constify 'struct net' parameter of socket lookups Eric Dumazet
@ 2024-08-05 13:54 ` Simon Horman
0 siblings, 0 replies; 12+ messages in thread
From: Simon Horman @ 2024-08-05 13:54 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, David Ahern,
Willem de Bruijn, Tom Herbert, netdev, eric.dumazet
On Fri, Aug 02, 2024 at 01:40:29PM +0000, Eric Dumazet wrote:
> Following helpers do not touch their 'struct net' argument.
>
> - udp6_lib_lookup()
> - __udp6_lib_lookup()
>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH net-next 0/5] net: constify 'struct net' parameter of socket lookups
2024-08-02 13:40 [PATCH net-next 0/5] net: constify 'struct net' parameter of socket lookups Eric Dumazet
` (4 preceding siblings ...)
2024-08-02 13:40 ` [PATCH net-next 5/5] ipv6: udp: constify 'struct net' parameter of socket lookups Eric Dumazet
@ 2024-08-05 23:54 ` patchwork-bot+netdevbpf
5 siblings, 0 replies; 12+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-08-05 23:54 UTC (permalink / raw)
To: Eric Dumazet
Cc: davem, kuba, pabeni, dsahern, willemb, tom, netdev, eric.dumazet
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 2 Aug 2024 13:40:24 +0000 you wrote:
> We should keep const qualifiers whenever possible.
>
> This series should remove the need for Tom patch in :
>
> Link: https://lore.kernel.org/netdev/20240731172332.683815-2-tom@herbertland.com/
>
> Eric Dumazet (5):
> inet: constify inet_sk_bound_dev_eq() net parameter
> inet: constify 'struct net' parameter of various lookup helpers
> udp: constify 'struct net' parameter of socket lookups
> inet6: constify 'struct net' parameter of various lookup helpers
> ipv6: udp: constify 'struct net' parameter of socket lookups
>
> [...]
Here is the summary with links:
- [net-next,1/5] inet: constify inet_sk_bound_dev_eq() net parameter
https://git.kernel.org/netdev/net-next/c/a2dc7bee4f77
- [net-next,2/5] inet: constify 'struct net' parameter of various lookup helpers
https://git.kernel.org/netdev/net-next/c/d4433e8b405a
- [net-next,3/5] udp: constify 'struct net' parameter of socket lookups
https://git.kernel.org/netdev/net-next/c/b9abcbb1239c
- [net-next,4/5] inet6: constify 'struct net' parameter of various lookup helpers
https://git.kernel.org/netdev/net-next/c/10b2a44ccb0c
- [net-next,5/5] ipv6: udp: constify 'struct net' parameter of socket lookups
https://git.kernel.org/netdev/net-next/c/87d973e8ddee
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-08-05 23:54 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-02 13:40 [PATCH net-next 0/5] net: constify 'struct net' parameter of socket lookups Eric Dumazet
2024-08-02 13:40 ` [PATCH net-next 1/5] inet: constify inet_sk_bound_dev_eq() net parameter Eric Dumazet
2024-08-05 13:52 ` Simon Horman
2024-08-02 13:40 ` [PATCH net-next 2/5] inet: constify 'struct net' parameter of various lookup helpers Eric Dumazet
2024-08-05 13:52 ` Simon Horman
2024-08-02 13:40 ` [PATCH net-next 3/5] udp: constify 'struct net' parameter of socket lookups Eric Dumazet
2024-08-05 13:53 ` Simon Horman
2024-08-02 13:40 ` [PATCH net-next 4/5] inet6: constify 'struct net' parameter of various lookup helpers Eric Dumazet
2024-08-05 13:54 ` Simon Horman
2024-08-02 13:40 ` [PATCH net-next 5/5] ipv6: udp: constify 'struct net' parameter of socket lookups Eric Dumazet
2024-08-05 13:54 ` Simon Horman
2024-08-05 23:54 ` [PATCH net-next 0/5] net: " patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).