Skip to content

Commit

Permalink
Do not allow the use of the loopback interface in netmap.
Browse files Browse the repository at this point in the history
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:	luigirizzo/netmap#322
Reported by:	Vincenzo Maffione <v.maffione@gmail.com>
Sponsored by:	Rubicon Communications, LLC (Netgate)
  • Loading branch information
loos-br authored and brooksdavis committed May 31, 2018
2 parents 79a2484 + 8080cd3 commit a9d94e2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sys/dev/netmap/netmap_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h> /* sockaddrs */
#include <sys/selinfo.h>
#include <net/if.h>
#include <net/if_types.h>
#include <net/if_var.h>
#include <machine/bus.h> /* bus_dmamap_* in netmap_kern.h */

Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit a9d94e2

Please sign in to comment.