From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Alexey Perevalov <a.perevalov@samsung.com>
Cc: alexey.perevalov@hotmail.com, mathieu.poirier@linaro.org,
netfilter-devel@vger.kernel.org, kyungmin.park@samsung.com,
hs81.go@samsung.com
Subject: Re: [PATCH v2] netfilter: nfnetlink_acct: add filter support to nfacct counter list/reset
Date: Wed, 20 Aug 2014 15:34:01 +0200 [thread overview]
Message-ID: <20140820133401.GA7422@salvia> (raw)
In-Reply-To: <1407321662-4536-1-git-send-email-a.perevalov@samsung.com>
On Wed, Aug 06, 2014 at 02:41:02PM +0400, Alexey Perevalov wrote:
> +enum nfnl_attr_filter_type {
> + NFACCT_FILTER_ATTR_UNSPEC,
> + NFACCT_FILTER_ATTR_MASK,
> + NFACCT_FILTER_ATTR_VALUE,
> + __NFACCT_FILTER_ATTR_MAX
> +};
Minor nitpick: Could you remove the _ATTR so we get smaller name?
> +#define NFACCT_FILTER_ATTR_MAX (__NFACCT_FILTER_ATTR_MAX - 1)
>
> #endif /* _UAPI_NFNL_ACCT_H_ */
> diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
> index 3ea0eac..94a47c4 100644
[...]
> +static struct nfacct_filter *
> +init_filter(const struct nlattr * const nla)
Rename this to nfacct_filter_alloc(), this fits in one line of
80-chars, no need to split it..
> + struct nfacct_filter *filter = NULL;
> + struct nlattr *attrs[NFACCT_FILTER_ATTR_MAX + 1];
> +
> + if (!nla)
> + return NULL;
> +
> + if (nla_parse_nested(attrs, NFACCT_FILTER_ATTR_MAX,
> + nla, filter_policy) != 0)
> + return NULL;
err = nla_parse_nested(...);
if (err < 0)
return ERR_PTR(err),
> +
> + filter = kzalloc(sizeof(struct nfacct_filter), GFP_KERNEL);
> + if (!filter)
> + return NULL;
return ERR_PTR(-ENOMEM);
> +
> + filter->mask = nla_get_be32(attrs[NFACCT_FILTER_ATTR_MASK]);
> + filter->value = nla_get_be32(attrs[NFACCT_FILTER_ATTR_VALUE]);
> +
> + return filter;
> +}
> +
> +static int
> nfnl_acct_get(struct sock *nfnl, struct sk_buff *skb,
> const struct nlmsghdr *nlh, const struct nlattr * const tb[])
> {
> @@ -220,9 +265,13 @@ nfnl_acct_get(struct sock *nfnl, struct sk_buff *skb,
> char *acct_name;
>
> if (nlh->nlmsg_flags & NLM_F_DUMP) {
> + /* using filters only for dump/list operation */
> struct netlink_dump_control c = {
> .dump = nfnl_acct_dump,
> + .done = nfnl_acct_done,
> };
> + c.data = init_filter(tb[NFACCT_FILTER]);
I need better a bit error handling here, I suggest:
if (tb[NFACCT_FILTER]) {
filter = nfacct_filter_alloc(tb[NFACCT_FILTER]);
if (IS_ERR(filter))
return PTR_ERR(filter);
}
Currently, if we fail to allocate the filter, it silently ignores the
user request and it is not exactly doing what he requested.
Please, address this and resubmit. Thanks!
next prev parent reply other threads:[~2014-08-20 13:33 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-25 8:05 reset nfacct counters Alexey Perevalov
2014-07-25 16:01 ` Pablo Neira Ayuso
2014-07-25 16:39 ` Alexey Perevalov
2014-07-28 17:57 ` [PATCH] " Alexey Perevalov
2014-07-28 22:03 ` Pablo Neira Ayuso
2014-07-28 17:57 ` [PATCH] netfilter: nfnetlink_acct: use flag to reset counters Alexey Perevalov
2014-07-28 21:53 ` Pablo Neira Ayuso
2014-07-29 11:46 ` Alexey Perevalov
2014-07-29 16:32 ` Pablo Neira Ayuso
2014-07-29 21:00 ` Alexey Perevalov
2014-08-04 15:52 ` [PATCH] netfilter: nfnetlink_acct: add filter support to nfacct counter list/reset Alexey Perevalov
2014-08-04 15:52 ` Alexey Perevalov
2014-08-05 15:51 ` Pablo Neira Ayuso
2014-08-06 10:41 ` [PATCH v2] " Alexey Perevalov
2014-08-20 13:34 ` Pablo Neira Ayuso [this message]
2014-08-20 18:03 ` [[PATCH v3]] " Alexey Perevalov
2014-08-24 13:15 ` Pablo Neira Ayuso
2014-08-26 19:15 ` Alexey Perevalov
2014-08-26 19:38 ` Pablo Neira Ayuso
2014-08-26 19:24 ` Alexey Perevalov
2014-08-06 10:50 ` [PATCH] " Alexey Perevalov
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=20140820133401.GA7422@salvia \
--to=pablo@netfilter.org \
--cc=a.perevalov@samsung.com \
--cc=alexey.perevalov@hotmail.com \
--cc=hs81.go@samsung.com \
--cc=kyungmin.park@samsung.com \
--cc=mathieu.poirier@linaro.org \
--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).