diff options
author | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2022-08-28 21:35:13 +0000 |
---|---|---|
committer | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2022-08-28 21:35:13 +0000 |
commit | 31feaae51c9922573ee3d887ace299f8a88fc802 (patch) | |
tree | a1b41d959f3bc717efb7a70a0db512ed03b26a3f | |
parent | 93657dcbc8fa66fdad6c7b342e0501e189ed0c01 (diff) |
Move PRU_SENSE request to (*pru_sense)().
ok bluhm@
-rw-r--r-- | sys/kern/uipc_usrreq.c | 44 | ||||
-rw-r--r-- | sys/net/pfkeyv2.c | 6 | ||||
-rw-r--r-- | sys/net/rtsock.c | 6 | ||||
-rw-r--r-- | sys/netinet/ip_divert.c | 5 | ||||
-rw-r--r-- | sys/netinet/raw_ip.c | 8 | ||||
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 26 | ||||
-rw-r--r-- | sys/netinet/tcp_var.h | 4 | ||||
-rw-r--r-- | sys/netinet/udp_usrreq.c | 12 | ||||
-rw-r--r-- | sys/netinet6/ip6_divert.c | 5 | ||||
-rw-r--r-- | sys/netinet6/raw_ip6.c | 7 | ||||
-rw-r--r-- | sys/sys/protosw.h | 9 | ||||
-rw-r--r-- | sys/sys/unpcb.h | 6 |
12 files changed, 66 insertions, 72 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 93a49040a42..55939039a91 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_usrreq.c,v 1.177 2022/08/28 18:44:16 mvs Exp $ */ +/* $OpenBSD: uipc_usrreq.c,v 1.178 2022/08/28 21:35:11 mvs Exp $ */ /* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */ /* @@ -139,6 +139,7 @@ const struct pr_usrreqs uipc_usrreqs = { .pru_rcvd = uipc_rcvd, .pru_send = uipc_send, .pru_abort = uipc_abort, + .pru_sense = uipc_sense, }; void @@ -246,25 +247,6 @@ uipc_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, } break; - case PRU_SENSE: { - struct stat *sb = (struct stat *)m; - - sb->st_blksize = so->so_snd.sb_hiwat; - sb->st_dev = NODEV; - mtx_enter(&unp_ino_mtx); - if (unp->unp_ino == 0) - unp->unp_ino = unp_ino++; - mtx_leave(&unp_ino_mtx); - sb->st_atim.tv_sec = - sb->st_mtim.tv_sec = - sb->st_ctim.tv_sec = unp->unp_ctime.tv_sec; - sb->st_atim.tv_nsec = - sb->st_mtim.tv_nsec = - sb->st_ctim.tv_nsec = unp->unp_ctime.tv_nsec; - sb->st_ino = unp->unp_ino; - break; - } - case PRU_RCVOOB: case PRU_SENDOOB: error = EOPNOTSUPP; @@ -598,6 +580,28 @@ uipc_abort(struct socket *so) } int +uipc_sense(struct socket *so, struct stat *sb) +{ + struct unpcb *unp = sotounpcb(so); + + sb->st_blksize = so->so_snd.sb_hiwat; + sb->st_dev = NODEV; + mtx_enter(&unp_ino_mtx); + if (unp->unp_ino == 0) + unp->unp_ino = unp_ino++; + mtx_leave(&unp_ino_mtx); + sb->st_atim.tv_sec = + sb->st_mtim.tv_sec = + sb->st_ctim.tv_sec = unp->unp_ctime.tv_sec; + sb->st_atim.tv_nsec = + sb->st_mtim.tv_nsec = + sb->st_ctim.tv_nsec = unp->unp_ctime.tv_nsec; + sb->st_ino = unp->unp_ino; + + return (0); +} + +int uipc_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c index 549bb568468..8d1185d27ed 100644 --- a/sys/net/pfkeyv2.c +++ b/sys/net/pfkeyv2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkeyv2.c,v 1.245 2022/08/28 20:32:01 bluhm Exp $ */ +/* $OpenBSD: pfkeyv2.c,v 1.246 2022/08/28 21:35:11 mvs Exp $ */ /* * @(#)COPYRIGHT 1.1 (NRL) 17 January 1995 @@ -417,10 +417,6 @@ pfkeyv2_usrreq(struct socket *so, int req, struct mbuf *m, error = EOPNOTSUPP; break; - case PRU_SENSE: - /* stat: don't bother with a blocksize. */ - break; - /* minimal support, just implement a fake peer address */ case PRU_SOCKADDR: error = EINVAL; diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 21a2b4ecd82..5e54c1c94fd 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.345 2022/08/28 20:32:01 bluhm Exp $ */ +/* $OpenBSD: rtsock.c,v 1.346 2022/08/28 21:35:12 mvs Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -242,10 +242,6 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, error = EOPNOTSUPP; break; - case PRU_SENSE: - /* stat: don't bother with a blocksize. */ - break; - /* minimal support, just implement a fake peer address */ case PRU_SOCKADDR: error = EINVAL; diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index dffb8e8477b..5a012b0cefb 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.c,v 1.79 2022/08/28 18:44:16 mvs Exp $ */ +/* $OpenBSD: ip_divert.c,v 1.80 2022/08/28 21:35:12 mvs Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -279,9 +279,6 @@ divert_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr, in_setpeeraddr(inp, addr); break; - case PRU_SENSE: - break; - case PRU_CONNECT2: case PRU_SENDOOB: case PRU_FASTTIMO: diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 14d8b23e06c..bb1704529fe 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip.c,v 1.140 2022/08/28 18:44:16 mvs Exp $ */ +/* $OpenBSD: raw_ip.c,v 1.141 2022/08/28 21:35:12 mvs Exp $ */ /* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */ /* @@ -482,12 +482,6 @@ rip_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, error = EOPNOTSUPP; break; - case PRU_SENSE: - /* - * stat: don't bother with a blocksize. - */ - break; - /* * Not supported. */ diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 310caee591b..cbb64ba295b 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.197 2022/08/28 18:44:16 mvs Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.198 2022/08/28 21:35:12 mvs Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -124,6 +124,7 @@ const struct pr_usrreqs tcp_usrreqs = { .pru_rcvd = tcp_rcvd, .pru_send = tcp_send, .pru_abort = tcp_abort, + .pru_sense = tcp_sense, }; static int pr_slowhz = PR_SLOWHZ; @@ -227,10 +228,6 @@ tcp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, error = EOPNOTSUPP; break; - case PRU_SENSE: - ((struct stat *) m)->st_blksize = so->so_snd.sb_hiwat; - break; - case PRU_RCVOOB: if ((so->so_oobmark == 0 && (so->so_state & SS_RCVATMARK) == 0) || @@ -984,6 +981,25 @@ tcp_abort(struct socket *so) return (0); } +int +tcp_sense(struct socket *so, struct stat *ub) +{ + struct inpcb *inp; + struct tcpcb *tp; + int error; + + soassertlocked(so); + + if ((error = tcp_sogetpcb(so, &inp, &tp))) + return (error); + + ub->st_blksize = so->so_snd.sb_hiwat; + + if (so->so_options & SO_DEBUG) + tcp_trace(TA_USER, tp->t_state, tp, tp, NULL, PRU_SENSE, 0); + return (0); +} + /* * Initiate (or continue) disconnect. * If embryonic state, just send reset (once). diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 516b3c478c8..9d7f83b486a 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_var.h,v 1.150 2022/08/28 18:44:16 mvs Exp $ */ +/* $OpenBSD: tcp_var.h,v 1.151 2022/08/28 21:35:12 mvs Exp $ */ /* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */ /* @@ -513,6 +513,7 @@ struct tcp_ident_mapping { #ifdef _KERNEL #include <sys/percpu.h> +#include <sys/stat.h> enum tcpstat_counters { tcps_connattempt, @@ -724,6 +725,7 @@ int tcp_rcvd(struct socket *); int tcp_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); int tcp_abort(struct socket *); +int tcp_sense(struct socket *, struct stat *); void tcp_xmit_timer(struct tcpcb *, int); void tcpdropoldhalfopen(struct tcpcb *, u_int16_t); void tcp_sack_option(struct tcpcb *,struct tcphdr *,u_char *,int); diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 3dd324f735a..ebd152cde10 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.292 2022/08/28 18:44:16 mvs Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.293 2022/08/28 21:35:12 mvs Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -1106,16 +1106,6 @@ udp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr, in_setpeeraddr(inp, addr); break; - case PRU_SENSE: - /* - * stat: don't bother with a blocksize. - */ - /* - * Perhaps Path MTU might be returned for a connected - * UDP socket in this case. - */ - break; - case PRU_SENDOOB: case PRU_FASTTIMO: case PRU_SLOWTIMO: diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c index 73019e5914f..93e1fe10699 100644 --- a/sys/netinet6/ip6_divert.c +++ b/sys/netinet6/ip6_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_divert.c,v 1.78 2022/08/28 18:44:17 mvs Exp $ */ +/* $OpenBSD: ip6_divert.c,v 1.79 2022/08/28 21:35:12 mvs Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -285,9 +285,6 @@ divert6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr, in6_setpeeraddr(inp, addr); break; - case PRU_SENSE: - break; - case PRU_CONNECT2: case PRU_SENDOOB: case PRU_FASTTIMO: diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index 20306191f8a..deb48119590 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.c,v 1.160 2022/08/28 18:44:17 mvs Exp $ */ +/* $OpenBSD: raw_ip6.c,v 1.161 2022/08/28 21:35:12 mvs Exp $ */ /* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */ /* @@ -597,11 +597,6 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, error = EOPNOTSUPP; break; - case PRU_SENSE: - /* - * stat: don't bother with a blocksize - */ - break; /* * Not supported. */ diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 3f6bfa87765..6552a33a1b4 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -1,4 +1,4 @@ -/* $OpenBSD: protosw.h,v 1.47 2022/08/28 20:32:02 bluhm Exp $ */ +/* $OpenBSD: protosw.h,v 1.48 2022/08/28 21:35:12 mvs Exp $ */ /* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */ /*- @@ -58,6 +58,7 @@ struct sockaddr; struct socket; struct domain; struct proc; +struct stat; struct pr_usrreqs { /* user request: see list below */ @@ -76,6 +77,7 @@ struct pr_usrreqs { int (*pru_send)(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); int (*pru_abort)(struct socket *); + int (*pru_sense)(struct socket *, struct stat *); }; struct protosw { @@ -347,8 +349,9 @@ pru_control(struct socket *so, u_long cmd, caddr_t data, static inline int pru_sense(struct socket *so, struct stat *ub) { - return (*so->so_proto->pr_usrreqs->pru_usrreq)(so, - PRU_SENSE, (struct mbuf *)ub, NULL, NULL, curproc); + if (so->so_proto->pr_usrreqs->pru_sense) + return (*so->so_proto->pr_usrreqs->pru_sense)(so, ub); + return (0); } static inline int diff --git a/sys/sys/unpcb.h b/sys/sys/unpcb.h index b4e46618688..de6da21017c 100644 --- a/sys/sys/unpcb.h +++ b/sys/sys/unpcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: unpcb.h,v 1.36 2022/08/28 18:44:17 mvs Exp $ */ +/* $OpenBSD: unpcb.h,v 1.37 2022/08/28 21:35:12 mvs Exp $ */ /* $NetBSD: unpcb.h,v 1.6 1994/06/29 06:46:08 cgd Exp $ */ /* @@ -102,6 +102,9 @@ struct unpcb { #define sotounpcb(so) ((struct unpcb *)((so)->so_pcb)) #ifdef _KERNEL + +struct stat; + struct fdpass { struct file *fp; int flags; @@ -123,6 +126,7 @@ int uipc_rcvd(struct socket *); int uipc_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); int uipc_abort(struct socket *); +int uipc_sense(struct socket *, struct stat *); void unp_init(void); int unp_bind(struct unpcb *, struct mbuf *, struct proc *); |