]> git.pld-linux.org Git - packages/dhcp.git/blame - dhcp-unicast-bootp.patch
unit files missed in previous commit
[packages/dhcp.git] / dhcp-unicast-bootp.patch
CommitLineData
19507c9d
AM
1diff -up dhcp-4.3.4/server/bootp.c.unicast dhcp-4.3.4/server/bootp.c
2--- dhcp-4.3.4/server/bootp.c.unicast 2016-03-22 14:16:51.000000000 +0100
3+++ dhcp-4.3.4/server/bootp.c 2016-05-02 15:09:40.023243008 +0200
4@@ -52,6 +52,7 @@ void bootp (packet)
8c878a4c
ER
5 char msgbuf [1024];
6 int ignorep;
7 int peer_has_leases = 0;
8+ int norelay = 0;
9
10 if (packet -> raw -> op != BOOTREQUEST)
11 return;
19507c9d 12@@ -67,7 +68,7 @@ void bootp (packet)
8c878a4c
ER
13 ? inet_ntoa (packet -> raw -> giaddr)
14 : packet -> interface -> name);
15
16- if (!locate_network (packet)) {
17+ if ((norelay = locate_network (packet)) == 0) {
18 log_info ("%s: network unknown", msgbuf);
19 return;
20 }
19507c9d
AM
21@@ -428,6 +429,15 @@ void bootp (packet)
22
8c878a4c
ER
23 goto out;
24 }
25+ } else if (norelay == 2) {
26+ to.sin_addr = raw.ciaddr;
27+ to.sin_port = remote_port;
28+ if (fallback_interface) {
19507c9d
AM
29+ result = send_packet (fallback_interface, NULL, &raw,
30+ outgoing.packet_length, from,
31+ &to, &hto);
8c878a4c
ER
32+ goto out;
33+ }
34
35 /* If it comes from a client that already knows its address
36 and is not requesting a broadcast response, and we can
19507c9d
AM
37diff -up dhcp-4.3.4/server/dhcp.c.unicast dhcp-4.3.4/server/dhcp.c
38--- dhcp-4.3.4/server/dhcp.c.unicast 2016-03-22 14:16:51.000000000 +0100
39+++ dhcp-4.3.4/server/dhcp.c 2016-05-02 15:10:13.255267511 +0200
40@@ -5132,6 +5132,7 @@ int locate_network (packet)
8c878a4c
ER
41 struct data_string data;
42 struct subnet *subnet = (struct subnet *)0;
43 struct option_cache *oc;
44+ int norelay = 0;
45
19507c9d
AM
46 #if defined(DHCPv6) && defined(DHCP4o6)
47 if (dhcpv4_over_dhcpv6 && (packet->dhcp4o6_response != NULL)) {
48@@ -5153,12 +5154,24 @@ int locate_network (packet)
8c878a4c
ER
49 from the interface, if there is one. If not, fail. */
50 if (!oc && !packet -> raw -> giaddr.s_addr) {
51 if (packet -> interface -> shared_network) {
52- shared_network_reference
53- (&packet -> shared_network,
54- packet -> interface -> shared_network, MDL);
55- return 1;
56+ struct in_addr any_addr;
57+ any_addr.s_addr = INADDR_ANY;
58+
59+ if (!packet -> packet_type && memcmp(&packet -> raw -> ciaddr, &any_addr, 4)) {
60+ struct iaddr cip;
61+ memcpy(cip.iabuf, &packet -> raw -> ciaddr, 4);
62+ cip.len = 4;
63+ if (!find_grouped_subnet(&subnet, packet->interface->shared_network, cip, MDL))
64+ norelay = 2;
65+ }
66+
67+ if (!norelay) {
68+ shared_network_reference(&packet -> shared_network, packet -> interface -> shared_network, MDL);
69+ return 1;
70+ }
71+ } else {
72+ return 0;
73 }
74- return 0;
75 }
76
19507c9d
AM
77 /* If there's an option indicating link connection, and it's valid,
78@@ -5185,7 +5198,10 @@ int locate_network (packet)
8c878a4c
ER
79 data_string_forget (&data, MDL);
80 } else {
81 ia.len = 4;
82- memcpy (ia.iabuf, &packet -> raw -> giaddr, 4);
83+ if (norelay)
84+ memcpy (ia.iabuf, &packet->raw->ciaddr, 4);
85+ else
86+ memcpy (ia.iabuf, &packet->raw->giaddr, 4);
87 }
88
89 /* If we know the subnet on which the IP address lives, use it. */
19507c9d 90@@ -5193,7 +5209,10 @@ int locate_network (packet)
8c878a4c
ER
91 shared_network_reference (&packet -> shared_network,
92 subnet -> shared_network, MDL);
93 subnet_dereference (&subnet, MDL);
94- return 1;
95+ if (norelay)
96+ return norelay;
97+ else
98+ return 1;
99 }
100
101 /* Otherwise, fail. */
This page took 0.417301 seconds and 4 git commands to generate.