Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Add MPLS support, proposed on tech-net@ a couple of days...



details:   https://anonhg.NetBSD.org/src/rev/1f1d6435978b
branches:  trunk
changeset: 755882:1f1d6435978b
user:      kefren <kefren%NetBSD.org@localhost>
date:      Sat Jun 26 14:24:27 2010 +0000

description:
Add MPLS support, proposed on tech-net@ a couple of days ago

Welcome to 5.99.33

diffstat:

 sys/Makefile                           |    4 +-
 sys/conf/files                         |    6 +-
 sys/net/Makefile                       |    4 +-
 sys/net/if_ethersubr.c                 |   28 +-
 sys/net/if_gre.c                       |   26 +-
 sys/net/if_mpls.c                      |  599 +++++++++++++++++++++++++++++++++
 sys/net/if_mpls.h                      |   41 ++
 sys/net/netisr.h                       |    7 +-
 sys/net/netisr_dispatch.h              |    5 +-
 sys/net/route.c                        |   23 +-
 sys/net/route.h                        |   17 +-
 sys/net/rtsock.c                       |   19 +-
 sys/netinet/ip_icmp.c                  |    8 +-
 sys/netinet/ip_icmp.h                  |    3 +-
 sys/netmpls/Makefile                   |    7 +
 sys/netmpls/mpls.h                     |   74 ++++
 sys/netmpls/mpls_proto.c               |  209 +++++++++++
 sys/netmpls/mpls_ttl.c                 |  381 ++++++++++++++++++++
 sys/netmpls/mpls_var.h                 |   63 +++
 sys/rump/net/lib/libnet/opt/opt_mpls.h |    3 +
 sys/sys/param.h                        |    4 +-
 sys/sys/socket.h                       |    7 +-
 22 files changed, 1503 insertions(+), 35 deletions(-)

diffs (truncated from 1947 to 300 lines):

diff -r 48f6ac0361e0 -r 1f1d6435978b sys/Makefile
--- a/sys/Makefile      Sat Jun 26 13:08:37 2010 +0000
+++ b/sys/Makefile      Sat Jun 26 14:24:27 2010 +0000
@@ -1,8 +1,8 @@
-#      $NetBSD: Makefile,v 1.75 2008/12/30 22:18:11 pooka Exp $
+#      $NetBSD: Makefile,v 1.76 2010/06/26 14:24:27 kefren Exp $
 
 SUBDIR=        altq arch compat dev fs miscfs \
        net net80211 netatalk netbt netipsec netinet netinet6 \
-        netisdn netiso netkey netnatm netsmb \
+        netisdn netiso netkey netmpls netnatm netsmb \
        nfs opencrypto sys ufs uvm
 
 # interrupt implementation depends on the kernel within the port
diff -r 48f6ac0361e0 -r 1f1d6435978b sys/conf/files
--- a/sys/conf/files    Sat Jun 26 13:08:37 2010 +0000
+++ b/sys/conf/files    Sat Jun 26 14:24:27 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.989 2010/04/30 20:47:17 pooka Exp $
+#      $NetBSD: files,v 1.990 2010/06/26 14:24:27 kefren Exp $
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
 version        20100430
@@ -1273,6 +1273,7 @@
 defpseudo gre:         ifnet
 defpseudo gif:         ifnet
 defpseudo faith:       ifnet
+defpseudo mpls:                ifnet
 defpseudo srt:         ifnet
 defpseudo stf:         ifnet
 defpseudodev tap:      ifnet, ether, arp
@@ -1611,6 +1612,9 @@
 file   net/if_ieee1394subr.c           ieee1394
 file   net/if_loop.c                   loop                    needs-flag
 file   net/if_media.c
+file   net/if_mpls.c                   mpls                    needs-flag
+file   netmpls/mpls_proto.c            mpls
+file   netmpls/mpls_ttl.c              mpls
 file   net/if_ppp.c                    ppp                     needs-flag
 file   net/if_srt.c                    srt
 file   net/if_stf.c                    stf & inet & inet6      needs-flag
diff -r 48f6ac0361e0 -r 1f1d6435978b sys/net/Makefile
--- a/sys/net/Makefile  Sat Jun 26 13:08:37 2010 +0000
+++ b/sys/net/Makefile  Sat Jun 26 14:24:27 2010 +0000
@@ -1,10 +1,10 @@
-#      $NetBSD: Makefile,v 1.27 2009/05/30 09:04:35 hannken Exp $
+#      $NetBSD: Makefile,v 1.28 2010/06/26 14:24:28 kefren Exp $
 
 INCSDIR= /usr/include/net
 
 INCS=  bpf.h bpfdesc.h dlt.h ethertypes.h if.h if_arc.h if_arp.h \
        if_atm.h if_bridgevar.h if_dl.h if_ether.h if_etherip.h if_fddi.h if_gif.h \
-       if_gre.h if_hippi.h if_ieee1394.h if_llc.h if_media.h \
+       if_gre.h if_hippi.h if_ieee1394.h if_llc.h if_media.h if_mpls.h \
        if_pflog.h if_ppp.h if_pppoe.h if_sppp.h if_srt.h if_stf.h \
        if_tap.h if_token.h if_tun.h if_types.h if_vlanvar.h net_stats.h \
        netisr.h pfil.h pfkeyv2.h pfvar.h ppp-comp.h ppp_defs.h radix.h \
diff -r 48f6ac0361e0 -r 1f1d6435978b sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Sat Jun 26 13:08:37 2010 +0000
+++ b/sys/net/if_ethersubr.c    Sat Jun 26 14:24:27 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ethersubr.c,v 1.181 2010/05/19 20:43:51 christos Exp $      */
+/*     $NetBSD: if_ethersubr.c,v 1.182 2010/06/26 14:24:28 kefren Exp $        */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,13 +61,14 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.181 2010/05/19 20:43:51 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.182 2010/06/26 14:24:28 kefren Exp $");
 
 #include "opt_inet.h"
 #include "opt_atalk.h"
 #include "opt_iso.h"
 #include "opt_ipx.h"
 #include "opt_mbuftrace.h"
+#include "opt_mpls.h"
 #include "opt_gateway.h"
 #include "opt_pfil_hooks.h"
 #include "opt_pppoe.h"
@@ -178,6 +179,11 @@
 extern u_char  aarp_org_code[3];
 #endif /* NETATALK */
 
+#ifdef MPLS
+#include <netmpls/mpls.h>
+#include <netmpls/mpls_var.h>
+#endif
+
 static struct timeval bigpktppslim_last;
 static int bigpktppslim = 2;   /* XXX */
 static int bigpktpps_count;
@@ -447,6 +453,15 @@
                senderr(EAFNOSUPPORT);
        }
 
+#ifdef MPLS
+               if (rt0 != NULL && rt_gettag(rt0) != NULL) {
+                       union mpls_shim msh;
+                       msh.s_addr = MPLS_GETSADDR(rt0);
+                       if (msh.shim.label != MPLS_LABEL_IMPLNULL)
+                               etype = htons(ETHERTYPE_MPLS);
+               }
+#endif
+
        if (mcopy)
                (void)looutput(ifp, mcopy, dst, rt);
 
@@ -508,7 +523,6 @@
        if (ALTQ_IS_ENABLED(&ifp->if_snd))
                altq_etherclassify(&ifp->if_snd, m, &pktattr);
 #endif
-
        return ifq_enqueue(ifp, m ALTQ_COMMA ALTQ_DECL(&pktattr));
 
 bad:
@@ -640,7 +654,7 @@
        /*
         * Determine if the packet is within its size limits.
         */
