-/* $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 $ */
/*
.pru_rcvd = uipc_rcvd,
.pru_send = uipc_send,
.pru_abort = uipc_abort,
+ .pru_sense = uipc_sense,
};
void
}
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;
return (0);
}
+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)
-/* $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
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;
-/* $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 $ */
/*
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;
-/* $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>
in_setpeeraddr(inp, addr);
break;
- case PRU_SENSE:
- break;
-
case PRU_CONNECT2:
case PRU_SENDOOB:
case PRU_FASTTIMO:
-/* $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 $ */
/*
error = EOPNOTSUPP;
break;
- case PRU_SENSE:
- /*
- * stat: don't bother with a blocksize.
- */
- break;
-
/*
* Not supported.
*/
-/* $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 $ */
/*
.pru_rcvd = tcp_rcvd,
.pru_send = tcp_send,
.pru_abort = tcp_abort,
+ .pru_sense = tcp_sense,
};
static int pr_slowhz = PR_SLOWHZ;
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) ||
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).
-/* $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 $ */
/*
#ifdef _KERNEL
#include <sys/percpu.h>
+#include <sys/stat.h>
enum tcpstat_counters {
tcps_connattempt,
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);
-/* $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 $ */
/*
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:
-/* $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>
in6_setpeeraddr(inp, addr);
break;
- case PRU_SENSE:
- break;
-
case PRU_CONNECT2:
case PRU_SENDOOB:
case PRU_FASTTIMO:
-/* $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 $ */
/*
error = EOPNOTSUPP;
break;
- case PRU_SENSE:
- /*
- * stat: don't bother with a blocksize
- */
- break;
/*
* Not supported.
*/
-/* $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 $ */
/*-
struct socket;
struct domain;
struct proc;
+struct stat;
struct pr_usrreqs {
/* user request: see list below */
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 {
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
-/* $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 $ */
/*
#define sotounpcb(so) ((struct unpcb *)((so)->so_pcb))
#ifdef _KERNEL
+
+struct stat;
+
struct fdpass {
struct file *fp;
int flags;
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 *);