Skip to contentSkip to conversation

GRE: Refactor GRE tunneling code.

PATCH Superseded Pravin B Shelar 4 participants 15 messages Mar 18, 2013 – Mar 25, 2013

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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/ip_tunnels.h |  169 ++++++
 include/net/ipip.h       |   88 ---
 net/ipv4/Kconfig         |    5 +
 net/ipv4/Makefile        |    1 +
 net/ipv4/af_inet.c       |    1 -
 net/ipv4/gre.c           |    5 -
 net/ipv4/ip_gre.c        | 1501 ++++++++++------------------------------------
 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 +-
 17 files changed, 1580 insertions(+), 1289 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/ip_tunnels.h new file +169 -0

169 lines not on this page · raw message

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

88 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 9e5882c..a1fca33 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 +312 -1189

1,805 lines not on this page · raw message

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

827 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..af4a5e2 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.

maintainer
#1 lore raw

From: Pravin B Shelar <[email protected]>
Date: Mon, 18 Mar 2013 11:13:25 -0700

Quoted 1 line

+EXPORT_SYMBOL(ip_tunnel_get_stats64);

EXPORT_SYMBOL_GPL() please.

maintainer
#2 lore raw

From: David Miller <[email protected]>
Date: Mon, 18 Mar 2013 15:23:37 -0400 (EDT)

Quoted 6 lines

From: Pravin B Shelar <[email protected]>
Date: Mon, 18 Mar 2013 11:13:25 -0700

Quoted 1 line

+EXPORT_SYMBOL(ip_tunnel_get_stats64);

EXPORT_SYMBOL_GPL() please.

In case it isn't clear, I want you to use GPL exports for all of the symbols exported from the new library.

Thanks.

#3 lore raw
In reply to Pravin B Shelar

net/ipv4/Kconfig config NET_IPGRE_DEMUX · line 192

Quoted 12 lines · On Mon, 18 Mar 2013 11:13:25 -0700 Pravin B Shelar <[email protected]> wrote:
net/ipv4/Kconfig +4 -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
+

Won't this break existing kernel config's, shouldn't this default y?

maintainer
#4 lore raw

From: Stephen Hemminger <[email protected]>
Date: Mon, 18 Mar 2013 12:24:09 -0700

Quoted 11 lines
Quoted 8 lines · On Mon, 18 Mar 2013 11:13:25 -0700 Pravin B Shelar <[email protected]> wrote:
net/ipv4/Kconfig +0 -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.
 
Quoted 6 lines

net/ipv4/Kconfig config NET_IPGRE_DEMUX · line 192

Quoted 4 lines
net/ipv4/Kconfig +4 -0
+config NET_IP_TUNNEL
+	tristate
+	default n
+

Won't this break existing kernel config's, shouldn't this default y?

Or "m". But indeed, it should be made to automatically work for existing configs.

#5 lore raw
Quoted 21 lines · David Miller

From: Stephen Hemminger <[email protected]>
Date: Mon, 18 Mar 2013 12:24:09 -0700

Quoted 11 lines
Quoted 8 lines · On Mon, 18 Mar 2013 11:13:25 -0700 Pravin B Shelar <[email protected]> wrote:
net/ipv4/Kconfig +0 -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.
 
Quoted 6 lines

net/ipv4/Kconfig config NET_IPGRE_DEMUX · line 192

Quoted 4 lines
net/ipv4/Kconfig +4 -0
+config NET_IP_TUNNEL
+    tristate
+    default n
+

Won't this break existing kernel config's, shouldn't this default y?

Quoted 2 lines

Or "m". But indeed, it should be made to automatically work for existing configs.

ok,
I will post updated patch.

Thanks.

#6 lore raw
In reply to David Miller
Quoted 19 lines · David Miller

From: Stephen Hemminger <[email protected]>

Quoted 11 lines
Quoted 8 lines · On Mon, 18 Mar 2013 11:13:25 -0700 Pravin B Shelar <[email protected]> wrote:
net/ipv4/Kconfig +0 -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.
 
Quoted 6 lines

net/ipv4/Kconfig config NET_IPGRE_DEMUX · line 192

Quoted 4 lines
net/ipv4/Kconfig +4 -0
+config NET_IP_TUNNEL
+	tristate
+	default n
+

Won't this break existing kernel config's, shouldn't this default y?

Quoted 2 lines

Or "m". But indeed, it should be made to automatically work for existing configs.

Won't the "select NET_IP_TUNNEL" statements do just that?

Changing the default to m will enable this module even if all of NET_IPGRE, VXLAN and NET_IPIP are disabled. That's pointless, isn't it?

Bjørn

#7 lore raw
Quoted 20 lines · On Tue, 19 Mar 2013 11:31:30 +0100 Bjørn Mork <[email protected]> wrote:
Quoted 19 lines · David Miller

From: Stephen Hemminger <[email protected]>

Quoted 17 lines

net/ipv4/Kconfig config NET_IPGRE_DEMUX · line 192

Quoted 12 lines · On Mon, 18 Mar 2013 11:13:25 -0700 Pravin B Shelar <[email protected]> wrote:
net/ipv4/Kconfig +4 -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
+

Won't this break existing kernel config's, shouldn't this default y?

Quoted 7 lines
Quoted 2 lines

Or "m". But indeed, it should be made to automatically work for existing configs.

Won't the "select NET_IP_TUNNEL" statements do just that?

Changing the default to m will enable this module even if all of NET_IPGRE, VXLAN and NET_IPIP are disabled. That's pointless, isn't it?

Looks like you are right, just tried a number of different kernel configs with 'make oldconfig' and it picks up the dependency correctly.

