From 9015f35cec2574cf95ce962d2f2782cb2bca540d Mon Sep 17 00:00:00 2001 From: bluhm Date: Sat, 11 Nov 2023 14:24:03 +0000 Subject: [PATCH] Pass constant struct sockaddr to interface lookup functions. OK mvs@ --- sys/net/if.c | 20 ++++++++++---------- sys/net/if.h | 4 ++-- sys/net/if_var.h | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 3c2266133a9..89c164fdd3a 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.710 2023/11/10 15:51:24 bluhm Exp $ */ +/* $OpenBSD: if.c,v 1.711 2023/11/11 14:24:03 bluhm Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1522,7 +1522,7 @@ if_congested(void) * Locate an interface based on a complete address. */ struct ifaddr * -ifa_ifwithaddr(struct sockaddr *addr, u_int rtableid) +ifa_ifwithaddr(const struct sockaddr *addr, u_int rtableid) { struct ifnet *ifp; struct ifaddr *ifa; @@ -1551,7 +1551,7 @@ ifa_ifwithaddr(struct sockaddr *addr, u_int rtableid) * Locate the point to point interface with a given destination address. */ struct ifaddr * -ifa_ifwithdstaddr(struct sockaddr *addr, u_int rdomain) +ifa_ifwithdstaddr(const struct sockaddr *addr, u_int rdomain) { struct ifnet *ifp; struct ifaddr *ifa; @@ -1581,10 +1581,10 @@ ifa_ifwithdstaddr(struct sockaddr *addr, u_int rdomain) * a given address. */ struct ifaddr * -ifaof_ifpforaddr(struct sockaddr *addr, struct ifnet *ifp) +ifaof_ifpforaddr(const struct sockaddr *addr, struct ifnet *ifp) { struct ifaddr *ifa; - char *cp, *cp2, *cp3; + const char *cp, *cp2, *cp3; char *cplim; struct ifaddr *ifa_maybe = NULL; u_int af = addr->sa_family; @@ -3124,20 +3124,20 @@ if_getgrouplist(caddr_t data) } void -if_group_routechange(struct sockaddr *dst, struct sockaddr *mask) +if_group_routechange(const struct sockaddr *dst, const struct sockaddr *mask) { switch (dst->sa_family) { case AF_INET: - if (satosin(dst)->sin_addr.s_addr == INADDR_ANY && + if (satosin_const(dst)->sin_addr.s_addr == INADDR_ANY && mask && (mask->sa_len == 0 || - satosin(mask)->sin_addr.s_addr == INADDR_ANY)) + satosin_const(mask)->sin_addr.s_addr == INADDR_ANY)) if_group_egress_build(); break; #ifdef INET6 case AF_INET6: - if (IN6_ARE_ADDR_EQUAL(&(satosin6(dst))->sin6_addr, + if (IN6_ARE_ADDR_EQUAL(&(satosin6_const(dst))->sin6_addr, &in6addr_any) && mask && (mask->sa_len == 0 || - IN6_ARE_ADDR_EQUAL(&(satosin6(mask))->sin6_addr, + IN6_ARE_ADDR_EQUAL(&(satosin6_const(mask))->sin6_addr, &in6addr_any))) if_group_egress_build(); break; diff --git a/sys/net/if.h b/sys/net/if.h index fdf04c50715..c32a15ed0e9 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.214 2023/05/30 23:55:42 dlg Exp $ */ +/* $OpenBSD: if.h,v 1.215 2023/11/11 14:24:03 bluhm Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -550,7 +550,7 @@ int ifsetlro(struct ifnet *, int); struct ifg_group *if_creategroup(const char *); int if_addgroup(struct ifnet *, const char *); int if_delgroup(struct ifnet *, const char *); -void if_group_routechange(struct sockaddr *, struct sockaddr *); +void if_group_routechange(const struct sockaddr *, const struct sockaddr *); struct ifnet *if_unit(const char *); struct ifnet *if_get(unsigned int); void if_put(struct ifnet *); diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 73d6e8ea323..7eb59a85bed 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_var.h,v 1.129 2023/07/07 08:05:02 bluhm Exp $ */ +/* $OpenBSD: if_var.h,v 1.130 2023/11/11 14:24:03 bluhm Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -337,9 +337,9 @@ void p2p_rtrequest(struct ifnet *, int, struct rtentry *); void p2p_input(struct ifnet *, struct mbuf *); int p2p_bpf_mtap(caddr_t, const struct mbuf *, u_int); -struct ifaddr *ifa_ifwithaddr(struct sockaddr *, u_int); -struct ifaddr *ifa_ifwithdstaddr(struct sockaddr *, u_int); -struct ifaddr *ifaof_ifpforaddr(struct sockaddr *, struct ifnet *); +struct ifaddr *ifa_ifwithaddr(const struct sockaddr *, u_int); +struct ifaddr *ifa_ifwithdstaddr(const struct sockaddr *, u_int); +struct ifaddr *ifaof_ifpforaddr(const struct sockaddr *, struct ifnet *); struct ifaddr *ifaref(struct ifaddr *); void ifafree(struct ifaddr *); -- 2.20.1