All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jamal Hadi Salim <jhs@mojatatu.com>
To: David Ahern <dsahern@gmail.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: Wed, 17 Jan 2018 09:32:47 -0500	[thread overview]
Message-ID: <1886f57b-d9b1-02d7-6c94-721ee5f34e59@mojatatu.com> (raw)
In-Reply-To: <4092eaf5-120b-488e-1378-c19d29f665c2@gmail.com>

On 18-01-16 10:22 PM, David Ahern wrote:

>          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;
>                  }
> 


The assumption is if we got that far in the code a create
path(per the comment) is the sane thing to do. A create
requires tca[TCA_KIND], protocol, RTM_NEWTFILTER and
NLM_F_CREATE

> 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.
> 

To be honest, I am not fond of those checks either, I find myself
thinking sometimes about what would happen given a specific message.
A lot of these control paths in tc kernel parts sometimes are too
clever. That code needs refactoring to separate all 3 operations
for readability/maintainability. I would say the same for sch_api
We could fix it up (but those are separate patches); then we can
have much better error messages as well.

>> 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.
We are having a discussion.

>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.


That is one use case which is sensible. It is not like the
message is saying "consult IBM manual X for error code 1234"
IMO:
The kernel should be helpful to the user - but that user is not just
the user of an app within iproute2. It could be a robot, a human
using another CLI app, a developer etc. I think we need to look
at specific cases and make those calls. My view is that we should
never fail from tc for this specific case unless someone is fixing
up tc.

If you want to say it is always a human that needs to interpret
and react - then we need rules well stated somewhere
(eg you stated ENOMEM should not have extack, it was sufficiently
expressive etc). This will help reduce the time spent reviewing
patches or for people to respin.

The kernel should - when it makes sense - even return an extack for
a _successful message_ (I can give you several use cases in tc today)
or binary data via the cookie; and hopefully we can avoid collission
when we start sending such patches by having the discussion now.

cheers,
jamal

  reply	other threads:[~2018-01-17 14:32 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
2018-01-17 14:32         ` Jamal Hadi Salim [this message]
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=1886f57b-d9b1-02d7-6c94-721ee5f34e59@mojatatu.com \
    --to=jhs@mojatatu.com \
    --cc=aring@mojatatu.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.