• [PATCH] net/parpd: use BIOCSDIRECTION to set inbound-only BPF capture

    From alexandr.baryshnyev@alexandr.baryshnyev@gmail.com to muc.lists.freebsd.ports on Wed Nov 11 18:23:25 2026
    From Newsgroup: muc.lists.freebsd.ports

    Hello,

    While configuring parpd 1.3 on FreeBSD, a likely typo was identified
    in bind_interface() in bpf.c.

    The function initializes direction to BPF_D_IN, but then calls
    BIOCGDIRECTION. This ioctl reads the current capture direction
    rather than setting it, overwriting the initialized value.

    Replacing BIOCGDIRECTION with BIOCSDIRECTION sets the intended
    inbound-only capture.

    This matters because handle_arp_packet() does not explicitly stop
    processing locally originated ARP requests after arp_learn().
    If outgoing broadcast ARP requests are captured, they may reach
    the proxy ARP response rules.

    Proposed fix:

    --- bpf.c.orig
    +++ bpf.c
    @@ -48 +48 @@
    - if(0 > ioctl(fd, BIOCGDIRECTION, &direction)) {
    + if(0 > ioctl(fd, BIOCSDIRECTION, &direction)) {

    Attribution: the issue was identified and the patch prepared with
    assistance from an AI assistant (Auto Router via OpenRouter).
    I applied the patch, built the program, and performed the deployment
    and connectivity tests described below. I am submitting it for human
    review, not claiming independent authorship of the analysis.

    Test environment:
    - FreeBSD 12.4-RELEASE-p9 amd64;
    - parpd 1.3, built with base clang 13;
    - 11 separate instances on VLAN interfaces;
    - static-MAC proxy ARP rules pointing clients to the central router.

    The patched program builds and starts successfully. Bidirectional
    IPv4 connectivity between two clients in different VLANs was verified.
    This is a functional test, not a complete regression test.

    I understand that FreeBSD 12.4 is EOL. This report concerns the ioctl
    usage in parpd 1.3; I have not tested newer FreeBSD releases.

    Could you please review this change for upstream and the FreeBSD port?

    Thank you,
    Oleksandr Baryshniev


    --
    Posted automagically by a mail2news gateway at muc.de e.V.
    Please direct questions, flames, donations, etc. to news-admin@muc.de
    --- Synchronet 3.22a-Linux NewsLink 1.2