netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Jamal Hadi Salim <jhs@mojatatu.com>,
	Alexander Aring <aring@mojatatu.com>
Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net,
	netdev@vger.kernel.org, kernel@mojatatu.com
Subject: Re: [PATCH net-next 2/8] net: sched: cls_api: handle generic cls errors
Date: Tue, 16 Jan 2018 19:22:42 -0800	[thread overview]
Message-ID: <4092eaf5-120b-488e-1378-c19d29f665c2@gmail.com> (raw)
In-Reply-To: <ee8a4a80-8ab0-51de-57c7-9f3aab9326eb@mojatatu.com>

On 1/16/18 4:19 PM, Jamal Hadi Salim wrote:
> On 18-01-16 06:58 PM, David Ahern wrote:
>> On 1/16/18 9:20 AM, Alexander Aring wrote:
> 
> 
>>>           }
>>>             if (n->nlmsg_type != RTM_NEWTFILTER ||
>>>               !(n->nlmsg_flags & NLM_F_CREATE)) {
>>> +            NL_SET_ERR_MSG(extack, "Need both RTM_NEWTFILTER and
>>> NLM_F_CREATE to create a new filter");
>>
>> that does not seem the right message. tc_ctl_tfilter is overloaded for
>> new, delete and get so the response here needs to reflect that. I
>> believe in this case the user did not specify a valid chain.
>>
> 
> Are you sure you are looking at the correct code?

        tp = tcf_chain_tp_find(chain, &chain_info, protocol,
                               prio, prio_allocate);
        if (IS_ERR(tp)) {
                err = PTR_ERR(tp);
                goto errout;
        }

        if (tp == NULL) {
                /* Proto-tcf does not exist, create new one */

                if (tca[TCA_KIND] == NULL || !protocol) {
                        err = -EINVAL;
                        goto errout;
                }

                if (n->nlmsg_type != RTM_NEWTFILTER ||
                    !(n->nlmsg_flags & NLM_F_CREATE)) {
                        err = -ENOENT;
                        goto errout;
                }

Seems like that code path is run for other than RTM_NEWTFILTER. Even the
check there says != is ok -- just error out with an ENOENT.


> It is a create message that is at stake here.
> A create has to have RTM_NEWTFILTER and NLM_F_CREATE
> 
>> Also, the messages are targeted at users not developers, so no code
>> jargon / API references.
> 
> Generally true, but should this rule really be scripture?
> The main user here is tc in  user space and it doesnt make mistakes
> in this case i.e we will  never see this error with tc because a
> create will always have those two set correctly; OTOH, a developer
> writing some new app is more likely to make this mistake (in which
> case this message is very helpful).

argumentative. I have focused on adding specific error messages that
help a user understand why a command failed. It can be done with
referencing API names.

  reply	other threads:[~2018-01-17  3:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-16 17:20 [PATCH net-next 0/8] net: sched: cls: add extack support Alexander Aring
2018-01-16 17:20 ` [PATCH net-next 1/8] net: sched: cls: fix code style issues Alexander Aring
2018-01-16 17:20 ` [PATCH net-next 2/8] net: sched: cls_api: handle generic cls errors Alexander Aring
2018-01-16 23:12   ` Cong Wang
2018-01-16 23:58   ` David Ahern
2018-01-17  0:19     ` Jamal Hadi Salim
2018-01-17  3:22       ` David Ahern [this message]
2018-01-17 14:32         ` Jamal Hadi Salim
2018-01-16 17:20 ` [PATCH net-next 3/8] net: sched: cls: add extack support for change callback Alexander Aring
2018-01-16 17:20 ` [PATCH net-next 4/8] net: sched: cls: add extack support for tcf_exts_validate Alexander Aring
2018-01-16 17:20 ` [PATCH net-next 5/8] net: sched: cls: add extack support for delete callback Alexander Aring
2018-01-16 17:20 ` [PATCH net-next 6/8] net: sched: cls: add extack support for tcf_change_indev Alexander Aring
2018-01-16 17:20 ` [PATCH net-next 7/8] net: sched: cls: add extack support for tc_setup_cb_call Alexander Aring
2018-01-16 23:14   ` Cong Wang
2018-01-16 17:20 ` [PATCH net-next 8/8] net: sched: cls_u32: add extack support Alexander Aring
2018-01-16 21:50   ` Jakub Kicinski
2018-01-16 23:00   ` Cong Wang
2018-01-16 21:46 ` [PATCH net-next 0/8] net: sched: cls: " Jakub Kicinski
2018-01-16 22:12   ` Jamal Hadi Salim
2018-01-16 22:41     ` Jakub Kicinski
2018-01-16 23:27       ` Jamal Hadi Salim
2018-01-17  0:08         ` Daniel Borkmann
2018-01-17  1:10           ` Daniel Borkmann

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=4092eaf5-120b-488e-1378-c19d29f665c2@gmail.com \
    --to=dsahern@gmail.com \
    --cc=aring@mojatatu.com \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kernel@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@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).