Skip to contentSkip to conversation

extensions: libipt_LOG: Avoid to print the default log level in the translation

PATCH Applied Laura Garcia Liebana 3 participants 4 messages Mar 10, 2016 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 extensions: libipt_LOG: Avoid to print the default log level in the translation

Avoid to print the log level in the translation when the level is the default value.

Example:

$ sudo iptables-translate -t filter -A INPUT -m icmp ! --icmp-type 10 -j LOG
nft add rule ip filter INPUT icmp type != router-solicitation counter log
---
 extensions/libipt_LOG.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
extensions/libipt_LOG.c +2 -1
index f3875b6..216b1ca 100644
@@ -194,7 +194,8 @@ static int LOG_xlate(const struct xt_entry_target *target,
 		xt_xlate_add(xl, "prefix \\\"%s\\\" ", loginfo->prefix);
 
 	for (i = 0; i < ARRAY_SIZE(ipt_log_xlate_names); ++i)
-		if (loginfo->level == ipt_log_xlate_names[i].level) {
+		if (loginfo->level != LOG_DEFAULT_LEVEL &&
+		    loginfo->level == ipt_log_xlate_names[i].level) {
 			xt_xlate_add(xl, "level %s ",
 				   ipt_log_xlate_names[i].name);
 			break;
Signature · 1 line
2.7.0
#1 lore raw
Quoted 8 lines · Laura Garcia Liebana

Avoid to print the log level in the translation when the level is the default value.

Example:

$ sudo iptables-translate -t filter -A INPUT -m icmp ! --icmp-type 10 -j LOG
nft add rule ip filter INPUT icmp type != router-solicitation counter log

Looks good. Don't forget to send a patch for libip6t_LOG too.

Same is the case with reject as well. When I did the translations, I left its default nature intact.

$ sudo ip6tables-translate -A FORWARD -p TCP --dport 22 -j REJECT
nft add rule ip6 filter FORWARD tcp dport 22 counter reject with
icmpv6 type port-unreachable

Pablo, should this be corrected too?

Laura, may be you can send more patches depending on his response.

Thanks.

Quoted 22 lines
---
 extensions/libipt_LOG.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
extensions/libipt_LOG.c +2 -2
index f3875b6..216b1ca 100644
@@ -194,7 +194,8 @@ static int LOG_xlate(const struct xt_entry_target *target,
                xt_xlate_add(xl, "prefix \\\"%s\\\" ", loginfo->prefix);
 
        for (i = 0; i < ARRAY_SIZE(ipt_log_xlate_names); ++i)
-               if (loginfo->level == ipt_log_xlate_names[i].level) {
+               if (loginfo->level != LOG_DEFAULT_LEVEL &&
+                   loginfo->level == ipt_log_xlate_names[i].level) {
                        xt_xlate_add(xl, "level %s ",
                                   ipt_log_xlate_names[i].name);
                        break;
--

2.7.0

#2 lore raw
Quoted 11 lines · Shivani Bhardwaj
Quoted 8 lines · Laura Garcia Liebana

Avoid to print the log level in the translation when the level is the default value.

Example:

$ sudo iptables-translate -t filter -A INPUT -m icmp ! --icmp-type 10 -j LOG
nft add rule ip filter INPUT icmp type != router-solicitation counter log

Looks good. Don't forget to send a patch for libip6t_LOG too.

Yes please, send a patch for libip6t_LOG too.

Quoted 7 lines

Same is the case with reject as well. When I did the translations, I left its default nature intact.

$ sudo ip6tables-translate -A FORWARD -p TCP --dport 22 -j REJECT
nft add rule ip6 filter FORWARD tcp dport 22 counter reject with
icmpv6 type port-unreachable

Pablo, should this be corrected too?

It would be good to translate this to the more compact syntax, if possible.

Quoted 1 line

Laura, may be you can send more patches depending on his response.

Yes please. Thanks for commenting on this Shivani.

maintainer Applied
#3 lore raw
In reply to Laura Garcia Liebana
Quoted 7 lines · Laura Garcia Liebana

Avoid to print the log level in the translation when the level is the default value.

Example:

$ sudo iptables-translate -t filter -A INPUT -m icmp ! --icmp-type 10 -j LOG
nft add rule ip filter INPUT icmp type != router-solicitation counter log

Applied, thanks Laura.