Skip to content

Commit b9abcbb

Browse files
edumazetkuba-moo
authored andcommitted
udp: constify 'struct net' parameter of socket lookups
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 <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d4433e8 commit b9abcbb

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

include/net/udp.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ struct udp_table {
7979
extern struct udp_table udp_table;
8080
void udp_table_init(struct udp_table *, const char *);
8181
static inline struct udp_hslot *udp_hashslot(struct udp_table *table,
82-
struct net *net, unsigned int num)
82+
const struct net *net,
83+
unsigned int num)
8384
{
8485
return &table->hash[udp_hashfn(net, num, table->mask)];
8586
}
@@ -245,7 +246,7 @@ static inline int udp_rqueue_get(struct sock *sk)
245246
return sk_rmem_alloc_get(sk) - READ_ONCE(udp_sk(sk)->forward_deficit);
246247
}
247248

248-
static inline bool udp_sk_bound_dev_eq(struct net *net, int bound_dev_if,
249+
static inline bool udp_sk_bound_dev_eq(const struct net *net, int bound_dev_if,
249250
int dif, int sdif)
250251
{
251252
#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
@@ -296,9 +297,10 @@ int udp_lib_getsockopt(struct sock *sk, int level, int optname,
296297
int udp_lib_setsockopt(struct sock *sk, int level, int optname,
297298
sockptr_t optval, unsigned int optlen,
298299
int (*push_pending_frames)(struct sock *));
299-
struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
300+
struct sock *udp4_lib_lookup(const struct net *net, __be32 saddr, __be16 sport,
300301
__be32 daddr, __be16 dport, int dif);
301-
struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
302+
struct sock *__udp4_lib_lookup(const struct net *net, __be32 saddr,
303+
__be16 sport,
302304
__be32 daddr, __be16 dport, int dif, int sdif,
303305
struct udp_table *tbl, struct sk_buff *skb);
304306
struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb,

net/ipv4/udp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ int udp_v4_get_port(struct sock *sk, unsigned short snum)
365365
return udp_lib_get_port(sk, snum, hash2_nulladdr);
366366
}
367367

368-
static int compute_score(struct sock *sk, struct net *net,
368+
static int compute_score(struct sock *sk, const struct net *net,
369369
__be32 saddr, __be16 sport,
370370
__be32 daddr, unsigned short hnum,
371371
int dif, int sdif)
@@ -420,7 +420,7 @@ u32 udp_ehashfn(const struct net *net, const __be32 laddr, const __u16 lport,
420420
}
421421

422422
/* called with rcu_read_lock() */
423-
static struct sock *udp4_lib_lookup2(struct net *net,
423+
static struct sock *udp4_lib_lookup2(const struct net *net,
424424
__be32 saddr, __be16 sport,
425425
__be32 daddr, unsigned int hnum,
426426
int dif, int sdif,
@@ -480,7 +480,7 @@ static struct sock *udp4_lib_lookup2(struct net *net,
480480
/* UDP is nearly always wildcards out the wazoo, it makes no sense to try
481481
* harder than this. -DaveM
482482
*/
483-
struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr,
483+
struct sock *__udp4_lib_lookup(const struct net *net, __be32 saddr,
484484
__be16 sport, __be32 daddr, __be16 dport, int dif,
485485
int sdif, struct udp_table *udptable, struct sk_buff *skb)
486486
{
@@ -561,7 +561,7 @@ struct sock *udp4_lib_lookup_skb(const struct sk_buff *skb,
561561
* Does increment socket refcount.
562562
*/
563563
#if IS_ENABLED(CONFIG_NF_TPROXY_IPV4) || IS_ENABLED(CONFIG_NF_SOCKET_IPV4)
564-
struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
564+
struct sock *udp4_lib_lookup(const struct net *net, __be32 saddr, __be16 sport,
565565
__be32 daddr, __be16 dport, int dif)
566566
{
567567
struct sock *sk;

0 commit comments

Comments
 (0)