|
|
324fcf |
diff -up dhcp-4.3.4/server/bootp.c.unicast dhcp-4.3.4/server/bootp.c
|
|
|
324fcf |
--- dhcp-4.3.4/server/bootp.c.unicast 2016-03-22 14:16:51.000000000 +0100
|
|
|
324fcf |
+++ dhcp-4.3.4/server/bootp.c 2016-05-02 15:09:40.023243008 +0200
|
|
|
324fcf |
@@ -52,6 +52,7 @@ void bootp (packet)
|
|
|
324fcf |
char msgbuf [1024];
|
|
|
324fcf |
int ignorep;
|
|
|
324fcf |
int peer_has_leases = 0;
|
|
|
324fcf |
+ int norelay = 0;
|
|
|
324fcf |
|
|
|
324fcf |
if (packet -> raw -> op != BOOTREQUEST)
|
|
|
324fcf |
return;
|
|
|
324fcf |
@@ -67,7 +68,7 @@ void bootp (packet)
|
|
|
324fcf |
? inet_ntoa (packet -> raw -> giaddr)
|
|
|
324fcf |
: packet -> interface -> name);
|
|
|
324fcf |
|
|
|
324fcf |
- if (!locate_network (packet)) {
|
|
|
324fcf |
+ if ((norelay = locate_network (packet)) == 0) {
|
|
|
324fcf |
log_info ("%s: network unknown", msgbuf);
|
|
|
324fcf |
return;
|
|
|
324fcf |
}
|
|
|
324fcf |
@@ -428,6 +429,15 @@ void bootp (packet)
|
|
|
324fcf |
|
|
|
324fcf |
goto out;
|
|
|
324fcf |
}
|
|
|
324fcf |
+ } else if (norelay == 2) {
|
|
|
324fcf |
+ to.sin_addr = raw.ciaddr;
|
|
|
324fcf |
+ to.sin_port = remote_port;
|
|
|
324fcf |
+ if (fallback_interface) {
|
|
|
324fcf |
+ result = send_packet (fallback_interface, NULL, &raw,
|
|
|
324fcf |
+ outgoing.packet_length, from,
|
|
|
324fcf |
+ &to, &hto);
|
|
|
324fcf |
+ goto out;
|
|
|
324fcf |
+ }
|
|
|
324fcf |
|
|
|
324fcf |
/* If it comes from a client that already knows its address
|
|
|
324fcf |
and is not requesting a broadcast response, and we can
|
|
|
324fcf |
diff -up dhcp-4.3.4/server/dhcp.c.unicast dhcp-4.3.4/server/dhcp.c
|
|
|
324fcf |
--- dhcp-4.3.4/server/dhcp.c.unicast 2016-03-22 14:16:51.000000000 +0100
|
|
|
324fcf |
+++ dhcp-4.3.4/server/dhcp.c 2016-05-02 15:10:13.255267511 +0200
|
|
|
324fcf |
@@ -5132,6 +5132,7 @@ int locate_network (packet)
|
|
|
324fcf |
struct data_string data;
|
|
|
324fcf |
struct subnet *subnet = (struct subnet *)0;
|
|
|
324fcf |
struct option_cache *oc;
|
|
|
324fcf |
+ int norelay = 0;
|
|
|
324fcf |
|
|
|
324fcf |
#if defined(DHCPv6) && defined(DHCP4o6)
|
|
|
324fcf |
if (dhcpv4_over_dhcpv6 && (packet->dhcp4o6_response != NULL)) {
|
|
|
324fcf |
@@ -5153,12 +5154,24 @@ int locate_network (packet)
|
|
|
324fcf |
from the interface, if there is one. If not, fail. */
|
|
|
324fcf |
if (!oc && !packet -> raw -> giaddr.s_addr) {
|
|
|
324fcf |
if (packet -> interface -> shared_network) {
|
|
|
324fcf |
- shared_network_reference
|
|
|
324fcf |
- (&packet -> shared_network,
|
|
|
324fcf |
- packet -> interface -> shared_network, MDL);
|
|
|
324fcf |
- return 1;
|
|
|
324fcf |
+ struct in_addr any_addr;
|
|
|
324fcf |
+ any_addr.s_addr = INADDR_ANY;
|
|
|
324fcf |
+
|
|
|
324fcf |
+ if (!packet -> packet_type && memcmp(&packet -> raw -> ciaddr, &any_addr, 4)) {
|
|
|
324fcf |
+ struct iaddr cip;
|
|
|
324fcf |
+ memcpy(cip.iabuf, &packet -> raw -> ciaddr, 4);
|
|
|
324fcf |
+ cip.len = 4;
|
|
|
324fcf |
+ if (!find_grouped_subnet(&subnet, packet->interface->shared_network, cip, MDL))
|
|
|
324fcf |
+ norelay = 2;
|
|
|
324fcf |
+ }
|
|
|
324fcf |
+
|
|
|
324fcf |
+ if (!norelay) {
|
|
|
324fcf |
+ shared_network_reference(&packet -> shared_network, packet -> interface -> shared_network, MDL);
|
|
|
324fcf |
+ return 1;
|
|
|
324fcf |
+ }
|
|
|
324fcf |
+ } else {
|
|
|
324fcf |
+ return 0;
|
|
|
324fcf |
}
|
|
|
324fcf |
- return 0;
|
|
|
324fcf |
}
|
|
|
324fcf |
|
|
|
324fcf |
/* If there's an option indicating link connection, and it's valid,
|
|
|
324fcf |
@@ -5185,7 +5198,10 @@ int locate_network (packet)
|
|
|
324fcf |
data_string_forget (&data, MDL);
|
|
|
324fcf |
} else {
|
|
|
324fcf |
ia.len = 4;
|
|
|
324fcf |
- memcpy (ia.iabuf, &packet -> raw -> giaddr, 4);
|
|
|
324fcf |
+ if (norelay)
|
|
|
324fcf |
+ memcpy (ia.iabuf, &packet->raw->ciaddr, 4);
|
|
|
324fcf |
+ else
|
|
|
324fcf |
+ memcpy (ia.iabuf, &packet->raw->giaddr, 4);
|
|
|
324fcf |
}
|
|
|
324fcf |
|
|
|
324fcf |
/* If we know the subnet on which the IP address lives, use it. */
|
|
|
324fcf |
@@ -5193,7 +5209,10 @@ int locate_network (packet)
|
|
|
324fcf |
shared_network_reference (&packet -> shared_network,
|
|
|
324fcf |
subnet -> shared_network, MDL);
|
|
|
324fcf |
subnet_dereference (&subnet, MDL);
|
|
|
324fcf |
- return 1;
|
|
|
324fcf |
+ if (norelay)
|
|
|
324fcf |
+ return norelay;
|
|
|
324fcf |
+ else
|
|
|
324fcf |
+ return 1;
|
|
|
324fcf |
}
|
|
|
324fcf |
|
|
|
324fcf |
/* Otherwise, fail. */
|