From 033fded00be0049127194944432e56901e93c2a3 Mon Sep 17 00:00:00 2001 From: loos Date: Fri, 21 Jul 2017 03:28:35 +0000 Subject: [PATCH] Do not allow the use of the loopback interface in netmap. The generic support in netmap send the packets using if_transmit() and the loopback do not support packets coming from if_transmit()/if_start(). This avoids the use of the loopback interface and the subsequent crash that happens when the application send packets to the loopback interface. Details in: https://github.com/luigirizzo/netmap/issues/322 Reported by: Vincenzo Maffione Sponsored by: Rubicon Communications, LLC (Netgate) git-svn-id: svn+ssh://svn.freebsd.org/base/head@321317 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/netmap/netmap_generic.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sys/dev/netmap/netmap_generic.c b/sys/dev/netmap/netmap_generic.c index aea1b610962608..30f83a920825d6 100644 --- a/sys/dev/netmap/netmap_generic.c +++ b/sys/dev/netmap/netmap_generic.c @@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$"); #include /* sockaddrs */ #include #include +#include #include #include /* bus_dmamap_* in netmap_kern.h */ @@ -1198,6 +1199,13 @@ generic_netmap_attach(struct ifnet *ifp) int retval; u_int num_tx_desc, num_rx_desc; +#ifdef __FreeBSD__ + if (ifp->if_type == IFT_LOOP) { + D("if_loop is not supported by %s", __func__); + return EINVAL; + } +#endif + num_tx_desc = num_rx_desc = netmap_generic_ringsize; /* starting point */ nm_os_generic_find_num_desc(ifp, &num_tx_desc, &num_rx_desc); /* ignore errors */