]>
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 | ||
22 | #include <linux/netlink.h> | |
23 | ||
24 | #ifndef HAVE_NLA_NUL_STRING | |
25 | static inline int CHECK_NUL_STRING(struct nlattr *attr, int maxlen) | |
26 | { | |
27 | char *s; | |
28 | int len; | |
29 | if (!attr) | |
30 | return 0; | |
31 | ||
32 | len = nla_len(attr); | |
33 | if (len >= maxlen) | |
34 | return -EINVAL; | |
35 | ||
36 | s = nla_data(attr); | |
37 | if (s[len - 1] != '\0') | |
38 | return -EINVAL; | |
39 | ||
40 | return 0; | |
41 | } | |
42 | #else | |
43 | static inline int CHECK_NUL_STRING(struct nlattr *attr, int maxlen) | |
44 | { | |
45 | return 0; | |
46 | } | |
47 | #endif /* !HAVE_NLA_NUL_STRING */ | |
48 | ||
eba9291a PS |
49 | static inline void skb_clear_rxhash(struct sk_buff *skb) |
50 | { | |
51 | #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) | |
52 | skb->rxhash = 0; | |
53 | #endif | |
54 | } | |
55 | ||
a647150f BP |
56 | /* |
57 | * Enforces, mutual exclusion with the Linux bridge module, by declaring and | |
58 | * exporting br_should_route_hook. Because the bridge module also exports the | |
59 | * same symbol, the module loader will refuse to load both modules at the same | |
60 | * time (e.g. "bridge: exports duplicate symbol br_should_route_hook (owned by | |
9b80f761 | 61 | * openvswitch)"). |
a647150f BP |
62 | * |
63 | * Before Linux 2.6.36, Open vSwitch cannot safely coexist with the Linux | |
9b80f761 CW |
64 | * bridge module, so openvswitch uses this macro in those versions. In |
65 | * Linux 2.6.36 and later, Open vSwitch can coexist with the bridge module, | |
66 | * but it makes no sense to load both bridge and brcompat, so brcompat uses | |
a647150f BP |
67 | * this macro in those versions. |
68 | * | |
69 | * The use of "typeof" here avoids the need to track changes in the type of | |
70 | * br_should_route_hook over various kernel versions. | |
71 | */ | |
72 | #define BRIDGE_MUTUAL_EXCLUSION \ | |
73 | typeof(br_should_route_hook) br_should_route_hook; \ | |
74 | EXPORT_SYMBOL(br_should_route_hook) | |
75 | ||
2a4999f3 PS |
76 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32) |
77 | #define GENL_SOCK(net) (genl_sock) | |
78 | #define SET_NETNSOK | |
79 | #else | |
80 | #define GENL_SOCK(net) ((net)->genl_sock) | |
81 | #define SET_NETNSOK .netnsok = true, | |
82 | #endif | |
83 | ||
9cb8d24d | 84 | #endif /* compat.h */ |