* [PATCH] extensions: libxt_helper: Add translation to nft
@ 2015-12-23 9:53 Shivani Bhardwaj
2015-12-23 10:01 ` Pablo Neira Ayuso
0 siblings, 1 reply; 3+ messages in thread
From: Shivani Bhardwaj @ 2015-12-23 9:53 UTC (permalink / raw)
To: netfilter-devel
Add translation for helper module to nftables.
Examples:
$ sudo iptables-translate -A FORWARD -m helper --helper sip
nft add rule ip filter FORWARD ct helper \"sip\" counter
$ sudo iptables-translate -A FORWARD -m helper ! --helper ftp
nft add rule ip filter FORWARD ct helper != \"ftp\" counter
Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
---
extensions/libxt_helper.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/extensions/libxt_helper.c b/extensions/libxt_helper.c
index c9f9435..5f1d8b1 100644
--- a/extensions/libxt_helper.c
+++ b/extensions/libxt_helper.c
@@ -45,6 +45,19 @@ static void helper_save(const void *ip, const struct xt_entry_match *match)
xtables_save_string(info->name);
}
+static int helper_xlate(const struct xt_entry_match *match,
+ struct xt_buf *buf, int numeric)
+{
+ const struct xt_helper_info *info = (const void *)match->data;
+
+ xt_buf_add(buf, "ct helper");
+
+ xt_buf_add(buf, "%s \\\"%s\\\" ",
+ info->invert ? " !=" : "", info->name);
+
+ return 1;
+}
+
static struct xtables_match helper_match = {
.family = NFPROTO_UNSPEC,
.name = "helper",
@@ -55,6 +68,7 @@ static struct xtables_match helper_match = {
.save = helper_save,
.x6_parse = helper_parse,
.x6_options = helper_opts,
+ .xlate = helper_xlate,
};
void _init(void)
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] extensions: libxt_helper: Add translation to nft
2015-12-23 9:53 [PATCH] extensions: libxt_helper: Add translation to nft Shivani Bhardwaj
@ 2015-12-23 10:01 ` Pablo Neira Ayuso
2015-12-23 10:02 ` Shivani Bhardwaj
0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2015-12-23 10:01 UTC (permalink / raw)
To: Shivani Bhardwaj; +Cc: netfilter-devel
On Wed, Dec 23, 2015 at 03:23:47PM +0530, Shivani Bhardwaj wrote:
> Add translation for helper module to nftables.
>
> Examples:
>
> $ sudo iptables-translate -A FORWARD -m helper --helper sip
> nft add rule ip filter FORWARD ct helper \"sip\" counter
>
> $ sudo iptables-translate -A FORWARD -m helper ! --helper ftp
> nft add rule ip filter FORWARD ct helper != \"ftp\" counter
>
> Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
> ---
> extensions/libxt_helper.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/extensions/libxt_helper.c b/extensions/libxt_helper.c
> index c9f9435..5f1d8b1 100644
> --- a/extensions/libxt_helper.c
> +++ b/extensions/libxt_helper.c
> @@ -45,6 +45,19 @@ static void helper_save(const void *ip, const struct xt_entry_match *match)
> xtables_save_string(info->name);
> }
>
> +static int helper_xlate(const struct xt_entry_match *match,
> + struct xt_buf *buf, int numeric)
> +{
> + const struct xt_helper_info *info = (const void *)match->data;
> +
> + xt_buf_add(buf, "ct helper");
> +
> + xt_buf_add(buf, "%s \\\"%s\\\" ",
> + info->invert ? " !=" : "", info->name);
You can place this in one single call of xt_buf_add(), right?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] extensions: libxt_helper: Add translation to nft
2015-12-23 10:01 ` Pablo Neira Ayuso
@ 2015-12-23 10:02 ` Shivani Bhardwaj
0 siblings, 0 replies; 3+ messages in thread
From: Shivani Bhardwaj @ 2015-12-23 10:02 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
On Wed, Dec 23, 2015 at 3:31 PM, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> On Wed, Dec 23, 2015 at 03:23:47PM +0530, Shivani Bhardwaj wrote:
>> Add translation for helper module to nftables.
>>
>> Examples:
>>
>> $ sudo iptables-translate -A FORWARD -m helper --helper sip
>> nft add rule ip filter FORWARD ct helper \"sip\" counter
>>
>> $ sudo iptables-translate -A FORWARD -m helper ! --helper ftp
>> nft add rule ip filter FORWARD ct helper != \"ftp\" counter
>>
>> Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
>> ---
>> extensions/libxt_helper.c | 14 ++++++++++++++
>> 1 file changed, 14 insertions(+)
>>
>> diff --git a/extensions/libxt_helper.c b/extensions/libxt_helper.c
>> index c9f9435..5f1d8b1 100644
>> --- a/extensions/libxt_helper.c
>> +++ b/extensions/libxt_helper.c
>> @@ -45,6 +45,19 @@ static void helper_save(const void *ip, const struct xt_entry_match *match)
>> xtables_save_string(info->name);
>> }
>>
>> +static int helper_xlate(const struct xt_entry_match *match,
>> + struct xt_buf *buf, int numeric)
>> +{
>> + const struct xt_helper_info *info = (const void *)match->data;
>> +
>> + xt_buf_add(buf, "ct helper");
>> +
>> + xt_buf_add(buf, "%s \\\"%s\\\" ",
>> + info->invert ? " !=" : "", info->name);
>
> You can place this in one single call of xt_buf_add(), right?
Sending v2.
Thank you
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-23 10:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-23 9:53 [PATCH] extensions: libxt_helper: Add translation to nft Shivani Bhardwaj
2015-12-23 10:01 ` Pablo Neira Ayuso
2015-12-23 10:02 ` Shivani Bhardwaj
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.