1 diff -up dhcp-4.2.0/server/bootp.c.unicast dhcp-4.2.0/server/bootp.c
2 --- dhcp-4.2.0/server/bootp.c.unicast 2009-11-20 02:49:03.000000000 +0100
3 +++ dhcp-4.2.0/server/bootp.c 2010-07-21 13:40:25.000000000 +0200
4 @@ -58,6 +58,7 @@ void bootp (packet)
7 int peer_has_leases = 0;
10 if (packet -> raw -> op != BOOTREQUEST)
12 @@ -73,7 +74,7 @@ void bootp (packet)
13 ? inet_ntoa (packet -> raw -> giaddr)
14 : packet -> interface -> name);
16 - if (!locate_network (packet)) {
17 + if ((norelay = locate_network (packet)) == 0) {
18 log_info ("%s: network unknown", msgbuf);
21 @@ -390,6 +391,13 @@ void bootp (packet)
25 + } else if (norelay == 2) {
26 + to.sin_addr = raw.ciaddr;
27 + to.sin_port = remote_port;
28 + if (fallback_interface) {
29 + result = send_packet (fallback_interface, (struct packet *)0, &raw, outgoing.packet_length, from, &to, &hto);
33 /* If it comes from a client that already knows its address
34 and is not requesting a broadcast response, and we can
35 diff -up dhcp-4.2.0/server/dhcp.c.unicast dhcp-4.2.0/server/dhcp.c
36 --- dhcp-4.2.0/server/dhcp.c.unicast 2010-06-01 19:29:59.000000000 +0200
37 +++ dhcp-4.2.0/server/dhcp.c 2010-07-21 13:40:25.000000000 +0200
38 @@ -4185,6 +4185,7 @@ int locate_network (packet)
39 struct data_string data;
40 struct subnet *subnet = (struct subnet *)0;
41 struct option_cache *oc;
44 /* See if there's a Relay Agent Link Selection Option, or a
45 * Subnet Selection Option. The Link-Select and Subnet-Select
46 @@ -4200,12 +4201,24 @@ int locate_network (packet)
47 from the interface, if there is one. If not, fail. */
48 if (!oc && !packet -> raw -> giaddr.s_addr) {
49 if (packet -> interface -> shared_network) {
50 - shared_network_reference
51 - (&packet -> shared_network,
52 - packet -> interface -> shared_network, MDL);
54 + struct in_addr any_addr;
55 + any_addr.s_addr = INADDR_ANY;
57 + if (!packet -> packet_type && memcmp(&packet -> raw -> ciaddr, &any_addr, 4)) {
59 + memcpy(cip.iabuf, &packet -> raw -> ciaddr, 4);
61 + if (!find_grouped_subnet(&subnet, packet->interface->shared_network, cip, MDL))
66 + shared_network_reference(&packet -> shared_network, packet -> interface -> shared_network, MDL);
75 /* If there's an option indicating link connection, and it's valid,
76 @@ -4228,7 +4241,10 @@ int locate_network (packet)
77 data_string_forget (&data, MDL);
80 - memcpy (ia.iabuf, &packet -> raw -> giaddr, 4);
82 + memcpy (ia.iabuf, &packet->raw->ciaddr, 4);
84 + memcpy (ia.iabuf, &packet->raw->giaddr, 4);
87 /* If we know the subnet on which the IP address lives, use it. */
88 @@ -4236,7 +4252,10 @@ int locate_network (packet)
89 shared_network_reference (&packet -> shared_network,
90 subnet -> shared_network, MDL);
91 subnet_dereference (&subnet, MDL);
99 /* Otherwise, fail. */