mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 17:41:50 +00:00
net: ib_net pointer should depends on CONFIG_NET_NS
We can shrink size of "struct inet_bind_bucket" by 50%, using read_pnet() and write_pnet() Signed-off-by: Eric Dumazet <dada1@cosmosbay.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
8f424b5f32
commit
7a9546ee35
3 changed files with 12 additions and 5 deletions
|
@ -77,13 +77,20 @@ struct inet_ehash_bucket {
|
||||||
* ports are created in O(1) time? I thought so. ;-) -DaveM
|
* ports are created in O(1) time? I thought so. ;-) -DaveM
|
||||||
*/
|
*/
|
||||||
struct inet_bind_bucket {
|
struct inet_bind_bucket {
|
||||||
|
#ifdef CONFIG_NET_NS
|
||||||
struct net *ib_net;
|
struct net *ib_net;
|
||||||
|
#endif
|
||||||
unsigned short port;
|
unsigned short port;
|
||||||
signed short fastreuse;
|
signed short fastreuse;
|
||||||
struct hlist_node node;
|
struct hlist_node node;
|
||||||
struct hlist_head owners;
|
struct hlist_head owners;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static inline struct net *ib_net(struct inet_bind_bucket *ib)
|
||||||
|
{
|
||||||
|
return read_pnet(&ib->ib_net);
|
||||||
|
}
|
||||||
|
|
||||||
#define inet_bind_bucket_for_each(tb, node, head) \
|
#define inet_bind_bucket_for_each(tb, node, head) \
|
||||||
hlist_for_each_entry(tb, node, head, node)
|
hlist_for_each_entry(tb, node, head, node)
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
|
||||||
hashinfo->bhash_size)];
|
hashinfo->bhash_size)];
|
||||||
spin_lock(&head->lock);
|
spin_lock(&head->lock);
|
||||||
inet_bind_bucket_for_each(tb, node, &head->chain)
|
inet_bind_bucket_for_each(tb, node, &head->chain)
|
||||||
if (tb->ib_net == net && tb->port == rover)
|
if (ib_net(tb) == net && tb->port == rover)
|
||||||
goto next;
|
goto next;
|
||||||
break;
|
break;
|
||||||
next:
|
next:
|
||||||
|
@ -137,7 +137,7 @@ int inet_csk_get_port(struct sock *sk, unsigned short snum)
|
||||||
hashinfo->bhash_size)];
|
hashinfo->bhash_size)];
|
||||||
spin_lock(&head->lock);
|
spin_lock(&head->lock);
|
||||||
inet_bind_bucket_for_each(tb, node, &head->chain)
|
inet_bind_bucket_for_each(tb, node, &head->chain)
|
||||||
if (tb->ib_net == net && tb->port == snum)
|
if (ib_net(tb) == net && tb->port == snum)
|
||||||
goto tb_found;
|
goto tb_found;
|
||||||
}
|
}
|
||||||
tb = NULL;
|
tb = NULL;
|
||||||
|
|
|
@ -35,7 +35,7 @@ struct inet_bind_bucket *inet_bind_bucket_create(struct kmem_cache *cachep,
|
||||||
struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, GFP_ATOMIC);
|
struct inet_bind_bucket *tb = kmem_cache_alloc(cachep, GFP_ATOMIC);
|
||||||
|
|
||||||
if (tb != NULL) {
|
if (tb != NULL) {
|
||||||
tb->ib_net = hold_net(net);
|
write_pnet(&tb->ib_net, hold_net(net));
|
||||||
tb->port = snum;
|
tb->port = snum;
|
||||||
tb->fastreuse = 0;
|
tb->fastreuse = 0;
|
||||||
INIT_HLIST_HEAD(&tb->owners);
|
INIT_HLIST_HEAD(&tb->owners);
|
||||||
|
@ -51,7 +51,7 @@ void inet_bind_bucket_destroy(struct kmem_cache *cachep, struct inet_bind_bucket
|
||||||
{
|
{
|
||||||
if (hlist_empty(&tb->owners)) {
|
if (hlist_empty(&tb->owners)) {
|
||||||
__hlist_del(&tb->node);
|
__hlist_del(&tb->node);
|
||||||
release_net(tb->ib_net);
|
release_net(ib_net(tb));
|
||||||
kmem_cache_free(cachep, tb);
|
kmem_cache_free(cachep, tb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -449,7 +449,7 @@ int __inet_hash_connect(struct inet_timewait_death_row *death_row,
|
||||||
* unique enough.
|
* unique enough.
|
||||||
*/
|
*/
|
||||||
inet_bind_bucket_for_each(tb, node, &head->chain) {
|
inet_bind_bucket_for_each(tb, node, &head->chain) {
|
||||||
if (tb->ib_net == net && tb->port == port) {
|
if (ib_net(tb) == net && tb->port == port) {
|
||||||
WARN_ON(hlist_empty(&tb->owners));
|
WARN_ON(hlist_empty(&tb->owners));
|
||||||
if (tb->fastreuse >= 0)
|
if (tb->fastreuse >= 0)
|
||||||
goto next_port;
|
goto next_port;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue