summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorEsben Norby <norby@cvs.openbsd.org>2008-04-23 10:55:15 +0000
committerEsben Norby <norby@cvs.openbsd.org>2008-04-23 10:55:15 +0000
commit8694db9f97b2d1604d2285ca01ea73760386f1bc (patch)
tree4fd89de9cf376a77bb5a6468574b4529a20130aa /sys
parentc9d717b5186297c9c69c69b1e39f99859000ec30 (diff)
Import MPLS (Multi Protocol Label Switching)
MPLS support partly based on the (abandoned?) AYAME project. Basic LSR (Label Switch Router) functionality is present, but not fully functional yet. It is currently possible to insert entries in the LIB (Label Information Base) with route(8), but setting the operation type is not supported yet. Imported to allow more people to work on this in the coming weeks. ok claudio@ laurent@ dlg@
Diffstat (limited to 'sys')
-rw-r--r--sys/conf/files6
-rw-r--r--sys/kern/Makefile4
-rw-r--r--sys/kern/uipc_domain.c12
-rw-r--r--sys/net/if_ethersubr.c40
-rw-r--r--sys/net/netisr.h4
-rw-r--r--sys/net/netisr_dispatch.h5
-rw-r--r--sys/net/route.h3
-rw-r--r--sys/net/rtsock.c10
-rw-r--r--sys/sys/socket.h9
9 files changed, 81 insertions, 12 deletions
diff --git a/sys/conf/files b/sys/conf/files
index 225e7fc8b25..5ceb3897e72 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -1,4 +1,4 @@
-# $OpenBSD: files,v 1.428 2008/04/16 18:32:14 damien Exp $
+# $OpenBSD: files,v 1.429 2008/04/23 10:55:13 norby Exp $
# $NetBSD: files,v 1.87 1996/05/19 17:17:50 jonathan Exp $
# @(#)files.newconf 7.5 (Berkeley) 5/10/93
@@ -867,6 +867,10 @@ file netbt/rfcomm_socket.c bluetooth
file netbt/rfcomm_upper.c bluetooth
file netbt/sco_socket.c bluetooth
file netbt/sco_upper.c bluetooth
+file netmpls/mpls_input.c mpls
+file netmpls/mpls_proto.c mpls
+file netmpls/mpls_raw.c mpls
+file netmpls/mpls_shim.c mpls
file netnatm/natm_pcb.c natm
file netnatm/natm_proto.c natm
file netnatm/natm.c natm
diff --git a/sys/kern/Makefile b/sys/kern/Makefile
index e54f67e2fec..f556d151769 100644
--- a/sys/kern/Makefile
+++ b/sys/kern/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.17 2007/06/01 05:37:14 deraadt Exp $
+# $OpenBSD: Makefile,v 1.18 2008/04/23 10:55:14 norby Exp $
# Makefile for kernel tags files, init_sysent, etc.
@@ -41,7 +41,7 @@ DGEN= compat compat/common compat/freebsd compat/hpux compat/ibcs2 \
miscfs miscfs/deadfs miscfs/fifofs \
miscfs/portal miscfs/procfs miscfs/specfs \
msdosfs \
- net netinet \
+ net netinet netmpls \
nfs \
scsi \
sys \
diff --git a/sys/kern/uipc_domain.c b/sys/kern/uipc_domain.c
index e2bcfcc5320..c991d601566 100644
--- a/sys/kern/uipc_domain.c
+++ b/sys/kern/uipc_domain.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_domain.c,v 1.26 2007/06/06 10:04:36 henning Exp $ */
+/* $OpenBSD: uipc_domain.c,v 1.27 2008/04/23 10:55:14 norby Exp $ */
/* $NetBSD: uipc_domain.c,v 1.14 1996/02/09 19:00:44 christos Exp $ */
/*
@@ -91,6 +91,9 @@ domaininit(void)
#ifdef NETATALK
ADDDOMAIN(atalk);
#endif
+#ifdef MPLS
+ ADDDOMAIN(mpls);
+#endif
#ifdef NATM
ADDDOMAIN(natm);
#endif
@@ -202,6 +205,13 @@ net_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
dp = pffinddomain(family);
if (dp == NULL)
return (ENOPROTOOPT);
+#ifdef MPLS
+ /* XXX WARNING: big fat ugly hack */
+ /* stupid net.mpls is special as it does not have a protocol */
+ if (family == PF_MPLS)
+ return (dp->dom_protosw[0].pr_sysctl(name + 1, namelen - 1,
+ oldp, oldlenp, newp, newlen));
+#endif
if (namelen < 3)
return (EISDIR); /* overloaded */
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index f84c7d65d9c..c39d5f3a5e7 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ethersubr.c,v 1.117 2008/04/18 09:16:14 djm Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.118 2008/04/23 10:55:14 norby Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
@@ -150,6 +150,10 @@ extern u_char at_org_code[ 3 ];
extern u_char aarp_org_code[ 3 ];
#endif /* NETATALK */
+#ifdef MPLS
+#include <netmpls/mpls.h>
+#endif /* MPLS */
+
u_char etherbroadcastaddr[ETHER_ADDR_LEN] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
#define senderr(e) { error = (e); goto bad;}
@@ -325,6 +329,33 @@ ether_output(ifp0, m0, dst, rt0)
}
} break;
#endif /* NETATALK */
+#ifdef MPLS
+ case AF_MPLS:
+ if (rt)
+ dst = (struct sockaddr *)rt->rt_gateway;
+ else
+ senderr(EHOSTUNREACH);
+
+ switch (dst->sa_family) {
+ case AF_LINK:
+ if (satosdl(dst)->sdl_alen < sizeof(edst))
+ senderr(EHOSTUNREACH);
+ bcopy(LLADDR(satosdl(dst)), edst, sizeof(edst));
+ break;
+ case AF_INET:
+ if (!arpresolve(ac, rt, m, dst, edst))
+ return (0); /* if not yet resolved */
+ break;
+ default:
+ senderr(EHOSTUNREACH);
+ }
+ /* XXX handling for simplex devices in case of M/BCAST ?? */
+ if (m->m_flags & (M_BCAST | M_MCAST))
+ etype = htons(ETHERTYPE_MPLS_MCAST);
+ else
+ etype = htons(ETHERTYPE_MPLS);
+ break;
+#endif /* MPLS */
case pseudo_AF_HDRCMPLT:
hdrcmplt = 1;
eh = (struct ether_header *)dst->sa_data;
@@ -681,6 +712,13 @@ decapsulate:
schednetisr(NETISR_PPPOE);
break;
#endif /* NPPPOE > 0 */
+#ifdef MPLS
+ case ETHERTYPE_MPLS:
+ case ETHERTYPE_MPLS_MCAST:
+ inq = &mplsintrq;
+ schednetisr(NETISR_MPLS);
+ break;
+#endif
default:
if (llcfound || etype > ETHERMTU)
goto dropanyway;
diff --git a/sys/net/netisr.h b/sys/net/netisr.h
index 2887556c754..1ee79a8e39b 100644
--- a/sys/net/netisr.h
+++ b/sys/net/netisr.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: netisr.h,v 1.30 2008/04/10 23:15:45 dlg Exp $ */
+/* $OpenBSD: netisr.h,v 1.31 2008/04/23 10:55:14 norby Exp $ */
/* $NetBSD: netisr.h,v 1.12 1995/08/12 23:59:24 mycroft Exp $ */
/*
@@ -64,6 +64,7 @@
#define NETISR_BRIDGE 29 /* for bridge processing */
#define NETISR_PPPOE 30 /* for pppoe processing */
#define NETISR_BT 31 /* same as AF_BLUETOOTH */
+#define NETISR_MPLS 3 /* XXX AF_MPLS would overflow */
#ifndef _LOCORE
#ifdef _KERNEL
@@ -81,6 +82,7 @@ void pppintr(void);
void bridgeintr(void);
void pppoeintr(void);
void btintr(void);
+void mplsintr(void);
#include <machine/atomic.h>
#define schednetisr(anisr) \
diff --git a/sys/net/netisr_dispatch.h b/sys/net/netisr_dispatch.h
index 2f786985dac..a56187f2d1a 100644
--- a/sys/net/netisr_dispatch.h
+++ b/sys/net/netisr_dispatch.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: netisr_dispatch.h,v 1.14 2008/04/10 23:15:45 dlg Exp $ */
+/* $OpenBSD: netisr_dispatch.h,v 1.15 2008/04/23 10:55:14 norby Exp $ */
/* $NetBSD: netisr_dispatch.h,v 1.2 2000/07/02 04:40:47 cgd Exp $ */
/*
@@ -45,6 +45,9 @@
#ifdef INET6
DONETISR(NETISR_IPV6,ip6intr);
#endif
+#ifdef MPLS
+ DONETISR(NETISR_MPLS,mplsintr);
+#endif
#ifdef NETATALK
DONETISR(NETISR_ATALK,atintr);
#endif
diff --git a/sys/net/route.h b/sys/net/route.h
index ab82113c816..83e156d09d4 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.h,v 1.47 2007/09/03 15:24:49 claudio Exp $ */
+/* $OpenBSD: route.h,v 1.48 2008/04/23 10:55:14 norby Exp $ */
/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
@@ -290,6 +290,7 @@ struct rt_addrinfo {
struct route_cb {
int ip_count;
int ip6_count;
+ int mpls_count;
int any_count;
};
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 6ff81919676..aadd17ff1f2 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.68 2007/09/15 16:43:51 henning Exp $ */
+/* $OpenBSD: rtsock.c,v 1.69 2008/04/23 10:55:14 norby Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -77,6 +77,10 @@
#include <net/route.h>
#include <net/raw_cb.h>
+#ifdef MPLS
+#include <netmpls/mpls.h>
+#endif /* MPLS */
+
#include <sys/stdarg.h>
struct sockaddr route_dst = { 2, PF_ROUTE, };
@@ -151,6 +155,10 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
route_cb.ip_count++;
else if (af == AF_INET6)
route_cb.ip6_count++;
+#ifdef MPLS
+ else if (af == AF_MPLS)
+ route_cb.mpls_count++;
+#endif /* MPLS */
rp->rcb_faddr = &route_src;
route_cb.any_count++;
soisconnected(so);
diff --git a/sys/sys/socket.h b/sys/sys/socket.h
index 7c7401ee695..b29ec70c4bd 100644
--- a/sys/sys/socket.h
+++ b/sys/sys/socket.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: socket.h,v 1.55 2007/11/27 16:22:14 martynas Exp $ */
+/* $OpenBSD: socket.h,v 1.56 2008/04/23 10:55:14 norby Exp $ */
/* $NetBSD: socket.h,v 1.14 1996/02/09 18:25:36 christos Exp $ */
/*
@@ -134,8 +134,8 @@ struct linger {
#define pseudo_AF_HDRCMPLT 31 /* Used by BPF to not rewrite headers
in interface output routine */
#define AF_BLUETOOTH 32 /* Bluetooth */
-
-#define AF_MAX 33
+#define AF_MPLS 33 /* MPLS */
+#define AF_MAX 34
/*
* Structure used by kernel to store most
@@ -214,6 +214,7 @@ struct sockproto {
#define PF_KEY AF_KEY
#define PF_BPF pseudo_AF_HDRCMPLT
#define PF_BLUETOOTH AF_BLUETOOTH
+#define PF_MPLS AF_MPLS
#define PF_MAX AF_MAX
/*
@@ -284,6 +285,8 @@ struct sockcred {
{ "sip", CTLTYPE_NODE }, \
{ "key", CTLTYPE_NODE }, \
{ "bpf", CTLTYPE_NODE }, \
+ { "bluetooth", CTLTYPE_NODE }, \
+ { "mpls", CTLTYPE_NODE }, \
}
/*