--- src/sys/net/if_ethersubr.c 2008/06/25 11:45:07 1.74 +++ src/sys/net/if_ethersubr.c 2008/07/07 22:02:10 1.75 @@ -39,6 +39,7 @@ #include "opt_inet.h" #include "opt_inet6.h" #include "opt_ipx.h" +#include "opt_mpls.h" #include "opt_netgraph.h" #include "opt_carp.h" #include "opt_ethernet.h" @@ -111,6 +112,10 @@ extern u_char at_org_code[3]; extern u_char aarp_org_code[3]; #endif /* NETATALK */ +#ifdef MPLS +#include +#endif + /* netgraph node hooks for ng_ether(4) */ void (*ng_ether_input_p)(struct ifnet *ifp, struct mbuf **mp); void (*ng_ether_input_orphan_p)(struct ifnet *ifp, @@ -303,6 +308,33 @@ ether_output(struct ifnet *ifp, struct m m->m_flags |= M_BCAST; break; #endif +#ifdef MPLS + case AF_MPLS: + { + struct sockaddr *sa_gw; + + if (rt) + sa_gw = (struct sockaddr *)rt->rt_gateway; + else { + /* We realy need a gateway. */ + m_freem(m); + return (0); + } + + switch (sa_gw->sa_family) { + case AF_INET: + if (!arpresolve(ifp, rt, m, sa_gw, edst)) + return (0); + break; + default: + kprintf("ether_output: address family not supported to forward mpls packets: %d.\n", sa_gw->sa_family); + m_freem(m); + return (0); + } + eh->ether_type = htons(ETHERTYPE_MPLS); /* XXX how about multicast? */ + break; + } +#endif case pseudo_AF_HDRCMPLT: case AF_UNSPEC: loop_copy = -1; /* if this is for us, don't do it */ @@ -788,6 +820,13 @@ post_stats: break; #endif +#ifdef MPLS + case ETHERTYPE_MPLS: + case ETHERTYPE_MPLS_MCAST: + isr = NETISR_MPLS; + break; +#endif + default: #ifdef IPX if (ef_inputp && ef_inputp(ifp, &save_eh, m) == 0)