* [PATCHv2] extensions: libip6t_frag: Add translation to nft
@ 2016-06-06 19:25 Laura Garcia Liebana
2016-06-06 22:43 ` Pablo Neira Ayuso
0 siblings, 1 reply; 3+ messages in thread
From: Laura Garcia Liebana @ 2016-06-06 19:25 UTC (permalink / raw)
To: netfilter-devel
Add translation for frag to nftables. According to the --fraglen code:
case O_FRAGLEN:
/*
* As of Linux 3.0, the kernel does not check for
* fraglen at all.
*/
In addition, the kernel code doesn't show any reference to the flag
IP6T_FRAG_LEN, so this option is deprecated and won't be translated to
nft.
Examples:
$ sudo iptables-translate -t filter -A INPUT -m frag --fragid 100:200 -j ACCEPT
nft add rule ip6 filter INPUT frag id 100-200 counter accept
$ sudo iptables-translate -t filter -A INPUT -m frag --fragid 100 --fragres --fragmore -j ACCEPT
nft add rule ip6 filter INPUT frag id 100 frag reserved 1 frag more-fragments 1 counter accept
$ sudo iptables-translate -t filter -A INPUT -m frag ! --fragid 100:200 -j ACCEPT
nft add rule ip6 filter INPUT frag id != 100-200 counter accept
$ sudo iptables-translate -t filter -A INPUT -m frag --fragid 100:200 --fraglast -j ACCEPT
nft add rule ip6 filter INPUT frag id 100-200 frag more-fragments 1 counter accept
$ sudo iptables-translate -t filter -A INPUT -m frag --fragid 100:200 --fragfirst -j ACCEPT
nft add rule ip6 filter INPUT frag id 100-200 frag frag-off 0 counter accept
Signed-off-by: Laura Garcia Liebana <nevola@gmail.com>
---
Changes in v2:
- Include translation for fragfirst and fraglast.
- fraglen is marked as deprecated.
extensions/libip6t_frag.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/extensions/libip6t_frag.c b/extensions/libip6t_frag.c
index 023df62..0a24eae 100644
--- a/extensions/libip6t_frag.c
+++ b/extensions/libip6t_frag.c
@@ -173,6 +173,38 @@ static void frag_save(const void *ip, const struct xt_entry_match *match)
printf(" --fraglast");
}
+static int frag_xlate(const void *ip, const struct xt_entry_match *match,
+ struct xt_xlate *xl, int numeric)
+{
+ const struct ip6t_frag *fraginfo = (struct ip6t_frag *)match->data;
+
+ if (fraginfo->flags & IP6T_FRAG_LEN)
+ return 0;
+
+ if (!(fraginfo->ids[0] == 0 && fraginfo->ids[1] == 0xFFFFFFFF)) {
+ xt_xlate_add(xl, "frag id %s",
+ (fraginfo->invflags & IP6T_FRAG_INV_IDS) ?
+ "!= " : "");
+ if (fraginfo->ids[0] != fraginfo->ids[1])
+ xt_xlate_add(xl, "%u-%u ", fraginfo->ids[0],
+ fraginfo->ids[1]);
+ else
+ xt_xlate_add(xl, "%u ", fraginfo->ids[0]);
+ }
+
+ if (fraginfo->flags & IP6T_FRAG_RES)
+ xt_xlate_add(xl, "frag reserved 1 ");
+
+ if (fraginfo->flags & IP6T_FRAG_FST)
+ xt_xlate_add(xl, "frag frag-off 0 ");
+
+ if ((fraginfo->flags & IP6T_FRAG_MF) ||
+ (fraginfo->flags & IP6T_FRAG_NMF))
+ xt_xlate_add(xl, "frag more-fragments 1 ");
+
+ return 1;
+}
+
static struct xtables_match frag_mt6_reg = {
.name = "frag",
.version = XTABLES_VERSION,
@@ -185,6 +217,7 @@ static struct xtables_match frag_mt6_reg = {
.save = frag_save,
.x6_parse = frag_parse,
.x6_options = frag_opts,
+ .xlate = frag_xlate,
};
void
--
2.7.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCHv2] extensions: libip6t_frag: Add translation to nft
2016-06-06 19:25 [PATCHv2] extensions: libip6t_frag: Add translation to nft Laura Garcia Liebana
@ 2016-06-06 22:43 ` Pablo Neira Ayuso
2016-06-06 22:45 ` Pablo Neira Ayuso
0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2016-06-06 22:43 UTC (permalink / raw)
To: Laura Garcia Liebana; +Cc: netfilter-devel
On Mon, Jun 06, 2016 at 09:25:46PM +0200, Laura Garcia Liebana wrote:
> Add translation for frag to nftables. According to the --fraglen code:
>
> case O_FRAGLEN:
> /*
> * As of Linux 3.0, the kernel does not check for
> * fraglen at all.
> */
>
> In addition, the kernel code doesn't show any reference to the flag
> IP6T_FRAG_LEN, so this option is deprecated and won't be translated to
> nft.
>
> Examples:
>
> $ sudo iptables-translate -t filter -A INPUT -m frag --fragid 100:200 -j ACCEPT
> nft add rule ip6 filter INPUT frag id 100-200 counter accept
>
> $ sudo iptables-translate -t filter -A INPUT -m frag --fragid 100 --fragres --fragmore -j ACCEPT
> nft add rule ip6 filter INPUT frag id 100 frag reserved 1 frag more-fragments 1 counter accept
>
> $ sudo iptables-translate -t filter -A INPUT -m frag ! --fragid 100:200 -j ACCEPT
> nft add rule ip6 filter INPUT frag id != 100-200 counter accept
>
> $ sudo iptables-translate -t filter -A INPUT -m frag --fragid 100:200 --fraglast -j ACCEPT
> nft add rule ip6 filter INPUT frag id 100-200 frag more-fragments 1 counter accept
>
> $ sudo iptables-translate -t filter -A INPUT -m frag --fragid 100:200 --fragfirst -j ACCEPT
> nft add rule ip6 filter INPUT frag id 100-200 frag frag-off 0 counter accept
Also applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCHv2] extensions: libip6t_frag: Add translation to nft
2016-06-06 22:43 ` Pablo Neira Ayuso
@ 2016-06-06 22:45 ` Pablo Neira Ayuso
0 siblings, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2016-06-06 22:45 UTC (permalink / raw)
To: Laura Garcia Liebana; +Cc: netfilter-devel
On Tue, Jun 07, 2016 at 12:43:45AM +0200, Pablo Neira Ayuso wrote:
> On Mon, Jun 06, 2016 at 09:25:46PM +0200, Laura Garcia Liebana wrote:
> > Add translation for frag to nftables. According to the --fraglen code:
> >
> > case O_FRAGLEN:
> > /*
> > * As of Linux 3.0, the kernel does not check for
> > * fraglen at all.
> > */
> >
> > In addition, the kernel code doesn't show any reference to the flag
> > IP6T_FRAG_LEN, so this option is deprecated and won't be translated to
> > nft.
> >
> > Examples:
> >
> > $ sudo iptables-translate -t filter -A INPUT -m frag --fragid 100:200 -j ACCEPT
> > nft add rule ip6 filter INPUT frag id 100-200 counter accept
> >
> > $ sudo iptables-translate -t filter -A INPUT -m frag --fragid 100 --fragres --fragmore -j ACCEPT
> > nft add rule ip6 filter INPUT frag id 100 frag reserved 1 frag more-fragments 1 counter accept
> >
> > $ sudo iptables-translate -t filter -A INPUT -m frag ! --fragid 100:200 -j ACCEPT
> > nft add rule ip6 filter INPUT frag id != 100-200 counter accept
> >
> > $ sudo iptables-translate -t filter -A INPUT -m frag --fragid 100:200 --fraglast -j ACCEPT
> > nft add rule ip6 filter INPUT frag id 100-200 frag more-fragments 1 counter accept
> >
> > $ sudo iptables-translate -t filter -A INPUT -m frag --fragid 100:200 --fragfirst -j ACCEPT
> > nft add rule ip6 filter INPUT frag id 100-200 frag frag-off 0 counter accept
>
> Also applied, thanks.
Wait..
+static int frag_xlate(const void *ip, const struct xt_entry_match *match,
+ struct xt_xlate *xl, int numeric)
+{
+ const struct ip6t_frag *fraginfo = (struct ip6t_frag
*)match->data;
+
+ if (fraginfo->flags & IP6T_FRAG_LEN)
+ return 0;
You better ignore completely IP6T_FRAG_LEN as the kernelside does.
No need to give up on providing a translation if this is used,
instead, let's relax this.
So please, remove this check. Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-06 22:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-06 19:25 [PATCHv2] extensions: libip6t_frag: Add translation to nft Laura Garcia Liebana
2016-06-06 22:43 ` Pablo Neira Ayuso
2016-06-06 22:45 ` Pablo Neira Ayuso
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).