Deleted Added
full compact
if_gre.c (147643) if_gre.c (148613)
1/* $NetBSD: if_gre.c,v 1.49 2003/12/11 00:22:29 itojun Exp $ */
1/* $NetBSD: if_gre.c,v 1.49 2003/12/11 00:22:29 itojun Exp $ */
2/* $FreeBSD: head/sys/net/if_gre.c 147643 2005-06-28 06:55:45Z bz $ */
2/* $FreeBSD: head/sys/net/if_gre.c 148613 2005-08-01 08:14:21Z bz $ */
3
4/*-
5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Heiko W.Rupp <hwr@pilhuhn.de>
10 *
3
4/*-
5 * Copyright (c) 1998 The NetBSD Foundation, Inc.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation
9 * by Heiko W.Rupp <hwr@pilhuhn.de>
10 *
11 * IPv6-over-GRE contributed by Gert Doering <gert@greenie.muc.de>
12 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.

--- 15 unchanged lines hidden (view full) ---

34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40/*
41 * Encapsulate L3 protocols into IP
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.

--- 15 unchanged lines hidden (view full) ---

36 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
40 */
41
42/*
43 * Encapsulate L3 protocols into IP
42 * See RFC 1701 and 1702 for more details.
44 * See RFC 2784 (successor of RFC 1701 and 1702) for more details.
43 * If_gre is compatible with Cisco GRE tunnels, so you can
44 * have a NetBSD box as the other end of a tunnel interface of a Cisco
45 * router. See gre(4) for more details.
46 * Also supported: IP in IP encaps (proto 55) as of RFC 2004
47 */
48
49#include "opt_atalk.h"
50#include "opt_inet.h"

--- 181 unchanged lines hidden (view full) ---

232static int
233gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
234 struct rtentry *rt)
235{
236 int error = 0;
237 struct gre_softc *sc = ifp->if_softc;
238 struct greip *gh;
239 struct ip *ip;
45 * If_gre is compatible with Cisco GRE tunnels, so you can
46 * have a NetBSD box as the other end of a tunnel interface of a Cisco
47 * router. See gre(4) for more details.
48 * Also supported: IP in IP encaps (proto 55) as of RFC 2004
49 */
50
51#include "opt_atalk.h"
52#include "opt_inet.h"

--- 181 unchanged lines hidden (view full) ---

234static int
235gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
236 struct rtentry *rt)
237{
238 int error = 0;
239 struct gre_softc *sc = ifp->if_softc;
240 struct greip *gh;
241 struct ip *ip;
242 u_short ip_id = 0;
243 uint8_t ip_tos = 0;
240 u_int16_t etype = 0;
241 struct mobile_h mob_h;
242 u_int32_t af;
243
244 /*
245 * gre may cause infinite recursion calls when misconfigured.
246 * We'll prevent this by introducing upper limit.
247 */

--- 99 unchanged lines hidden (view full) ---

347 m_freem(m);
348 error = EINVAL;
349 goto end;
350 }
351 } else if (sc->g_proto == IPPROTO_GRE) {
352 switch (dst->sa_family) {
353 case AF_INET:
354 ip = mtod(m, struct ip *);
244 u_int16_t etype = 0;
245 struct mobile_h mob_h;
246 u_int32_t af;
247
248 /*
249 * gre may cause infinite recursion calls when misconfigured.
250 * We'll prevent this by introducing upper limit.
251 */

--- 99 unchanged lines hidden (view full) ---

351 m_freem(m);
352 error = EINVAL;
353 goto end;
354 }
355 } else if (sc->g_proto == IPPROTO_GRE) {
356 switch (dst->sa_family) {
357 case AF_INET:
358 ip = mtod(m, struct ip *);
359 ip_tos = ip->ip_tos;
360 ip_id = ip->ip_id;
355 etype = ETHERTYPE_IP;
356 break;
361 etype = ETHERTYPE_IP;
362 break;
363#ifdef INET6
364 case AF_INET6:
365 ip_id = ip_newid();
366 etype = ETHERTYPE_IPV6;
367 break;
368#endif
357#ifdef NETATALK
358 case AF_APPLETALK:
359 etype = ETHERTYPE_ATALK;
360 break;
361#endif
362 default:
363 _IF_DROP(&ifp->if_snd);
364 m_freem(m);

--- 23 unchanged lines hidden (view full) ---

388
389 gh->gi_pr = sc->g_proto;
390 if (sc->g_proto != IPPROTO_MOBILE) {
391 gh->gi_src = sc->g_src;
392 gh->gi_dst = sc->g_dst;
393 ((struct ip*)gh)->ip_v = IPPROTO_IPV4;
394 ((struct ip*)gh)->ip_hl = (sizeof(struct ip)) >> 2;
395 ((struct ip*)gh)->ip_ttl = GRE_TTL;
369#ifdef NETATALK
370 case AF_APPLETALK:
371 etype = ETHERTYPE_ATALK;
372 break;
373#endif
374 default:
375 _IF_DROP(&ifp->if_snd);
376 m_freem(m);

--- 23 unchanged lines hidden (view full) ---

400
401 gh->gi_pr = sc->g_proto;
402 if (sc->g_proto != IPPROTO_MOBILE) {
403 gh->gi_src = sc->g_src;
404 gh->gi_dst = sc->g_dst;
405 ((struct ip*)gh)->ip_v = IPPROTO_IPV4;
406 ((struct ip*)gh)->ip_hl = (sizeof(struct ip)) >> 2;
407 ((struct ip*)gh)->ip_ttl = GRE_TTL;
396 ((struct ip*)gh)->ip_tos = ip->ip_tos;
397 ((struct ip*)gh)->ip_id = ip->ip_id;
408 ((struct ip*)gh)->ip_tos = ip_tos;
409 ((struct ip*)gh)->ip_id = ip_id;
398 gh->gi_len = m->m_pkthdr.len;
399 }
400
401 ifp->if_opackets++;
402 ifp->if_obytes += m->m_pkthdr.len;
403 /*
404 * Send it off and with IP_FORWARD flag to prevent it from
405 * overwriting the ip_id again. ip_id is already set to the

--- 62 unchanged lines hidden (view full) ---

468 error = EAFNOSUPPORT;
469 break;
470 }
471 switch (ifr->ifr_addr.sa_family) {
472#ifdef INET
473 case AF_INET:
474 break;
475#endif
410 gh->gi_len = m->m_pkthdr.len;
411 }
412
413 ifp->if_opackets++;
414 ifp->if_obytes += m->m_pkthdr.len;
415 /*
416 * Send it off and with IP_FORWARD flag to prevent it from
417 * overwriting the ip_id again. ip_id is already set to the

--- 62 unchanged lines hidden (view full) ---

480 error = EAFNOSUPPORT;
481 break;
482 }
483 switch (ifr->ifr_addr.sa_family) {
484#ifdef INET
485 case AF_INET:
486 break;
487#endif
488#ifdef INET6
489 case AF_INET6:
490 break;
491#endif
476 default:
477 error = EAFNOSUPPORT;
478 break;
479 }
480 break;
481 case GRESPROTO:
482 if ((error = suser(curthread)) != 0)
483 break;

--- 315 unchanged lines hidden ---
492 default:
493 error = EAFNOSUPPORT;
494 break;
495 }
496 break;
497 case GRESPROTO:
498 if ((error = suser(curthread)) != 0)
499 break;

--- 315 unchanged lines hidden ---