]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/dnsmasq/015-Handle_v4-mapped_IPv6_addresses_sanely_for_--synth-domain.patch
BUG11177: pppoe password not required anymore
[ipfire-2.x.git] / src / patches / dnsmasq / 015-Handle_v4-mapped_IPv6_addresses_sanely_for_--synth-domain.patch
1 From 6d95099c56a926d672e0407d6017fef9714f40c4 Mon Sep 17 00:00:00 2001
2 From: Simon Kelley <simon@thekelleys.org.uk>
3 Date: Thu, 11 Aug 2016 23:38:54 +0100
4 Subject: [PATCH] Handle v4-mapped IPv6 addresses sanely for --synth-domain.
5
6 ---
7 CHANGELOG | 7 ++++++-
8 man/dnsmasq.8 | 2 ++
9 src/domain.c | 34 ++++++++++++++++++++++++----------
10 3 files changed, 32 insertions(+), 11 deletions(-)
11
12 diff --git a/CHANGELOG b/CHANGELOG
13 index 4f89799..2731cc4 100644
14 --- a/CHANGELOG
15 +++ b/CHANGELOG
16 @@ -24,7 +24,12 @@ version 2.77
17 Bump zone serial on reloading /etc/hosts and friends
18 when providing authoritative DNS. Thanks to Harrald
19 Dunkel for spotting this.
20 -
21 +
22 + Handle v4-mapped IPv6 addresses sanely in --synth-domain.
23 + These have standard representation like ::ffff:1.2.3.4
24 + and are now converted to names like
25 + <prefix>--ffff-1-2-3-4.<domain>
26 +
27
28 version 2.76
29 Include 0.0.0.0/8 in DNS rebind checks. This range
30 diff --git a/man/dnsmasq.8 b/man/dnsmasq.8
31 index 8910947..91fe672 100644
32 --- a/man/dnsmasq.8
33 +++ b/man/dnsmasq.8
34 @@ -619,6 +619,8 @@ but IPv6 addresses may start with '::'
35 but DNS labels may not start with '-' so in this case if no prefix is
36 configured a zero is added in front of the label. ::1 becomes 0--1.
37
38 +V4 mapped IPv6 addresses, which have a representation like ::ffff:1.2.3.4 are handled specially, and become like 0--ffff-1-2-3-4
39 +
40 The address range can be of the form
41 <ip address>,<ip address> or <ip address>/<netmask>
42 .TP
43 diff --git a/src/domain.c b/src/domain.c
44 index 1dd5027..a007acd 100644
45 --- a/src/domain.c
46 +++ b/src/domain.c
47 @@ -77,18 +77,31 @@ int is_name_synthetic(int flags, char *name, struct all_addr *addr)
48
49 *p = 0;
50
51 - /* swap . or : for - */
52 - for (p = tail; *p; p++)
53 - if (*p == '-')
54 - {
55 - if (prot == AF_INET)
56 + #ifdef HAVE_IPV6
57 + if (prot == AF_INET6 && strstr(tail, "--ffff-") == tail)
58 + {
59 + /* special hack for v4-mapped. */
60 + memcpy(tail, "::ffff:", 7);
61 + for (p = tail + 7; *p; p++)
62 + if (*p == '-')
63 *p = '.';
64 + }
65 + else
66 +#endif
67 + {
68 + /* swap . or : for - */
69 + for (p = tail; *p; p++)
70 + if (*p == '-')
71 + {
72 + if (prot == AF_INET)
73 + *p = '.';
74 #ifdef HAVE_IPV6
75 - else
76 - *p = ':';
77 + else
78 + *p = ':';
79 #endif
80 - }
81 -
82 + }
83 + }
84 +
85 if (hostname_isequal(c->domain, p+1) && inet_pton(prot, tail, addr))
86 {
87 if (prot == AF_INET)
88 @@ -169,8 +182,9 @@ int is_rev_synth(int flag, struct all_addr *addr, char *name)
89 inet_ntop(AF_INET6, &addr->addr.addr6, name+1, ADDRSTRLEN);
90 }
91
92 + /* V4-mapped have periods.... */
93 for (p = name; *p; p++)
94 - if (*p == ':')
95 + if (*p == ':' || *p == '.')
96 *p = '-';
97
98 strncat(name, ".", MAXDNAME);
99 --
100 1.7.10.4
101