From ddbbc98bd549dbb61ac9ea2e847890cc07e48120 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Sat, 29 Mar 2025 21:29:26 +0100 Subject: [PATCH] socket-util: drop SO_BINDTODEVICE fallback in socket_bind_to_ifindex() Our baseline is v5.4 now. --- src/basic/socket-util.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 9190072f4e2..c095168ed19 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -1445,25 +1445,13 @@ int socket_bind_to_ifname(int fd, const char *ifname) { } int socket_bind_to_ifindex(int fd, int ifindex) { - char ifname[IF_NAMESIZE]; - int r; - assert(fd >= 0); if (ifindex <= 0) /* Drop binding */ return RET_NERRNO(setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, NULL, 0)); - r = setsockopt_int(fd, SOL_SOCKET, SO_BINDTOIFINDEX, ifindex); - if (r != -ENOPROTOOPT) - return r; - - /* Fall back to SO_BINDTODEVICE on kernels < 5.0 which didn't have SO_BINDTOIFINDEX */ - r = format_ifname(ifindex, ifname); - if (r < 0) - return r; - - return socket_bind_to_ifname(fd, ifname); + return setsockopt_int(fd, SOL_SOCKET, SO_BINDTOIFINDEX, ifindex); } ssize_t recvmsg_safe(int sockfd, struct msghdr *msg, int flags) { -- 2.47.3