[PATCH] Part 1 of low level 802.1p priority support

2007-02-10 Thread Bruce M Simpson

Hi,

Here is the first patch to bring in 802.1p Packet Priority to FreeBSD; 
this is to support Differentiated Services and Quality-of-Service. This 
builds on the M_VLANTAG support introduced by Andre last September.


This first stage enables FreeBSD to pass packets for 802.1q with VLAN 0 
to the main input path in the stack, which is the IEEE 
standards-compliant behaviour. With the attached patch and test packet, 
you can test this for yourself.


Currently this is limited to interfaces which support VLAN_HWTAGGING. To 
make the change universal, an architectural change is needed; some of 
the inline 802.1q processing needs to be moved from if_vlan.c to 
if_ethersubr.c.


To use this:
1. Apply attached patch on a separate machine to be used as a test peer.
2. Process attached hex dump with xxd from Vim distribution 
(editors/vim) to convert back to a binary pcap file.
3. Configure test address on test peer, preferably using a separate 
physical LAN.
4. Use ports/net-mgmt/tcpreplay to inject the traffic, with the 
appropriate IP and MAC addresses.
5. Observe that you get an ICMP echo reply back WITHOUT 802.1q 
encapsulation.


Currently, the code deals only with receiving VLAN tags at a low level 
and does nothing about sending them.
This is just the low level stuff -- QoS is not magically happening right 
now.


Comments... testing... suggestions...

Regards,
BMS

