aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/uipc_socket.c
diff options
context:
space:
mode:
authorLuigi Rizzo <luigi@FreeBSD.org>2010-11-12 13:02:26 +0000
committerLuigi Rizzo <luigi@FreeBSD.org>2010-11-12 13:02:26 +0000
commit5c9d0a9ad384b852bdbc408697e27015334ea249 (patch)
treee91599dcbd47fe55ea222b065a06b499aa245cca /sys/kern/uipc_socket.c
parent2f8d87d326d2a274b1a932d537f182bdae4dbf88 (diff)
downloadsrc-5c9d0a9ad384b852bdbc408697e27015334ea249.tar.gz
src-5c9d0a9ad384b852bdbc408697e27015334ea249.zip
This commit implements the SO_USER_COOKIE socket option, which lets
you tag a socket with an uint32_t value. The cookie can then be used by the kernel for various purposes, e.g. setting the skipto rule or pipe number in ipfw (this is the reason SO_USER_COOKIE has been implemented; however there is nothing ipfw-specific in its implementation). The ipfw-related code that uses the optopn will be committed separately. This change adds a field to 'struct socket', but the struct is not part of any driver or userland-visible ABI so the change should be harmless. See the discussion at http://lists.freebsd.org/pipermail/freebsd-ipfw/2009-October/004001.html Idea and code from Paul Joe, small modifications and manpage changes by myself. Submitted by: Paul Joe MFC after: 1 week
Notes
Notes: svn path=/head/; revision=215178
Diffstat (limited to 'sys/kern/uipc_socket.c')
-rw-r--r--sys/kern/uipc_socket.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index d6c9854fa1fb..e3e8e288a179 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -2386,6 +2386,7 @@ sosetopt(struct socket *so, struct sockopt *sopt)
struct linger l;
struct timeval tv;
u_long val;
+ uint32_t val32;
#ifdef MAC
struct mac extmac;
#endif
@@ -2461,6 +2462,15 @@ sosetopt(struct socket *so, struct sockopt *sopt)
so->so_fibnum = 0;
}
break;
+
+ case SO_USER_COOKIE:
+ error = sooptcopyin(sopt, &val32, sizeof val32,
+ sizeof val32);
+ if (error)
+ goto bad;
+ so->so_user_cookie = val32;
+ break;
+
case SO_SNDBUF:
case SO_RCVBUF:
case SO_SNDLOWAT: