summaryrefslogtreecommitdiff
path: root/include/net/sock.h
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2015-07-29 22:44:05 -0700
committerDavid S. Miller <davem@davemloft.net>2015-07-29 22:44:05 -0700
commit97493e6a4b527a9f3504908fdd0531b7036b9157 (patch)
tree23b4f2c90130092b17f1c560331266cb85cb4a26 /include/net/sock.h
parent7a86d96e4a990aab2fc7b3b97c3bb09f9da0a290 (diff)
parent265f94ff54d62503663d9c788ba1f082e448f8b8 (diff)
Merge branch 'sk_txhash'
Tom Herbert says: ==================== net: Initialize sk_hash to random value and reset for failing cnxs This patch set implements a common function to simply set sk_txhash to a random number instead of going through the trouble to call flow dissector. From dst_negative_advice we now reset the sk_txhash in hopes of finding a better ECMP path through the network. Changing sk_txhash affects: - IPv6 flow label and UDP source port which affect ECMP in the network - Local ECMP route selection (pending changes to use sk_txhash) ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sock.h')
-rw-r--r--include/net/sock.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 4353ef70bf48..24aa75c5317a 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -1687,6 +1687,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)
{
@@ -1711,6 +1725,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);