Date: Mon, 05 Jun 2006 22:36:31 +0200 From: Gregory Nou <gregorynou@altern.org> To: freebsd-net@freebsd.org Subject: [patch] taking M_PROMISC from netbsd Message-ID: <448495CF.4080303@altern.org>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------010403050609030009070703 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hi, I've (tried) to import M_PROMISC from netbsd, as suggested in project Dingo. There is not much difference from manuel bouyer's patch (see http://mail-index.netbsd.org/tech-net/2003/03/19/0001.html and http://mail-index.netbsd.org/source-changes/2003/03/25/0020.html) I've made the patch against -CURRENT from today, and compiled it. I ran it for 1 month without problems, but I would appreciate if somebody could review it, and test it, as it is my first patch for freebsd. Thanks -- Gregory --------------010403050609030009070703 Content-Type: text/x-patch; name="M_PROMISC-3.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="M_PROMISC-3.diff" diff -rcu sys.orig/net/if_bridgevar.h sys/net/if_bridgevar.h --- sys.orig/net/if_bridgevar.h Mon Jun 5 21:21:53 2006 +++ sys/net/if_bridgevar.h Sun Mar 26 19:15:03 2006 @@ -345,6 +345,7 @@ #define BRIDGE_INPUT(_ifp, _m) do { \ KASSERT(bridge_input_p != NULL, \ ("%s: if_bridge not loaded!", __func__)); \ + _m->m_flags &= ~M_PROMISC; \ _m = (*bridge_input_p)(_ifp, _m); \ if (_m != NULL) \ _ifp = _m->m_pkthdr.rcvif; \ diff -rcu sys.orig/net/if_ethersubr.c sys/net/if_ethersubr.c --- sys.orig/net/if_ethersubr.c Mon Jun 5 21:21:51 2006 +++ sys/net/if_ethersubr.c Mon Jun 5 21:46:18 2006 @@ -655,8 +655,7 @@ && bcmp(eh->ether_dhost, IF_LLADDR(ifp), ETHER_ADDR_LEN) != 0 && (ifp->if_flags & IFF_PPROMISC) == 0) { - m_freem(m); - return; + m->m_flags |= M_PROMISC; } } @@ -675,8 +674,12 @@ else m->m_flags |= M_MCAST; } - if (m->m_flags & (M_BCAST|M_MCAST)) + if (m->m_flags & (M_BCAST|M_MCAST)) { ifp->if_imcasts++; + if ((ifp->if_flags & IFF_PROMISC) != 0) { + m->m_flags |= M_PROMISC; + } + } #if defined(INET) || defined(INET6) post_stats: @@ -707,7 +710,9 @@ * or drop the packet. */ KASSERT(vlan_input_p != NULL,("ether_input: VLAN not loaded!")); + m->m_flags &= ~M_PROMISC; (*vlan_input_p)(ifp, m); + m_freem(m); return; } @@ -719,6 +724,7 @@ 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++; diff -rcu sys.orig/sys/mbuf.h sys/sys/mbuf.h --- sys.orig/sys/mbuf.h Mon Jun 5 21:22:51 2006 +++ sys/sys/mbuf.h Sun Mar 26 19:28:59 2006 @@ -179,6 +179,7 @@ #define M_FIRSTFRAG 0x1000 /* packet is first fragment */ #define M_LASTFRAG 0x2000 /* packet is last fragment */ #define M_VLANTAG 0x10000 /* packet has VLAN tag attached */ +#define M_PROMISC 0x20000 /* this packet is not for us */ /* * External buffer types: identify ext_buf type. --------------010403050609030009070703--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?448495CF.4080303>