? .swp
Index: if_ethersubr.c
===
RCS file: /home/ncvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.222
diff -u -p -r1.222 if_ethersubr.c
--- if_ethersubr.c	24 Dec 2006 08:52:13 -	1.222
+++ if_ethersubr.c	10 Feb 2007 16:46:42 -
@@ -618,6 +618,7 @@ ether_demux(struct ifnet *ifp, struct mb
 	struct ether_header *eh;
 	int isr;
 	u_short ether_type;
+	uint16_t vlanid;
 #if defined(NETATALK)
 	struct llc *l;
 #endif
@@ -627,6 +628,7 @@ ether_demux(struct ifnet *ifp, struct mb
 
 	KASSERT(ifp != NULL, ("ether_demux: NULL interface pointer"));
 
+	vlanid = 0;
 	eh = mtod(m, struct ether_header *);
 	ether_type = ntohs(eh->ether_type);
 
@@ -708,36 +710,44 @@ post_stats:
 	 */
 	if (m->m_flags & M_VLANTAG) {
 		/*
-		 * If no VLANs are configured, drop.
+		 * Deal with numbered 802.1q VLANs, by passing frames for
+		 * specifically numbered VLANs to the VLAN input handler.
 		 */
-		if (ifp->if_vlantrunk == NULL) {
-			ifp->if_noproto++;
-			m_freem(m);
+		vlanid = EVL_VLANOFTAG(m->m_pkthdr.ether_vtag);
+		if (ifp->if_vlantrunk != NULL && vlanid != 0) {
+			KASSERT(vlan_input_p != NULL,
+			("ether_input: VLAN not loaded!"));
+			(*vlan_input_p)(ifp, m);
 			return;
 		}
 		/*
-		 * vlan_input() will either recursively call ether_input()
-		 * or drop the packet.
+		 * Drop frames with VLAN encapsulation if VLANs are not
+		 * configured on this interface, if and only if they did
+		 * not contain 802.1p priority information.
+		 * Such frames are preserved, because code further up the
+		 * stack may use the 802.1p information.
 		 */
-		KASSERT(vlan_input_p != NULL,("ether_input: VLAN not loaded!"));
-		(*vlan_input_p)(ifp, m);
-		return;
+		if (ifp->if_vlantrunk == NULL && vlanid != 0) {
+			ifp->if_noproto++;
+			m_freem(m);
+			return;
+		}
 	}
 
 	/*
 	 * Handle protocols that expect to have the Ethernet header
 	 * (and possibly FCS) intact.
 	 */
-	switch (ether_type) {
-	case ETHERTYPE_VLAN:
+	if (ether_type == ETHERTYPE_VLAN && vlanid != 0) {
 		if (ifp->if_vlantrunk != NULL) {
-			KASSERT(vlan_input_p,("ether_input: VLAN not loaded!"));
+			KASSERT(vlan_input_p,
+			("ether_input: VLAN not loaded!"));
 			(*vlan_input_p)(ifp, m);
 		} else {
 			ifp->if_noproto++;
 			m_freem(m);
+			return;
 		}
-		return;
 	}
 
 	/* Strip off Ethernet header. */
000: d4c3 b2a1 0200 0400      
010:   0100  51ed cd45 e444 0d00  Q..E.D..
020: 6600  6600     0010  f...f...
030: c6bb 16f4 8100  0800 4500 0054 258f  ..E..T%.
040:  4001 4110 0a00 0005 0a00 0006 0800  [EMAIL PROTECTED]
050: ca41 4154  45cd ed51 000c ce3b 0809  .AAT..E..Q...;..
060: 0a0b 0c0d 0e0f 1011 1213 1415 1617 1819  
070: 1a1b 1c1d 1e1f 2021 2223 2425 2627 2829  .. !"#$%&'()
080: 2a2b 2c2d 2e2f 3031 3233 3435 3637   *+,-./01234567
___
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

[PATCH] Part 2 of low level 802.1p priority support

2007-02-10 Thread Bruce M. Simpson
This updated patch moves VLAN tag decapsulation into if_ethersubr.c and 
always uses M_VLANTAG, which is also passed to the upper layer.


Tests with ping:
fxp (no VLAN_HWTAGGING support)  OK
msk (VLAN_HWTAGGING enabled) OK
msk (VLAN_HWTAGGING disanabled) FAIL

I am concerned that this may need review and testing to support 
situations where we do nested VLANs or with bridge(4) before it can be 
committed.


Further testing with drivers is needed (I can't be 100% sure it fails 
with msk(4) because something strange is happening when vlan tagging is 
turned off). Perhaps Pyun knows?


Regards,
BMS


Index: if_ethersubr.c
===
RCS file: /home/ncvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.222
diff -u -p -r1.222 if_ethersubr.c
--- if_ethersubr.c	24 Dec 2006 08:52:13 -	1.222
+++ if_ethersubr.c	10 Feb 2007 18:16:54 -
@@ -701,43 +701,50 @@ post_stats:
 		}
 	}
 #endif
-
 	/*
-	 * Check to see if the device performed the VLAN decapsulation and
-	 * provided us with the tag.
+	 * If the device did not perform decapsulation of the 802.1q VLAN
+	 * header itself, do this now, and tag the mbuf with M_VLANTAG.
+	 * Remove the 802.1q header by copying the Ethernet addresses over
+	 * it and adjusting the beginning of the data in the mbuf.
+	 * Re-inspect the ether_type field so we do the right thing
+	 * for VLAN 0.
 	 */
-	if (m->m_flags & M_VLANTAG) {
-		/*
-		 * If no VLANs are configured, drop.
-		 */
-		if (ifp->if_vlantrunk == NULL) {
-			ifp->if_noproto++;
-			m_freem(m);
+	if ((ether_type == ETHERTYPE_VLAN) && !(m->m_flags & M_VLANTAG)) {
+		struct ether_vlan_header *evl;
+
+		if (m->m_len < sizeof(*evl) &&
+		(m = m_pullup(m, sizeof(*evl))) == NULL) {
+			if_printf(ifp, "cannot pullup VLAN header\n");
 			return;
 		}
-		/*
-		 * vlan_input() will either recursively call ether_input()
-		 * or drop the packet.
-		 */
-		KASSERT(vlan_input_p != NULL,("ether_input: VLAN not loaded!"));
-		(*vlan_input_p)(ifp, m);
-		return;
+
+		evl = mtod(m, struct ether_vlan_header *);
+		m->m_pkthdr.ether_vtag = ntohs(evl->evl_tag);
+		m->m_flags |= M_VLANTAG;
+		bcopy((char *)evl, (char *)evl + ETHER_VLAN_ENCAP_LEN,
+		  ETHER_HDR_LEN - ETHER_TYPE_LEN);
+		m_adj(m, ETHER_VLAN_ENCAP_LEN);
+		/* We need to see the inner type field in case of reentry. */
+		eh = mtod(m, struct ether_header *);
+		ether_type = ntohs(eh->ether_type);
 	}
 
 	/*
-	 * Handle protocols that expect to have the Ethernet header
-	 * (and possibly FCS) intact.
+	 * Deal with numbered 802.1q VLANs, by passing these frames to
+	 * the VLAN input handler. Frames destined for VLAN 0 are for
+	 * the main input path. Otherwise, drop frames with VLAN tags.
 	 */
-	switch (ether_type) {
-	case ETHERTYPE_VLAN:
+	if ((m->m_flags & M_VLANTAG) &&
+	EVL_VLANOFTAG(m->m_pkthdr.ether_vtag) != EVL_VLAN_ZERO) {
 		if (ifp->if_vlantrunk != NULL) {
-			KASSERT(vlan_input_p,("ether_input: VLAN not loaded!"));
+			KASSERT(vlan_input_p,
+			("ether_input: VLAN not loaded!"));
 			(*vlan_input_p)(ifp, m);
 		} else {
 			ifp->if_noproto++;
 			m_freem(m);
+			return;
 		}
-		return;
 	}
 
 	/* Strip off Ethernet header. */
Index: if_vlan.c
===
RCS file: /home/ncvs/src/sys/net/if_vlan.c,v
retrieving revision 1.117
diff -u -p -r1.117 if_vlan.c
--- if_vlan.c	30 Dec 2006 21:10:25 -	1.117
+++ if_vlan.c	10 Feb 2007 18:16:54 -
@@ -911,51 +911,9 @@ vlan_input(struct ifnet *ifp, struct mbu
 	uint16_t tag;
 
 	KASSERT(trunk != NULL, ("%s: no trunk", __func__));
+	KASSERT((m->m_flags & M_VLANTAG),("%s: M_VLANTAG not set", __func__));
 
-	if (m->m_flags & M_VLANTAG) {
-		/*
-		 * Packet is tagged, but m contains a normal
-		 * Ethernet frame; the tag is stored out-of-band.
-		 */
-		tag = EVL_VLANOFTAG(m->m_pkthdr.ether_vtag);
-		m->m_flags &= ~M_VLANTAG;
-	} else {
-		struct ether_vlan_header *evl;
-
-		/*
-		 * Packet is tagged in-band as specified by 802.1q.
-		 */
-		switch (ifp->if_type) {
-		case IFT_ETHER:
-			if (m->m_len < sizeof(*evl) &&
-			(m = m_pullup(m, sizeof(*evl))) == NULL) {
-if_printf(ifp, "cannot pullup VLAN header\n");
-return;
-			}
-			evl = mtod(m, struct ether_vlan_header *);
-			tag = EVL_VLANOFTAG(ntohs(evl->evl_tag));
-
-			/*
-			 * Remove the 802.1q header by copying the Ethernet
-			 * addresses over it and adjusting the beginning of
-			 * the data in the mbuf.  The encapsulated Ethernet
-			 * type field is already in place.
-			 */
-			bcopy((char *)evl, (char *)evl + ETHER_VLAN_ENCAP_LEN,
-			  ETHER_HDR_LEN - ETHER_TYPE_LEN);
-			m_adj(m, ETHER_VLAN_ENCAP_LEN);
-			break;
-
-		default:
-#ifdef INVARIANTS
-			panic("%s: %s has unsupported if_type %u",
-			  __func__, ifp->if_xname, ifp->if_type);
-#endif
-			m_freem(m);
-			ifp->if_noproto++;
-			return;
-		}
-	}
+	tag = EVL_VLANOFTAG(m->m_pkthdr.ether_vtag);
 
 	TRUNK_RLOCK(trunk);
 #ifdef VLAN_ARRAY

[PATCH] Introduce M_PROMISC to lower part of Ethernet code

2007-02-10 Thread Bruce M Simpson

Hi,

Thunderbird keeps crashing whenever I draft these messages, which is 
frustrating.


Can we discuss this change? I would like to get it in as we get the 
following wins:


1. Potentially cleaner code in ether_demux()/ether_input()
2. Ways of detecting and preventing L2/L3 forwarding loops
3. Being able to do more with promiscuous mode in general e.g. using it 
to emulate broken IFF_ALLMULTI with network cards which can't support 
multicast routing properly.


Feedback eagerly looked forward to; this is not a complete change; this 
is strictly development quality at the moment.


Regards,
BMS
Index: net/if_ethersubr.c
===
RCS file: /home/ncvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.222
diff -u -p -r1.222 if_ethersubr.c
--- net/if_ethersubr.c	24 Dec 2006 08:52:13 -	1.222
+++ net/if_ethersubr.c	10 Feb 2007 20:59:39 -
@@ -582,6 +582,7 @@ ether_input(struct ifnet *ifp, struct mb
 	if (IFP2AC(ifp)->ac_netgraph != NULL) {
 		KASSERT(ng_ether_input_p != NULL,
 		("ng_ether_input_p is NULL"));
+		m->m_flags &= ~M_PROMISC;
 		(*ng_ether_input_p)(ifp, &m);
 		if (m == NULL)
 			return;
@@ -598,6 +599,7 @@ ether_input(struct ifnet *ifp, struct mb
 	 * at the src/sys/netgraph/ng_ether.c:ng_ether_rcv_upper()
 	 */
 	if (ifp->if_bridge) {
+		m->m_flags &= ~M_PROMISC;
 		BRIDGE_INPUT(ifp, m);
 		if (m == NULL)
 			return;
@@ -634,6 +636,14 @@ ether_demux(struct ifnet *ifp, struct mb
 	if (rule)	/* packet was already bridged */
 		goto post_stats;
 #endif
+	/*
+	 * If the frame was received promiscuously, mark it as such.
+	 */
+	if ((ifp->if_flags & IFF_PROMISC) &&
+	!ETHER_IS_MULTICAST(eh->ether_dhost) &&
+	bcmp(eh->ether_dhost, IF_LLADDR(ifp), ETHER_ADDR_LEN) != 0) {
+		m->m_flags |= M_PROMISC;
+	}
 
 	if (!(ifp->if_bridge) &&
 	!((ether_type == ETHERTYPE_VLAN || m->m_flags & M_VLANTAG) &&
@@ -648,8 +658,10 @@ ether_demux(struct ifnet *ifp, struct mb
 		 * evaluation, to see if the carp ether_dhost values break any
 		 * of these checks!
 		 */
-		if (ifp->if_carp && carp_forus(ifp->if_carp, eh->ether_dhost))
+		if (ifp->if_carp && carp_forus(ifp->if_carp, eh->ether_dhost)) {
+			m->m_flags &= ~M_PROMISC;
 			goto pre_stats;
+		}
 #endif
 		/*
 		 * Discard packet if upper layers shouldn't see it because it
@@ -662,14 +674,16 @@ ether_demux(struct ifnet *ifp, struct mb
 		 * give them a chance to consider it as well (e. g. in case
 		 * bridging is only active on a VLAN).  They will drop it if
 		 * it's undesired.
+		 *
+		 * XXX: There is no way this check can be invoked if
+		 * there are no VLANs attached to this parent interface,
+		 * which is likely to cause recursion if we're acting
+		 * as an IP forwarder...
 		 */
-		if ((ifp->if_flags & IFF_PROMISC) != 0
-		&& !ETHER_IS_MULTICAST(eh->ether_dhost)
-		&& bcmp(eh->ether_dhost,
-		  IF_LLADDR(ifp), ETHER_ADDR_LEN) != 0
-		&& (ifp->if_flags & IFF_PPROMISC) == 0) {
-			m_freem(m);
-			return;
+		if ((m->m_flags & M_PROMISC) &&
+		(ifp->if_flags & IFF_PPROMISC) == 0) {
+			m_freem(m);
+			return;
 		}
 	}
 
@@ -720,6 +734,7 @@ post_stats:
 		 * or drop the packet.
 		 */
 		KASSERT(vlan_input_p != NULL,("ether_input: VLAN not loaded!"));
+		m->m_flags &= ~M_PROMISC;
 		(*vlan_input_p)(ifp, m);
 		return;
 	}
@@ -732,6 +747,7 @@ post_stats:
 	case ETHERTYPE_VLAN:
 		if (ifp->if_vlantrunk != NULL) {
 			KASSERT(vlan_input_p,("ether_input: VLAN not loaded!"));
+			m->m_flags &= ~M_PROMISC;
 			(*vlan_input_p)(ifp, m);
 		} else {
 			ifp->if_noproto++;
Index: sys/mbuf.h
===
RCS file: /home/ncvs/src/sys/sys/mbuf.h,v
retrieving revision 1.202
diff -u -p -r1.202 mbuf.h
--- sys/mbuf.h	25 Jan 2007 01:05:23 -	1.202
+++ sys/mbuf.h	10 Feb 2007 20:59:40 -
@@ -182,6 +182,7 @@ struct mbuf {
 #define	M_FIRSTFRAG	0x1000	/* packet is first fragment */
 #define	M_LASTFRAG	0x2000	/* packet is last fragment */
 #define	M_VLANTAG	0x1	/* ether_vtag is valid */
+#define	M_PROMISC	0x2	/* packet was not for us */
 
 /*
  * External buffer types: identify ext_buf type.
@@ -203,7 +204,7 @@ struct mbuf {
 #define	M_COPYFLAGS	(M_PKTHDR|M_EOR|M_RDONLY|M_PROTO1|M_PROTO1|M_PROTO2|\
 			M_PROTO3|M_PROTO4|M_PROTO5|M_SKIP_FIREWALL|\
 			M_BCAST|M_MCAST|M_FRAG|M_FIRSTFRAG|M_LASTFRAG|\
-			M_VLANTAG)
+			M_VLANTAG|M_PROMISC)
 
 /*
  * Flags to purge when crossing layers.
___
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

[PATCH] Make INET6 MROUTING dynamically loadable in GENERIC

2007-02-10 Thread Bruce M Simpson

Hi,

This should do what it says on the tin...

Regards,
BMS
Make IPv6 multicast forwarding dynamically loadable into a GENERIC kernel.

Index: conf/files
===
RCS file: /home/ncvs/src/sys/conf/files,v
retrieving revision 1.1175
diff -u -p -r1.1175 files
--- conf/files	7 Feb 2007 18:55:29 -	1.1175
+++ conf/files	10 Feb 2007 22:07:19 -
@@ -1759,6 +1759,7 @@ netinet/ip_icmp.c		optional inet
 netinet/ip_input.c		optional inet
 netinet/ip_ipsec.c		optional ipsec
 netinet/ip_ipsec.c		optional fast_ipsec
+netinet/ip_mroute.c		optional inet | inet6
 netinet/ip_mroute.c		optional mrouting
 netinet/ip_options.c		optional inet
 netinet/ip_output.c		optional inet
@@ -1814,7 +1815,7 @@ netinet6/in6_src.c		optional inet6
 netinet6/ip6_forward.c		optional inet6
 netinet6/ip6_id.c		optional inet6
 netinet6/ip6_input.c		optional inet6
-netinet6/ip6_mroute.c		optional inet6
+netinet6/ip6_mroute.c		optional mrouting inet6
 netinet6/ip6_output.c		optional inet6
 netinet6/ipcomp_core.c		optional ipsec
 netinet6/ipcomp_input.c		optional ipsec
Index: modules/ip_mroute_mod/Makefile
===
RCS file: /home/ncvs/src/sys/modules/ip_mroute_mod/Makefile,v
retrieving revision 1.14
diff -u -p -r1.14 Makefile
--- modules/ip_mroute_mod/Makefile	9 Feb 2007 01:42:43 -	1.14
+++ modules/ip_mroute_mod/Makefile	10 Feb 2007 22:07:19 -
@@ -1,13 +1,21 @@
 # $FreeBSD: src/sys/modules/ip_mroute_mod/Makefile,v 1.14 2007/02/09 01:42:43 bms Exp $
 
-.PATH: ${.CURDIR}/../../netinet
+.PATH: ${.CURDIR}/../../netinet ${.CURDIR}/../../netinet6
 
 KMOD=	ip_mroute
-SRCS=	ip_mroute.c opt_mac.h opt_mrouting.h
+SRCS=	ip_mroute.c
+SRCS+=	ip6_mroute.c
+SRCS+=	opt_inet.h opt_inet6.h opt_mac.h opt_mrouting.h
 
 .if !defined(KERNBUILDDIR)
+opt_inet.h:
+	echo "#define INET 1" > ${.TARGET}
+
+opt_inet6.h:
+	echo "#define INET6 1" > ${.TARGET}
+
 opt_mrouting.h:
-	echo "#define	MROUTING 1" > ${.TARGET}
+	echo "#define MROUTING 1" > ${.TARGET}
 .endif
 
 .include 
Index: netinet/ip_mroute.c
===
RCS file: /home/ncvs/src/sys/netinet/ip_mroute.c,v
retrieving revision 1.128
diff -u -p -r1.128 ip_mroute.c
--- netinet/ip_mroute.c	10 Feb 2007 14:48:42 -	1.128
+++ netinet/ip_mroute.c	10 Feb 2007 22:07:20 -
@@ -55,6 +55,8 @@
  * $FreeBSD: src/sys/netinet/ip_mroute.c,v 1.128 2007/02/10 14:48:42 bms Exp $
  */
 
+#include "opt_inet.h"
+#include "opt_inet6.h"
 #include "opt_mac.h"
 #include "opt_mrouting.h"
 
@@ -217,6 +219,12 @@ struct protosw in_pim_protosw = {
 	.pr_usrreqs =		&rip_usrreqs
 };
 static const struct encaptab *pim_encap_cookie;
+
+#ifdef INET6
+extern struct protosw in6_pim_protosw;	/* ip6_mroute.c: struct in6_protosw */
+static const struct encaptab *pim6_encap_cookie;
+#endif
+
 static int pim_encapcheck(const struct mbuf *, int, int, void *);
 
 /*
@@ -2737,7 +2745,7 @@ pim_register_send_rp(struct ip *ip, stru
 }
 
 /*
- * pim_encapcheck() is called by the encap4_input() path at runtime to
+ * pim_encapcheck() is called by the encap[46]_input() path at runtime to
  * determine if a packet is for PIM; allowing PIM to be dynamically loaded
  * into the kernel.
  */
@@ -2995,6 +3003,10 @@ pim_input_to_daemon:
 return;
 }
 
+/*
+ * XXX: This is common code for dealing with initialization for both
+ * the IPv4 and IPv6 multicast forwarding paths. It could do with cleanup.
+ */
 static int
 ip_mroute_modevent(module_t mod, int type, void *unused)
 {
@@ -3006,6 +3018,7 @@ ip_mroute_modevent(module_t mod, int typ
 	ip_mrouter_reset();
 	TUNABLE_ULONG_FETCH("net.inet.pim.squelch_wholepkt",
 	&pim_squelch_wholepkt);
+
 	pim_encap_cookie = encap_attach_func(AF_INET, IPPROTO_PIM,
 	pim_encapcheck, &in_pim_protosw, NULL);
 	if (pim_encap_cookie == NULL) {
@@ -3015,6 +3028,23 @@ ip_mroute_modevent(module_t mod, int typ
 		mtx_destroy(&mrouter_mtx);
 		return (EINVAL);
 	}
+
+#ifdef INET6
+	pim6_encap_cookie = encap_attach_func(AF_INET6, IPPROTO_PIM,
+	pim_encapcheck, &in6_pim_protosw, NULL);
+	if (pim6_encap_cookie == NULL) {
+		printf("ip_mroute: unable to attach pim6 encap\n");
+		if (pim_encap_cookie) {
+		encap_detach(pim_encap_cookie);
+		pim_encap_cookie = NULL;
+		}
+		VIF_LOCK_DESTROY();
+		MFC_LOCK_DESTROY();
+		mtx_destroy(&mrouter_mtx);
+		return (EINVAL);
+	}
+#endif
+
 	ip_mcast_src = X_ip_mcast_src;
 	ip_mforward = X_ip_mforward;
 	ip_mrouter_done = X_ip_mrouter_done;
@@ -3039,6 +3069,12 @@ ip_mroute_modevent(module_t mod, int typ
 	if (ip_mrouter)
 	return EINVAL;
 
+#ifdef INET6
+	if (pim6_encap_cookie) {
+	encap_detach(pim6_encap_cookie);
+	pim6_encap_cookie = NULL;
+	}
+#endif
 	if (pim_encap_cookie) {
 	encap_detach(pim_encap_cookie);
 	pim_encap_cookie = NULL;
Index: netinet6/in6_proto.c
===
RCS file: /home/ncvs/src/sys/netinet6/in6_proto.c,v

[PATCH] netstat(1) should print CIDR prefixes

2007-02-10 Thread Bruce M Simpson

Hi,

This is a POLA violating 'let's move with the times' patch that gets rid 
of the special treatment of classful IPv4 network prefixes in 'netstat 
-rn' output. Comments please!


Rgards,
BMS
Index: route.c
===
RCS file: /home/ncvs/src/usr.bin/netstat/route.c,v
retrieving revision 1.76
diff -u -p -r1.76 route.c
--- route.c	13 May 2005 16:31:10 -	1.76
+++ route.c	10 Feb 2007 22:55:50 -
@@ -865,32 +865,7 @@ netname(u_long in, u_long mask)
 		strncpy(line, cp, sizeof(line) - 1);
 		line[sizeof(line) - 1] = '\0';
 	} else {
-		switch (dmask) {
-		case IN_CLASSA_NET:
-			if ((i & IN_CLASSA_HOST) == 0) {
-sprintf(line, "%lu", C(i >> 24));
-break;
-			}
-			/* FALLTHROUGH */
-		case IN_CLASSB_NET:
-			if ((i & IN_CLASSB_HOST) == 0) {
-sprintf(line, "%lu.%lu",
-	C(i >> 24), C(i >> 16));
-break;
-			}
-			/* FALLTHROUGH */
-		case IN_CLASSC_NET:
-			if ((i & IN_CLASSC_HOST) == 0) {
-sprintf(line, "%lu.%lu.%lu",
-	C(i >> 24), C(i >> 16), C(i >> 8));
-break;
-			}
-			/* FALLTHROUGH */
-		default:
-			sprintf(line, "%lu.%lu.%lu.%lu",
-C(i >> 24), C(i >> 16), C(i >> 8), C(i));
-			break;
-		}
+		inet_ntop(AF_INET, (char *)&in, line, sizeof(line) - 1);
 	}
 	domask(line + strlen(line), i, mask);
 	return (line);
___
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Re: Networking FreeBSD Wiki

2007-02-10 Thread gnn
At Fri, 09 Feb 2007 12:07:45 +0100,
Christian Brueffer wrote:
> 
> [1  ]
> On Thu, Feb 08, 2007 at 05:07:31PM -0800, [EMAIL PROTECTED] wrote:
> > Hi,
> > 
> > I've started a Wiki page in the FreeBSD Wiki in an attempt to
> > coordinate some of the clean up work and networking projects that
> > aren't already covered.  Please see:
> > 
> > http://wiki.freebsd.org/Networking
> > 
> > and update (if you're a committer) or email me corrections etc.
> > 
> 
> Some of the stuff seems to come from
> http://www.freebsd.org/projects/dingo/ .
> 
> Should we move all the entries to the wiki and simply nuke the dingo
> page?

Yes.

Later,
George
___
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: [PATCH] netstat(1) should print CIDR prefixes

2007-02-10 Thread Matthew D. Fuller
On Sat, Feb 10, 2007 at 10:57:13PM + I heard the voice of
Bruce M Simpson, and lo! it spake thus:
> 
> This is a POLA violating 'let's move with the times' patch that gets
> rid of the special treatment of classful IPv4 network prefixes in
> 'netstat -rn' output. Comments please!

Please!

1.2.3/24 is *wrong* when you're referring to 1.2.3.0/24 and not
1.2.0.3/24.  Talking netstat out of giving me that wrong information
is a Good Thing(tm).


-- 
Matthew Fuller (MF4839)   |  [EMAIL PROTECTED]
Systems/Network Administrator |  http://www.over-yonder.net/~fullermd/
   On the Internet, nobody can hear you scream.
___
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: [PATCH] netstat(1) should print CIDR prefixes

2007-02-10 Thread Gary Corcoran

Bruce M Simpson wrote:

Hi,

This is a POLA violating 'let's move with the times' patch that gets rid 
of the special treatment of classful IPv4 network prefixes in 'netstat 
-rn' output. Comments please!


Since those 'classes' haven't meant anything for many years, and interpreting
them as 'special' is just plain wrong in almost all cases these days, I think
the change is the right thing to do.

Just my $0.02 worth...

Gary
___
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: [PATCH] Part 2 of low level 802.1p priority support

2007-02-10 Thread Andrew Thompson
On Sat, Feb 10, 2007 at 06:28:41PM +, Bruce M. Simpson wrote:
> This updated patch moves VLAN tag decapsulation into if_ethersubr.c and 
> always uses M_VLANTAG, which is also passed to the upper layer.
> 
> Tests with ping:
> fxp (no VLAN_HWTAGGING support)  OK
> msk (VLAN_HWTAGGING enabled) OK
> msk (VLAN_HWTAGGING disanabled) FAIL
> 
> I am concerned that this may need review and testing to support 
> situations where we do nested VLANs or with bridge(4) before it can be 
> committed.

This is great for the bridge, it has needed to take the vlan tag into
account when deciding to forward or not. Having m_pkthdr.ether_vtag
always set makes this much easier to implement.

> Index: if_vlan.c
> ===
> RCS file: /home/ncvs/src/sys/net/if_vlan.c,v
>  
> - if (m->m_flags & M_VLANTAG) {
> - /*
> -  * Packet is tagged, but m contains a normal
> -  * Ethernet frame; the tag is stored out-of-band.
> -  */
> - tag = EVL_VLANOFTAG(m->m_pkthdr.ether_vtag);
> - m->m_flags &= ~M_VLANTAG;

> - } else {

...

> + tag = EVL_VLANOFTAG(m->m_pkthdr.ether_vtag);

In the deleted code M_VLANTAG is cleared but is not done anymore, is
this right?


Andrew
___
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: [PATCH] Part 2 of low level 802.1p priority support

2007-02-10 Thread Pyun YongHyeon
On Sat, Feb 10, 2007 at 06:28:41PM +, Bruce M. Simpson wrote:
 > This updated patch moves VLAN tag decapsulation into if_ethersubr.c and 
 > always uses M_VLANTAG, which is also passed to the upper layer.
 > 
 > Tests with ping:
 > fxp (no VLAN_HWTAGGING support)  OK
 > msk (VLAN_HWTAGGING enabled) OK
 > msk (VLAN_HWTAGGING disanabled) FAIL
 > 
 > I am concerned that this may need review and testing to support 
 > situations where we do nested VLANs or with bridge(4) before it can be 
 > committed.
 > 
 > Further testing with drivers is needed (I can't be 100% sure it fails 
 > with msk(4) because something strange is happening when vlan tagging is 
 > turned off). Perhaps Pyun knows?
 > 

I guess I've not merged local changes before committing to HEAD.
How about attached one?

 > Regards,
 > BMS
 > 
 > 

-- 
Regards,
Pyun YongHyeon
Index: if_msk.c
===
RCS file: /home/ncvs/src/sys/dev/msk/if_msk.c,v
retrieving revision 1.8
diff -u -r1.8 if_msk.c
--- if_msk.c9 Jan 2007 01:31:22 -   1.8
+++ if_msk.c11 Feb 2007 07:26:08 -
@@ -3029,7 +3029,8 @@
cons = sc_if->msk_cdata.msk_rx_cons;
do {
rxlen = status >> 16;
-   if ((status & GMR_FS_VLAN) != 0)
+   if ((status & GMR_FS_VLAN) != 0 &&
+   (ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0)
rxlen -= ETHER_VLAN_ENCAP_LEN;
if (len > sc_if->msk_framesize ||
((status & GMR_FS_ANY_ERR) != 0) ||
___
freebsd-net@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "[EMAIL PROTECTED]"