git: socket: Implement the SO_USER_COOKIE option

Aaron LI aly at crater.dragonflybsd.org
Thu Jan 25 05:53:08 PST 2024


commit 5c6946781e218c960a6b9322e734d644e384e677
Author: Aaron LI <aly at aaronly.me>
Date:   Tue Oct 31 09:06:01 2023 +0800

    socket: Implement the SO_USER_COOKIE option
    
    This socket option allows to attach an arbitrary uint32_t value to a
    socket as the user-defined cookie/metadata, and then the cookie can be
    used in the kernel help manipulate the traffic of the socket.
    
    For example, this socket option can be set by WireGuard and then matched
    in IPFW to help control the WireGuard traffic.
    
    This commit is mostly derived from FreeBSD, but I decided to also
    support this option in getsockopt().
    
    Note that the support of this option in IPFW (and PF and others) is
    still need to be implemented.  I'd like to do it in the future but it
    may take quite some efforts.  This commit alone doesn't achieve much
    benefits, but it helps port the WireGuard code from FreeBSD, so commit
    it first.
    
    Bump __DragonFly_version.
    
    Credit: https://github.com/freebsd/freebsd-src/commit/d5e8d236f4009fc2611f996c317e94b2c8649cf5

Summary of changes:
 lib/libc/sys/getsockopt.2 |  6 ++++++
 sys/kern/uipc_socket.c    | 16 ++++++++++++++++
 sys/sys/param.h           |  3 ++-
 sys/sys/socket.h          |  4 +++-
 sys/sys/socketvar.h       |  2 ++
 5 files changed, 29 insertions(+), 2 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/5c6946781e218c960a6b9322e734d644e384e677


-- 
DragonFly BSD source repository


More information about the Commits mailing list