diff options
Diffstat (limited to 'include/net/sock.h')
| -rw-r--r-- | include/net/sock.h | 53 | 
1 files changed, 19 insertions, 34 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index 05a8c1aea251..7aa78440559a 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -429,7 +429,9 @@ struct sock {  	void			*sk_security;  #endif  	__u32			sk_mark; +#ifdef CONFIG_CGROUP_NET_CLASSID  	u32			sk_classid; +#endif  	struct cg_proto		*sk_cgrp;  	void			(*sk_state_change)(struct sock *sk);  	void			(*sk_data_ready)(struct sock *sk); @@ -902,7 +904,7 @@ void sk_stream_kill_queues(struct sock *sk);  void sk_set_memalloc(struct sock *sk);  void sk_clear_memalloc(struct sock *sk); -int sk_wait_data(struct sock *sk, long *timeo); +int sk_wait_data(struct sock *sk, long *timeo, const struct sk_buff *skb);  struct request_sock_ops;  struct timewait_sock_ops; @@ -1040,42 +1042,9 @@ struct proto {  #endif  }; -/* - * Bits in struct cg_proto.flags - */ -enum cg_proto_flags { -	/* Currently active and new sockets should be assigned to cgroups */ -	MEMCG_SOCK_ACTIVE, -	/* It was ever activated; we must disarm static keys on destruction */ -	MEMCG_SOCK_ACTIVATED, -}; - -struct cg_proto { -	struct page_counter	memory_allocated;	/* Current allocated memory. */ -	struct percpu_counter	sockets_allocated;	/* Current number of sockets. */ -	int			memory_pressure; -	long			sysctl_mem[3]; -	unsigned long		flags; -	/* -	 * memcg field is used to find which memcg we belong directly -	 * Each memcg struct can hold more than one cg_proto, so container_of -	 * won't really cut. -	 * -	 * The elegant solution would be having an inverse function to -	 * proto_cgroup in struct proto, but that means polluting the structure -	 * for everybody, instead of just for memcg users. -	 */ -	struct mem_cgroup	*memcg; -}; -  int proto_register(struct proto *prot, int alloc_slab);  void proto_unregister(struct proto *prot); -static inline bool memcg_proto_active(struct cg_proto *cg_proto) -{ -	return test_bit(MEMCG_SOCK_ACTIVE, &cg_proto->flags); -} -  #ifdef SOCK_REFCNT_DEBUG  static inline void sk_refcnt_debug_inc(struct sock *sk)  { @@ -1685,6 +1654,20 @@ static inline void sock_graft(struct sock *sk, struct socket *parent)  kuid_t sock_i_uid(struct sock *sk);  unsigned long sock_i_ino(struct sock *sk); +static inline void sk_set_txhash(struct sock *sk) +{ +	sk->sk_txhash = prandom_u32(); + +	if (unlikely(!sk->sk_txhash)) +		sk->sk_txhash = 1; +} + +static inline void sk_rethink_txhash(struct sock *sk) +{ +	if (sk->sk_txhash) +		sk_set_txhash(sk); +} +  static inline struct dst_entry *  __sk_dst_get(struct sock *sk)  { @@ -1709,6 +1692,8 @@ static inline void dst_negative_advice(struct sock *sk)  {  	struct dst_entry *ndst, *dst = __sk_dst_get(sk); +	sk_rethink_txhash(sk); +  	if (dst && dst->ops->negative_advice) {  		ndst = dst->ops->negative_advice(dst);  |