From: Pablo Neira Ayuso <pablo@netfilter.org>
To: ppang@linux.com
Cc: netfilter-devel@vger.kernel.org
Subject: Re: extensions: libxt_multiport: Multiport translations
Date: Sat, 5 Mar 2016 13:42:11 +0100 [thread overview]
Message-ID: <20160305124211.GA2676@salvia> (raw)
In-Reply-To: <CAKrM2X=PyBuF=ZrNkBFoTB4m+7pr15WUC_AahYn+x9wwf5Eibg@mail.gmail.com>
On Thu, Mar 03, 2016 at 06:02:41PM +0000, Piyush Pangtey wrote:
> Added multiport translations for ipv4 only .
> It's for review pupose only , it definitely needs changes .
>
> example :
> iptables-translate -A INPUT -p tcp -m multiport --dports 22,http,ssh -j ACCEPT
> nft add rule ip filter INPUT ip protocol tcp dport { 22,80,22 } counter accept
>
> diff --git a/extensions/libxt_multiport.c b/extensions/libxt_multiport.c
> index 03af5a9..6b46f93 100644
> --- a/extensions/libxt_multiport.c
> +++ b/extensions/libxt_multiport.c
> @@ -468,6 +468,67 @@ static void multiport_save6_v1(const void *ip_void,
> __multiport_save_v1(match, ip->proto);
> }
>
> +static int multiport_xlate(const struct xt_entry_match *match, struct
> xt_xlate *xl,
> + int numeric)
> +{
> + const struct xt_multiport_v1 *multiinfo
> + = (const struct xt_multiport_v1 *)match->data;
The = should be on the first line, ie.
const struct xt_multiport_v1 *multiinfo =
(const struct xt_multiport_v1 *)match->data;
> + unsigned int i;
^^^^
I see spaces here, there should be an 8-chars tab indentation there.
Please, make sure coding style is correct.
> + switch (multiinfo->flags) {
> + case XT_MULTIPORT_SOURCE:
> + xt_xlate_add(xl,"sport ");
^
add space after comma
> + break;
> +
No need for this extra line break;
> + case XT_MULTIPORT_DESTINATION:
> + xt_xlate_add(xl,"dport ");
> + break;
> +
> + default:
> + return 1;
> + }
> + xt_xlate_add(xl," { ");
> + for (i=0; i < multiinfo->count; i++) {
^
add space betwen variable and value, ie.
i = 0
this is preferred.
> + xt_xlate_add(xl,"%u%s", multiinfo->ports[i],
> + (i+1) != multiinfo->count ? "," : "");
Align this line with the parens:
xt_xlate_add(xl,"%u%s", multiinfo->ports[i],
i + 1 != multiinfo->count ? "," : "");
prev parent reply other threads:[~2016-03-05 12:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-03 18:02 extensions: libxt_multiport: Multiport translations Piyush Pangtey
2016-03-05 12:42 ` 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=20160305124211.GA2676@salvia \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=ppang@linux.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).