]>
Commit | Line | Data |
---|---|---|
9cb8d24d | 1 | /* |
e0edde6f | 2 | * Copyright (c) 2007-2012 Nicira, Inc. |
9cb8d24d | 3 | * |
a9a29d22 JG |
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 | |
9cb8d24d JG |
17 | */ |
18 | ||
19 | #ifndef COMPAT_H | |
20 | #define COMPAT_H 1 | |
21 | ||
6c5d24af PS |
22 | #include <linux/in.h> |
23 | #include <linux/in_route.h> | |
9cb8d24d | 24 | #include <linux/netlink.h> |
6c5d24af PS |
25 | #include <net/route.h> |
26 | #include <net/xfrm.h> | |
27 | ||
eba9291a PS |
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 | } | |
34 | ||
14002a59 PS |
35 | #ifdef HAVE_PARALLEL_OPS |
36 | #define SET_PARALLEL_OPS .parallel_ops = true, | |
37 | #else | |
38 | #define SET_PARALLEL_OPS | |
39 | #endif | |
40 | ||
5ebaf571 PS |
41 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) |
42 | #define rt_dst(rt) (rt->dst) | |
43 | #else | |
44 | #define rt_dst(rt) (rt->u.dst) | |
45 | #endif | |
46 | ||
1b7ee51f PS |
47 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33) |
48 | #define inet_sport(sk) (inet_sk(sk)->sport) | |
49 | #else | |
50 | #define inet_sport(sk) (inet_sk(sk)->inet_sport) | |
51 | #endif | |
52 | ||
6c5d24af PS |
53 | static inline struct rtable *find_route(struct net *net, |
54 | __be32 *saddr, __be32 daddr, | |
55 | u8 ipproto, u8 tos, u32 skb_mark) | |
56 | { | |
57 | struct rtable *rt; | |
58 | /* Tunnel configuration keeps DSCP part of TOS bits, But Linux | |
59 | * router expect RT_TOS bits only. */ | |
60 | ||
61 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39) | |
62 | struct flowi fl = { .nl_u = { .ip4_u = { | |
63 | .daddr = daddr, | |
64 | .saddr = *saddr, | |
6c5d24af | 65 | .tos = RT_TOS(tos) } }, |
6c5d24af | 66 | .mark = skb_mark, |
6c5d24af PS |
67 | .proto = ipproto }; |
68 | ||
69 | if (unlikely(ip_route_output_key(net, &rt, &fl))) | |
70 | return ERR_PTR(-EADDRNOTAVAIL); | |
71 | *saddr = fl.nl_u.ip4_u.saddr; | |
72 | return rt; | |
73 | #else | |
74 | struct flowi4 fl = { .daddr = daddr, | |
75 | .saddr = *saddr, | |
76 | .flowi4_tos = RT_TOS(tos), | |
77 | .flowi4_mark = skb_mark, | |
78 | .flowi4_proto = ipproto }; | |
79 | ||
80 | rt = ip_route_output_key(net, &fl); | |
81 | *saddr = fl.saddr; | |
82 | return rt; | |
83 | #endif | |
84 | } | |
9cb8d24d | 85 | #endif /* compat.h */ |