kern/80340: [patch] [if_gre] V6 support through GRE tunnels
Andrew Alston
aalston at its.uct.ac.za
Mon Apr 25 22:10:19 PDT 2005
The following reply was made to PR kern/80340; it has been noted by GNATS.
From: Andrew Alston <aalston at its.uct.ac.za>
To: bug-followup at FreeBSD.org, aalston at its.uct.ac.za
Cc:
Subject: Re: kern/80340: [patch] [if_gre] V6 support through GRE tunnels
Date: Tue, 26 Apr 2005 07:05:08 +0200
Hey, sorry about this! Dunno what happened there, I've incldued the
patch inline below:
--- Patch follows ---
diff -ruN sys/net.bak/if_gre.c sys/net/if_gre.c
--- sys/net.bak/if_gre.c Mon Apr 25 21:29:50 2005
+++ sys/net/if_gre.c Mon Apr 25 21:30:24 2005
@@ -39,7 +39,6 @@
/*
* Encapsulate L3 protocols into IP
- * See RFC 1701 and 1702 for more details.
* If_gre is compatible with Cisco GRE tunnels, so you can
* have a NetBSD box as the other end of a tunnel interface of a Cisco
* router. See gre(4) for more details.
@@ -230,6 +229,8 @@
struct gre_softc *sc = ifp->if_softc;
struct greip *gh;
struct ip *ip;
+ u_short ip_id = 0;
+ u_int8_t ip_tos = 0;
u_int16_t etype = 0;
struct mobile_h mob_h;
@@ -338,6 +339,8 @@
switch (dst->sa_family) {
case AF_INET:
ip = mtod(m, struct ip *);
+ ip_tos = ip->ip_tos;
+ ip_id = ip->ip_id;
etype = ETHERTYPE_IP;
break;
#ifdef NETATALK
@@ -345,6 +348,12 @@
etype = ETHERTYPE_ATALK;
break;
#endif
+#ifdef INET6
+ case AF_INET6:
+ ip_id = ip_newid();
+ etype = ETHERTYPE_IPV6;
+ break;
+#endif
default:
_IF_DROP(&ifp->if_snd);
m_freem(m);
@@ -379,8 +388,8 @@
((struct ip*)gh)->ip_v = IPPROTO_IPV4;
((struct ip*)gh)->ip_hl = (sizeof(struct ip)) >> 2;
((struct ip*)gh)->ip_ttl = GRE_TTL;
- ((struct ip*)gh)->ip_tos = ip->ip_tos;
- ((struct ip*)gh)->ip_id = ip->ip_id;
+ ((struct ip*)gh)->ip_tos = ip_tos;
+ ((struct ip*)gh)->ip_id = ip_id;
gh->gi_len = m->m_pkthdr.len;
}
@@ -457,6 +466,9 @@
switch (ifr->ifr_addr.sa_family) {
#ifdef INET
case AF_INET:
+ break;
+#endif
+#ifdef INET6 case AF_INET6:
break;
#endif
default:
diff -ruN sys/netinet.bak/ip_gre.c sys/netinet/ip_gre.c
--- sys/netinet.bak/ip_gre.c Mon Apr 25 21:29:54 2005
+++ sys/netinet/ip_gre.c Mon Apr 25 21:30:35 2005
@@ -45,6 +45,7 @@
#include "opt_inet.h"
#include "opt_atalk.h"
+#include "opt_inet6.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -81,6 +82,10 @@
#include <netatalk/at_extern.h>
#endif
+#ifdef INET6
+#include <netinet/ip6.h>
+#endif
+
/* Needs IP headers. */
#include <net/if_gre.h>
@@ -189,8 +194,11 @@
isr = NETISR_ATALK1;
break;
#endif
+#ifdef INET6
case ETHERTYPE_IPV6:
- /* FALLTHROUGH */
+ isr = NETISR_IPV6;
+ break;
+#endif
default: /* others not yet supported */
return (0);
}
More information about the freebsd-bugs
mailing list