PERFORCE change 144866 for review

Ryan French rfrench at FreeBSD.org
Tue Jul 8 08:52:28 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=144866

Change 144866 by rfrench at rfrench_mpls on 2008/07/08 08:52:13

	Imported the switch cases for the MPLS protocol	
	from the OpenBSD implementation.

Affected files ...

.. //depot/projects/soc2008/rfrench_mpls/net/if_ethersubr.c#2 edit

Differences ...

==== //depot/projects/soc2008/rfrench_mpls/net/if_ethersubr.c#2 (text+ko) ====

@@ -97,6 +97,10 @@
 extern u_char	aarp_org_code[3];
 #endif /* NETATALK */
 
+#ifdef MPLS
+#include <netmpls/mpls.h>
+#endif /* MPLS */
+
 #include <security/mac/mac_framework.h>
 
 /* netgraph node hooks for ng_ether(4) */
@@ -767,11 +771,6 @@
 	 */
 	switch (ether_type) {
 
-	/* MPLS switch case */
- 	case ETHERTYPE_MPLS:
-		isr = NETISR_MPLS;
-		break;
-
 #ifdef INET
 	case ETHERTYPE_IP:
 		if ((m = ip_fastforward(m)) == NULL)
@@ -808,6 +807,36 @@
 		isr = NETISR_AARP;
 		break;
 #endif /* NETATALK */
+#ifdef MPLS
+	case AF_MPLS:
+		printf("mpls packet received\n");
+		if (rt)
+			dst = rt_key(rt);
+		else
+			senderr(EHOSTUNREACH);
+			
+		switch (dst->sa_family) {
+			case AF_LINK:
+				if (((struct sockaddr_dl *) dst)->sdl_alen <
+					sizeof(edst))
+						senderr(EHOSTUNREACH);
+				bcopy(LLADDR(((struct sockaddr_dl *)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 */
 	default:
 #ifdef IPX
 		if (ef_inputp && ef_inputp(ifp, eh, m) == 0)


More information about the p4-projects mailing list