diff options
author | Tom Herbert <therbert@google.com> | 2014-11-12 14:54:09 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-11-12 15:01:35 -0500 |
commit | a8c5f90fb59a2d3bff0bd29adbb3e39fe0dd52f8 (patch) | |
tree | 49171c0ba2df50c16595901743dad7c0d32a7c33 /include/net | |
parent | 4243cdc2c1e5a1375cc8397e8f9b06530f099c60 (diff) |
ip_tunnel: Ops registration for secondary encap (fou, gue)
Instead of calling fou and gue functions directly from ip_tunnel
use ops for these that were previously registered. This patch adds the
logic to add and remove encapsulation operations for ip_tunnel,
and modified fou (and gue) to register with ip_tunnels.
This patch also addresses a circular dependency between ip_tunnel
and fou that was causing link errors when CONFIG_NET_IP_TUNNEL=y
and CONFIG_NET_FOU=m. References to fou an gue have been removed from
ip_tunnel.c
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Tom Herbert <therbert@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/fou.h | 25 | ||||
-rw-r--r-- | include/net/ip_tunnels.h | 16 |
2 files changed, 19 insertions, 22 deletions
diff --git a/include/net/fou.h b/include/net/fou.h index 25b26ffcf1df..19b8a0c62a98 100644 --- a/include/net/fou.h +++ b/include/net/fou.h | |||
@@ -8,31 +8,12 @@ | |||
8 | #include <net/ip_tunnels.h> | 8 | #include <net/ip_tunnels.h> |
9 | #include <net/udp.h> | 9 | #include <net/udp.h> |
10 | 10 | ||
11 | size_t fou_encap_hlen(struct ip_tunnel_encap *e); | ||
12 | static size_t gue_encap_hlen(struct ip_tunnel_encap *e); | ||
13 | |||
11 | int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, | 14 | int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, |
12 | u8 *protocol, struct flowi4 *fl4); | 15 | u8 *protocol, struct flowi4 *fl4); |
13 | int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, | 16 | int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e, |
14 | u8 *protocol, struct flowi4 *fl4); | 17 | u8 *protocol, struct flowi4 *fl4); |
15 | 18 | ||
16 | static size_t fou_encap_hlen(struct ip_tunnel_encap *e) | ||
17 | { | ||
18 | return sizeof(struct udphdr); | ||
19 | } | ||
20 | |||
21 | static size_t gue_encap_hlen(struct ip_tunnel_encap *e) | ||
22 | { | ||
23 | size_t len; | ||
24 | bool need_priv = false; | ||
25 | |||
26 | len = sizeof(struct udphdr) + sizeof(struct guehdr); | ||
27 | |||
28 | if (e->flags & TUNNEL_ENCAP_FLAG_REMCSUM) { | ||
29 | len += GUE_PLEN_REMCSUM; | ||
30 | need_priv = true; | ||
31 | } | ||
32 | |||
33 | len += need_priv ? GUE_LEN_PRIV : 0; | ||
34 | |||
35 | return len; | ||
36 | } | ||
37 | |||
38 | #endif | 19 | #endif |
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h index 5bc6edeb7143..25a59eb388a6 100644 --- a/include/net/ip_tunnels.h +++ b/include/net/ip_tunnels.h | |||
@@ -117,6 +117,22 @@ struct ip_tunnel_net { | |||
117 | struct hlist_head tunnels[IP_TNL_HASH_SIZE]; | 117 | struct hlist_head tunnels[IP_TNL_HASH_SIZE]; |
118 | }; | 118 | }; |
119 | 119 | ||
120 | struct ip_tunnel_encap_ops { | ||
121 | size_t (*encap_hlen)(struct ip_tunnel_encap *e); | ||
122 | int (*build_header)(struct sk_buff *skb, struct ip_tunnel_encap *e, | ||
123 | u8 *protocol, struct flowi4 *fl4); | ||
124 | }; | ||
125 | |||
126 | #define MAX_IPTUN_ENCAP_OPS 8 | ||
127 | |||
128 | extern const struct ip_tunnel_encap_ops __rcu * | ||
129 | iptun_encaps[MAX_IPTUN_ENCAP_OPS]; | ||
130 | |||
131 | int ip_tunnel_encap_add_ops(const struct ip_tunnel_encap_ops *op, | ||
132 | unsigned int num); | ||
133 | int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *op, | ||
134 | unsigned int num); | ||
135 | |||
120 | #ifdef CONFIG_INET | 136 | #ifdef CONFIG_INET |
121 | 137 | ||
122 | int ip_tunnel_init(struct net_device *dev); | 138 | int ip_tunnel_init(struct net_device *dev); |