aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2026-06-19 04:03:30 +0000
committerKyle Evans <kevans@FreeBSD.org>2026-06-19 04:03:30 +0000
commit0ae7df3708dd97515a5bc2a068d25a733c9b2b10 (patch)
tree2c397a30203a321d88a239c88d53f3d107b187f5
parent9b16399225f8acfba675cf0a9312dd9eac563ce3 (diff)
sockets: plumb SO_PASSRIGHTS into *sockopt(2)
This is a little different than the others in that it's not valid for anything but unix(4) sockets. New cases were added that jump into the more standard case out of a light preference for not taking advantage of case FALLTHROUGH with the additional logic- it doesn't scale very well for new cases added that might be slightly special, so we might as well just add the labels up-front. Reviewed by: glebius, markj Differential Revision: https://reviews.freebsd.org/D57424
-rw-r--r--sys/kern/uipc_socket.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 3debec547a80..c7a7fdd44aa0 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -3911,6 +3911,7 @@ sosetopt(struct socket *so, struct sockopt *sopt)
case SO_NO_DDP:
case SO_NO_OFFLOAD:
case SO_RERROR:
+stdopt:
error = sooptcopyin(sopt, &optval, sizeof optval,
sizeof optval);
if (error)
@@ -3923,6 +3924,14 @@ sosetopt(struct socket *so, struct sockopt *sopt)
SOCK_UNLOCK(so);
break;
+ case SO_PASSRIGHTS:
+ if (so->so_proto->pr_domain->dom_family != AF_LOCAL) {
+ error = EOPNOTSUPP;
+ goto bad;
+ }
+
+ goto stdopt;
+
case SO_SETFIB:
error = so->so_proto->pr_ctloutput(so, sopt);
break;
@@ -4162,11 +4171,20 @@ sogetopt(struct socket *so, struct sockopt *sopt)
case SO_NO_DDP:
case SO_NO_OFFLOAD:
case SO_RERROR:
+stdopt:
optval = so->so_options & sopt->sopt_name;
integer:
error = sooptcopyout(sopt, &optval, sizeof optval);
break;
+ case SO_PASSRIGHTS:
+ if (so->so_proto->pr_domain->dom_family != AF_LOCAL) {
+ error = EOPNOTSUPP;
+ goto bad;
+ }
+
+ goto stdopt;
+
case SO_FIB:
SOCK_LOCK(so);
optval = so->so_fibnum;