[iptables PATCH 4/4] extensions: xlate: Format sets consistently

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Print a space after separating commas.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 extensions/libxt_multiport.c      |  4 ++--
 extensions/libxt_multiport.txlate |  2 +-
 extensions/libxt_time.c           | 12 ++++--------
 extensions/libxt_time.txlate      |  6 +++---
 4 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/extensions/libxt_multiport.c b/extensions/libxt_multiport.c
index 6b0c8190a1020..f3136d8a1ff56 100644
--- a/extensions/libxt_multiport.c
+++ b/extensions/libxt_multiport.c
@@ -497,7 +497,7 @@ static int __multiport_xlate(struct xt_xlate *xl,
 		xt_xlate_add(xl, "{ ");
 
 	for (i = 0; i < multiinfo->count; i++)
-		xt_xlate_add(xl, "%s%u", i ? "," : "", multiinfo->ports[i]);
+		xt_xlate_add(xl, "%s%u", i ? ", " : "", multiinfo->ports[i]);
 
 	if (multiinfo->count > 1)
 		xt_xlate_add(xl, "}");
@@ -560,7 +560,7 @@ static int __multiport_xlate_v1(struct xt_xlate *xl,
 		xt_xlate_add(xl, "{ ");
 
 	for (i = 0; i < multiinfo->count; i++) {
-		xt_xlate_add(xl, "%s%u", i ? "," : "", multiinfo->ports[i]);
+		xt_xlate_add(xl, "%s%u", i ? ", " : "", multiinfo->ports[i]);
 		if (multiinfo->pflags[i])
 			xt_xlate_add(xl, "-%u", multiinfo->ports[++i]);
 	}
diff --git a/extensions/libxt_multiport.txlate b/extensions/libxt_multiport.txlate
index bf0152650d79e..4f0c9c020f865 100644
--- a/extensions/libxt_multiport.txlate
+++ b/extensions/libxt_multiport.txlate
@@ -1,5 +1,5 @@
 iptables-translate -t filter -A INPUT -p tcp -m multiport --dports 80,81 -j ACCEPT
-nft add rule ip filter INPUT ip protocol tcp tcp dport { 80,81 } counter accept
+nft add rule ip filter INPUT ip protocol tcp tcp dport { 80, 81 } counter accept
 
 iptables-translate -t filter -A INPUT -p tcp -m multiport --dports 80:88 -j ACCEPT
 nft add rule ip filter INPUT ip protocol tcp tcp dport 80-88 counter accept
diff --git a/extensions/libxt_time.c b/extensions/libxt_time.c
index d27d84caf546e..580861d3a940a 100644
--- a/extensions/libxt_time.c
+++ b/extensions/libxt_time.c
@@ -466,9 +466,10 @@ static int time_xlate(struct xt_xlate *xl,
 	const struct xt_time_info *info =
 		(const struct xt_time_info *)params->match->data;
 	unsigned int h, m, s,
-		     i, sep, mask, count;
+		     i, mask, count;
 	time_t tt_start, tt_stop;
 	struct tm *t_start, *t_stop;
+	const char *sep = "";
 
 	if (info->date_start != 0 ||
 	    info->date_stop != INT_MAX) {
@@ -498,7 +499,6 @@ static int time_xlate(struct xt_xlate *xl,
 	if (info->monthdays_match != XT_TIME_ALL_MONTHDAYS)
 		return 0;
 	if (info->weekdays_match != XT_TIME_ALL_WEEKDAYS) {
-		sep = 0;
 		mask = info->weekdays_match;
 		count = time_count_weekdays(mask);
 
@@ -507,12 +507,8 @@ static int time_xlate(struct xt_xlate *xl,
 			xt_xlate_add(xl, "{");
 		for (i = 1; i <= 7; ++i)
 			if (mask & (1 << i)) {
-				if (sep)
-					xt_xlate_add(xl, ",%u", i%7);
-				else {
-					xt_xlate_add(xl, "%u", i%7);
-					++sep;
-				}
+				xt_xlate_add(xl, "%s%u", sep, i%7);
+				sep = ", ";
 			}
 		if (count > 1)
 			xt_xlate_add(xl, "}");
diff --git a/extensions/libxt_time.txlate b/extensions/libxt_time.txlate
index 6aea2aed5fa22..5577c6ca4cbd1 100644
--- a/extensions/libxt_time.txlate
+++ b/extensions/libxt_time.txlate
@@ -1,5 +1,5 @@
 iptables-translate -A INPUT -p icmp --icmp-type echo-request -m time --weekdays Sa,Su -j REJECT
-nft add rule ip filter INPUT icmp type echo-request meta day { 6,0 } counter reject
+nft add rule ip filter INPUT icmp type echo-request meta day { 6, 0 } counter reject
 
 iptables-translate -A INPUT -p icmp --icmp-type echo-request -m time --timestart 12:00 -j REJECT
 nft add rule ip filter INPUT icmp type echo-request meta hour "12:00:00"-"23:59:59" counter reject
@@ -20,7 +20,7 @@ iptables-translate -A INPUT -p icmp --icmp-type echo-request -m time --datestart
 nft add rule ip filter INPUT icmp type echo-request meta time "2020-01-29 00:00:00"-"2038-01-19 03:14:07" meta hour "12:00:00"-"23:59:59" counter reject
 
 iptables-translate -A INPUT -p icmp --icmp-type echo-request -m time --datestart 2020-01-29T00:00:00 --timestart 12:00 --timestop 19:00 --weekdays Mon,Tue,Wed,Thu,Fri -j REJECT
-nft add rule ip filter INPUT icmp type echo-request meta time "2020-01-29 00:00:00"-"2038-01-19 03:14:07" meta hour "12:00:00"-"19:00:00" meta day { 1,2,3,4,5 } counter reject
+nft add rule ip filter INPUT icmp type echo-request meta time "2020-01-29 00:00:00"-"2038-01-19 03:14:07" meta hour "12:00:00"-"19:00:00" meta day { 1, 2, 3, 4, 5 } counter reject
 
 iptables-translate -A INPUT -p icmp --icmp-type echo-request -m time --datestart 2020-01-29T00:00:00 --timestart 12:00 --timestop 19:00 ! --weekdays Mon,Tue,Wed,Thu,Fri -j REJECT
-nft add rule ip filter INPUT icmp type echo-request meta time "2020-01-29 00:00:00"-"2038-01-19 03:14:07" meta hour "12:00:00"-"19:00:00" meta day { 6,0 } counter reject
+nft add rule ip filter INPUT icmp type echo-request meta time "2020-01-29 00:00:00"-"2038-01-19 03:14:07" meta hour "12:00:00"-"19:00:00" meta day { 6, 0 } counter reject
-- 
2.38.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux