Skip to content

Commit d4433e8

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

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

include/linux/filter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ extern struct static_key_false bpf_sk_lookup_enabled;
16161616
_all_pass || _selected_sk ? SK_PASS : SK_DROP; \
16171617
})
16181618

1619-
static inline bool bpf_sk_lookup_run_v4(struct net *net, int protocol,
1619+
static inline bool bpf_sk_lookup_run_v4(const struct net *net, int protocol,
16201620
const __be32 saddr, const __be16 sport,
16211621
const __be32 daddr, const u16 dport,
16221622
const int ifindex, struct sock **psk)

include/net/inet_hashtables.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ int __inet_hash(struct sock *sk, struct sock *osk);
304304
int inet_hash(struct sock *sk);
305305
void inet_unhash(struct sock *sk);
306306

307-
struct sock *__inet_lookup_listener(struct net *net,
307+
struct sock *__inet_lookup_listener(const struct net *net,
308308
struct inet_hashinfo *hashinfo,
309309
struct sk_buff *skb, int doff,
310310
const __be32 saddr, const __be16 sport,
@@ -368,7 +368,7 @@ static inline bool inet_match(const struct net *net, const struct sock *sk,
368368
/* Sockets in TCP_CLOSE state are _always_ taken out of the hash, so we need
369369
* not check it for lookups anymore, thanks Alexey. -DaveM
370370
*/
371-
struct sock *__inet_lookup_established(struct net *net,
371+
struct sock *__inet_lookup_established(const struct net *net,
372372
struct inet_hashinfo *hashinfo,
373373
const __be32 saddr, const __be16 sport,
374374
const __be32 daddr, const u16 hnum,
@@ -382,13 +382,13 @@ inet_ehashfn_t inet_ehashfn;
382382

383383
INDIRECT_CALLABLE_DECLARE(inet_ehashfn_t udp_ehashfn);
384384

385-
struct sock *inet_lookup_reuseport(struct net *net, struct sock *sk,
385+
struct sock *inet_lookup_reuseport(const struct net *net, struct sock *sk,
386386
struct sk_buff *skb, int doff,
387387
__be32 saddr, __be16 sport,
388388
__be32 daddr, unsigned short hnum,
389389
inet_ehashfn_t *ehashfn);
390390

391-
struct sock *inet_lookup_run_sk_lookup(struct net *net,
391+
struct sock *inet_lookup_run_sk_lookup(const struct net *net,
392392
int protocol,
393393
struct sk_buff *skb, int doff,
394394
__be32 saddr, __be16 sport,

net/ipv4/inet_hashtables.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static inline int compute_score(struct sock *sk, const struct net *net,
348348
* Return: NULL if sk doesn't have SO_REUSEPORT set, otherwise a pointer to
349349
* the selected sock or an error.
350350
*/
351-
struct sock *inet_lookup_reuseport(struct net *net, struct sock *sk,
351+
struct sock *inet_lookup_reuseport(const struct net *net, struct sock *sk,
352352
struct sk_buff *skb, int doff,
353353
__be32 saddr, __be16 sport,
354354
__be32 daddr, unsigned short hnum,
@@ -374,7 +374,7 @@ EXPORT_SYMBOL_GPL(inet_lookup_reuseport);
374374
*/
375375

376376
/* called with rcu_read_lock() : No refcount taken on the socket */
377-
static struct sock *inet_lhash2_lookup(struct net *net,
377+
static struct sock *inet_lhash2_lookup(const struct net *net,
378378
struct inet_listen_hashbucket *ilb2,
379379
struct sk_buff *skb, int doff,
380380
const __be32 saddr, __be16 sport,
@@ -401,7 +401,7 @@ static struct sock *inet_lhash2_lookup(struct net *net,
401401
return result;
402402
}
403403

404-
struct sock *inet_lookup_run_sk_lookup(struct net *net,
404+
struct sock *inet_lookup_run_sk_lookup(const struct net *net,
405405
int protocol,
406406
struct sk_buff *skb, int doff,
407407
__be32 saddr, __be16 sport,
@@ -423,7 +423,7 @@ struct sock *inet_lookup_run_sk_lookup(struct net *net,
423423
return sk;
424424
}
425425

426-
struct sock *__inet_lookup_listener(struct net *net,
426+
struct sock *__inet_lookup_listener(const struct net *net,
427427
struct inet_hashinfo *hashinfo,
428428
struct sk_buff *skb, int doff,
429429
const __be32 saddr, __be16 sport,
@@ -488,7 +488,7 @@ void sock_edemux(struct sk_buff *skb)
488488
}
489489
EXPORT_SYMBOL(sock_edemux);
490490

491-
struct sock *__inet_lookup_established(struct net *net,
491+
struct sock *__inet_lookup_established(const struct net *net,
492492
struct inet_hashinfo *hashinfo,
493493
const __be32 saddr, const __be16 sport,
494494
const __be32 daddr, const u16 hnum,

0 commit comments

Comments
 (0)