summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_socket.c
diff options
context:
space:
mode:
authorluigi <luigi@FreeBSD.org>2010-11-12 13:02:26 +0000
committerluigi <luigi@FreeBSD.org>2010-11-12 13:02:26 +0000
commitd5e8d236f4009fc2611f996c317e94b2c8649cf5 (patch)
treee91599dcbd47fe55ea222b065a06b499aa245cca /sys/kern/uipc_socket.c
parent20a2600f84554023f0954887c9cfc8bf63c28cf0 (diff)
downloadFreeBSD-src-d5e8d236f4009fc2611f996c317e94b2c8649cf5.zip
FreeBSD-src-d5e8d236f4009fc2611f996c317e94b2c8649cf5.tar.gz
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
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 d6c9854..e3e8e28 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:
OpenPOWER on IntegriCloud