-       if (m->m_pkthdr.len >
+       if (etype != ETHERTYPE_MPLS && m->m_pkthdr.len >
            ETHER_MAX_FRAME(ifp, etype, m->m_flags & M_HASFCS)) {
                if (ppsratecheck(&bigpktppslim_last, &bigpktpps_count,
                            bigpktppslim)) {
@@ -905,6 +919,12 @@
                        aarpinput(ifp, m); /* XXX */
                        return;
 #endif /* NETATALK */
+#ifdef MPLS
+               case ETHERTYPE_MPLS:
+                       schednetisr(NETISR_MPLS);
+                       inq = &mplsintrq;
+                       break;
+#endif
                default:
                        m_freem(m);
                        return;
diff -r 48f6ac0361e0 -r 1f1d6435978b sys/net/if_gre.c
--- a/sys/net/if_gre.c  Sat Jun 26 13:08:37 2010 +0000
+++ b/sys/net/if_gre.c  Sat Jun 26 14:24:27 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_gre.c,v 1.143 2010/04/05 07:22:23 joerg Exp $ */
+/*     $NetBSD: if_gre.c,v 1.144 2010/06/26 14:24:28 kefren Exp $ */
 
 /*
  * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -45,11 +45,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.143 2010/04/05 07:22:23 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gre.c,v 1.144 2010/06/26 14:24:28 kefren Exp $");
 
 #include "opt_atalk.h"
 #include "opt_gre.h"
 #include "opt_inet.h"
+#include "opt_mpls.h"
 
 #include <sys/param.h>
 #include <sys/file.h>
@@ -95,6 +96,11 @@
 #include <netinet6/in6_var.h>
 #endif
 
+#ifdef MPLS
+#include <netmpls/mpls.h>
+#include <netmpls/mpls_var.h>
+#endif
+
 #ifdef NETATALK
 #include <netatalk/at.h>
 #include <netatalk/at_var.h>
@@ -899,6 +905,13 @@
                af = AF_INET6;
                break;
 #endif
+#ifdef MPLS
+       case ETHERTYPE_MPLS:
+               ifq = &mplsintrq;
+               isr = NETISR_MPLS;
+               af = AF_MPLS;
+               break;
+#endif
        default:           /* others not yet supported */
                GRE_DPRINTF(sc, "unhandled ethertype 0x%04x\n",
                    ntohs(gh->ptype));
@@ -981,6 +994,15 @@
                goto end;
        }
 
+#ifdef MPLS
+               if (rt != NULL && rt_gettag(rt) != NULL) {
+                       union mpls_shim msh;
+                       msh.s_addr = MPLS_GETSADDR(rt);
+                       if (msh.shim.label != MPLS_LABEL_IMPLNULL)
+                               etype = htons(ETHERTYPE_MPLS);
+               }
+#endif
+
        M_PREPEND(m, sizeof(*gh), M_DONTWAIT);
 
        if (m == NULL) {
diff -r 48f6ac0361e0 -r 1f1d6435978b sys/net/if_mpls.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/net/if_mpls.c Sat Jun 26 14:24:27 2010 +0000
@@ -0,0 +1,599 @@
+/*     $NetBSD: if_mpls.c,v 1.1 2010/06/26 14:24:28 kefren Exp $ */
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Mihai Chelaru <kefren%NetBSD.org@localhost>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: if_mpls.c,v 1.1 2010/06/26 14:24:28 kefren Exp $");
+
+#include "opt_inet.h"
+#include "opt_mpls.h"
+
+#include <sys/param.h>
+
+#include <sys/errno.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/sysctl.h>
+
+#include <net/bpf.h>
+#include <net/if.h>
+#include <net/if_types.h>
+#include <net/netisr.h>
+#include <net/route.h>
+
+#ifdef INET
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#endif
+
+#ifdef INET6
+#include <netinet/ip6.h>
+#include <netinet6/in6_var.h>
+#include <netinet6/ip6_var.h>
+#endif
+
+#include <netmpls/mpls.h>
+#include <netmpls/mpls_var.h>
+
+#include "if_mpls.h"
+
+void mplsattach(int);
+
+static int mpls_clone_create(struct if_clone *, int);
+static int mpls_clone_destroy(struct ifnet *);
+
+static struct if_clone mpls_if_cloner =
+       IF_CLONE_INITIALIZER("mpls", mpls_clone_create, mpls_clone_destroy);
+
+
+static void mpls_input(struct ifnet *, struct mbuf *);
+static int mpls_output(struct ifnet *, struct mbuf *, const struct sockaddr *,
+       struct rtentry *);
+static int mpls_ioctl(struct ifnet *, u_long, void *);
+static int mpls_send_frame(struct mbuf *, struct ifnet *, struct rtentry *);
+static int mpls_lse(struct mbuf *);
+
+#ifdef INET
+static int mpls_unlabel_inet(struct mbuf *);
+static struct mbuf *mpls_label_inet(struct mbuf *, union mpls_shim *);
+#endif
+
+#ifdef INET6
+static int mpls_unlabel_inet6(struct mbuf *);



Home | Main Index | Thread Index | Old Index