summaryrefslogtreecommitdiff
path: root/sys/netinet/in_pcb.c
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2024-01-28 20:34:26 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2024-01-28 20:34:26 +0000
commit8a7b6b6004f3eb0b6a4209b412a5371526bc7e6d (patch)
treee36a5dfd3813c7797aac03d68d444e05b82a881c /sys/netinet/in_pcb.c
parent6a571adde7d27d1d3cc5e316429dd65e4e6e5232 (diff)
Use more specific sockaddr type for inpcb notify.
in_pcbnotifyall() is an IPv4 only function. All callers check that sockaddr dst is in fact a sockaddr_in. Pass the more spcific type and remove the runtime check at beginning of in_pcbnotifyall(). Use const sockaddr_in in in_pcbnotifyall() and const sockaddr_in6 in6_pcbnotify() as dst parameter. OK millert@
Diffstat (limited to 'sys/netinet/in_pcb.c')
-rw-r--r--sys/netinet/in_pcb.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 29250092d80..20a5c5c97fc 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.c,v 1.286 2024/01/19 02:24:07 bluhm Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.287 2024/01/28 20:34:25 bluhm Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
@@ -720,18 +720,14 @@ in_peeraddr(struct socket *so, struct mbuf *nam)
* any errors for each matching socket.
*/
void
-in_pcbnotifyall(struct inpcbtable *table, struct sockaddr *dst, u_int rtable,
- int errno, void (*notify)(struct inpcb *, int))
+in_pcbnotifyall(struct inpcbtable *table, const struct sockaddr_in *dst,
+ u_int rtable, int errno, void (*notify)(struct inpcb *, int))
{
SIMPLEQ_HEAD(, inpcb) inpcblist;
struct inpcb *inp;
- struct in_addr faddr;
u_int rdomain;
- if (dst->sa_family != AF_INET)
- return;
- faddr = satosin(dst)->sin_addr;
- if (faddr.s_addr == INADDR_ANY)
+ if (dst->sin_addr.s_addr == INADDR_ANY)
return;
if (notify == NULL)
return;
@@ -754,7 +750,7 @@ in_pcbnotifyall(struct inpcbtable *table, struct sockaddr *dst, u_int rtable,
if (ISSET(inp->inp_flags, INP_IPV6))
continue;
#endif
- if (inp->inp_faddr.s_addr != faddr.s_addr ||
+ if (inp->inp_faddr.s_addr != dst->sin_addr.s_addr ||
rtable_l2(inp->inp_rtableid) != rdomain) {
continue;
}