Skip to contentSkip to conversation

GRE: Refactor GRE tunneling code.

PATCH In review Pravin B Shelar 1 participant 1 message Mar 26, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/5 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

---
 drivers/net/vxlan.c      |    2 +-
 include/net/gre.h        |   51 ++
 include/net/ip6_tunnel.h |    1 +
 include/net/ip_tunnels.h |  177 ++++++
 include/net/ipip.h       |   84 ---
 net/ipv4/Kconfig         |    5 +
 net/ipv4/Makefile        |    1 +
 net/ipv4/af_inet.c       |    1 -
 net/ipv4/gre.c           |    5 -
 net/ipv4/ip_gre.c        | 1504 ++++++++++------------------------------------
 net/ipv4/ip_tunnel.c     | 1035 +++++++++++++++++++++++++++++++
 net/ipv4/ip_vti.c        |    2 +-
 net/ipv4/ipip.c          |    2 +-
 net/ipv4/ipmr.c          |    2 +-
 net/ipv6/af_inet6.c      |    1 -
 net/ipv6/ip6_gre.c       |    1 +
 net/ipv6/ip6_tunnel.c    |    1 +
 net/ipv6/sit.c           |    2 +-
 18 files changed, 1594 insertions(+), 1283 deletions(-)
 create mode 100644 include/net/ip_tunnels.h
 delete mode 100644 include/net/ipip.h
 create mode 100644 net/ipv4/ip_tunnel.c
drivers/net/vxlan.c +1 -1
index 33427fd..fe9ea7d 100644
@@ -33,7 +33,7 @@
 #include <net/arp.h>
 #include <net/ndisc.h>
 #include <net/ip.h>
-#include <net/ipip.h>
+#include <net/ip_tunnels.h>
 #include <net/icmp.h>
 #include <net/udp.h>
 #include <net/rtnetlink.h>
include/net/gre.h +51 -0

64 lines not on this page · raw message

include/net/ip6_tunnel.h +1 -0
index ebdef7f..4da5de1 100644
@@ -3,6 +3,7 @@
 
 #include <linux/ipv6.h>
 #include <linux/netdevice.h>
+#include <linux/if_tunnel.h>
 #include <linux/ip6_tunnel.h>
 
 #define IP6TUNNEL_ERR_TIMEO (30*HZ)
include/net/ip_tunnels.h new file +177 -0

177 lines not on this page · raw message

include/net/ipip.h deleted +0 -84

84 lines not on this page · raw message

net/ipv4/Kconfig +5 -0
index 7944df7..2073226 100644
@@ -186,9 +186,14 @@ config NET_IPGRE_DEMUX
 	 This is helper module to demultiplex GRE packets on GRE version field criteria.
 	 Required by ip_gre and pptp modules.
 
+config NET_IP_TUNNEL
+	tristate
+	default n
+
 config NET_IPGRE
 	tristate "IP: GRE tunnels over IP"
 	depends on (IPV6 || IPV6=n) && NET_IPGRE_DEMUX
+	select NET_IP_TUNNEL
 	help
 	  Tunneling means encapsulating data of one protocol type within
 	  another protocol and sending it over a channel that understands the
net/ipv4/Makefile +1 -0
index 15ca63e..089cb9f 100644
@@ -13,6 +13,7 @@ obj-y     := route.o inetpeer.o protocol.o \
 	     fib_frontend.o fib_semantics.o fib_trie.o \
 	     inet_fragment.o ping.o
 
+obj-$(CONFIG_NET_IP_TUNNEL) += ip_tunnel.o
 obj-$(CONFIG_SYSCTL) += sysctl_net_ipv4.o
 obj-$(CONFIG_PROC_FS) += proc.o
 obj-$(CONFIG_IP_MULTIPLE_TABLES) += fib_rules.o
net/ipv4/af_inet.c +0 -1
index 70b2d4c..93824c5 100644
@@ -111,7 +111,6 @@
 #include <net/sock.h>
 #include <net/raw.h>
 #include <net/icmp.h>
-#include <net/ipip.h>
 #include <net/inet_common.h>
 #include <net/xfrm.h>
 #include <net/net_namespace.h>
net/ipv4/gre.c +0 -5
index 7a4c710..d2d5a99 100644
@@ -27,11 +27,6 @@
 
 static const struct gre_protocol __rcu *gre_proto[GREPROTO_MAX] __read_mostly;
 static DEFINE_SPINLOCK(gre_proto_lock);
-struct gre_base_hdr {
-	__be16 flags;
-	__be16 protocol;
-};
-#define GRE_HEADER_SECTION 4
 
 int gre_add_protocol(const struct gre_protocol *proto, u8 version)
 {
net/ipv4/ip_gre.c +317 -1187

1,820 lines not on this page · raw message

net/ipv4/ip_tunnel.c new file +1035 -0

801 lines not on this page · raw message

net/ipv4/ip_vti.c +1 -1
index c3a4233..6a628fb 100644

Lines of this file are not shown. View the raw message.

net/ipv4/ipip.c +1 -1
index 34e006f..a557d6a 100644

Lines of this file are not shown. View the raw message.

net/ipv4/ipmr.c +1 -1
index 5f95b3a..fd61fe1 100644

Lines of this file are not shown. View the raw message.

net/ipv6/af_inet6.c +0 -1
index f56277f..ab5c7ad 100644

Lines of this file are not shown. View the raw message.

net/ipv6/ip6_gre.c +1 -0
index 6a6ba73..df89cca 100644

Lines of this file are not shown. View the raw message.

net/ipv6/ip6_tunnel.c +1 -0
index bef3fed..1e55866 100644

Lines of this file are not shown. View the raw message.

net/ipv6/sit.c +1 -1
index 898e671..ee4fc57 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.1

Part of the diff is not shown here. View the raw message.