git: 97f8198e95df - main - sockets: make SO_SND/SO_RCV a enum
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 09 May 2022 17:55:03 UTC
The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=97f8198e95df75f7bf01b885084cfc00f450c396 commit 97f8198e95df75f7bf01b885084cfc00f450c396 Author: Gleb Smirnoff <glebius@FreeBSD.org> AuthorDate: 2022-05-09 17:42:47 +0000 Commit: Gleb Smirnoff <glebius@FreeBSD.org> CommitDate: 2022-05-09 17:42:47 +0000 sockets: make SO_SND/SO_RCV a enum Not a functional change now. The enum will also be used for other socket buffer related KPIs. --- sys/kern/uipc_socket.c | 6 ++---- sys/sys/socketvar.h | 11 +++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 4c4fde0d6a26..f33814efd176 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -4240,7 +4240,7 @@ sodtor_set(struct socket *so, so_dtor_t *func) * Register per-socket buffer upcalls. */ void -soupcall_set(struct socket *so, int which, so_upcall_t func, void *arg) +soupcall_set(struct socket *so, sb_which which, so_upcall_t func, void *arg) { struct sockbuf *sb; @@ -4263,7 +4263,7 @@ soupcall_set(struct socket *so, int which, so_upcall_t func, void *arg) } void -soupcall_clear(struct socket *so, int which) +soupcall_clear(struct socket *so, sb_which which) { struct sockbuf *sb; @@ -4276,8 +4276,6 @@ soupcall_clear(struct socket *so, int which) case SO_SND: sb = &so->so_snd; break; - default: - panic("soupcall_clear: bad which"); } SOCKBUF_LOCK_ASSERT(sb); KASSERT(sb->sb_upcall != NULL, diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index 019fdfc372ac..b379dc319cea 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -281,6 +281,9 @@ struct socket { #define SOCK_SENDBUF_UNLOCK_ASSERT(so) \ mtx_assert(SOCK_SENDBUF_MTX(so), MA_NOTOWNED) +/* 'which' values for socket buffer events and upcalls. */ +typedef enum { SO_RCV, SO_SND } sb_which; + /* * Macros for sockets and socket buffering. */ @@ -443,10 +446,6 @@ struct sockaddr; struct ucred; struct uio; -/* 'which' values for socket upcalls. */ -#define SO_RCV 1 -#define SO_SND 2 - /* Return values for socket upcalls. */ #define SU_OK 0 #define SU_ISCONNECTED 1 @@ -516,8 +515,8 @@ int sosend_generic(struct socket *so, struct sockaddr *addr, struct uio *uio, struct mbuf *top, struct mbuf *control, int flags, struct thread *td); int soshutdown(struct socket *so, int how); -void soupcall_clear(struct socket *, int); -void soupcall_set(struct socket *, int, so_upcall_t, void *); +void soupcall_clear(struct socket *, sb_which); +void soupcall_set(struct socket *, sb_which, so_upcall_t, void *); void solisten_upcall_set(struct socket *, so_upcall_t, void *); void sowakeup(struct socket *so, struct sockbuf *sb); void sowakeup_aio(struct socket *so, struct sockbuf *sb);