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] extensions: libxt_esp: Add translation to nft
Date: Tue, 22 Dec 2015 17:29:37 +0100	[thread overview]
Message-ID: <20151222162937.GA15518@salvia> (raw)
In-Reply-To: <20151220181321.GA15015@gmail.com>

On Sun, Dec 20, 2015 at 11:43:21PM +0530, Shivani Bhardwaj wrote:
> Add translation for ESP Protocol to nftables.
> 
> Examples:
> 
> $ sudo iptables-translate -A FORWARD -p esp -j ACCEPT
> nft add rule ip filter FORWARD ip protocol esp counter accept
> 
> $ sudo iptables-translate -A INPUT  --in-interface  wan --protocol esp -j ACCEPT
> nft add rule ip filter INPUT iifname wan ip protocol esp counter accept
> 
> $ sudo iptables-translate -A INPUT -p 50 -m esp --espspi 500 -j DROP
> nft add rule ip filter INPUT  esp spi 500 counter drop

Applied with changes.

> Signed-off-by: Shivani Bhardwaj <shivanib134@gmail.com>
> ---
>  extensions/libxt_esp.c | 23 +++++++++++++++++++++--
>  1 file changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/extensions/libxt_esp.c b/extensions/libxt_esp.c
> index 294338b..1c198c6 100644
> --- a/extensions/libxt_esp.c
> +++ b/extensions/libxt_esp.c
> @@ -79,10 +79,28 @@ static void esp_save(const void *ip, const struct xt_entry_match *match)
>  
>  }
>  
> +static int esp_xlate(const struct xt_entry_match *match,
> +		     struct xt_buf *buf, int numeric)
> +{
> +	const struct xt_esp *espinfo = (struct xt_esp *)match->data;
> +
> +	if (!(espinfo->spis[0] == 0 && espinfo->spis[1] == 0xFFFFFFFF)) {
> +		xt_buf_add(buf, "%s esp spi ",

This should be "esp spi%s" instead.

> +			   (espinfo->invflags & XT_ESP_INV_SPI) ? " !=" : "");
> +		if (espinfo->spis[0] != espinfo->spis[1])
> +			xt_buf_add(buf, "%u:%u ", espinfo->spis[0],

This should be "%u-%u".

Please, make sure you test all possible branches in your code next
time.

Thanks.

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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-20 18:13 [PATCH] extensions: libxt_esp: Add translation to nft Shivani Bhardwaj
2015-12-22 16:29 ` Pablo Neira Ayuso [this message]

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=20151222162937.GA15518@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).