diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2022-02-25 08:36:02 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2022-02-25 08:36:02 +0000 |
commit | 8238d29934c502864bde6a443ec0477043c6bba5 (patch) | |
tree | 0209ea9e5a21710204de93312ec9aa9af413decf /sys/net | |
parent | d73b76e55d5db7e118c36225e527630ec207c4ff (diff) |
Move pr_attach and pr_detach to a new structure pr_usrreqs that can
then be shared among protosw structures, following the same basic
direction as NetBSD and FreeBSD for this.
Split PRU_CONTROL out of pr_usrreq into pru_control, giving it the
proper prototype to eliminate the previously necessary casts.
ok mvs@ bluhm@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if.c | 13 | ||||
-rw-r--r-- | sys/net/pfkeyv2.c | 13 | ||||
-rw-r--r-- | sys/net/rtsock.c | 13 |
3 files changed, 21 insertions, 18 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 0bda92609c6..c7a3f6b1924 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.647 2022/01/07 16:39:18 deraadt Exp $ */ +/* $OpenBSD: if.c,v 1.648 2022/02/25 08:36:01 guenther Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -2258,11 +2258,12 @@ forceup: break; /* FALLTHROUGH */ default: - error = ((*so->so_proto->pr_usrreq)(so, PRU_CONTROL, - (struct mbuf *) cmd, (struct mbuf *) data, - (struct mbuf *) ifp, p)); - if (error != EOPNOTSUPP) - break; + if (so->so_proto->pr_usrreqs->pru_control != NULL) { + error = ((*so->so_proto->pr_usrreqs->pru_control)(so, + cmd, data, ifp)); + if (error != EOPNOTSUPP) + break; + } switch (cmd) { case SIOCAIFADDR: case SIOCDIFADDR: diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c index b848dab990a..fc08630cfb6 100644 --- a/sys/net/pfkeyv2.c +++ b/sys/net/pfkeyv2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkeyv2.c,v 1.229 2021/12/19 23:30:08 bluhm Exp $ */ +/* $OpenBSD: pfkeyv2.c,v 1.230 2022/02/25 08:36:01 guenther Exp $ */ /* * @(#)COPYRIGHT 1.1 (NRL) 17 January 1995 @@ -199,6 +199,11 @@ pfdatatopacket(void *data, int len, struct mbuf **packet) return (0); } +const struct pr_usrreqs pfkeyv2_usrreqs = { + .pru_attach = pfkeyv2_attach, + .pru_detach = pfkeyv2_detach, +}; + const struct protosw pfkeysw[] = { { .pr_type = SOCK_RAW, @@ -207,8 +212,7 @@ const struct protosw pfkeysw[] = { .pr_flags = PR_ATOMIC | PR_ADDR, .pr_output = pfkeyv2_output, .pr_usrreq = pfkeyv2_usrreq, - .pr_attach = pfkeyv2_attach, - .pr_detach = pfkeyv2_detach, + .pr_usrreqs = &pfkeyv2_usrreqs, .pr_sysctl = pfkeyv2_sysctl, } }; @@ -335,9 +339,6 @@ pfkeyv2_usrreq(struct socket *so, int req, struct mbuf *m, struct pkpcb *kp; int error = 0; - if (req == PRU_CONTROL) - return (EOPNOTSUPP); - soassertlocked(so); if (control && control->m_len) { diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 0ff8dd87531..9a9d6f40c4b 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.324 2022/01/20 11:06:57 bluhm Exp $ */ +/* $OpenBSD: rtsock.c,v 1.325 2022/02/25 08:36:01 guenther Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -214,9 +214,6 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, struct rtpcb *rop; int error = 0; - if (req == PRU_CONTROL) - return (EOPNOTSUPP); - soassertlocked(so); if (control && control->m_len) { @@ -2389,6 +2386,11 @@ rt_setsource(unsigned int rtableid, struct sockaddr *src) * Definitions of protocols supported in the ROUTE domain. */ +const struct pr_usrreqs route_usrreqs = { + .pru_attach = route_attach, + .pru_detach = route_detach, +}; + const struct protosw routesw[] = { { .pr_type = SOCK_RAW, @@ -2397,8 +2399,7 @@ const struct protosw routesw[] = { .pr_output = route_output, .pr_ctloutput = route_ctloutput, .pr_usrreq = route_usrreq, - .pr_attach = route_attach, - .pr_detach = route_detach, + .pr_usrreqs = &route_usrreqs, .pr_init = route_prinit, .pr_sysctl = sysctl_rtable } |