]> git.ipfire.org Git - people/dweismueller/ipfire-2.x.git/blame - src/patches/dnsmasq/006-Fix_for_DHCP_in_transmission_interface_when_--bridge-interface_in_use.patch
dnsmasq: Update to 2.76test13 with latest patches (001-006)
[people/dweismueller/ipfire-2.x.git] / src / patches / dnsmasq / 006-Fix_for_DHCP_in_transmission_interface_when_--bridge-interface_in_use.patch
CommitLineData
4d36732f
MF
1From ff325644c7afae2588583f935f4ea9b9694eb52e Mon Sep 17 00:00:00 2001
2From: Neil Jerram <Neil.Jerram@metaswitch.com>
3Date: Tue, 3 May 2016 22:45:14 +0100
4Subject: [PATCH] Fix for DHCP in transmission interface when
5 --bridge-interface in use.
6
7From f3d832b41f44c856003517c583fbd7af4dca722c Mon Sep 17 00:00:00 2001
8From: Neil Jerram <Neil.Jerram@metaswitch.com>
9Date: Fri, 8 Apr 2016 19:23:47 +0100
10Subject: [PATCH] Fix DHCPv4 reply via --bridge-interface alias interface
11
12Sending a DHCPv4 reply through a --bridge-interface alias interface
13was inadvertently broken by
14
15 commit 65c721200023ef0023114459a8d12f8b0a24cfd8
16 Author: Lung-Pin Chang <changlp@cs.nctu.edu.tw>
17 Date: Thu Mar 19 23:22:21 2015 +0000
18
19 dhcp: set outbound interface via cmsg in unicast reply
20
21 If multiple routes to the same network exist, Linux blindly picks
22 the first interface (route) based on destination address, which might not be
23 the one we're actually offering leases. Rather than relying on this,
24 always set the interface for outgoing unicast DHCP packets.
25
26because in the aliasing case, iface_index is changed from the index of
27the interface on which the packet was received, to be the interface
28index of the 'bridge' interface (where the DHCP context is expected to
29be defined, and so needs to be looked up).
30
31For the cmsg code that the cited commit added, we need the original
32iface_index; so this commit saves that off before the aliasing code
33can change it, as rcvd_iface_index, and then uses rcvd_iface_index
34instead of iface_index for the cmsg code.
35---
36 src/dhcp.c | 4 +++-
37 1 file changed, 3 insertions(+), 1 deletion(-)
38
39diff --git a/src/dhcp.c b/src/dhcp.c
40index 00145bc..10f1fb9 100644
41--- a/src/dhcp.c
42+++ b/src/dhcp.c
43@@ -146,6 +146,7 @@ void dhcp_packet(time_t now, int pxe_fd)
44 struct iovec iov;
45 ssize_t sz;
46 int iface_index = 0, unicast_dest = 0, is_inform = 0;
47+ int rcvd_iface_index;
48 struct in_addr iface_addr;
49 struct iface_param parm;
50 #ifdef HAVE_LINUX_NETWORK
51@@ -230,6 +231,7 @@ void dhcp_packet(time_t now, int pxe_fd)
52 --bridge-interface option), change ifr.ifr_name so that we look
53 for DHCP contexts associated with the aliased interface instead
54 of with the aliasing one. */
55+ rcvd_iface_index = iface_index;
56 for (bridge = daemon->bridges; bridge; bridge = bridge->next)
57 {
58 for (alias = bridge->alias; alias; alias = alias->next)
59@@ -387,7 +389,7 @@ void dhcp_packet(time_t now, int pxe_fd)
60 msg.msg_controllen = sizeof(control_u);
61 cmptr = CMSG_FIRSTHDR(&msg);
62 pkt = (struct in_pktinfo *)CMSG_DATA(cmptr);
63- pkt->ipi_ifindex = iface_index;
64+ pkt->ipi_ifindex = rcvd_iface_index;
65 pkt->ipi_spec_dst.s_addr = 0;
66 msg.msg_controllen = cmptr->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
67 cmptr->cmsg_level = IPPROTO_IP;
68--
692.5.5
70