ifconfig: fix incorrect wg allowed-ips netmask

Currently when peer information is displayed with `ifconfig wgN peer ..`
or `ifconfig wgN peer-list`, the netmask of the first `allowed-ips` will
be used as the netmask of all CIDR in `allowed-ips`.  For example, if
the list is `192.168.1.0/24, 172.16.0.0/16`, it will display as
`192.168.1.0/24, 172.16.0.0/24`. While this does not affect the actual
functionality, it is very confusing.

Submitted by:   Michael Chiu <nyan -at- myuji.xyz>
Reviewed by:	grehan
Differential Revision: https://reviews.freebsd.org/D28655
MFC after:	1 day
This commit is contained in:
Michael Chiu 2021-02-15 00:38:26 +00:00 committed by Philip Paeps
parent a0698341cd
commit be2003ccfa

View File

@ -309,7 +309,7 @@ dump_peer(const nvlist_t *nvl_peer)
sa = __DECONST(void *, &aips[i].a_addr);
bitmask = __DECONST(void *,
((const struct sockaddr *)&aips->a_mask)->sa_data);
((const struct sockaddr *)&(&aips[i])->a_mask)->sa_data);
family = aips[i].a_addr.ss_family;
getnameinfo(sa, sa->sa_len, addr_buf, INET6_ADDRSTRLEN, NULL,
0, NI_NUMERICHOST);