pandora: defconfig: update
[pandora-kernel.git] / net / ipv6 / output_core.c
1 #include <linux/export.h>
2 #include <linux/skbuff.h>
3 #include <net/ip.h>
4 #include <net/ipv6.h>
5
6 /* This function exists only for tap drivers that must support broken
7  * clients requesting UFO without specifying an IPv6 fragment ID.
8  *
9  * This is similar to ipv6_select_ident() but we use an independent hash
10  * seed to limit information leakage.
11  */
12 void ipv6_proxy_select_ident(struct sk_buff *skb)
13 {
14         static u32 ip6_proxy_idents_hashrnd __read_mostly;
15         static bool hashrnd_initialized = false;
16         struct in6_addr buf[2];
17         struct in6_addr *addrs;
18         u32 hash, id;
19
20         addrs = skb_header_pointer(skb,
21                                    skb_network_offset(skb) +
22                                    offsetof(struct ipv6hdr, saddr),
23                                    sizeof(buf), buf);
24         if (!addrs)
25                 return;
26
27         if (unlikely(!hashrnd_initialized)) {
28                 hashrnd_initialized = true;
29                 get_random_bytes(&ip6_proxy_idents_hashrnd,
30                                  sizeof(ip6_proxy_idents_hashrnd));
31         }
32         hash = __ipv6_addr_jhash(&addrs[1], ip6_proxy_idents_hashrnd);
33         hash = __ipv6_addr_jhash(&addrs[0], hash);
34
35         id = ip_idents_reserve(hash, 1);
36         skb_shinfo(skb)->ip6_frag_id = htonl(id);
37 }
38 EXPORT_SYMBOL_GPL(ipv6_proxy_select_ident);