From: Patrick McHardy <kaber@trash.net>
To: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: netfilter-devel@vger.kernel.org, Pablo Neira Ayuso <pablo@netfilter.org>
Subject: Re: [PATCH 02/13] IP set core support
Date: Wed, 02 Feb 2011 07:40:08 +0100 [thread overview]
Message-ID: <4D48FC48.3000807@trash.net> (raw)
In-Reply-To: <alpine.DEB.2.00.1102012002430.24267@blackhole.kfki.hu>
On 01.02.2011 20:43, Jozsef Kadlecsik wrote:
> On Tue, 1 Feb 2011, Patrick McHardy wrote:
>
>> Am 31.01.2011 23:52, schrieb Jozsef Kadlecsik:
>>> +static int
>>> +call_ad(struct sk_buff *skb, struct ip_set *set,
>>> + struct nlattr *tb[], enum ipset_adt adt,
>>> + u32 flags, bool use_lineno)
>>> +{
>>> + int ret, retried = 0;
>>> + u32 lineno = 0;
>>> + bool eexist = flags & IPSET_FLAG_EXIST;
>>> +
>>> + do {
>>> + write_lock_bh(&set->lock);
>>> + ret = set->variant->uadt(set, tb, adt, &lineno, flags);
>>> + write_unlock_bh(&set->lock);
>>> + } while (ret == -EAGAIN &&
>>> + set->variant->resize &&
>>> + (ret = set->variant->resize(set, retried++)) == 0);
>>> +
>>> + if (!ret || (ret == -IPSET_ERR_EXIST && eexist))
>>> + return 0;
>>> + if (lineno && use_lineno) {
>>> + /* Error in restore/batch mode: send back lineno */
>>> + struct nlmsghdr *nlh = nlmsg_hdr(skb);
>>> + int min_len = NLMSG_SPACE(sizeof(struct nfgenmsg));
>>> + struct nlattr *cda[IPSET_ATTR_CMD_MAX+1];
>>> + struct nlattr *cmdattr = (void *)nlh + min_len;
>>> + u32 *errline;
>>> +
>>> + nla_parse(cda, IPSET_ATTR_CMD_MAX,
>>> + cmdattr, nlh->nlmsg_len - min_len,
>>> + ip_set_adt_policy);
>>> +
>>> + errline = nla_data(cda[IPSET_ATTR_LINENO]);
>>> +
>>> + *errline = lineno;
>>
>> This is still not correct. I didn't mean to remove the const attributes
>> (the message is still considered const by the higher layers, the netlink
>> functions just cast this away). You're modifying the received message,
>> I don't see how this can be useful to userspace.
>
> I can't find where the message is considered const in netlink/nfnetlink.
> It seems to be freely writable via skb.
>
>> I guess you're relying on that the original message is appended to a
>> nlmsgerr message. That doesn't seem right though, if you want to return
>> something to userspace, you should construct a new message.
>
> The message we are processing here carried multiple commands (each having
> an attribute with the line number of the given command) and one failed
> from some reason. We have to notify the userspace which command, at what
> line failed. For this reason the multi-command messages have got an
> attribute, which can be filled out with the line number - that happens
> here. The attribute is already there, the message is not enlarged, just
> the empty value is overwritten with the proper value.
>
> The line number reporting works this way, tested in the testsuite too.
I'm still not really clear how this works since the message contents
have been copied from userspace, so modifying the contents seems
useless. I'll have a closer look at userspace to understand how this
works.
> If I had to construct a completely new message and sent it, that'd be more
> or less the duplication of netlink_ack. Additionally I had to suppress
> netlink from sending an errmsg/ack too.
>
> If one can't rely on the modifiable message and nlmsgerr, then the error
> reporting in netlink is, hm, not really useful :-(
I'm mainly not clear about how this works at all, will have a closer
look at userspace :)
next prev parent reply other threads:[~2011-02-02 6:40 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-31 22:52 [PATCH 00/13] ipset kernel patches v3 Jozsef Kadlecsik
2011-01-31 22:52 ` [PATCH 01/13] NFNL_SUBSYS_IPSET id and NLA_PUT_NET* macros Jozsef Kadlecsik
2011-01-31 22:52 ` [PATCH 02/13] IP set core support Jozsef Kadlecsik
2011-01-31 22:52 ` [PATCH 03/13] bitmap:ip set type support Jozsef Kadlecsik
2011-01-31 22:52 ` [PATCH 04/13] bitmap:ip,mac " Jozsef Kadlecsik
2011-01-31 22:53 ` [PATCH 05/13] bitmap:port set " Jozsef Kadlecsik
2011-01-31 22:53 ` [PATCH 06/13] hash:ip " Jozsef Kadlecsik
2011-01-31 22:53 ` [PATCH 07/13] hash:ip,port " Jozsef Kadlecsik
2011-01-31 22:53 ` [PATCH 08/13] hash:ip,port,ip " Jozsef Kadlecsik
2011-01-31 22:53 ` [PATCH 09/13] hash:ip,port,net " Jozsef Kadlecsik
2011-01-31 22:53 ` [PATCH 10/13] hash:net " Jozsef Kadlecsik
2011-01-31 22:53 ` [PATCH 11/13] hash:net,port " Jozsef Kadlecsik
2011-01-31 22:53 ` [PATCH 12/13] list:set " Jozsef Kadlecsik
2011-01-31 22:53 ` [PATCH 13/13] "set" match and "SET" target support Jozsef Kadlecsik
2011-02-01 14:56 ` Patrick McHardy
2011-02-01 14:55 ` [PATCH 12/13] list:set set type support Patrick McHardy
2011-02-01 14:54 ` [PATCH 11/13] hash:net,port " Patrick McHardy
2011-02-01 14:53 ` [PATCH 10/13] hash:net " Patrick McHardy
2011-02-01 14:52 ` [PATCH 09/13] hash:ip,port,net " Patrick McHardy
2011-02-01 14:42 ` [PATCH 08/13] hash:ip,port,ip " Patrick McHardy
2011-02-01 14:40 ` [PATCH 07/13] hash:ip,port " Patrick McHardy
2011-02-01 14:39 ` [PATCH 06/13] hash:ip " Patrick McHardy
2011-02-01 14:37 ` [PATCH 05/13] bitmap:port " Patrick McHardy
2011-02-01 14:36 ` [PATCH 04/13] bitmap:ip,mac " Patrick McHardy
2011-02-01 14:34 ` [PATCH 03/13] bitmap:ip set " Patrick McHardy
2011-02-01 14:31 ` [PATCH 02/13] IP set core support Patrick McHardy
2011-02-01 15:34 ` Patrick McHardy
2011-02-01 19:43 ` Jozsef Kadlecsik
2011-02-01 21:22 ` Jozsef Kadlecsik
2011-02-01 21:28 ` Jozsef Kadlecsik
2011-02-02 6:50 ` Patrick McHardy
2011-02-02 19:46 ` Jozsef Kadlecsik
2011-02-02 22:56 ` Patrick McHardy
2011-02-02 6:40 ` Patrick McHardy [this message]
2011-02-02 6:45 ` Patrick McHardy
2011-02-01 14:24 ` [PATCH 01/13] NFNL_SUBSYS_IPSET id and NLA_PUT_NET* macros Patrick McHardy
2011-02-01 14:18 ` [PATCH 00/13] ipset kernel patches v3 Patrick McHardy
2011-02-01 17:42 ` Patrick McHardy
-- strict thread matches above, loose matches on Subject: below --
2011-01-21 14:01 [PATCH 00/13] ipset kernel patches v2 Jozsef Kadlecsik
2011-01-21 14:01 ` [PATCH 01/13] NFNL_SUBSYS_IPSET id and NLA_PUT_NET* macros Jozsef Kadlecsik
2011-01-21 14:01 ` [PATCH 02/13] IP set core support Jozsef Kadlecsik
2011-01-21 21:39 ` Jozsef Kadlecsik
2011-01-25 14:47 ` Patrick McHardy
2011-01-25 21:23 ` Jozsef Kadlecsik
2011-01-26 11:57 ` Patrick McHardy
2011-01-26 11:57 ` Patrick McHardy
2011-01-25 15:06 ` Patrick McHardy
2011-01-25 21:28 ` Jozsef Kadlecsik
2011-01-27 8:58 ` Jozsef Kadlecsik
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=4D48FC48.3000807@trash.net \
--to=kaber@trash.net \
--cc=kadlec@blackhole.kfki.hu \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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).