[Dnsmasq-discuss] rfc3527 support

Takayuki Kaiso tkaiso2 at thinktube.com
Sat Apr 30 12:16:40 BST 2011


Hi,

I needed to apply the following patch to work with decp relay which is using
rfc3527 link selection sub option.

As far as I looked around dhcp.c, complete_context() failed to locate the
target context because parm.relay is set to be mess->giaddr even though
we should use the subnet address specified in link-selection sub option.

I think we also need to do the similar thing also for rfc3011 handling,
and I will take care of it if I get review on this patch by any of you.

Thank you
Takayuki kaiso

P.S. I forgot to remove my debugging line (syslog) from th patch. sorry.


diff -ru a/src/dhcp.c b/src/dhcp.c
--- a/src/dhcp.c 2011-02-18 00:30:15.000000000 +0900
+++ b/src/dhcp.c 2011-04-30 19:55:50.999706223 +0900
@@ -274,6 +274,16 @@
parm.current = NULL;
parm.ind = iface_index;

+ /* look for RFC3527 Link selection sub-option */
+ struct in_addr subnet_addr;
+
+ if ( chcek_rfc3527_link_selection(mess,sz, &subnet_addr ) )
+ {
+ /* For rfc3527, giaddr can not be used to find the context, rather use
the subnet info set by the relay */
+ /* Presumably, we need to do same stuff for rfc3011 */
+ parm.relay = subnet_addr;
+ }
+
/* interface may have been changed by alias in iface_check, make sure it
gets priority in case
there is more than one address on the interface in the same subnet */
if (ioctl(daemon->dhcpfd, SIOCGIFADDR, &ifr) == -1)

diff -ru a/src/dnsmasq.h b/src/dnsmasq.h
--- a/src/dnsmasq.h 2011-02-18 00:30:15.000000000 +0900
+++ b/src/dnsmasq.h 2011-04-30 19:56:11.619706224 +0900
@@ -887,6 +887,7 @@
size_t sz, time_t now, int unicast_dest, int *is_inform, int pxe_fd);
unsigned char *extended_hwaddr(int hwtype, int hwlen, unsigned char
*hwaddr,
int clid_len, unsigned char *clid, int *len_out);
+int chcek_rfc3527_link_selection(struct dhcp_packet *mess, size_t sz,
struct in_addr *subnet_addr );
#endif

/* dnsmasq.c */

diff -ru a/src/rfc2131.c b/src/rfc2131.c
--- a/src/rfc2131.c 2011-02-18 00:30:15.000000000 +0900
+++ b/src/rfc2131.c 2011-04-30 19:55:38.195706224 +0900
@@ -65,7 +65,28 @@
static struct dhcp_opt *pxe_opts(int pxe_arch, struct dhcp_netid *netid,
struct in_addr local);
struct dhcp_boot *find_boot(struct dhcp_netid *netid);

+int chcek_rfc3527_link_selection(struct dhcp_packet *mess, size_t sz,
struct in_addr *subnet_addr )
+{
+ unsigned char *opt;
+ unsigned char *sopt;
+ struct in_addr addr;

+ if ((opt = option_find(mess, sz, OPTION_AGENT_ID, 1)))
+ {
+ /* look for RFC3527 Link selection sub-option */
+ if ((sopt = option_find1(option_ptr(opt, 0), option_ptr(opt,
option_len(opt)), SUBOPT_SUBNET_SELECT, INADDRSZ)))
+ {
+ addr = option_addr(sopt);
+ /***** THINKTUBE ****/
+ my_syslog(MS_DHCP | LOG_INFO, _("@@ rfc3527 check @@ subnet_addr=%s
\n"), inet_ntoa(addr)) ;
+
+ *subnet_addr = addr ;
+ return 1;
+ }
+ }
+ return 0;
+}
+
size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int
int_index,
size_t sz, time_t now, int unicast_dest, int *is_inform, int pxe)
{




More information about the Dnsmasq-discuss mailing list