stream-ssl: Enable TLSv1.1 and TLSv1.2.
[cascardo/ovs.git] / datapath / compat.h
1 /*
2  * Copyright (c) 2007-2012 Nicira, Inc.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of version 2 of the GNU General Public
6  * License as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16  * 02110-1301, USA
17  */
18
19 #ifndef COMPAT_H
20 #define COMPAT_H 1
21
22 #include <linux/in.h>
23 #include <linux/in_route.h>
24 #include <linux/netlink.h>
25 #include <net/route.h>
26 #include <net/xfrm.h>
27
28 static inline void skb_clear_rxhash(struct sk_buff *skb)
29 {
30 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
31         skb->rxhash = 0;
32 #endif
33 #ifdef HAVE_L4_RXHASH
34         skb->l4_rxhash = 0;
35 #endif
36 }
37
38 #ifdef HAVE_PARALLEL_OPS
39 #define SET_PARALLEL_OPS        .parallel_ops = true,
40 #else
41 #define SET_PARALLEL_OPS
42 #endif
43
44 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
45 #define rt_dst(rt) (rt->dst)
46 #else
47 #define rt_dst(rt) (rt->u.dst)
48 #endif
49
50 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
51 #define inet_sport(sk)  (inet_sk(sk)->sport)
52 #else
53 #define inet_sport(sk)  (inet_sk(sk)->inet_sport)
54 #endif
55
56 static inline struct rtable *find_route(struct net *net,
57                                         __be32 *saddr, __be32 daddr,
58                                         u8 ipproto, u8 tos, u32 skb_mark)
59 {
60         struct rtable *rt;
61         /* Tunnel configuration keeps DSCP part of TOS bits, But Linux
62          * router expect RT_TOS bits only. */
63
64 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
65         struct flowi fl = { .nl_u = { .ip4_u = {
66                                         .daddr = daddr,
67                                         .saddr = *saddr,
68                                         .tos   = RT_TOS(tos) } },
69                                         .mark = skb_mark,
70                                         .proto = ipproto };
71
72         if (unlikely(ip_route_output_key(net, &rt, &fl)))
73                 return ERR_PTR(-EADDRNOTAVAIL);
74         *saddr = fl.nl_u.ip4_u.saddr;
75         return rt;
76 #else
77         struct flowi4 fl = { .daddr = daddr,
78                              .saddr = *saddr,
79                              .flowi4_tos = RT_TOS(tos),
80                              .flowi4_mark = skb_mark,
81                              .flowi4_proto = ipproto };
82
83         rt = ip_route_output_key(net, &fl);
84         *saddr = fl.saddr;
85         return rt;
86 #endif
87 }
88 #endif /* compat.h */