Skip to contentSkip to conversation

net/ipv4: VTI support new module for ip_vti.

PATCH In review Saurabh 2 participants 2 messages Jun 29, 2012

Subsystems (4)
lore
Share & tools
lore

Saurabh

author
#0 lore raw

PATCH 2/2 net/ipv4: VTI support new module for ip_vti.

Incorporated David and Steffen's comments.
New VTI tunnel kernel module, Kconfig and Makefile changes.

---

include/linux/if_tunnel.h +14 -0
index 16b92d0..5efff60 100644
@@ -80,4 +80,18 @@ enum {
 
 #define IFLA_GRE_MAX	(__IFLA_GRE_MAX - 1)
 
+/* VTI-mode i_flags */
+#define VTI_ISVTI 0x0001
+
+enum {
+	IFLA_VTI_UNSPEC,
+	IFLA_VTI_LINK,
+	IFLA_VTI_IKEY,
+	IFLA_VTI_OKEY,
+	IFLA_VTI_LOCAL,
+	IFLA_VTI_REMOTE,
+	__IFLA_VTI_MAX,
+};
+
+#define IFLA_VTI_MAX	(__IFLA_VTI_MAX - 1)
 #endif /* _IF_TUNNEL_H_ */
net/ipv4/Kconfig +10 -0
index 20f1cb5..32d467b 100644
@@ -310,6 +310,16 @@ config SYN_COOKIES
 
 	  If unsure, say N.
 
+config NET_IPVTI
+	tristate "Virtual (secure) IP: tunneling"
+	select INET_TUNNEL
+	depends on INET_XFRM_MODE_TUNNEL
+	---help---
+	Tunneling means encapsulating data of one protocol type within
+	another protocol and sending it over a channel that understands the
+	Pencapsulating protocol. This can be used with xfrm mode tunnel to give
+	the notion of a secure tunnel for IPSEC and then use routing protocol on top.
+
 config INET_AH
 	tristate "IP: AH transformation"
 	select XFRM_ALGO
net/ipv4/Makefile +1 -0
index ff75d3b..3999ce9 100644
@@ -20,6 +20,7 @@ obj-$(CONFIG_IP_MROUTE) += ipmr.o
 obj-$(CONFIG_NET_IPIP) += ipip.o
 obj-$(CONFIG_NET_IPGRE_DEMUX) += gre.o
 obj-$(CONFIG_NET_IPGRE) += ip_gre.o
+obj-$(CONFIG_NET_IPVTI) += ip_vti.o
 obj-$(CONFIG_SYN_COOKIES) += syncookies.o
 obj-$(CONFIG_INET_AH) += ah4.o
 obj-$(CONFIG_INET_ESP) += esp4.o
net/ipv4/ip_vti.c new file +970 -0

970 lines not on this page · raw message

maintainer
#1 lore raw

From: Saurabh <[email protected]>
Date: Thu, 28 Jun 2012 17:52:31 -0700

net/ipv4/ip_vti.c line 99

Quoted 2 lines
net/ipv4/ip_vti.c new file +2 -0
+static struct rtnl_link_stats64 *vti_get_stats64(struct net_device *dev,
+					       struct rtnl_link_stats64 *tot)

Imporperly indentex, all of the argument lines must line up with the first column after the initial "(" on the first line.

net/ipv4/ip_vti.c line 137

Quoted 2 lines
net/ipv4/ip_vti.c new file +2 -0
+static struct ip_tunnel *vti_tunnel_lookup(struct net *net,
+					 __be32 remote, __be32 local)

Likewise.

net/ipv4/ip_vti.c line 163

Quoted 2 lines
net/ipv4/ip_vti.c new file +2 -0
+static struct ip_tunnel **__vti_bucket(struct vti_net *ipn,
+				     struct ip_tunnel_parm *parms)

Likewise.

net/ipv4/ip_vti.c line 182

Quoted 2 lines
net/ipv4/ip_vti.c new file +2 -0
+static inline struct ip_tunnel **vti_bucket(struct vti_net *ipn,
+					  struct ip_tunnel *t)

Likewise.

net/ipv4/ip_vti.c line 212

Quoted 3 lines
net/ipv4/ip_vti.c new file +3 -0
+static struct ip_tunnel *vti_tunnel_locate(struct net *net,
+					 struct ip_tunnel_parm *parms,
+					 int create)

Likewise.

net/ipv4/ip_vti.c line 224

Quoted 3 lines
net/ipv4/ip_vti.c new file +3 -0
+	for (tp = __vti_bucket(ipn, parms);
+	     (t = rtnl_dereference(*tp)) != NULL;
+	     tp = &t->next) {

I find it very amusing that you are able to format this for() statement
correctly, but in the entire patch #1 you were unable to. It's like
this patch was written by a completely different person.

net/ipv4/ip_vti.c line 309

Quoted 4 lines
net/ipv4/ip_vti.c new file +4 -0
+	rcu_read_lock();
+	t = vti_tunnel_lookup(dev_net(skb->dev), iph->daddr, iph->saddr);
+	if (t == NULL)
+		goto out;

You should return -ENOENT, like ipip() does, when the tunnel cannot be found.

net/ipv4/ip_vti.c line 397

Quoted 4 lines
net/ipv4/ip_vti.c new file +4 -0
+	flowi4_init_output(&fl4, tunnel->parms.link,
+		htonl(tunnel->parms.i_key), RT_TOS(tos), RT_SCOPE_UNIVERSE,
+		IPPROTO_IPIP, 0,
+		dst, tiph->saddr, 0, 0);

Indent these arguments properly.

net/ipv4/ip_vti.c line 407

Quoted 4 lines
net/ipv4/ip_vti.c new file +4 -0
+		/*
+		 * if there is no transform then this tunnel is not functional.
+		 * Or if the xfrm is not mode tunnel.
+		 */

Format comments:

	/* Like
	 * this.
	 */

Not:

	/*
	 * Like
	 * this.
	 */

net/ipv4/ip_vti.c line 468

Quoted 4 lines
net/ipv4/ip_vti.c new file +4 -0
+		flowi4_init_output(&fl4, tunnel->parms.link,
+				htonl(tunnel->parms.i_key), RT_TOS(iph->tos), RT_SCOPE_UNIVERSE,
+				IPPROTO_IPIP, 0,
+				iph->daddr, iph->saddr, 0, 0);

Fix this indentation.