git: 77ba029133bd - stable/13 - netlink: make it working without INET6
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 23 Jan 2023 22:11:50 UTC
The branch stable/13 has been updated by melifaro: URL: https://cgit.FreeBSD.org/src/commit/?id=77ba029133bdd714239a258e1c98cf5da0f84f52 commit 77ba029133bdd714239a258e1c98cf5da0f84f52 Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2022-10-04 21:39:49 +0000 Commit: Alexander V. Chernikov <melifaro@FreeBSD.org> CommitDate: 2023-01-23 22:04:02 +0000 netlink: make it working without INET6 (cherry picked from commit b958b862b1f43f5fef881c1f9aee6618d7d24197) --- sys/netlink/route/iface.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/sys/netlink/route/iface.c b/sys/netlink/route/iface.c index 8bb4406ad8be..5ffe11cc7e80 100644 --- a/sys/netlink/route/iface.c +++ b/sys/netlink/route/iface.c @@ -196,21 +196,27 @@ dump_sa(struct nl_writer *nw, int attr, const struct sockaddr *sa) { uint32_t addr_len = 0; const void *addr_data = NULL; +#ifdef INET6 struct in6_addr addr6; +#endif if (sa == NULL) return (true); switch (sa->sa_family) { +#ifdef INET case AF_INET: addr_len = sizeof(struct in_addr); addr_data = &((const struct sockaddr_in *)sa)->sin_addr; break; +#endif +#ifdef INET6 case AF_INET6: in6_splitscope(&((const struct sockaddr_in6 *)sa)->sin6_addr, &addr6, &addr_len); addr_len = sizeof(struct in6_addr); addr_data = &addr6; break; +#endif case AF_LINK: addr_len = ((const struct sockaddr_dl *)sa)->sdl_alen; addr_data = LLADDR_CONST((const struct sockaddr_dl *)sa); @@ -563,6 +569,7 @@ ifa_get_scope(const struct ifaddr *ifa) sa = ifa->ifa_addr; switch (sa->sa_family) { +#ifdef INET case AF_INET: { struct in_addr addr; @@ -573,6 +580,8 @@ ifa_get_scope(const struct ifaddr *ifa) addr_scope = RT_SCOPE_LINK; break; } +#endif +#ifdef INET6 case AF_INET6: { const struct in6_addr *addr; @@ -583,6 +592,7 @@ ifa_get_scope(const struct ifaddr *ifa) addr_scope = RT_SCOPE_LINK; break; } +#endif } return (addr_scope); @@ -599,20 +609,28 @@ inet6_get_plen(const struct in6_addr *addr) static uint8_t get_sa_plen(const struct sockaddr *sa) { - const struct in6_addr *paddr6; +#ifdef INET const struct in_addr *paddr; +#endif +#ifdef INET6 + const struct in6_addr *paddr6; +#endif switch (sa->sa_family) { +#ifdef INET case AF_INET: if (sa == NULL) return (32); paddr = &(((const struct sockaddr_in *)sa)->sin_addr); return bitcount32(paddr->s_addr);; +#endif +#ifdef INET6 case AF_INET6: if (sa == NULL) return (128); paddr6 = &(((const struct sockaddr_in6 *)sa)->sin6_addr); return inet6_get_plen(paddr6); +#endif } return (0); @@ -718,12 +736,16 @@ rtnl_handle_ifaddr(void *arg __unused, struct ifaddr *ifa, int cmd) uint32_t group = 0; switch (ifa->ifa_addr->sa_family) { +#ifdef INET case AF_INET: group = RTNLGRP_IPV4_IFADDR; break; +#endif +#ifdef INET6 case AF_INET6: group = RTNLGRP_IPV6_IFADDR; break; +#endif default: NL_LOG(LOG_DEBUG2, "ifa notification for unknown AF: %d", ifa->ifa_addr->sa_family);