Add IPv6 over GRE (contributed by Gert Doering in PR 29150).
This commit is contained in:
parent
5d3d04b484
commit
a0c9bc9616
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_gre.c,v 1.55 2005/02/26 22:45:09 perry Exp $ */
|
||||
/* $NetBSD: if_gre.c,v 1.56 2005/03/30 16:34:54 is Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -7,6 +7,8 @@
|
|||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Heiko W.Rupp <hwr@pilhuhn.de>
|
||||
*
|
||||
* IPv6-over-GRE contributed by Gert Doering <gert@greenie.muc.de>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
|
@ -46,7 +48,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.55 2005/02/26 22:45:09 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.56 2005/03/30 16:34:54 is Exp $");
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ns.h"
|
||||
|
@ -180,6 +182,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
|
|||
struct gre_softc *sc = ifp->if_softc;
|
||||
struct greip *gh;
|
||||
struct ip *ip;
|
||||
u_int8_t ip_tos = 0;
|
||||
u_int16_t etype = 0;
|
||||
struct mobile_h mob_h;
|
||||
|
||||
|
@ -263,9 +266,14 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
|
|||
goto end;
|
||||
}
|
||||
} else if (sc->g_proto == IPPROTO_GRE) {
|
||||
#ifdef GRE_DEBUG
|
||||
printf( "start gre_output/GRE, dst->sa_family=%d\n",
|
||||
dst->sa_family );
|
||||
#endif
|
||||
switch (dst->sa_family) {
|
||||
case AF_INET:
|
||||
ip = mtod(m, struct ip *);
|
||||
ip_tos = ip->ip_tos;
|
||||
etype = ETHERTYPE_IP;
|
||||
break;
|
||||
#ifdef NETATALK
|
||||
|
@ -277,6 +285,11 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
|
|||
case AF_NS:
|
||||
etype = ETHERTYPE_NS;
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
etype = ETHERTYPE_IPV6;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
IF_DROP(&ifp->if_snd);
|
||||
|
@ -312,7 +325,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
|
|||
gh->gi_dst = sc->g_dst;
|
||||
((struct ip*)gh)->ip_hl = (sizeof(struct ip)) >> 2;
|
||||
((struct ip*)gh)->ip_ttl = ip_gre_ttl;
|
||||
((struct ip*)gh)->ip_tos = ip->ip_tos;
|
||||
((struct ip*)gh)->ip_tos = ip_tos;
|
||||
gh->gi_len = htons(m->m_pkthdr.len);
|
||||
}
|
||||
|
||||
|
@ -380,6 +393,10 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
|||
#ifdef INET
|
||||
case AF_INET:
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case AF_INET6:
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
error = EAFNOSUPPORT;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ip_gre.c,v 1.33 2005/02/26 22:45:12 perry Exp $ */
|
||||
/* $NetBSD: ip_gre.c,v 1.34 2005/03/30 16:34:54 is Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -7,6 +7,8 @@
|
|||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Heiko W.Rupp <hwr@pilhuhn.de>
|
||||
*
|
||||
* IPv6-over-GRE contributed by Gert Doering <gert@greenie.muc.de>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
|
@ -43,7 +45,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_gre.c,v 1.33 2005/02/26 22:45:12 perry Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ip_gre.c,v 1.34 2005/03/30 16:34:54 is Exp $");
|
||||
|
||||
#include "gre.h"
|
||||
#if NGRE > 0
|
||||
|
@ -145,7 +147,7 @@ int
|
|||
gre_input2(struct mbuf *m, int hlen, u_char proto)
|
||||
{
|
||||
struct greip *gip;
|
||||
int s;
|
||||
int s, isr;
|
||||
struct ifqueue *ifq;
|
||||
struct gre_softc *sc;
|
||||
u_int16_t flags;
|
||||
|
@ -186,22 +188,31 @@ gre_input2(struct mbuf *m, int hlen, u_char proto)
|
|||
switch (ntohs(gip->gi_ptype)) { /* ethertypes */
|
||||
case ETHERTYPE_IP: /* shouldn't need a schednetisr(), as */
|
||||
ifq = &ipintrq; /* we are in ip_input */
|
||||
isr = NETISR_IP;
|
||||
break;
|
||||
#ifdef NS
|
||||
case ETHERTYPE_NS:
|
||||
ifq = &nsintrq;
|
||||
schednetisr(NETISR_NS);
|
||||
isr = NETISR_NS;
|
||||
break;
|
||||
#endif
|
||||
#ifdef NETATALK
|
||||
case ETHERTYPE_ATALK:
|
||||
ifq = &atintrq1;
|
||||
schednetisr(NETISR_ATALK);
|
||||
isr = NETISR_ATALK;
|
||||
break;
|
||||
#endif
|
||||
#ifdef INET6
|
||||
case ETHERTYPE_IPV6:
|
||||
/* FALLTHROUGH */
|
||||
#ifdef GRE_DEBUG
|
||||
printf( "ip_gre.c/gre_input2: IPv6 packet\n" );
|
||||
#endif
|
||||
ifq = &ip6intrq;
|
||||
isr = NETISR_IPV6;
|
||||
break;
|
||||
#endif
|
||||
default: /* others not yet supported */
|
||||
printf( "ip_gre.c/gre_input2: unhandled ethertype 0x%04x\n", (int) ntohs(gip->gi_ptype) );
|
||||
return (0);
|
||||
}
|
||||
break;
|
||||
|
@ -239,6 +250,8 @@ gre_input2(struct mbuf *m, int hlen, u_char proto)
|
|||
} else {
|
||||
IF_ENQUEUE(ifq, m);
|
||||
}
|
||||
/* we need schednetisr since the address family may change */
|
||||
schednetisr(isr);
|
||||
splx(s);
|
||||
|
||||
return (1); /* packet is done, no further processing needed */
|
||||
|
|
Loading…
Reference in New Issue