#8 lore raw
In reply to Pravin B Shelar
Quoted 16 lines · On Mon, 18 Mar 2013 11:13:25 -0700 Pravin B Shelar <[email protected]> wrote:

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.

Quoted 3 lines

ipip.h header is renamed to ip_tunnel.h

Doesn't build with this patch alone (ie. not bisectable).

CC [M] net/ipv6/ip6_gre.o
net/ipv6/ip6_gre.c:41:27: fatal error: net/ip_tunnel.h: No such file or directory compilation terminated.

maintainer
#9 lore raw

From: Stephen Hemminger <[email protected]>
Date: Tue, 19 Mar 2013 14:21:41 -0700

Quoted 5 lines

Doesn't build with this patch alone (ie. not bisectable).

CC [M] net/ipv6/ip6_gre.o
net/ipv6/ip6_gre.c:41:27: fatal error: net/ip_tunnel.h: No such file or directory compilation terminated.

Oh well, too late, it's all already in my tree.

#10 lore raw
Quoted 10 lines · David Miller

From: Stephen Hemminger <[email protected]>
Date: Tue, 19 Mar 2013 14:21:41 -0700

Quoted 5 lines

Doesn't build with this patch alone (ie. not bisectable).

CC [M] net/ipv6/ip6_gre.o
net/ipv6/ip6_gre.c:41:27: fatal error: net/ip_tunnel.h: No such file or directory compilation terminated.

Oh well, too late, it's all already in my tree.

sorry about that.
I am sending update patch soon.

maintainer
#11 lore raw

From: Pravin Shelar <[email protected]>
Date: Tue, 19 Mar 2013 14:38:11 -0700

Quoted 6 lines · David Miller
Quoted 5 lines

From: Stephen Hemminger <[email protected]>
Date: Tue, 19 Mar 2013 14:21:41 -0700

Quoted 2 lines

Doesn't build with this patch alone (ie. not bisectable).

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

CC [M] net/ipv6/ip6_gre.o
net/ipv6/ip6_gre.c:41:27: fatal error: net/ip_tunnel.h: No such file or directory compilation terminated.

Oh well, too late, it's all already in my tree.

sorry about that.
I am sending update patch soon.

There is nothing for you to send, what's in my tree is not changing.

#12 lore raw
Quoted 13 lines · David Miller

From: Pravin Shelar <[email protected]>
Date: Tue, 19 Mar 2013 14:38:11 -0700

Quoted 10 lines · David Miller
Quoted 9 lines

From: Stephen Hemminger <[email protected]>
Date: Tue, 19 Mar 2013 14:21:41 -0700

Quoted 5 lines

Doesn't build with this patch alone (ie. not bisectable).

CC [M] net/ipv6/ip6_gre.o
net/ipv6/ip6_gre.c:41:27: fatal error: net/ip_tunnel.h: No such file or directory compilation terminated.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Oh well, too late, it's all already in my tree.

sorry about that.
I am sending update patch soon.

There is nothing for you to send, what's in my tree is not changing.

I do not see these patches in net-next and now there are few conflicts due GRE commits.
Do you want me to send updated patches against latest net-next?

maintainer
#13 lore raw

From: Pravin Shelar <[email protected]>
Date: Mon, 25 Mar 2013 12:30:46 -0700

Quoted 16 lines · David Miller
Quoted 15 lines

From: Pravin Shelar <[email protected]>
Date: Tue, 19 Mar 2013 14:38:11 -0700

Quoted 12 lines · David Miller
Quoted 10 lines

From: Stephen Hemminger <[email protected]>
Date: Tue, 19 Mar 2013 14:21:41 -0700

Quoted 5 lines

Doesn't build with this patch alone (ie. not bisectable).

CC [M] net/ipv6/ip6_gre.o
net/ipv6/ip6_gre.c:41:27: fatal error: net/ip_tunnel.h: No such file or directory compilation terminated.

Oh well, too late, it's all already in my tree.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

sorry about that.
I am sending update patch soon.

There is nothing for you to send, what's in my tree is not changing.

I do not see these patches in net-next and now there are few conflicts due GRE commits.
Do you want me to send updated patches against latest net-next?

You need to send whatever relative fixes are necessary.

maintainer
#14 lore raw

From: David Miller <[email protected]>
Date: Mon, 25 Mar 2013 15:39:34 -0400 (EDT)

Quoted 22 lines

From: Pravin Shelar <[email protected]>
Date: Mon, 25 Mar 2013 12:30:46 -0700

Quoted 19 lines · David Miller
Quoted 18 lines

From: Pravin Shelar <[email protected]>
Date: Tue, 19 Mar 2013 14:38:11 -0700

Quoted 14 lines · David Miller
Quoted 10 lines

From: Stephen Hemminger <[email protected]>
Date: Tue, 19 Mar 2013 14:21:41 -0700

Quoted 5 lines

Doesn't build with this patch alone (ie. not bisectable).

CC [M] net/ipv6/ip6_gre.o
net/ipv6/ip6_gre.c:41:27: fatal error: net/ip_tunnel.h: No such file or directory compilation terminated.

Oh well, too late, it's all already in my tree.

sorry about that.
I am sending update patch soon.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

There is nothing for you to send, what's in my tree is not changing.

I do not see these patches in net-next and now there are few conflicts due GRE commits.
Do you want me to send updated patches against latest net-next?

You need to send whatever relative fixes are necessary.

Actually I see where the confusion is.

I thought I had applied v3 of this series, looks like I didn't, so yes you should respin this fixing the build problems Stephen pointed out.

Thanks.