9c49c9
From 193c4d7631fd623efa601f52fdab6018bf8be771 Mon Sep 17 00:00:00 2001
7c0972
From: Pavel Zhukov <pzhukov@redhat.com>
7c0972
Date: Thu, 21 Feb 2019 10:39:36 +0100
9c49c9
Subject: [PATCH 17/26] Send unicast request/release via correct interface
7c0972
Cc: pzhukov@redhat.com
7c0972
7c0972
(#800561, #1177351)
7c0972
(Submitted to dhcp-bugs@isc.org - [ISC-Bugs #30544])
7c0972
---
7c0972
 client/dhclient.c | 30 ++++++++++++++++++++++++++++++
7c0972
 1 file changed, 30 insertions(+)
7c0972
7c0972
diff --git a/client/dhclient.c b/client/dhclient.c
7c0972
index ccc98e4..27fde69 100644
7c0972
--- a/client/dhclient.c
7c0972
+++ b/client/dhclient.c
7c0972
@@ -3171,6 +3171,14 @@ void send_request (cpp)
8173a6
 #endif
8e6888
 	if (destination.sin_addr.s_addr != INADDR_BROADCAST &&
8e6888
 	    fallback_interface) {
8e6888
+#if defined(SO_BINDTODEVICE)
8e6888
+		if (setsockopt(fallback_interface -> wfdesc, SOL_SOCKET,
8e6888
+			       SO_BINDTODEVICE, client->interface->name,
8e6888
+			       strlen(client->interface->name)) < 0) {
8e6888
+			log_error("%s:%d: Failed to bind fallback interface"
8e6888
+				  " to %s: %m", MDL, client->interface->name);
8e6888
+		}
8e6888
+#endif
8e6888
 		result = send_packet(fallback_interface, NULL, &client->packet,
8e6888
 				     client->packet_length, from, &destination,
8e6888
 				     NULL);
7c0972
@@ -3180,6 +3188,13 @@ void send_request (cpp)
8e6888
 				  client->packet_length,
8e6888
 				  fallback_interface->name);
8e6888
 		}
8e6888
+#if defined(SO_BINDTODEVICE)
8e6888
+		if (setsockopt(fallback_interface -> wfdesc, SOL_SOCKET,
8e6888
+			       SO_BINDTODEVICE, NULL, 0) < 0) {
8e6888
+			log_fatal("%s:%d: Failed to unbind fallback interface:"
8e6888
+				  " %m", MDL);
8e6888
+		}
8e6888
+#endif
8e6888
         }
8e6888
 	else {
8e6888
 		/* Send out a packet. */
7c0972
@@ -3297,6 +3312,14 @@ void send_release (cpp)
8173a6
 	} else
8173a6
 #endif
8e6888
 	if (fallback_interface) {
8e6888
+#if defined(SO_BINDTODEVICE)
8e6888
+		if (setsockopt(fallback_interface -> wfdesc, SOL_SOCKET,
8e6888
+			       SO_BINDTODEVICE, client->interface->name,
8e6888
+			       strlen(client->interface->name)) < 0) {
8e6888
+			log_error("%s:%d: Failed to bind fallback interface"
8e6888
+				  " to %s: %m", MDL, client->interface->name);
8e6888
+		}
8e6888
+#endif
8e6888
 		result = send_packet(fallback_interface, NULL, &client->packet,
8e6888
 				      client->packet_length, from, &destination,
8e6888
 				      NULL);
7c0972
@@ -3306,6 +3329,13 @@ void send_release (cpp)
8e6888
 				  client->packet_length,
8e6888
 				  fallback_interface->name);
8e6888
 		}
8e6888
+#if defined(SO_BINDTODEVICE)
8e6888
+		if (setsockopt(fallback_interface -> wfdesc, SOL_SOCKET,
8e6888
+			       SO_BINDTODEVICE, NULL, 0) < 0) {
8e6888
+			log_fatal("%s:%d: Failed to unbind fallback interface:"
8e6888
+				  " %m", MDL);
8e6888
+		}
8e6888
+#endif
8e6888
         } else {
8e6888
 		/* Send out a packet. */
8e6888
 		result = send_packet(client->interface, NULL, &client->packet,
7c0972
-- 
7c0972
2.14.5
7c0972