]> git.ipfire.org Git - thirdparty/systemd.git/commit
socket-util: add wrappers for binding socket to ifindex/ifname
authorLennart Poettering <lennart@poettering.net>
Mon, 18 Mar 2019 10:58:11 +0000 (11:58 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 18 Mar 2019 11:02:32 +0000 (12:02 +0100)
commit5d594d012da06bec9b22cac41ecea7ee77aa972b
tree8b5fedea80dfe490003e4d0592ddf9f97857727f
parentef57c69b787e8efc0d451d0e3f8c6d3b41c67a21
socket-util: add wrappers for binding socket to ifindex/ifname

socket_bind_to_ifindex() uses the the SO_BINDTOIFINDEX sockopt of kernel
5.0, with a fallback to SO_BINDTODEVICE on older kernels.

socket_bind_to_ifname() is a trivial wrapper around SO_BINDTODEVICE, the
only benefit of using it instead of SO_BINDTODEVICE directly is that it
determines the size of the interface name properly so that it also works
for unbinding. Moreover, it's an attempt to unify our invocations of the
sockopt with a size of strlen(ifname) rather than strlen(ifname)+1...
src/basic/missing_socket.h
src/basic/socket-util.c
src/basic/socket-util.h