From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Taehee Yoo <ap420073@gmail.com>
Cc: fw@strlen.de, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH v2] netfilter: nf_nat_snmp_basic: use asn1 decoder library
Date: Mon, 13 Nov 2017 14:50:20 +0100 [thread overview]
Message-ID: <20171113135020.GA21079@salvia> (raw)
In-Reply-To: <20171107145836.29917-1-ap420073@gmail.com>
Hi Taehee,
On Tue, Nov 07, 2017 at 11:58:36PM +0900, Taehee Yoo wrote:
> The basic SNMP ALG parse snmp ASN.1 payload
> however, since 2012 linux kernel provide ASN.1 decoder library.
> If we use ASN.1 decoder in the /lib/asn1_decoder.c, we can remove
> about 1000 line of ASN.1 parsing routine.
>
> To use asn1_decoder.c, we should write mib file(nf_nat_snmp_basic.asn1)
> then /script/asn1_compiler.c makes *-asn1.c and *-asn1.h file
> at the compiletime.(nf_nat_snmp_basic-asn1.c, nf_nat_snmp_basic-asn1.h)
> The nf_nat_snmp_basic.asn1 is made by RFC1155, RFC1157, RFC1902, RFC1905,
> RFC2578, RFC3416. of course that mib file supports only the basic SNMP ALG.
>
> Previous SNMP ALG mangles only first octet of IPv4 address.
> but after this patch, the SNMP ALG mangles whole IPv4 Address.
> And SNMPv3 is not supported.
Was SNMPv3 supported before this patch?
> I tested with snmp commands such ans snmpd, snmpwalk, snmptrap.
If you can develop a bit more how you have tested this, I'd really
appreciate.
This is removing quite a lot of code, which as I said is great since
it's way less code to maintain.
My concern is that this patch is doing way many things in one go, and
the lack of tests also make me feel concerned about regressions. If
you could provide a more comprehensive description of what you have
tested, I'd really appreciate.
Just to mention a few things that got introduced here in one go, that
probably can be done incrementally:
> @@ -1232,14 +185,17 @@ static int help(struct sk_buff *skb, unsigned int protoff,
> if (ntohs(udph->len) != skb->len - (iph->ihl << 2)) {
> net_warn_ratelimited("SNMP: dropping malformed packet src=%pI4 dst=%pI4\n",
> &iph->saddr, &iph->daddr);
> - return NF_DROP;
> + nf_ct_helper_log(skb, ct, "too short packet");
> + return NF_DROP;
> }
>
> - if (!skb_make_writable(skb, skb->len))
> + if (!skb_make_writable(skb, skb->len)) {
> + nf_ct_helper_log(skb, ct, "cannot mangle packet");
This log line is new, probably good to add this in a separated initial patch.
> return NF_DROP;
> + }
>
> spin_lock_bh(&snmp_lock);
> - ret = snmp_translate(ct, ctinfo, skb);
> + ret = snmp_translate(ct, dir, skb);
Conversion to use 'dir' could be done in a initial patch too I think.
> spin_unlock_bh(&snmp_lock);
> return ret;
> }
> @@ -1259,12 +215,6 @@ static struct nf_conntrack_helper snmp_trap_helper __read_mostly = {
> .tuple.dst.protonum = IPPROTO_UDP,
> };
>
> -/*****************************************************************************
> - *
> - * Module stuff.
> - *
> - *****************************************************************************/
> -
This useless comment can also go away in an initial patch.
> static int __init nf_nat_snmp_basic_init(void)
> {
> BUG_ON(nf_nat_snmp_hook != NULL);
> @@ -1282,5 +232,3 @@ static void __exit nf_nat_snmp_basic_fini(void)
>
> module_init(nf_nat_snmp_basic_init);
> module_exit(nf_nat_snmp_basic_fini);
> -
> -module_param(debug, int, 0600);
I'm fine with killing this old debug parameter, but better in an
initial patch.
Thanks for your work!
next prev parent reply other threads:[~2017-11-13 13:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-07 14:58 [PATCH v2] netfilter: nf_nat_snmp_basic: use asn1 decoder library Taehee Yoo
2017-11-13 13:50 ` Pablo Neira Ayuso [this message]
2017-11-18 7:59 ` Taehee Yoo
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=20171113135020.GA21079@salvia \
--to=pablo@netfilter.org \
--cc=ap420073@gmail.com \
--cc=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
/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).