netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Shivani Bhardwaj <shivanib134@gmail.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH v4] extensions: libxt_mark: Add translation to nft
Date: Tue, 22 Dec 2015 17:19:48 +0100	[thread overview]
Message-ID: <20151222161948.GA13092@salvia> (raw)
In-Reply-To: <20151220031412.GA8273@gmail.com>

On Sun, Dec 20, 2015 at 08:44:12AM +0530, Shivani Bhardwaj wrote:
> Add translation for metainformation mark to nftables.
>
> Examples:
> 
> $ sudo iptables-translate -I INPUT -m mark --mark 12
> nft insert rule ip filter INPUT mark  0xc counter
> 
> $ sudo iptables-translate -A FORWARD -m mark --mark 22 -j ACCEPT
> nft add rule ip filter FORWARD mark  0x16 counter accept
> 
> $ sudo iptables-translate -t mangle -A PREROUTING -p tcp --dport 4600 -m mark --mark 0x40
> nft add rule ip mangle PREROUTING tcp dport 4600 mark  0x40 counter
> 
> $ sudo iptables-translate -A FORWARD -m mark --mark 0x400/0x400 -j ACCEPT
> nft add rule ip filter FORWARD mark  and 0x400 == 0x400 counter accept

Applied with minor glitch I have fixed here.

> +static void
> +print_mark_xlate(struct xt_buf *buf,
> +		 unsigned int mark, unsigned int mask)
> +{
> +	if (mask != 0xffffffffU)
> +		xt_buf_add(buf, " and 0x%x == 0x%x", mark, mask);
> +	else
> +		xt_buf_add(buf, " 0x%x", mark);
> +}
> +
> +static int
> +mark_mt_xlate(const struct xt_entry_match *match,
> +	      struct xt_buf *buf, int numeric)
> +{
> +	const struct xt_mark_mtinfo1 *info = (const void *)match->data;
> +
> +	xt_buf_add(buf, "mark %s", info->invert ? " !=" : "");

I have edited the line above to become:

	xt_buf_add(buf, "mark%s", info->invert ? " !=" : "");

So we get rid of the extra space:

> nft add rule ip filter FORWARD mark  and 0x400 == 0x400 counter accept
                                     ^
                                   here

> +	print_mark_xlate(buf, info->mark, info->mask);
> +	xt_buf_add(buf, " ");

Removed this xt_buf_add(buf, " ") and added the space to
print_mark_xlate().

  reply	other threads:[~2015-12-22 16:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-20  3:14 [PATCH v4] extensions: libxt_mark: Add translation to nft Shivani Bhardwaj
2015-12-22 16:19 ` Pablo Neira Ayuso [this message]
2015-12-22 16:22   ` Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151222161948.GA13092@salvia \
    --to=pablo@netfilter.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=shivanib134@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).