datapath: Use upstream ipv6_find_hdr().
[cascardo/ovs.git] / datapath / linux / compat / include / net / ipv6.h
1 #ifndef __NET_IPV6_WRAPPER_H
2 #define __NET_IPV6_WRAPPER_H 1
3
4 #include <linux/version.h>
5
6 #include_next <net/ipv6.h>
7
8 #ifndef NEXTHDR_SCTP
9 #define NEXTHDR_SCTP    132 /* Stream Control Transport Protocol */
10 #endif
11
12 #ifndef HAVE_IP6_FH_F_SKIP_RH
13
14 enum {
15         IP6_FH_F_FRAG           = (1 << 0),
16         IP6_FH_F_AUTH           = (1 << 1),
17         IP6_FH_F_SKIP_RH        = (1 << 2),
18 };
19
20 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
21 #define ipv6_skip_exthdr rpl_ipv6_skip_exthdr
22 extern int ipv6_skip_exthdr(const struct sk_buff *skb, int start,
23                             u8 *nexthdrp, __be16 *frag_offp);
24 #endif
25
26 /* This function is upstream, but not the version which skips routing
27  * headers with 0 segments_left. We fixed it when we introduced
28  * IP6_FH_F_SKIP_RH.
29  */
30 #define ipv6_find_hdr rpl_ipv6_find_hdr
31 extern int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset,
32                          int target, unsigned short *fragoff, int *fragflg);
33 #endif
34
35 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
36 static inline u32 ipv6_addr_hash(const struct in6_addr *a)
37 {
38 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
39         const unsigned long *ul = (const unsigned long *)a;
40         unsigned long x = ul[0] ^ ul[1];
41
42         return (u32)(x ^ (x >> 32));
43 #else
44         return (__force u32)(a->s6_addr32[0] ^ a->s6_addr32[1] ^
45                              a->s6_addr32[2] ^ a->s6_addr32[3]);
46 #endif
47 }
48 #endif
49
50 #endif