]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/dnsmasq/0108-Allow-router-advertisements-to-have-the-off-link-bit.patch
Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into next
[ipfire-2.x.git] / src / patches / dnsmasq / 0108-Allow-router-advertisements-to-have-the-off-link-bit.patch
1 From 2fd5bc952dc802433ffebc90eacb78da3d30b80e Mon Sep 17 00:00:00 2001
2 From: Neil Jerram <Neil.Jerram@metaswitch.com>
3 Date: Wed, 10 Jun 2015 22:13:06 +0100
4 Subject: [PATCH 108/113] Allow router advertisements to have the "off-link"
5 bit set.
6
7 ---
8 src/dnsmasq.h | 1 +
9 src/option.c | 2 ++
10 src/radv.c | 13 +++++++++----
11 3 files changed, 12 insertions(+), 4 deletions(-)
12
13 diff --git a/src/dnsmasq.h b/src/dnsmasq.h
14 index ab16f79b3ec9..8d005d732e72 100644
15 --- a/src/dnsmasq.h
16 +++ b/src/dnsmasq.h
17 @@ -868,6 +868,7 @@ struct dhcp_context {
18 #define CONTEXT_USED (1u<<15)
19 #define CONTEXT_OLD (1u<<16)
20 #define CONTEXT_V6 (1u<<17)
21 +#define CONTEXT_RA_OFF_LINK (1u<<18)
22
23 struct ping_result {
24 struct in_addr addr;
25 diff --git a/src/option.c b/src/option.c
26 index c7add88de7ac..f99c3f59e9d3 100644
27 --- a/src/option.c
28 +++ b/src/option.c
29 @@ -2699,6 +2699,8 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
30 new->flags |= CONTEXT_RA_ROUTER | CONTEXT_RA;
31 else if (strcmp(a[leasepos], "ra-stateless") == 0)
32 new->flags |= CONTEXT_RA_STATELESS | CONTEXT_DHCP | CONTEXT_RA;
33 + else if (strcmp(a[leasepos], "off-link") == 0)
34 + new->flags |= CONTEXT_RA_OFF_LINK;
35 else if (leasepos == 1 && inet_pton(AF_INET6, a[leasepos], &new->end6))
36 new->flags |= CONTEXT_DHCP;
37 else if (strstr(a[leasepos], "constructor:") == a[leasepos])
38 diff --git a/src/radv.c b/src/radv.c
39 index d0faddf8684a..ec22464b78b9 100644
40 --- a/src/radv.c
41 +++ b/src/radv.c
42 @@ -313,8 +313,10 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de
43 opt->type = ICMP6_OPT_PREFIX;
44 opt->len = 4;
45 opt->prefix_len = context->prefix;
46 - /* autonomous only if we're not doing dhcp, always set "on-link" */
47 - opt->flags = do_slaac ? 0xC0 : 0x80;
48 + /* autonomous only if we're not doing dhcp, set
49 + "on-link" unless "off-link" was specified */
50 + opt->flags = (do_slaac ? 0x40 : 0) |
51 + ((context->flags & CONTEXT_RA_OFF_LINK) ? 0 : 0x80);
52 opt->valid_lifetime = htonl(context->saved_valid - old);
53 opt->preferred_lifetime = htonl(0);
54 opt->reserved = 0;
55 @@ -514,6 +516,7 @@ static int add_prefixes(struct in6_addr *local, int prefix,
56 int deprecate = 0;
57 int constructed = 0;
58 int adv_router = 0;
59 + int off_link = 0;
60 unsigned int time = 0xffffffff;
61 struct dhcp_context *context;
62
63 @@ -586,6 +589,7 @@ static int add_prefixes(struct in6_addr *local, int prefix,
64 context->ra_time = 0;
65 context->flags |= CONTEXT_RA_DONE;
66 real_prefix = context->prefix;
67 + off_link = (context->flags & CONTEXT_RA_OFF_LINK);
68 }
69
70 param->first = 0;
71 @@ -636,8 +640,9 @@ static int add_prefixes(struct in6_addr *local, int prefix,
72 opt->type = ICMP6_OPT_PREFIX;
73 opt->len = 4;
74 opt->prefix_len = real_prefix;
75 - /* autonomous only if we're not doing dhcp, always set "on-link" */
76 - opt->flags = 0x80;
77 + /* autonomous only if we're not doing dhcp, set
78 + "on-link" unless "off-link" was specified */
79 + opt->flags = (off_link ? 0 : 0x80);
80 if (do_slaac)
81 opt->flags |= 0x40;
82 if (adv_router)
83 --
84 2.1.0
85