]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
ssh: optional bind interface if bind address specified.
authorDmitrii Turlupov <dturlupov@factor-ts.ru>
Thu, 4 Feb 2021 13:27:31 +0000 (16:27 +0300)
committerDamien Miller <djm@mindrot.org>
Fri, 26 Feb 2021 04:46:47 +0000 (15:46 +1100)
Allows the -b and -B options to be used together.
For example, when the interface is in the VRF.

sshconnect.c

index 74f9e76702f016bd23401f91306baa43818075d6..8666bd6edb225b18653b03179089546f810dd599 100644 (file)
@@ -390,6 +390,12 @@ ssh_create_socket(struct addrinfo *ai)
                }
                memcpy(&bindaddr, res->ai_addr, res->ai_addrlen);
                bindaddrlen = res->ai_addrlen;
+
+               /*'-B' option*/
+               if (options.bind_interface != NULL) {
+                       if (setsockopt(sock, SOL_SOCKET, SO_BINDTODEVICE, options.bind_interface, strlen(options.bind_interface) + 1))
+                               debug("error: setsockopt SO_BINDTODEVICE");
+               }
        } else if (options.bind_interface != NULL) {
 #ifdef HAVE_IFADDRS_H
                if ((r = getifaddrs(&ifaddrs)) != 0) {