Blame SOURCES/0006-don-t-print-IPv6-mask-if-it-s-all-ones-based-on-patc.patch

05e71a
From 657c50fea3cc6a05dca5f055f4377ab412fe21f0 Mon Sep 17 00:00:00 2001
05e71a
From: Bart De Schuymer <bdschuym@pandora.be>
05e71a
Date: Mon, 14 Apr 2014 22:04:55 +0200
05e71a
Subject: [PATCH] don't print IPv6 mask if it's all ones (based on patch by
05e71a
 Mariusz Mazur <mmazur at axeos.com>)
05e71a
05e71a
Signed-off-by: Phil Sutter <psutter@redhat.com>
05e71a
---
05e71a
 extensions/ebt_ip6.c |  4 ++--
05e71a
 include/ebtables_u.h |  1 +
05e71a
 useful_functions.c   | 13 +++++++++++++
05e71a
 3 files changed, 16 insertions(+), 2 deletions(-)
05e71a
05e71a
diff --git a/extensions/ebt_ip6.c b/extensions/ebt_ip6.c
05e71a
index bbdc4aef9a172..e3e0956e00f01 100644
05e71a
--- a/extensions/ebt_ip6.c
05e71a
+++ b/extensions/ebt_ip6.c
05e71a
@@ -449,14 +449,14 @@ static void print(const struct ebt_u_entry *entry,
05e71a
 		if (ipinfo->invflags & EBT_IP6_SOURCE)
05e71a
 			printf("! ");
05e71a
 		printf("%s", ebt_ip6_to_numeric(&ipinfo->saddr));
05e71a
-		printf("/%s ", ebt_ip6_to_numeric(&ipinfo->smsk));
05e71a
+		printf("%s ", ebt_ip6_mask_to_string(&ipinfo->smsk));
05e71a
 	}
05e71a
 	if (ipinfo->bitmask & EBT_IP6_DEST) {
05e71a
 		printf("--ip6-dst ");
05e71a
 		if (ipinfo->invflags & EBT_IP6_DEST)
05e71a
 			printf("! ");
05e71a
 		printf("%s", ebt_ip6_to_numeric(&ipinfo->daddr));
05e71a
-		printf("/%s ", ebt_ip6_to_numeric(&ipinfo->dmsk));
05e71a
+		printf("%s ", ebt_ip6_mask_to_string(&ipinfo->dmsk));
05e71a
 	}
05e71a
 	if (ipinfo->bitmask & EBT_IP6_TCLASS) {
05e71a
 		printf("--ip6-tclass ");
05e71a
diff --git a/include/ebtables_u.h b/include/ebtables_u.h
05e71a
index ab615c1d59c44..35a5bcc54c865 100644
05e71a
--- a/include/ebtables_u.h
05e71a
+++ b/include/ebtables_u.h
05e71a
@@ -303,6 +303,7 @@ char *ebt_mask_to_dotted(uint32_t mask);
05e71a
 void ebt_parse_ip6_address(char *address, struct in6_addr *addr, 
05e71a
 						   struct in6_addr *msk);
05e71a
 char *ebt_ip6_to_numeric(const struct in6_addr *addrp);
05e71a
+char *ebt_ip6_mask_to_string(const struct in6_addr *msk);
05e71a
 
05e71a
 
05e71a
 int do_command(int argc, char *argv[], int exec_style,
05e71a
diff --git a/useful_functions.c b/useful_functions.c
05e71a
index d20b68e31eabb..d14cbe9dbdba1 100644
05e71a
--- a/useful_functions.c
05e71a
+++ b/useful_functions.c
05e71a
@@ -411,3 +411,16 @@ char *ebt_ip6_to_numeric(const struct in6_addr *addrp)
05e71a
 	static char buf[50+1];
05e71a
 	return (char *)inet_ntop(AF_INET6, addrp, buf, sizeof(buf));
05e71a
 }
05e71a
+
05e71a
+char *ebt_ip6_mask_to_string(const struct in6_addr *msk)
05e71a
+{
05e71a
+   	/* /0000:0000:0000:0000:0000:000.000.000.000
05e71a
+	 * /0000:0000:0000:0000:0000:0000:0000:0000 */
05e71a
+	static char buf[51+1];
05e71a
+	if (msk->s6_addr32[0] == 0xFFFFFFFFL && msk->s6_addr32[1] == 0xFFFFFFFFL &&
05e71a
+	    msk->s6_addr32[2] == 0xFFFFFFFFL && msk->s6_addr32[3] == 0xFFFFFFFFL)
05e71a
+		*buf = '\0';
05e71a
+	else
05e71a
+		sprintf(buf, "/%s", ebt_ip6_to_numeric(msk));
05e71a
+	return buf;
05e71a
+}
05e71a
-- 
05e71a
2.21.0
05e71a