netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] iptables: nft-ipv6: Use meta l4proto instead of nexthdr
@ 2016-02-21 18:52 Shivani Bhardwaj
  2016-02-21 18:53 ` [PATCH 2/2] extensions: libip6t_mh: Add translation to nft Shivani Bhardwaj
  2016-03-02 19:02 ` [PATCH 1/2] iptables: nft-ipv6: Use meta l4proto instead of nexthdr Pablo Neira Ayuso
  0 siblings, 2 replies; 4+ messages in thread
From: Shivani Bhardwaj @ 2016-02-21 18:52 UTC (permalink / raw)
  To: netfilter-devel

Use meta l4proto in place of nexthdr for ipv6 protocols as it is not
necessary that all protocols be next header.

Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
---
 iptables/nft-ipv6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/iptables/nft-ipv6.c b/iptables/nft-ipv6.c
index 0ee7957..bbf289b 100644
--- a/iptables/nft-ipv6.c
+++ b/iptables/nft-ipv6.c
@@ -416,7 +416,7 @@ static int nft_ipv6_xlate(const void *data, struct xt_xlate *xl)
 			snprintf(protonum, sizeof(protonum), "%u",
 				 cs->fw6.ipv6.proto);
 			protonum[sizeof(protonum) - 1] = '\0';
-			xt_xlate_add(xl, "ip6 nexthdr %s%s ",
+			xt_xlate_add(xl, "meta l4proto %s%s ",
 				   cs->fw6.ipv6.invflags & IP6T_INV_PROTO ?
 					"!= " : "",
 				   pent ? pent->p_name : protonum);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] extensions: libip6t_mh: Add translation to nft
  2016-02-21 18:52 [PATCH 1/2] iptables: nft-ipv6: Use meta l4proto instead of nexthdr Shivani Bhardwaj
@ 2016-02-21 18:53 ` Shivani Bhardwaj
  2016-03-02 19:02   ` Pablo Neira Ayuso
  2016-03-02 19:02 ` [PATCH 1/2] iptables: nft-ipv6: Use meta l4proto instead of nexthdr Pablo Neira Ayuso
  1 sibling, 1 reply; 4+ messages in thread
From: Shivani Bhardwaj @ 2016-02-21 18:53 UTC (permalink / raw)
  To: netfilter-devel

Add translation for mobility header to nftables.

Examples:

$ sudo ip6tables-translate -A INPUT -p mh --mh-type 1 -j ACCEPT
nft add rule ip6 filter INPUT meta l4proto mobility-header mh type 1 counter accept

$ sudo ip6tables-translate -A INPUT -p mh --mh-type 1:3 -j ACCEPT
nft add rule ip6 filter INPUT meta l4proto mobility-header mh type 1-3 counter accept

Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
---
 extensions/libip6t_mh.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/extensions/libip6t_mh.c b/extensions/libip6t_mh.c
index 686a293..e0c214c 100644
--- a/extensions/libip6t_mh.c
+++ b/extensions/libip6t_mh.c
@@ -202,6 +202,26 @@ static void mh_save(const void *ip, const struct xt_entry_match *match)
 		printf(" --mh-type %u", mhinfo->types[0]);
 }
 
+static int mh_xlate(const struct xt_entry_match *match,
+		    struct xt_xlate *xl, int numeric)
+{
+	const struct ip6t_mh *mhinfo = (struct ip6t_mh *)match->data;
+
+	if (mhinfo->types[0] == 0 && mhinfo->types[1] == 0xFF)
+		return 1;
+
+	if (mhinfo->types[0] != mhinfo->types[1])
+		xt_xlate_add(xl, "mh type %s%u-%u ",
+			     mhinfo->invflags & IP6T_MH_INV_TYPE ? "!= " : "",
+			     mhinfo->types[0], mhinfo->types[1]);
+	else
+		xt_xlate_add(xl, "mh type %s%u ",
+			     mhinfo->invflags & IP6T_MH_INV_TYPE ? "!= " : "",
+			     mhinfo->types[0]);
+
+	return 1;
+}
+
 static const struct xt_option_entry mh_opts[] = {
 	{.name = "mh-type", .id = O_MH_TYPE, .type = XTTYPE_STRING,
 	 .flags = XTOPT_INVERT},
@@ -220,6 +240,7 @@ static struct xtables_match mh_mt6_reg = {
 	.print		= mh_print,
 	.save		= mh_save,
 	.x6_options	= mh_opts,
+	.xlate		= mh_xlate,
 };
 
 void _init(void)
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] iptables: nft-ipv6: Use meta l4proto instead of nexthdr
  2016-02-21 18:52 [PATCH 1/2] iptables: nft-ipv6: Use meta l4proto instead of nexthdr Shivani Bhardwaj
  2016-02-21 18:53 ` [PATCH 2/2] extensions: libip6t_mh: Add translation to nft Shivani Bhardwaj
@ 2016-03-02 19:02 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2016-03-02 19:02 UTC (permalink / raw)
  To: Shivani Bhardwaj; +Cc: netfilter-devel

On Mon, Feb 22, 2016 at 12:22:48AM +0530, Shivani Bhardwaj wrote:
> Use meta l4proto in place of nexthdr for ipv6 protocols as it is not
> necessary that all protocols be next header.

Applied, thanks Shivani.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] extensions: libip6t_mh: Add translation to nft
  2016-02-21 18:53 ` [PATCH 2/2] extensions: libip6t_mh: Add translation to nft Shivani Bhardwaj
@ 2016-03-02 19:02   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2016-03-02 19:02 UTC (permalink / raw)
  To: Shivani Bhardwaj; +Cc: netfilter-devel

On Mon, Feb 22, 2016 at 12:23:45AM +0530, Shivani Bhardwaj wrote:
> Add translation for mobility header to nftables.
> 
> Examples:
> 
> $ sudo ip6tables-translate -A INPUT -p mh --mh-type 1 -j ACCEPT
> nft add rule ip6 filter INPUT meta l4proto mobility-header mh type 1 counter accept
> 
> $ sudo ip6tables-translate -A INPUT -p mh --mh-type 1:3 -j ACCEPT
> nft add rule ip6 filter INPUT meta l4proto mobility-header mh type 1-3 counter accept

Also applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-03-02 19:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-21 18:52 [PATCH 1/2] iptables: nft-ipv6: Use meta l4proto instead of nexthdr Shivani Bhardwaj
2016-02-21 18:53 ` [PATCH 2/2] extensions: libip6t_mh: Add translation to nft Shivani Bhardwaj
2016-03-02 19:02   ` Pablo Neira Ayuso
2016-03-02 19:02 ` [PATCH 1/2] iptables: nft-ipv6: Use meta l4proto instead of nexthdr 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).