8173a6
diff -up dhcp-4.3.4/client/dhclient.c.bind-iface dhcp-4.3.4/client/dhclient.c
8173a6
--- dhcp-4.3.4/client/dhclient.c.bind-iface	2016-04-29 13:06:50.595257108 +0200
8173a6
+++ dhcp-4.3.4/client/dhclient.c	2016-04-29 13:08:30.237281528 +0200
8173a6
@@ -3023,6 +3023,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);
8173a6
@@ -3032,6 +3040,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. */
8173a6
@@ -3144,6 +3159,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);
8173a6
@@ -3153,6 +3176,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,