tcpdump mailing list archives

Re: What's the correct new API to request pcap_linux to not open an eventfd


From: Bill Fenner via tcpdump-workers <tcpdump-workers () lists tcpdump org>
Date: Fri, 20 May 2022 15:10:58 -0700

--- Begin Message --- From: Bill Fenner <fenner () gmail com>
Date: Fri, 20 May 2022 15:10:58 -0700
On Fri, May 20, 2022 at 12:36 PM Guy Harris <gharris () sonic net> wrote:

If it's putting them in non-blocking mode, and using some
select/poll/epoll/etc. mechanism in a single event loop, then the right
name for the API is pcap_setnonblock().  There's no need for an eventfd to
wake up the blocking poll() if there *is* no blocking poll(), so:

        if non-blocking mode is on before pcap_activate() is called, no
eventfd should be opened, and poll_breakloop_fd should be set to -1;

        if non-blocking mode is turned on after pcap_activate() is called,
the eventfd should be closed, and poll_breakloop_fd should be set to -1;

        if non-blocking mode is turned *off* afterwards, an eventfd should
be opened, and poll_breakloop_fd should be set to it;

        if poll_breakloop_fd is -1, the poll() should only wait on the
socket FD;

so this can be handled without API changes.


Thank you for the excellent observation, Guy.  It is indeed setting
non-block before pcap_activate().  I'll work on this plan.

  Bill

--- End Message ---
_______________________________________________
tcpdump-workers mailing list
tcpdump-workers () lists tcpdump org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers

Current thread: