summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitrii Turlupov <dturlupov@factor-ts.ru>2021-02-04 16:27:31 +0300
committerDamien Miller <djm@mindrot.org>2021-02-26 15:46:47 +1100
commit5a878a71a3528c2626aa1d331934fd964782d41c (patch)
tree97230ee037f8e74e894dd3c4c39574d0f2ed2d23
parent1fe4d70df94d3bcc2b35fd57cad6b5fc4b2d7b16 (diff)
ssh: optional bind interface if bind address specified.
Allows the -b and -B options to be used together. For example, when the interface is in the VRF.
-rw-r--r--sshconnect.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sshconnect.c b/sshconnect.c
index 74f9e767..8666bd6e 100644
--- a/sshconnect.c
+++ b/sshconnect.c
@@ -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) {