summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenda Xu <heroxbd@gentoo.org>2019-02-13 21:58:21 +0800
committerBenda Xu <heroxbd@gentoo.org>2019-02-13 22:07:50 +0800
commitb9d15085b5a041a2eb50019828e3925d29e16e98 (patch)
treeed28ba5ee06653b496586820194fcb95f4fd8c65
parentdb5cd169b2687371cd277383330d0f06dc6ed335 (diff)
debian/patches/0007-static-EAM.patch: calculate netmask for /0.
Allow the subnet mapping to be of form "0.0.0.0/0" to represent the whole ipv4 address space.
-rw-r--r--debian/patches/0007-static-EAM.patch41
1 files changed, 33 insertions, 8 deletions
diff --git a/debian/patches/0007-static-EAM.patch b/debian/patches/0007-static-EAM.patch
index 48c451a..2a9de34 100644
--- a/debian/patches/0007-static-EAM.patch
+++ b/debian/patches/0007-static-EAM.patch
@@ -9,15 +9,40 @@ Introduce Explicit Address Mapping as defined in RFC7757. This extends the
Forwarded: Nathan Lutchansky <lutchann@litech.org>
---
- addrmap.c | 18 +++++++++++++++++-
+ addrmap.c | 29 +++++++++++++++++++++++------
conffile.c | 40 +++++++++++++++++++++++++++++++++++++---
- 2 files changed, 54 insertions(+), 4 deletions(-)
+ 2 files changed, 60 insertions(+), 9 deletions(-)
diff --git a/addrmap.c b/addrmap.c
-index 7a4bf8b..895c3fc 100644
+index 7a4bf8b..24926d8 100644
--- a/addrmap.c
+++ b/addrmap.c
-@@ -422,6 +422,9 @@ int map_ip4_to_ip6(struct in6_addr *addr6, const struct in_addr *addr4,
+@@ -22,10 +22,6 @@ extern time_t now;
+
+ int validate_ip4_addr(const struct in_addr *a)
+ {
+- /* First octet == 0 */
+- if (!(a->s_addr & htonl(0xff000000)))
+- return -1;
+-
+ /* First octet == 127 */
+ if ((a->s_addr & htonl(0xff000000)) == htonl(0x7f000000))
+ return -1;
+@@ -97,7 +93,12 @@ int is_private_ip4_addr(const struct in_addr *a)
+
+ int calc_ip4_mask(struct in_addr *mask, const struct in_addr *addr, int len)
+ {
+- mask->s_addr = htonl(~((1 << (32 - len)) - 1));
++ if (len) {
++ mask->s_addr = htonl(~((1 << (32 - len)) - 1));
++ } else {
++ /* len==0 */
++ mask->s_addr = 0;
++ }
+ if (addr && (addr->s_addr & ~mask->s_addr))
+ return -1;
+ return 0;
+@@ -422,6 +423,9 @@ int map_ip4_to_ip6(struct in6_addr *addr6, const struct in_addr *addr4,
case MAP_TYPE_STATIC:
s = container_of(map4, struct map_static, map4);
*addr6 = s->map6.addr;
@@ -27,7 +52,7 @@ index 7a4bf8b..895c3fc 100644
break;
case MAP_TYPE_RFC6052:
s = container_of(map4, struct map_static, map4);
-@@ -564,7 +567,13 @@ int map_ip6_to_ip4(struct in_addr *addr4, const struct in6_addr *addr6,
+@@ -564,7 +568,13 @@ int map_ip6_to_ip4(struct in_addr *addr4, const struct in6_addr *addr6,
switch (map6->type) {
case MAP_TYPE_STATIC:
s = container_of(map6, struct map_static, map6);
@@ -42,7 +67,7 @@ index 7a4bf8b..895c3fc 100644
break;
case MAP_TYPE_RFC6052:
if (extract_from_prefix(addr4, addr6, map6->prefix_len) < 0)
-@@ -629,3 +638,10 @@ void addrmap_maint(void)
+@@ -629,3 +639,10 @@ void addrmap_maint(void)
}
}
}
@@ -54,7 +79,7 @@ index 7a4bf8b..895c3fc 100644
+End:
+*/
diff --git a/conffile.c b/conffile.c
-index ec6433c..1c77371 100644
+index ec6433c..dd4193c 100644
--- a/conffile.c
+++ b/conffile.c
@@ -217,16 +217,43 @@ static void config_map(int ln, int arg_count, char **args)
@@ -88,7 +113,7 @@ index ec6433c..1c77371 100644
+
+ if ((32 - prefix4) != (128 - prefix6)) {
+ slog(LOG_CRIT, "IPv4 and IPv6 subnet must be of the same size, but found"
-+ " %s and %s line %d\n", args[0], args[1], ln);
++ " %s and %s on line %d\n", args[0], args[1], ln);
+ exit(1);
+ }
+