diff options
Diffstat (limited to 'include/net/inet_hashtables.h')
-rw-r--r-- | include/net/inet_hashtables.h | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index dd1950a7e273..73fe0f9525d9 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h | |||
@@ -76,9 +76,7 @@ struct inet_ehash_bucket { | |||
76 | * ports are created in O(1) time? I thought so. ;-) -DaveM | 76 | * ports are created in O(1) time? I thought so. ;-) -DaveM |
77 | */ | 77 | */ |
78 | struct inet_bind_bucket { | 78 | struct inet_bind_bucket { |
79 | #ifdef CONFIG_NET_NS | 79 | possible_net_t ib_net; |
80 | struct net *ib_net; | ||
81 | #endif | ||
82 | unsigned short port; | 80 | unsigned short port; |
83 | signed char fastreuse; | 81 | signed char fastreuse; |
84 | signed char fastreuseport; | 82 | signed char fastreuseport; |
@@ -223,8 +221,8 @@ inet_bind_bucket_create(struct kmem_cache *cachep, struct net *net, | |||
223 | void inet_bind_bucket_destroy(struct kmem_cache *cachep, | 221 | void inet_bind_bucket_destroy(struct kmem_cache *cachep, |
224 | struct inet_bind_bucket *tb); | 222 | struct inet_bind_bucket *tb); |
225 | 223 | ||
226 | static inline int inet_bhashfn(struct net *net, const __u16 lport, | 224 | static inline u32 inet_bhashfn(const struct net *net, const __u16 lport, |
227 | const int bhash_size) | 225 | const u32 bhash_size) |
228 | { | 226 | { |
229 | return (lport + net_hash_mix(net)) & (bhash_size - 1); | 227 | return (lport + net_hash_mix(net)) & (bhash_size - 1); |
230 | } | 228 | } |
@@ -233,7 +231,7 @@ void inet_bind_hash(struct sock *sk, struct inet_bind_bucket *tb, | |||
233 | const unsigned short snum); | 231 | const unsigned short snum); |
234 | 232 | ||
235 | /* These can have wildcards, don't try too hard. */ | 233 | /* These can have wildcards, don't try too hard. */ |
236 | static inline int inet_lhashfn(struct net *net, const unsigned short num) | 234 | static inline u32 inet_lhashfn(const struct net *net, const unsigned short num) |
237 | { | 235 | { |
238 | return (num + net_hash_mix(net)) & (INET_LHTABLE_SIZE - 1); | 236 | return (num + net_hash_mix(net)) & (INET_LHTABLE_SIZE - 1); |
239 | } | 237 | } |
@@ -251,6 +249,7 @@ void inet_put_port(struct sock *sk); | |||
251 | void inet_hashinfo_init(struct inet_hashinfo *h); | 249 | void inet_hashinfo_init(struct inet_hashinfo *h); |
252 | 250 | ||
253 | int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw); | 251 | int __inet_hash_nolisten(struct sock *sk, struct inet_timewait_sock *tw); |
252 | int __inet_hash(struct sock *sk, struct inet_timewait_sock *tw); | ||
254 | void inet_hash(struct sock *sk); | 253 | void inet_hash(struct sock *sk); |
255 | void inet_unhash(struct sock *sk); | 254 | void inet_unhash(struct sock *sk); |
256 | 255 | ||
@@ -385,13 +384,32 @@ static inline struct sock *__inet_lookup_skb(struct inet_hashinfo *hashinfo, | |||
385 | iph->daddr, dport, inet_iif(skb)); | 384 | iph->daddr, dport, inet_iif(skb)); |
386 | } | 385 | } |
387 | 386 | ||
387 | u32 sk_ehashfn(const struct sock *sk); | ||
388 | u32 inet6_ehashfn(const struct net *net, | ||
389 | const struct in6_addr *laddr, const u16 lport, | ||
390 | const struct in6_addr *faddr, const __be16 fport); | ||
391 | |||
392 | static inline void sk_daddr_set(struct sock *sk, __be32 addr) | ||
393 | { | ||
394 | sk->sk_daddr = addr; /* alias of inet_daddr */ | ||
395 | #if IS_ENABLED(CONFIG_IPV6) | ||
396 | ipv6_addr_set_v4mapped(addr, &sk->sk_v6_daddr); | ||
397 | #endif | ||
398 | } | ||
399 | |||
400 | static inline void sk_rcv_saddr_set(struct sock *sk, __be32 addr) | ||
401 | { | ||
402 | sk->sk_rcv_saddr = addr; /* alias of inet_rcv_saddr */ | ||
403 | #if IS_ENABLED(CONFIG_IPV6) | ||
404 | ipv6_addr_set_v4mapped(addr, &sk->sk_v6_rcv_saddr); | ||
405 | #endif | ||
406 | } | ||
407 | |||
388 | int __inet_hash_connect(struct inet_timewait_death_row *death_row, | 408 | int __inet_hash_connect(struct inet_timewait_death_row *death_row, |
389 | struct sock *sk, u32 port_offset, | 409 | struct sock *sk, u32 port_offset, |
390 | int (*check_established)(struct inet_timewait_death_row *, | 410 | int (*check_established)(struct inet_timewait_death_row *, |
391 | struct sock *, __u16, | 411 | struct sock *, __u16, |
392 | struct inet_timewait_sock **), | 412 | struct inet_timewait_sock **)); |
393 | int (*hash)(struct sock *sk, | ||
394 | struct inet_timewait_sock *twp)); | ||
395 | 413 | ||
396 | int inet_hash_connect(struct inet_timewait_death_row *death_row, | 414 | int inet_hash_connect(struct inet_timewait_death_row *death_row, |
397 | struct sock *sk); | 415 | struct sock *sk); |