* [iptables PATCH 1/3] extensions: libebt_stp: Eliminate duplicate space in output
@ 2022-10-01 23:39 Phil Sutter
2022-10-01 23:39 ` [iptables PATCH 2/3] extensions: libip6t_dst: Fix output for empty options Phil Sutter
2022-10-01 23:39 ` [iptables PATCH 3/3] extensions: TCPOPTSTRIP: Do not print " Phil Sutter
0 siblings, 2 replies; 3+ messages in thread
From: Phil Sutter @ 2022-10-01 23:39 UTC (permalink / raw)
To: netfilter-devel
No need for print_range() to print a trailing whitespace, caller does
this already.
Fixes: fd8d7d7e5d911 ("ebtables-nft: add stp match")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
extensions/libebt_stp.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/extensions/libebt_stp.c b/extensions/libebt_stp.c
index 3e9e24474eb61..41059baae7078 100644
--- a/extensions/libebt_stp.c
+++ b/extensions/libebt_stp.c
@@ -146,9 +146,9 @@ static int parse_range(const char *portstring, void *lower, void *upper,
static void print_range(unsigned int l, unsigned int u)
{
if (l == u)
- printf("%u ", l);
+ printf("%u", l);
else
- printf("%u:%u ", l, u);
+ printf("%u:%u", l, u);
}
static int
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [iptables PATCH 2/3] extensions: libip6t_dst: Fix output for empty options
2022-10-01 23:39 [iptables PATCH 1/3] extensions: libebt_stp: Eliminate duplicate space in output Phil Sutter
@ 2022-10-01 23:39 ` Phil Sutter
2022-10-01 23:39 ` [iptables PATCH 3/3] extensions: TCPOPTSTRIP: Do not print " Phil Sutter
1 sibling, 0 replies; 3+ messages in thread
From: Phil Sutter @ 2022-10-01 23:39 UTC (permalink / raw)
To: netfilter-devel
If no --dst-opts were given, print_options() would print just a
whitespace.
Fixes: 73866357e4a7a ("iptables: do not print trailing whitespaces")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
extensions/libip6t_dst.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/extensions/libip6t_dst.c b/extensions/libip6t_dst.c
index bf0e3e436665d..baa010f56ac22 100644
--- a/extensions/libip6t_dst.c
+++ b/extensions/libip6t_dst.c
@@ -125,15 +125,15 @@ static void
print_options(unsigned int optsnr, uint16_t *optsp)
{
unsigned int i;
+ char sep = ' ';
- printf(" ");
for(i = 0; i < optsnr; i++) {
- printf("%d", (optsp[i] & 0xFF00) >> 8);
+ printf("%c%d", sep, (optsp[i] & 0xFF00) >> 8);
if ((optsp[i] & 0x00FF) != 0x00FF)
printf(":%d", (optsp[i] & 0x00FF));
- printf("%c", (i != optsnr - 1) ? ',' : ' ');
+ sep = ',';
}
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [iptables PATCH 3/3] extensions: TCPOPTSTRIP: Do not print empty options
2022-10-01 23:39 [iptables PATCH 1/3] extensions: libebt_stp: Eliminate duplicate space in output Phil Sutter
2022-10-01 23:39 ` [iptables PATCH 2/3] extensions: libip6t_dst: Fix output for empty options Phil Sutter
@ 2022-10-01 23:39 ` Phil Sutter
1 sibling, 0 replies; 3+ messages in thread
From: Phil Sutter @ 2022-10-01 23:39 UTC (permalink / raw)
To: netfilter-devel
No point in printing anything if none of the bits are set.
Fixes: aef4c1e727563 ("libxt_TCPOPTSTRIP")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
extensions/libxt_TCPOPTSTRIP.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/extensions/libxt_TCPOPTSTRIP.c b/extensions/libxt_TCPOPTSTRIP.c
index 6ea3489224602..ff873f98b3aaa 100644
--- a/extensions/libxt_TCPOPTSTRIP.c
+++ b/extensions/libxt_TCPOPTSTRIP.c
@@ -142,6 +142,13 @@ tcpoptstrip_print_list(const struct xt_tcpoptstrip_target_info *info,
}
}
+static bool tcpoptstrip_empty(const struct xt_tcpoptstrip_target_info *info)
+{
+ static const struct xt_tcpoptstrip_target_info empty = {};
+
+ return memcmp(info, &empty, sizeof(empty)) == 0;
+}
+
static void
tcpoptstrip_tg_print(const void *ip, const struct xt_entry_target *target,
int numeric)
@@ -149,6 +156,9 @@ tcpoptstrip_tg_print(const void *ip, const struct xt_entry_target *target,
const struct xt_tcpoptstrip_target_info *info =
(const void *)target->data;
+ if (tcpoptstrip_empty(info))
+ return;
+
printf(" TCPOPTSTRIP options ");
tcpoptstrip_print_list(info, numeric);
}
@@ -159,6 +169,9 @@ tcpoptstrip_tg_save(const void *ip, const struct xt_entry_target *target)
const struct xt_tcpoptstrip_target_info *info =
(const void *)target->data;
+ if (tcpoptstrip_empty(info))
+ return;
+
printf(" --strip-options ");
tcpoptstrip_print_list(info, true);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-01 23:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-01 23:39 [iptables PATCH 1/3] extensions: libebt_stp: Eliminate duplicate space in output Phil Sutter
2022-10-01 23:39 ` [iptables PATCH 2/3] extensions: libip6t_dst: Fix output for empty options Phil Sutter
2022-10-01 23:39 ` [iptables PATCH 3/3] extensions: TCPOPTSTRIP: Do not print " Phil Sutter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).