summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Knockel <jeffk@cs.unm.edu>2014-12-12 06:14:26 +0000
committerZefan Li <lizefan@huawei.com>2015-02-02 17:05:26 +0800
commitfd873bf1ce5477514515e82aa8acdc7ec06a9b97 (patch)
tree527f25c8de3c7fd05b18161f9c1b1a1aa1ab2b79
parentcfa0515dc4826a9d14bc871d88d6d80bafe0e7cf (diff)
Patch for 3.2.x, 3.4.x IP identifier regression
commit c3b4ccb8b03769e2867fabecc078483ee6710ccf upstream. With commits 73f156a6e8c1 ("inetpeer: get rid of ip_id_count") and 04ca6973f7c1 ("ip: make IP identifiers less predictable"), IP identifiers are generated from a counter chosen from an array of counters indexed by the hash of the outgoing packet header's source address, destination address, and protocol number. Thus, in __ip_make_skb(), we must now call ip_select_ident() only after setting these fields in the IP header to prevent IP identifiers from being generated from bogus counters. IP id sequence before fix: 18174, 5789, 5953, 59420, 59637, ... After fix: 5967, 6185, 6374, 6600, 6795, 6892, 7051, 7288, ... Signed-off-by: Jeffrey Knockel <jeffk@cs.unm.edu> Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Cc: Eric Dumazet <edumazet@google.com> [Backported to 3.4: adjust context] Signed-off-by: Zefan Li <lizefan@huawei.com>
-rw-r--r--net/ipv4/ip_output.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 7827436ae843..330be870c1ef 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1346,10 +1346,10 @@ struct sk_buff *__ip_make_skb(struct sock *sk,
iph->ihl = 5;
iph->tos = inet->tos;
iph->frag_off = df;
- ip_select_ident(skb, sk);
iph->ttl = ttl;
iph->protocol = sk->sk_protocol;
ip_copy_addrs(iph, fl4);
+ ip_select_ident(skb, sk);
if (opt) {
iph->ihl += opt->optlen>>2;