All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joerg Roedel <joro-lkml@zlug.org>
To: Patrick McHardy <kaber@trash.net>, davem@davemloft.net
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH 03/03][IPROUTE2] EtherIP tunnel and device support for iproute2
Date: Sat, 23 Sep 2006 14:20:36 +0200	[thread overview]
Message-ID: <20060923122036.GD32284@zlug.org> (raw)
In-Reply-To: <20060923120704.GA32284@zlug.org>

[-- Attachment #1: Type: text/plain, Size: 150 bytes --]

This patch adds support for EtherIP tunnels and devices to the iproute2
userspace software package.

Signed-off-by: Joerg Roedel <joro-lkml@zlug.org>

[-- Attachment #2: patch_iproute2 --]
[-- Type: text/plain, Size: 5317 bytes --]

diff -urp iproute2-2.6.16-060323.orig/ip/iptunnel.c iproute2-2.6.16-060323/ip/iptunnel.c
--- iproute2-2.6.16-060323.orig/ip/iptunnel.c	2005-02-10 19:31:18.000000000 +0100
+++ iproute2-2.6.16-060323/ip/iptunnel.c	2006-09-20 22:35:30.000000000 +0200
@@ -44,7 +44,7 @@ static void usage(void) __attribute__((n
 static void usage(void)
 {
 	fprintf(stderr, "Usage: ip tunnel { add | change | del | show } [ NAME ]\n");
-	fprintf(stderr, "          [ mode { ipip | gre | sit } ] [ remote ADDR ] [ local ADDR ]\n");
+	fprintf(stderr, "          [ mode { ipip | gre | sit | etherip } ] [ remote ADDR ] [ local ADDR ]\n");
 	fprintf(stderr, "          [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n");
 	fprintf(stderr, "          [ ttl TTL ] [ tos TOS ] [ [no]pmtudisc ] [ dev PHYS_DEV ]\n");
 	fprintf(stderr, "\n");
@@ -202,6 +202,12 @@ static int parse_args(int argc, char **a
 					exit(-1);
 				}
 				p->iph.protocol = IPPROTO_IPV6;
+			} else if (strcmp(*argv, "etherip") == 0) {
+				if (p->iph.protocol && p->iph.protocol != IPPROTO_ETHERIP) {
+					fprintf(stderr,"You managed to ask for more than one tunnel mode.\n");
+					exit(-1);
+				}
+				p->iph.protocol = IPPROTO_ETHERIP;
 			} else {
 				fprintf(stderr,"Cannot guess tunnel mode.\n");
 				exit(-1);
@@ -324,11 +330,15 @@ static int parse_args(int argc, char **a
 			p->iph.protocol = IPPROTO_IPIP;
 		else if (memcmp(p->name, "sit", 3) == 0)
 			p->iph.protocol = IPPROTO_IPV6;
+		else if (memcmp(p->name, "ethip", 5) == 0)
+			p->iph.protocol = IPPROTO_ETHERIP;
 	}
 
-	if (p->iph.protocol == IPPROTO_IPIP || p->iph.protocol == IPPROTO_IPV6) {
+	if (p->iph.protocol == IPPROTO_IPIP || 
+	    p->iph.protocol == IPPROTO_IPV6 ||
+	    p->iph.protocol == IPPROTO_ETHERIP) {
 		if ((p->i_flags & GRE_KEY) || (p->o_flags & GRE_KEY)) {
-			fprintf(stderr, "Keys are not allowed with ipip and sit.\n");
+			fprintf(stderr, "Keys are not allowed with ipip, sit or etherip.\n");
 			return -1;
 		}
 	}
@@ -351,6 +361,21 @@ static int parse_args(int argc, char **a
 		fprintf(stderr, "Broadcast tunnel requires a source address.\n");
 		return -1;
 	}
+
+	if (p->iph.protocol == IPPROTO_ETHERIP) {
+		if ((cmd == SIOCADDTUNNEL || cmd == SIOCCHGTUNNEL) && !p->iph.daddr) {
+			fprintf(stderr, "EtherIP tunnel requires a "
+					"destination address.\n");
+			return -1;
+		}
+
+		/*
+		if (cmd != SIOCDELTUNNEL && p->iph.frag_off & htons(IP_DF)) {
+			fprintf(stderr, "Warning: [no]pmtudisc is ignored on"
+					" EtherIP tunnels\n");
+		}
+		*/
+	}
 	return 0;
 }
 
@@ -374,6 +399,8 @@ static int do_add(int cmd, int argc, cha
 		return do_add_ioctl(cmd, "gre0", &p);
 	case IPPROTO_IPV6:
 		return do_add_ioctl(cmd, "sit0", &p);
+	case IPPROTO_ETHERIP:
+		return do_add_ioctl(cmd, "ethip0", &p);
 	default:	
 		fprintf(stderr, "cannot determine tunnel mode (ipip, gre or sit)\n");
 		return -1;
@@ -395,6 +422,8 @@ int do_del(int argc, char **argv)
 		return do_del_ioctl("gre0", &p);
 	case IPPROTO_IPV6:
 		return do_del_ioctl("sit0", &p);
+	case IPPROTO_ETHERIP:
+		return do_del_ioctl("ethip0", &p);
 	default:	
 		return do_del_ioctl(p.name, &p);
 	}
@@ -418,7 +447,8 @@ void print_tunnel(struct ip_tunnel_parm 
 	       p->name,
 	       p->iph.protocol == IPPROTO_IPIP ? "ip" :
 	       (p->iph.protocol == IPPROTO_GRE ? "gre" :
-		(p->iph.protocol == IPPROTO_IPV6 ? "ipv6" : "unknown")),
+	       (p->iph.protocol == IPPROTO_ETHERIP ? "etherip" :
+		(p->iph.protocol == IPPROTO_IPV6 ? "ipv6" : "unknown"))),
 	       p->iph.daddr ? format_host(AF_INET, 4, &p->iph.daddr, s1, sizeof(s1))  : "any",
 	       p->iph.saddr ? rt_addr_n2a(AF_INET, 4, &p->iph.saddr, s2, sizeof(s2)) : "any");
 
@@ -431,19 +461,19 @@ void print_tunnel(struct ip_tunnel_parm 
 	if (p->iph.ttl)
 		printf(" ttl %d ", p->iph.ttl);
 	else
-		printf(" ttl inherit ");
+		printf(" ttl %s", p->iph.protocol != IPPROTO_ETHERIP ? "inherit " : "default");
 	
 	if (p->iph.tos) {
 		SPRINT_BUF(b1);
 		printf(" tos");
 		if (p->iph.tos&1)
-			printf(" inherit");
+			printf(" %s", p->iph.protocol != IPPROTO_ETHERIP ? "inherit" : "default");
 		if (p->iph.tos&~1)
 			printf("%c%s ", p->iph.tos&1 ? '/' : ' ',
 			       rtnl_dsfield_n2a(p->iph.tos&~1, b1, sizeof(b1)));
 	}
 
-	if (!(p->iph.frag_off&htons(IP_DF)))
+	if (p->iph.protocol != IPPROTO_ETHERIP && !(p->iph.frag_off&htons(IP_DF)))
 		printf(" nopmtudisc");
 
 	if ((p->i_flags&GRE_KEY) && (p->o_flags&GRE_KEY) && p->o_key == p->i_key)
@@ -506,8 +536,13 @@ static int do_tunnels_list(struct ip_tun
 			fprintf(stderr, "Failed to get type of [%s]\n", name);
 			continue;
 		}
-		if (type != ARPHRD_TUNNEL && type != ARPHRD_IPGRE && type != ARPHRD_SIT)
+
+		if (type != ARPHRD_TUNNEL &&
+		    type != ARPHRD_IPGRE &&
+		    type != ARPHRD_SIT &&
+		    type != ARPHRD_ETHERIP)
 			continue;
+
 		memset(&p1, 0, sizeof(p1));
 		if (do_get_ioctl(name, &p1))
 			continue;
diff -urp iproute2-2.6.16-060323.orig/lib/ll_types.c iproute2-2.6.16-060323/lib/ll_types.c
--- iproute2-2.6.16-060323.orig/lib/ll_types.c	2005-02-09 23:07:24.000000000 +0100
+++ iproute2-2.6.16-060323/lib/ll_types.c	2006-09-23 13:19:16.000000000 +0200
@@ -118,6 +118,9 @@ __PF(IEEE802_TR,tr)
 #ifdef ARPHRD_IEEE80211
 __PF(IEEE80211,ieee802.11)
 #endif
+#ifdef ARPHRD_ETHERIP
+__PF(ETHERIP, etherip)
+#endif
 #ifdef ARPHRD_VOID
 __PF(VOID,void)
 #endif

      parent reply	other threads:[~2006-09-23 12:21 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-23 12:07 [PATCH 00/03][RESUBMIT] net: EtherIP tunnel driver Joerg Roedel
2006-09-23 12:13 ` Jan-Benedict Glaw
2006-09-23 12:27   ` Joerg Roedel
2006-09-23 12:38   ` jamal
2006-09-23 13:27     ` Joerg Roedel
2006-09-25  1:07       ` Valdis.Kletnieks
2006-09-25  8:32         ` Joerg Roedel
2006-09-25 20:49           ` Brian Haley
2006-09-23 23:35     ` David Miller
2006-09-25  8:18       ` Joerg Roedel
2006-09-25 10:22       ` Andi Kleen
2006-09-25 11:57         ` Joerg Roedel
2006-09-25 12:16           ` Andi Kleen
2006-09-25 12:35             ` Joerg Roedel
2006-09-23 12:13 ` [PATCH 01/03] net: EtherIP driver, header and MAINTAINERS changes Joerg Roedel
2006-09-23 12:16 ` [PATCH 02/03] net/bridge: add support for EtherIP devices Joerg Roedel
2006-09-24  4:01   ` Stephen Hemminger
2006-09-25  8:24     ` Joerg Roedel
2006-09-25 14:40       ` Stephen Hemminger
2006-09-25 14:54         ` Joerg Roedel
2006-09-23 12:20 ` Joerg Roedel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060923122036.GD32284@zlug.org \
    --to=joro-lkml@zlug.org \
    --cc=davem@davemloft.net \
    --cc=kaber@trash.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.