Skip to content

use SO_BINDTOIFINDEX where appropriate - #12024

Merged
keszybz merged 2 commits into
systemd:masterfrom
poettering:bindtoifindex
Mar 20, 2019
Merged

keszybz merged 2 commits into
systemd:masterfrom
poettering:bindtoifindex

Conversation

@poettering

Copy link
Copy Markdown
Member

Let's use the new 5.0 kernel feature where appropriate.

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...
@keszybz

keszybz commented Mar 20, 2019

Copy link
Copy Markdown
Member

Nice!

@keszybz
keszybz merged commit 45ce112 into systemd:master Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants