diff options
author | Tom Herbert <therbert@google.com> | 2015-02-24 12:17:31 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-27 16:00:01 -0500 |
commit | 723b8e460d87e957f251dc5764f4ab86af6ab44e (patch) | |
tree | 2453607eb05e7cdf3913fedfe55599641c6a66b1 /net/ipv4/udp.c | |
parent | fed0a159c8c5e453d79d6a73897c576efea0a8a5 (diff) |
udp: In udp_flow_src_port use random hash value if skb_get_hash fails
In the unlikely event that skb_get_hash is unable to deduce a hash
in udp_flow_src_port we use a consistent random value instead.
This is specified in GRE/UDP draft section 3.2.1:
https://tools.ietf.org/html/draft-ietf-tsvwg-gre-in-udp-encap-04
Signed-off-by: Tom Herbert <therbert@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/udp.c')
-rw-r--r-- | net/ipv4/udp.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 97ef1f8b7be8..0224f930c613 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -2525,6 +2525,16 @@ void __init udp_table_init(struct udp_table *table, const char *name) | |||
2525 | } | 2525 | } |
2526 | } | 2526 | } |
2527 | 2527 | ||
2528 | u32 udp_flow_hashrnd(void) | ||
2529 | { | ||
2530 | static u32 hashrnd __read_mostly; | ||
2531 | |||
2532 | net_get_random_once(&hashrnd, sizeof(hashrnd)); | ||
2533 | |||
2534 | return hashrnd; | ||
2535 | } | ||
2536 | EXPORT_SYMBOL(udp_flow_hashrnd); | ||
2537 | |||
2528 | void __init udp_init(void) | 2538 | void __init udp_init(void) |
2529 | { | 2539 | { |
2530 | unsigned long limit; | 2540 | unsigned long limit; |