diff options
author | Esben Norby <norby@cvs.openbsd.org> | 2008-04-23 10:55:15 +0000 |
---|---|---|
committer | Esben Norby <norby@cvs.openbsd.org> | 2008-04-23 10:55:15 +0000 |
commit | 8694db9f97b2d1604d2285ca01ea73760386f1bc (patch) | |
tree | 4fd89de9cf376a77bb5a6468574b4529a20130aa /sys/net | |
parent | c9d717b5186297c9c69c69b1e39f99859000ec30 (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/net')
-rw-r--r-- | sys/net/if_ethersubr.c | 40 | ||||
-rw-r--r-- | sys/net/netisr.h | 4 | ||||
-rw-r--r-- | sys/net/netisr_dispatch.h | 5 | ||||
-rw-r--r-- | sys/net/route.h | 3 | ||||
-rw-r--r-- | sys/net/rtsock.c | 10 |
5 files changed, 57 insertions, 5 deletions
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); |