From 806cf78797bfe912a4912fd035d4f5eeb3d46718 Mon Sep 17 00:00:00 2001 From: Simon Kelley Date: Mon, 14 Oct 2013 14:08:44 +0100 Subject: [PATCH] Better defaults for address and lifetime of RDNS option in RA. --- src/radv.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/radv.c b/src/radv.c index 8e0a730..88395db 100644 --- a/src/radv.c +++ b/src/radv.c @@ -336,15 +336,15 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de if (opt_cfg->opt == OPTION6_DNS_SERVER) { struct in6_addr *a = (struct in6_addr *)opt_cfg->val; - + done_dns = 1; - if (opt_cfg->len == 0) - continue; + if (opt_cfg->len == 0 || (IN6_IS_ADDR_UNSPECIFIED(a) && parm.pref_time != 0)) + continue; put_opt6_char(ICMP6_OPT_RDNSS); put_opt6_char((opt_cfg->len/8) + 1); put_opt6_short(0); - put_opt6_long(parm.adv_interval * 2); /* lifetime - twice RA retransmit */ + put_opt6_long(parm.pref_time); /* zero means "self" */ for (i = 0; i < opt_cfg->len; i += IN6ADDRSZ, a++) if (IN6_IS_ADDR_UNSPECIFIED(a)) @@ -360,7 +360,7 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de put_opt6_char(ICMP6_OPT_DNSSL); put_opt6_char(len + 1); put_opt6_short(0); - put_opt6_long(parm.adv_interval * 2); /* lifetime - twice RA retransmit */ + put_opt6_long(parm.pref_time); put_opt6(opt_cfg->val, opt_cfg->len); /* pad */ @@ -369,14 +369,14 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de } } - if (daemon->port == NAMESERVER_PORT && !done_dns) + if (daemon->port == NAMESERVER_PORT && !done_dns && parm.pref_time != 0) { /* default == us, as long as we are supplying DNS service. */ put_opt6_char(ICMP6_OPT_RDNSS); put_opt6_char(3); put_opt6_short(0); - put_opt6_long(parm.adv_interval * 2); /* lifetime - twice RA retransmit */ - put_opt6(&parm.link_global, IN6ADDRSZ); + put_opt6_long(parm.pref_time); + put_opt6(&parm.link_local, IN6ADDRSZ); } /* set managed bits unless we're providing only RA on this link */