netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Roopa Prabhu <roopa@cumulusnetworks.com>
To: David Ahern <dsa@cumulusnetworks.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	Florian Westphal <fw@strlen.de>, idaifish <idaifish@gmail.com>,
	syzkaller@googlegroups.com, Dmitry Vyukov <dvyukov@google.com>,
	Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: [PATCH net] net: check and errout if res->fi is NULL when RTM_F_FIB_MATCH is set
Date: Tue, 15 Aug 2017 21:55:32 -0700	[thread overview]
Message-ID: <CAJieiUiDzph45Uzxfp=7rGKarZXpPQ4T488ykBQoZC3VPKSJvg@mail.gmail.com> (raw)
In-Reply-To: <577b280e-5bef-ff83-ab72-fe61b42e02f9@cumulusnetworks.com>

On Tue, Aug 15, 2017 at 7:56 PM, David Ahern <dsa@cumulusnetworks.com> wrote:
> On 8/15/17 8:50 PM, Roopa Prabhu wrote:
>> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
>> index 7effa62..49a018f 100644
>> --- a/net/ipv4/route.c
>> +++ b/net/ipv4/route.c
>> @@ -2763,14 +2763,21 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
>>       if (rtm->rtm_flags & RTM_F_LOOKUP_TABLE)
>>               table_id = rt->rt_table_id;
>>
>> -     if (rtm->rtm_flags & RTM_F_FIB_MATCH)
>> +     if (rtm->rtm_flags & RTM_F_FIB_MATCH) {
>> +             if (!res.fi) {
>> +                     err = fib_props[res->type].error;
>> +                     if (!err)
>> +                             err = -EINVAL;
>
> I think -EHOSTUNREACH is a better error than EINVAL. Nothing about the
> user inputs are invalid; rather the lookup is failing, but indirectly.

 I have been going back and forth on this looking at other examples.
I would have preferred ip_route_input_rcu returned the right error
code for this....but i prefer not to touch that given it may break
something else.

EHOSTUNREACH is only returned for RTN_UNREACHABLE routes.

        [RTN_UNREACHABLE] = {

                .error  = -EHOSTUNREACH,

                .scope  = RT_SCOPE_UNIVERSE,

        },

In the example i am using it was failing due to a daddr being zero. so
seemed like -EINVAL would fit.

If EHOSTUNREACH can cover most errors, I am fine with changing it to
-EHOSTUNREACH.

      reply	other threads:[~2017-08-16  4:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-16  2:50 [PATCH net] net: check and errout if res->fi is NULL when RTM_F_FIB_MATCH is set Roopa Prabhu
2017-08-16  2:56 ` David Ahern
2017-08-16  4:55   ` Roopa Prabhu [this message]

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='CAJieiUiDzph45Uzxfp=7rGKarZXpPQ4T488ykBQoZC3VPKSJvg@mail.gmail.com' \
    --to=roopa@cumulusnetworks.com \
    --cc=davem@davemloft.net \
    --cc=dsa@cumulusnetworks.com \
    --cc=dvyukov@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=fw@strlen.de \
    --cc=idaifish@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=syzkaller@googlegroups.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).