Package: dnsmasq
Version: 2.41-2
Severity: normal
Tags: patch
When dnsmasq replies to DHCP requests containing a Relay Agent Information
option, it should include the Relay Agent Information in the reply.
Unfortunately, this is not the case because dnsmasq does the following:
- copy the Relay Agent info to the end of the packet
and save a pointer to it (agent_id)
- clear out the packet (in clear_packet()) until "end"
=> you lose the Relay Agent info!
- move the Relay Agent information forward in do_options()
I have managed to get things sort of working by only doing clear_packet
until "agent_id" instead of "end" when "agent_id" is non NULL (see attached
patch).
This patch is just a start, there are two remaining calls to "clear_packet"
which I did not feel comfortable with touching:
- line 439 : the subsequent call to do_options() forcibly passes NULL as
the agent_id, so it seems the Relay Agent info is discarded => why?
- line 892 : it doesn't look as though do_options() is called after the
call to clear_packet(), so it seems the Relay Agent info is not used
here => why?
Thanks for dnsmasq!
Cheers,
Jeremy
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.24-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages dnsmasq depends on:
ii adduser 3.105 add and remove users and groups
ii dnsmasq-base 2.41-2 A small caching DNS proxy and DHCP
ii netbase 4.30 Basic TCP/IP networking system
dnsmasq recommends no packages.
-- no debconf information
diff -urN dnsmasq-2.41/src/rfc2131.c dnsmasq-2.41.mod/src/rfc2131.c
--- dnsmasq-2.41/src/rfc2131.c 2008-02-12 21:36:39.000000000 +0100
+++ dnsmasq-2.41.mod/src/rfc2131.c 2008-03-27 19:41:14.000000000 +0100
@@ -750,7 +750,7 @@
}
time = calc_time(context, config, option_find(mess, sz,
OPTION_LEASE_TIME, 4));
- clear_packet(mess, end);
+ clear_packet(mess, agent_id ? agent_id : end);
option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPOFFER);
option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ,
ntohl(context->local.s_addr));
option_put(mess, end, OPTION_LEASE_TIME, 4, time);
@@ -970,7 +970,7 @@
log_packet("ACK", &mess->yiaddr, emac, emac_len, iface_name,
hostname);
- clear_packet(mess, end);
+ clear_packet(mess, agent_id ? agent_id : end);
option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPACK);
option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ,
ntohl(context->local.s_addr));
option_put(mess, end, OPTION_LEASE_TIME, 4, time);
@@ -1015,7 +1015,7 @@
netid = &context->netid;
}
- clear_packet(mess, end);
+ clear_packet(mess, agent_id ? agent_id : end);
option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPACK);
option_put(mess, end, OPTION_SERVER_IDENTIFIER, INADDRSZ,
ntohl(context->local.s_addr));