]> git.ipfire.org Git - people/ms/dnsmasq.git/commitdiff
Allow router advertisements to have the "off-link" bit set.
authorNeil Jerram <Neil.Jerram@metaswitch.com>
Wed, 10 Jun 2015 21:13:06 +0000 (22:13 +0100)
committerSimon Kelley <simon@thekelleys.org.uk>
Wed, 10 Jun 2015 21:13:06 +0000 (22:13 +0100)
src/dnsmasq.h
src/option.c
src/radv.c

index ab16f79b3ec98cddf5896dc823ecd46152e025b8..8d005d732e72a1768fc0a2eec30475ad20c16cca 100644 (file)
@@ -868,6 +868,7 @@ struct dhcp_context {
 #define CONTEXT_USED           (1u<<15)
 #define CONTEXT_OLD            (1u<<16)
 #define CONTEXT_V6             (1u<<17)
+#define CONTEXT_RA_OFF_LINK    (1u<<18)
 
 struct ping_result {
   struct in_addr addr;
index c7add88de7ac8a1f77667edcc27182b2381f6e0c..f99c3f59e9d37ba9eb7584df3ca5379bc62c173e 100644 (file)
@@ -2699,6 +2699,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
                  new->flags |= CONTEXT_RA_ROUTER | CONTEXT_RA;
                else if (strcmp(a[leasepos], "ra-stateless") == 0)
                  new->flags |= CONTEXT_RA_STATELESS | CONTEXT_DHCP | CONTEXT_RA;
+               else if (strcmp(a[leasepos], "off-link") == 0)
+                 new->flags |= CONTEXT_RA_OFF_LINK;
                else if (leasepos == 1 && inet_pton(AF_INET6, a[leasepos], &new->end6))
                  new->flags |= CONTEXT_DHCP; 
                else if (strstr(a[leasepos], "constructor:") == a[leasepos])
index d0faddf8684a0e7792fe2387cb3d82557c40eb49..ec22464b78b94438782111697aac8cec8156e9e2 100644 (file)
@@ -313,8 +313,10 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de
                  opt->type = ICMP6_OPT_PREFIX;
                  opt->len = 4;
                  opt->prefix_len = context->prefix;
-                 /* autonomous only if we're not doing dhcp, always set "on-link" */
-                 opt->flags = do_slaac ? 0xC0 : 0x80;
+                 /* autonomous only if we're not doing dhcp, set
+                     "on-link" unless "off-link" was specified */
+                 opt->flags = (do_slaac ? 0x40 : 0) |
+                    ((context->flags & CONTEXT_RA_OFF_LINK) ? 0 : 0x80);
                  opt->valid_lifetime = htonl(context->saved_valid - old);
                  opt->preferred_lifetime = htonl(0);
                  opt->reserved = 0; 
@@ -514,6 +516,7 @@ static int add_prefixes(struct in6_addr *local,  int prefix,
          int deprecate  = 0;
          int constructed = 0;
          int adv_router = 0;
+         int off_link = 0;
          unsigned int time = 0xffffffff;
          struct dhcp_context *context;
          
@@ -586,6 +589,7 @@ static int add_prefixes(struct in6_addr *local,  int prefix,
                      context->ra_time = 0;
                    context->flags |= CONTEXT_RA_DONE;
                    real_prefix = context->prefix;
+                    off_link = (context->flags & CONTEXT_RA_OFF_LINK);
                  }
 
                param->first = 0;       
@@ -636,8 +640,9 @@ static int add_prefixes(struct in6_addr *local,  int prefix,
                  opt->type = ICMP6_OPT_PREFIX;
                  opt->len = 4;
                  opt->prefix_len = real_prefix;
-                 /* autonomous only if we're not doing dhcp, always set "on-link" */
-                 opt->flags = 0x80;
+                 /* autonomous only if we're not doing dhcp, set
+                     "on-link" unless "off-link" was specified */
+                 opt->flags = (off_link ? 0 : 0x80);
                  if (do_slaac)
                    opt->flags |= 0x40;
                  if (adv_router)