summaryrefslogtreecommitdiff
path: root/sys
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
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')
-rw-r--r--sys/netinet/in_pcb.c14
-rw-r--r--sys/netinet/in_pcb.h6
-rw-r--r--sys/netinet/tcp_subr.c4
-rw-r--r--sys/netinet/tcp_timer.c6
-rw-r--r--sys/netinet/udp_usrreq.c4
-rw-r--r--sys/netinet6/in6_pcb.c4
6 files changed, 17 insertions, 21 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;
}
diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h
index a98de28ed01..a463d87dc4a 100644
--- a/sys/netinet/in_pcb.h
+++ b/sys/netinet/in_pcb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_pcb.h,v 1.148 2024/01/09 19:57:00 bluhm Exp $ */
+/* $OpenBSD: in_pcb.h,v 1.149 2024/01/28 20:34:25 bluhm Exp $ */
/* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */
/*
@@ -352,7 +352,7 @@ void in_pcbinit(struct inpcbtable *, int);
struct inpcb *
in_pcblookup_local_lock(struct inpcbtable *, const void *, u_int, int,
u_int, int);
-void in_pcbnotifyall(struct inpcbtable *, struct sockaddr *,
+void in_pcbnotifyall(struct inpcbtable *, const struct sockaddr_in *,
u_int, int, void (*)(struct inpcb *, int));
void in_pcbrehash(struct inpcb *);
void in_rtchange(struct inpcb *, int);
@@ -367,7 +367,7 @@ struct rtentry *
in_pcbrtentry(struct inpcb *);
/* INET6 stuff */
-void in6_pcbnotify(struct inpcbtable *, struct sockaddr_in6 *,
+void in6_pcbnotify(struct inpcbtable *, const struct sockaddr_in6 *,
u_int, const struct sockaddr_in6 *, u_int, u_int, int, void *,
void (*)(struct inpcb *, int));
int in6_selecthlim(const struct inpcb *);
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 8b5982a018e..f7616f4da08 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_subr.c,v 1.196 2024/01/27 21:13:46 bluhm Exp $ */
+/* $OpenBSD: tcp_subr.c,v 1.197 2024/01/28 20:34:25 bluhm Exp $ */
/* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */
/*
@@ -833,7 +833,7 @@ tcp_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *v)
}
in_pcbunref(inp);
} else
- in_pcbnotifyall(&tcbtable, sa, rdomain, errno, notify);
+ in_pcbnotifyall(&tcbtable, satosin(sa), rdomain, errno, notify);
}
diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c
index 79863eb41e8..ee87e5699fe 100644
--- a/sys/netinet/tcp_timer.c
+++ b/sys/netinet/tcp_timer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_timer.c,v 1.75 2024/01/27 21:35:13 bluhm Exp $ */
+/* $OpenBSD: tcp_timer.c,v 1.76 2024/01/28 20:34:25 bluhm Exp $ */
/* $NetBSD: tcp_timer.c,v 1.14 1996/02/13 23:44:09 christos Exp $ */
/*
@@ -236,8 +236,8 @@ tcp_timer_rexmt(void *arg)
sin.sin_len = sizeof(sin);
sin.sin_family = AF_INET;
sin.sin_addr = inp->inp_faddr;
- in_pcbnotifyall(&tcbtable, sintosa(&sin), inp->inp_rtableid,
- EMSGSIZE, tcp_mtudisc);
+ in_pcbnotifyall(&tcbtable, &sin, inp->inp_rtableid, EMSGSIZE,
+ tcp_mtudisc);
goto out;
}
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 1064f8bd2ae..6a58bb91671 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_usrreq.c,v 1.315 2024/01/21 01:17:20 bluhm Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.316 2024/01/28 20:34:25 bluhm Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
@@ -919,7 +919,7 @@ udp_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *v)
notify(inp, errno);
in_pcbunref(inp);
} else
- in_pcbnotifyall(&udbtable, sa, rdomain, errno, notify);
+ in_pcbnotifyall(&udbtable, satosin(sa), rdomain, errno, notify);
}
int
diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c
index 8293704f8dd..3561446e8eb 100644
--- a/sys/netinet6/in6_pcb.c
+++ b/sys/netinet6/in6_pcb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in6_pcb.c,v 1.132 2024/01/09 19:57:01 bluhm Exp $ */
+/* $OpenBSD: in6_pcb.c,v 1.133 2024/01/28 20:34:25 bluhm Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -423,7 +423,7 @@ in6_peeraddr(struct socket *so, struct mbuf *nam)
* once PCB to be notified has been located.
*/
void
-in6_pcbnotify(struct inpcbtable *table, struct sockaddr_in6 *dst,
+in6_pcbnotify(struct inpcbtable *table, const struct sockaddr_in6 *dst,
uint fport_arg, const struct sockaddr_in6 *src, uint lport_arg,
u_int rtable, int cmd, void *cmdarg, void (*notify)(struct inpcb *, int))
{