Commit Graph

4 Commits

Author SHA1 Message Date
Harald Welte 90ef31873c add module parameter "sleep_on_enobufs" to work around -ENOBUFS
AF_PACKET sockets have these incredibly useful semantics in where
for both non-blocking and blocking I/O, they will tell you the
socket is rwite-able, but then still return -1 and sett errno=ENOBUFS
if the current socket buffer / transmit queue is full.

All we can do is usleep and retry.  The new module parameter, if set
to non-zero, determines the number of microseconds we shall sleep before
any retry.  If set to zero, the existing behavior is preserved:
TTCN_error().

Related: SYS#5343
Change-Id: I1608403d94a10ae52c7e1de0f1b02687b048c01e
2021-01-29 20:30:55 +01:00
Harald Welte cd698095c7 guard against race between socket(AF_PACKET) and bind()
An AF_PACKET socket will immediately receive packets of _all_ interfaces
until it is bound to one specific interface.  This introduces a race
condition between the socket() and the bind() syscall.

Let's use the ifindex passed for each packet in recvmsg() to drop
any packets received for other interfaces.

Change-Id: Icd0b23eb1d6f75ca3a05e5dd1a569fa389903fdf
2020-12-10 21:55:10 +01:00
Harald Welte f42a8ae5c4 AF_PACKET_PT.cc: Remove superfluous #include to osmocom/core/utils.h
Change-Id: I2586ee726aea8f5d3edf397b2db2156bfafd7d8a
2020-11-18 13:03:55 +01:00
Harald Welte 7f7437b0d7 initial check-in of new Linux AF_PACKET test port 2020-09-09 11:59:10 +02:00