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)
Sun, Jul 13, 5:16 PM
Unknown Object (File)
Sun, Jul 13, 12:13 AM
Unknown Object (File)
Sat, Jul 12, 3:51 PM
Unknown Object (File)
Fri, Jul 11, 9:04 PM
Unknown Object (File)
Tue, Jul 8, 9:42 PM
Unknown Object (File)
Tue, Jul 8, 6:30 AM
Unknown Object (File)
Tue, Jul 8, 6:29 AM
Unknown Object (File)
Sun, Jul 6, 11:21 PM
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