]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/dhcp/dhcp-unicast-bootp.patch
Merge remote-tracking branch 'mfischer/python' into next
[people/pmueller/ipfire-2.x.git] / src / patches / dhcp / dhcp-unicast-bootp.patch
CommitLineData
c1e9ba67
MF
1diff -up dhcp-4.3.0a1/server/bootp.c.unicast dhcp-4.3.0a1/server/bootp.c
2--- dhcp-4.3.0a1/server/bootp.c.unicast 2013-12-11 01:25:12.000000000 +0100
3+++ dhcp-4.3.0a1/server/bootp.c 2013-12-19 15:12:12.974671154 +0100
4@@ -59,6 +59,7 @@ void bootp (packet)
78ab9b04
MT
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;
c1e9ba67 12@@ -74,7 +75,7 @@ void bootp (packet)
78ab9b04
MT
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 }
c1e9ba67
MF
21@@ -396,6 +397,15 @@ void bootp (packet)
22
78ab9b04
MT
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) {
c1e9ba67
MF
29+ result = send_packet (fallback_interface, NULL, &raw,
30+ outgoing.packet_length, from,
31+ &to, &hto);
78ab9b04
MT
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
c1e9ba67
MF
37diff -up dhcp-4.3.0a1/server/dhcp.c.unicast dhcp-4.3.0a1/server/dhcp.c
38--- dhcp-4.3.0a1/server/dhcp.c.unicast 2013-12-13 21:50:38.000000000 +0100
39+++ dhcp-4.3.0a1/server/dhcp.c 2013-12-19 15:12:12.975671140 +0100
40@@ -4627,6 +4627,7 @@ int locate_network (packet)
78ab9b04
MT
41 struct data_string data;
42 struct subnet *subnet = (struct subnet *)0;
43 struct option_cache *oc;
44+ int norelay = 0;
45
46 /* See if there's a Relay Agent Link Selection Option, or a
47 * Subnet Selection Option. The Link-Select and Subnet-Select
c1e9ba67 48@@ -4642,12 +4643,24 @@ int locate_network (packet)
78ab9b04
MT
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
77 /* If there's an option indicating link connection, and it's valid,
c1e9ba67 78@@ -4670,7 +4683,10 @@ int locate_network (packet)
78ab9b04
MT
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. */
c1e9ba67 90@@ -4678,7 +4694,10 @@ int locate_network (packet)
78ab9b04
MT
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. */