mirror of https://github.com/OISF/suricata
af-packet: fix if/down issues with tpacket-v2/autofp
The AFPSwitchState function would close the socket and free the other resources when the interface went down _and_ the ref cnt was 0. However in autofp mode it was common to get to this point while packets were still processed in the autofp worker threads, meaning the ref cnt would not be 0. On the interface coming back up the initialization code would overwrite the socket and rings, leading to resource leaks. Socket ref cnt is decremented from the v2 release callback. If the callback would get to ref cnt 0, the packet would not be released in the kernel, but it would (possibly) close the socket if the iface was down, but not free other resources. This patch changes the logic to first release the packet to the kernel and then decrement the ref cnt and it makes the main receive loop the only one responsible for opening and closing sockets. Wait with closing the socket and rings until the ref count is 0, which can happen after AFPSwitchState is called due to packets still being processed by autofp worker threads. Bug: #4803.pull/6600/head
parent
3f8e15f70c
commit
12252ba751
Loading…
Reference in New Issue