From 52454f704637f58553f00f7f71b4c240cdab7d06 Mon Sep 17 00:00:00 2001 From: mvs Date: Mon, 29 Aug 2022 08:08:17 +0000 Subject: [PATCH] Move PRU_RCVOOB request to (*pru_rcvoob)(). ok bluhm@ --- sys/kern/uipc_usrreq.c | 3 +-- sys/net/pfkeyv2.c | 3 +-- sys/net/rtsock.c | 3 +-- sys/netinet/ip_divert.c | 3 +-- sys/netinet/raw_ip.c | 3 +-- sys/netinet/tcp_usrreq.c | 54 +++++++++++++++++++++++++-------------- sys/netinet/tcp_var.h | 3 ++- sys/netinet/udp_usrreq.c | 3 +-- sys/netinet6/ip6_divert.c | 3 +-- sys/netinet6/raw_ip6.c | 3 +-- sys/sys/protosw.h | 8 +++--- 11 files changed, 50 insertions(+), 39 deletions(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 55939039a91..35fd195679c 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_usrreq.c,v 1.178 2022/08/28 21:35:11 mvs Exp $ */ +/* $OpenBSD: uipc_usrreq.c,v 1.179 2022/08/29 08:08:17 mvs Exp $ */ /* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */ /* @@ -247,7 +247,6 @@ uipc_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, } break; - case PRU_RCVOOB: case PRU_SENDOOB: error = EOPNOTSUPP; break; diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c index 8d1185d27ed..0ec4e3c1fba 100644 --- a/sys/net/pfkeyv2.c +++ b/sys/net/pfkeyv2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkeyv2.c,v 1.246 2022/08/28 21:35:11 mvs Exp $ */ +/* $OpenBSD: pfkeyv2.c,v 1.247 2022/08/29 08:08:17 mvs Exp $ */ /* * @(#)COPYRIGHT 1.1 (NRL) 17 January 1995 @@ -426,7 +426,6 @@ pfkeyv2_usrreq(struct socket *so, int req, struct mbuf *m, nam->m_len = pfkey_addr.sa_len; break; - case PRU_RCVOOB: case PRU_SENDOOB: error = EOPNOTSUPP; break; diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index c7476a5b359..f4cfdeb52df 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.347 2022/08/29 07:51:45 bluhm Exp $ */ +/* $OpenBSD: rtsock.c,v 1.348 2022/08/29 08:08:17 mvs Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -251,7 +251,6 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, nam->m_len = route_src.sa_len; break; - case PRU_RCVOOB: case PRU_SENDOOB: error = EOPNOTSUPP; break; diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 5a012b0cefb..275f656f410 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.c,v 1.80 2022/08/28 21:35:12 mvs Exp $ */ +/* $OpenBSD: ip_divert.c,v 1.81 2022/08/29 08:08:17 mvs Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -285,7 +285,6 @@ divert_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr, case PRU_SLOWTIMO: case PRU_PROTORCV: case PRU_PROTOSEND: - case PRU_RCVOOB: error = EOPNOTSUPP; break; diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index bb1704529fe..ca617d96f52 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip.c,v 1.141 2022/08/28 21:35:12 mvs Exp $ */ +/* $OpenBSD: raw_ip.c,v 1.142 2022/08/29 08:08:17 mvs Exp $ */ /* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */ /* @@ -486,7 +486,6 @@ rip_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, * Not supported. */ case PRU_SENDOOB: - case PRU_RCVOOB: error = EOPNOTSUPP; break; diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index cbb64ba295b..889acc2b12d 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.198 2022/08/28 21:35:12 mvs Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.199 2022/08/29 08:08:17 mvs Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -125,6 +125,7 @@ const struct pr_usrreqs tcp_usrreqs = { .pru_send = tcp_send, .pru_abort = tcp_abort, .pru_sense = tcp_sense, + .pru_rcvoob = tcp_rcvoob, }; static int pr_slowhz = PR_SLOWHZ; @@ -228,24 +229,6 @@ tcp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, error = EOPNOTSUPP; break; - case PRU_RCVOOB: - if ((so->so_oobmark == 0 && - (so->so_state & SS_RCVATMARK) == 0) || - so->so_options & SO_OOBINLINE || - tp->t_oobflags & TCPOOB_HADDATA) { - error = EINVAL; - break; - } - if ((tp->t_oobflags & TCPOOB_HAVEDATA) == 0) { - error = EWOULDBLOCK; - break; - } - m->m_len = 1; - *mtod(m, caddr_t) = tp->t_iobc; - if (((long)nam & MSG_PEEK) == 0) - tp->t_oobflags ^= (TCPOOB_HAVEDATA | TCPOOB_HADDATA); - break; - case PRU_SENDOOB: if (sbspace(so, &so->so_snd) < -512) { m_freem(m); @@ -1000,6 +983,39 @@ tcp_sense(struct socket *so, struct stat *ub) return (0); } +int +tcp_rcvoob(struct socket *so, struct mbuf *m, int flags) +{ + struct inpcb *inp; + struct tcpcb *tp; + int error; + + soassertlocked(so); + + if ((error = tcp_sogetpcb(so, &inp, &tp))) + return (error); + + if ((so->so_oobmark == 0 && + (so->so_state & SS_RCVATMARK) == 0) || + so->so_options & SO_OOBINLINE || + tp->t_oobflags & TCPOOB_HADDATA) { + error = EINVAL; + goto out; + } + if ((tp->t_oobflags & TCPOOB_HAVEDATA) == 0) { + error = EWOULDBLOCK; + goto out; + } + m->m_len = 1; + *mtod(m, caddr_t) = tp->t_iobc; + if ((flags & MSG_PEEK) == 0) + tp->t_oobflags ^= (TCPOOB_HAVEDATA | TCPOOB_HADDATA); +out: + if (so->so_options & SO_DEBUG) + tcp_trace(TA_USER, tp->t_state, tp, tp, NULL, PRU_RCVOOB, 0); + return (error); +} + /* * 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 9d7f83b486a..56b978553ed 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_var.h,v 1.151 2022/08/28 21:35:12 mvs Exp $ */ +/* $OpenBSD: tcp_var.h,v 1.152 2022/08/29 08:08:17 mvs Exp $ */ /* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */ /* @@ -726,6 +726,7 @@ int tcp_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); int tcp_abort(struct socket *); int tcp_sense(struct socket *, struct stat *); +int tcp_rcvoob(struct socket *, struct mbuf *, int); 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 ebd152cde10..2edbff0781e 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.293 2022/08/28 21:35:12 mvs Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.294 2022/08/29 08:08:17 mvs Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -1111,7 +1111,6 @@ udp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr, case PRU_SLOWTIMO: case PRU_PROTORCV: case PRU_PROTOSEND: - case PRU_RCVOOB: error = EOPNOTSUPP; break; diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c index 93e1fe10699..847e3c35d0c 100644 --- a/sys/netinet6/ip6_divert.c +++ b/sys/netinet6/ip6_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_divert.c,v 1.79 2022/08/28 21:35:12 mvs Exp $ */ +/* $OpenBSD: ip6_divert.c,v 1.80 2022/08/29 08:08:17 mvs Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -291,7 +291,6 @@ divert6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr, case PRU_SLOWTIMO: case PRU_PROTORCV: case PRU_PROTOSEND: - case PRU_RCVOOB: error = EOPNOTSUPP; break; diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index deb48119590..00fe9192d44 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.c,v 1.161 2022/08/28 21:35:12 mvs Exp $ */ +/* $OpenBSD: raw_ip6.c,v 1.162 2022/08/29 08:08:17 mvs Exp $ */ /* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */ /* @@ -601,7 +601,6 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, * Not supported. */ case PRU_SENDOOB: - case PRU_RCVOOB: error = EOPNOTSUPP; break; diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 6552a33a1b4..490d155a074 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -1,4 +1,4 @@ -/* $OpenBSD: protosw.h,v 1.48 2022/08/28 21:35:12 mvs Exp $ */ +/* $OpenBSD: protosw.h,v 1.49 2022/08/29 08:08:17 mvs Exp $ */ /* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */ /*- @@ -78,6 +78,7 @@ struct pr_usrreqs { struct mbuf *); int (*pru_abort)(struct socket *); int (*pru_sense)(struct socket *, struct stat *); + int (*pru_rcvoob)(struct socket *, struct mbuf *, int); }; struct protosw { @@ -357,8 +358,9 @@ pru_sense(struct socket *so, struct stat *ub) static inline int pru_rcvoob(struct socket *so, struct mbuf *m, int flags) { - return (*so->so_proto->pr_usrreqs->pru_usrreq)(so, - PRU_RCVOOB, m, (struct mbuf *)(long)flags, NULL, curproc); + if (so->so_proto->pr_usrreqs->pru_rcvoob) + return (*so->so_proto->pr_usrreqs->pru_rcvoob)(so, m, flags); + return (EOPNOTSUPP); } static inline int -- 2.20.1