aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/gre.h
diff options
context:
space:
mode:
authorPravin B Shelar <pshelar@nicira.com>2013-03-25 10:49:35 -0400
committerDavid S. Miller <davem@davemloft.net>2013-03-26 12:27:18 -0400
commitc54419321455631079c7d6e60bc732dd0c5914c5 (patch)
treea0ad703b72313b98e70f4166bcea9a328d09e937 /include/net/gre.h
parenteaac5f3d3ad33547b299935e6db0cfc7be9a576a (diff)
GRE: Refactor GRE tunneling code.
Following patch refactors GRE code into ip tunneling code and GRE specific code. Common tunneling code is moved to ip_tunnel module. ip_tunnel module is written as generic library which can be used by different tunneling implementations. ip_tunnel module contains following components: - packet xmit and rcv generic code. xmit flow looks like (gre_xmit/ipip_xmit)->ip_tunnel_xmit->ip_local_out. - hash table of all devices. - lookup for tunnel devices. - control plane operations like device create, destroy, ioctl, netlink operations code. - registration for tunneling modules, like gre, ipip etc. - define single pcpu_tstats dev->tstats. - struct tnl_ptk_info added to pass parsed tunnel packet parameters. ipip.h header is renamed to ip_tunnel.h Signed-off-by: Pravin B Shelar <pshelar@nicira.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/gre.h')
-rw-r--r--include/net/gre.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/include/net/gre.h b/include/net/gre.h
index 82665474bcb7..9f03a390c826 100644
--- a/include/net/gre.h
+++ b/include/net/gre.h
@@ -2,6 +2,7 @@
2#define __LINUX_GRE_H 2#define __LINUX_GRE_H
3 3
4#include <linux/skbuff.h> 4#include <linux/skbuff.h>
5#include <net/ip_tunnels.h>
5 6
6#define GREPROTO_CISCO 0 7#define GREPROTO_CISCO 0
7#define GREPROTO_PPTP 1 8#define GREPROTO_PPTP 1
@@ -12,7 +13,57 @@ struct gre_protocol {
12 void (*err_handler)(struct sk_buff *skb, u32 info); 13 void (*err_handler)(struct sk_buff *skb, u32 info);
13}; 14};
14 15
16struct gre_base_hdr {
17 __be16 flags;
18 __be16 protocol;
19};
20#define GRE_HEADER_SECTION 4
21
15int gre_add_protocol(const struct gre_protocol *proto, u8 version); 22int gre_add_protocol(const struct gre_protocol *proto, u8 version);
16int gre_del_protocol(const struct gre_protocol *proto, u8 version); 23int gre_del_protocol(const struct gre_protocol *proto, u8 version);
17 24
25static inline __be16 gre_flags_to_tnl_flags(__be16 flags)
26{
27 __be16 tflags = 0;
28
29 if (flags & GRE_CSUM)
30 tflags |= TUNNEL_CSUM;
31 if (flags & GRE_ROUTING)
32 tflags |= TUNNEL_ROUTING;
33 if (flags & GRE_KEY)
34 tflags |= TUNNEL_KEY;
35 if (flags & GRE_SEQ)
36 tflags |= TUNNEL_SEQ;
37 if (flags & GRE_STRICT)
38 tflags |= TUNNEL_STRICT;
39 if (flags & GRE_REC)
40 tflags |= TUNNEL_REC;
41 if (flags & GRE_VERSION)
42 tflags |= TUNNEL_VERSION;
43
44 return tflags;
45}
46
47static inline __be16 tnl_flags_to_gre_flags(__be16 tflags)
48{
49 __be16 flags = 0;
50
51 if (tflags & TUNNEL_CSUM)
52 flags |= GRE_CSUM;
53 if (tflags & TUNNEL_ROUTING)
54 flags |= GRE_ROUTING;
55 if (tflags & TUNNEL_KEY)
56 flags |= GRE_KEY;
57 if (tflags & TUNNEL_SEQ)
58 flags |= GRE_SEQ;
59 if (tflags & TUNNEL_STRICT)
60 flags |= GRE_STRICT;
61 if (tflags & TUNNEL_REC)
62 flags |= GRE_REC;
63 if (tflags & TUNNEL_VERSION)
64 flags |= GRE_VERSION;
65
66 return flags;
67}
68
18#endif 69#endif