mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-06 06:21:31 +00:00
[NET] NETNS: Omit sock->sk_net without CONFIG_NET_NS.
Introduce per-sock inlines: sock_net(), sock_net_set() and per-inet_timewait_sock inlines: twsk_net(), twsk_net_set(). Without CONFIG_NET_NS, no namespace other than &init_net exists. Let's explicitly define them to help compiler optimizations. Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
This commit is contained in:
parent
c346dca108
commit
3b1e0a655f
69 changed files with 253 additions and 215 deletions
|
@ -126,7 +126,9 @@ struct sock_common {
|
|||
atomic_t skc_refcnt;
|
||||
unsigned int skc_hash;
|
||||
struct proto *skc_prot;
|
||||
#ifdef CONFIG_NET_NS
|
||||
struct net *skc_net;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1345,6 +1347,24 @@ static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_e
|
|||
}
|
||||
#endif
|
||||
|
||||
static inline
|
||||
struct net *sock_net(const struct sock *sk)
|
||||
{
|
||||
#ifdef CONFIG_NET_NS
|
||||
return sk->sk_net;
|
||||
#else
|
||||
return &init_net;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline
|
||||
void sock_net_set(struct sock *sk, const struct net *net)
|
||||
{
|
||||
#ifdef CONFIG_NET_NS
|
||||
sk->sk_net = net;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Kernel sockets, f.e. rtnl or icmp_socket, are a part of a namespace.
|
||||
* They should not hold a referrence to a namespace in order to allow
|
||||
|
@ -1353,8 +1373,8 @@ static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_e
|
|||
*/
|
||||
static inline void sk_change_net(struct sock *sk, struct net *net)
|
||||
{
|
||||
put_net(sk->sk_net);
|
||||
sk->sk_net = net;
|
||||
put_net(sock_net(sk));
|
||||
sock_net_set(sk, net);
|
||||
}
|
||||
|
||||
extern void sock_enable_timestamp(struct sock *sk);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue