extensions: libipt_REJECT: Avoid to print the default reject with value in the translation
PATCH 1/1 extensions: libipt_REJECT: Avoid to print the default reject with value in the translation
Avoid to print the reject with value in the translation when the value is the default.
Before this patch:
$ sudo iptables-translate -A FORWARD -p TCP --dport 22 -j REJECT nft add rule ip filter FORWARD tcp dport 22 counter reject with icmp type port-unreachable
After this patch:
$ sudo iptables-translate -A FORWARD -p TCP --dport 22 -j REJECT nft add rule ip filter FORWARD tcp dport 22 counter reject
Signed-off-by Laura Garcia Liebana <[email protected]>
--- extensions/libipt_REJECT.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
extensions/libipt_REJECT.c +6 -2
@@ -17,6 +17,8 @@#define IPT_ICMP_ADMIN_PROHIBITED IPT_TCP_RESET + 1#endif +#define DEFAULT_REJECT_WITH IPT_ICMP_PORT_UNREACHABLE +struct reject_names {const char *name;const char *alias;
@@ -92,7 +94,7 @@ static void REJECT_init(struct xt_entry_target *t)struct ipt_reject_info *reject = (struct ipt_reject_info *)t->data;/* default */ - reject->with =IPT_ICMP_PORT_UNREACHABLE ; + reject->with =DEFAULT_REJECT_WITH ; }
@@ -171,7 +173,9 @@ static int REJECT_xlate(const void *ip, const struct xt_entry_target *target,break ; } -if (reject->with ==IPT_TCP_RESET ) +if (reject->with ==DEFAULT_REJECT_WITH ) +xt_xlate_add (xl,"reject" ); +else if (reject->with ==IPT_TCP_RESET )xt_xlate_add (xl,"reject with %s" , reject_table_xlate[i].name);else
Signature · 1 line
2.7.0
Pablo Neira Ayuso
maintainerQuoted 22 lines · Laura Garcia Liebana
Avoid to print the reject with value in the translation when the value is the default.
Before this patch:
$ sudo iptables-translate -A FORWARD -p TCP --dport 22 -j REJECT nft add rule ip filter FORWARD tcp dport 22 counter reject with icmp type port-unreachableAfter this patch:
$ sudo iptables-translate -A FORWARD -p TCP --dport 22 -j REJECT nft add rule ip filter FORWARD tcp dport 22 counter rejectSigned-off-by Laura Garcia Liebana <[email protected]>--- extensions/libipt_REJECT.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)extensions/libipt_REJECT.c +0
-0
extensions/libipt_REJECT.c line 20
Quoted 4 lines
extensions/libipt_REJECT.c +1
-0@@ -17,6 +17,8 @@#define IPT_ICMP_ADMIN_PROHIBITED IPT_TCP_RESET + 1#endif +#define DEFAULT_REJECT_WITH IPT_ICMP_PORT_UNREACHABLE
This code is rather easy to read so I'd suggest no need to add this new definition, instead use IPT_ICMP_PORT_UNREACHABLE.
Thanks.