Page MenuHomeFreeBSD

kern: wg: split address/mask construction out of wg_aip_add()
ClosedPublic

Authored by kevans on May 21 2025, 4:00 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 9, 11:29 PM
Unknown Object (File)
Sun, Oct 5, 12:57 PM
Unknown Object (File)
Sun, Sep 28, 9:15 PM
Unknown Object (File)
Fri, Sep 26, 4:14 PM
Unknown Object (File)
Wed, Sep 24, 1:43 AM
Unknown Object (File)
Fri, Sep 19, 9:03 AM
Unknown Object (File)
Thu, Sep 18, 8:00 PM
Unknown Object (File)
Sep 15 2025, 11:19 AM
Subscribers

Details

Summary

We'll re-use these in a future wg_aip_del() to perfectly reconstruct
what we expect to find in a_addr/a_mask.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.May 23 2025, 7:31 PM
sys/dev/wg/if_wg.c
533

This function has quite a few parameters. Why not use something like:

static int
wg_aip_addrinfo(struct wg_aip *aip, const void *addr, uint8_t cidr)
{
    switch (aip->af) {
    ...
    }
}

static int
wg_aip_add(...)
{
    ...
    ret = wg_aip_addrinfo(...);
    if (ret != 0) { ... };

    MPASS(af == AF_INET4 || af == AF_INET6);
    root = af == AF_INET ? sc->sc_aip4 : sc->sc_aip6;
    ...
}
sys/dev/wg/if_wg.c
533

Generally because of the next review, where we have to construct an addr/mask before we can find the existing entry.

sys/dev/wg/if_wg.c
533

I had a rough look at the next review as well, and I think it's okay to simplify this function by using an on-stack struct wg_aip aip instead of struct aip_addr a_addr, a_mask.

kevans marked 2 inline comments as done.

Simplify wg_aip_addrinfo() a bit more based on feedback

This revision now requires review to proceed.Jun 12 2025, 12:32 AM
This revision is now accepted and ready to land.Jun 17 2025, 5:02 PM