Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Mar 2015 14:55:34 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r279920 - head/sys/net
Message-ID:  <201503121455.t2CEtYu1041322@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Thu Mar 12 14:55:33 2015
New Revision: 279920
URL: https://svnweb.freebsd.org/changeset/base/279920

Log:
  Add if_input_default() method, that will be used for if_input
  initialization, when no input method specified before if_attach().
  
  This prevents panics when if_input() method called directly e.g.
  from bpf(4) code.
  
  PR:		192426
  Reviewed by:	glebius
  MFC after:	1 week

Modified:
  head/sys/net/if.c

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c	Thu Mar 12 14:18:36 2015	(r279919)
+++ head/sys/net/if.c	Thu Mar 12 14:55:33 2015	(r279920)
@@ -160,6 +160,7 @@ static void	if_attachdomain1(struct ifne
 static int	ifconf(u_long, caddr_t);
 static void	if_freemulti(struct ifmultiaddr *);
 static void	if_grow(void);
+static void	if_input_default(struct ifnet *, struct mbuf *);
 static void	if_route(struct ifnet *, int flag, int fam);
 static int	if_setflag(struct ifnet *, int, int, int *, int);
 static int	if_transmit(struct ifnet *ifp, struct mbuf *m);
@@ -665,6 +666,8 @@ if_attach_internal(struct ifnet *ifp, in
 		ifp->if_transmit = if_transmit;
 		ifp->if_qflush = if_qflush;
 	}
+	if (ifp->if_input == NULL)
+		ifp->if_input = if_input_default;
 
 	if (!vmove) {
 #ifdef MAC
@@ -3516,6 +3519,13 @@ if_transmit(struct ifnet *ifp, struct mb
 	return (error);
 }
 
+static void
+if_input_default(struct ifnet *ifp __unused, struct mbuf *m)
+{
+
+	m_freem(m);
+}
+
 int
 if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp, int adjust)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201503121455.t2CEtYu1041322>