summaryrefslogtreecommitdiffstats
path: root/include/net/sock.h
diff options
context:
space:
mode:
authorTom Herbert <tom@herbertland.com>2015-07-28 16:02:05 -0700
committerDavid S. Miller <davem@davemloft.net>2015-07-29 22:44:04 -0700
commit877d1f6291f8e391237e324be58479a3e3a7407c (patch)
tree7fef04aed6fab396e8e1205a37fff6ad3a2450ed /include/net/sock.h
parent7a86d96e4a990aab2fc7b3b97c3bb09f9da0a290 (diff)
downloadlinux-877d1f6291f8e391237e324be58479a3e3a7407c.tar.bz2
net: Set sk_txhash from a random number
This patch creates sk_set_txhash and eliminates protocol specific inet_set_txhash and ip6_set_txhash. sk_set_txhash simply sets a random number instead of performing flow dissection. sk_set_txash is also allowed to be called multiple times for the same socket, we'll need this when redoing the hash for negative routing advice. Signed-off-by: Tom Herbert <tom@herbertland.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sock.h')
-rw-r--r--include/net/sock.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 4353ef70bf48..fe735c4841f6 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1687,6 +1687,14 @@ 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 struct dst_entry *
__sk_dst_get(struct sock *sk)
{