All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roopa Prabhu <roopa@cumulusnetworks.com>
To: David Ahern <dsa@cumulusnetworks.com>
Cc: David Miller <davem@davemloft.net>,
	netdev <netdev@vger.kernel.org>,
	Nikolay Aleksandrov <nikolay@cumulusnetworks.com>,
	Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [PATCH net-next 1/4] net: rtnetlink: support for fdb get
Date: Fri, 14 Dec 2018 10:09:07 -0800	[thread overview]
Message-ID: <CAJieiUgSSXACJAsa9U5pnxYW0bwr-=Hgu1oUmqMxS6HbvciSXA@mail.gmail.com> (raw)
In-Reply-To: <6daaa7f9-41db-30da-043c-0b34bc16bc72@cumulusnetworks.com>

On Fri, Dec 14, 2018 at 9:55 AM David Ahern <dsa@cumulusnetworks.com> wrote:
>
> On 12/14/18 10:43 AM, Roopa Prabhu wrote:
> > diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> > index f8bdb8ad..fcea76b 100644
> > --- a/net/core/rtnetlink.c
> > +++ b/net/core/rtnetlink.c
> > @@ -4021,6 +4021,111 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
> >       return skb->len;
> >  }
> >
> > +static int rtnl_fdb_get(struct sk_buff *in_skb, struct nlmsghdr *nlh,
> > +                     struct netlink_ext_ack *extack)
> > +{
> > +     const struct net_device_ops *ops = NULL;
> > +     struct net *net = sock_net(in_skb->sk);
> > +     struct net_device *dev = NULL, *br_dev = NULL;
> > +     struct nlattr *tb[NDA_MAX + 1];
> > +     struct sk_buff *skb;
> > +     struct ndmsg *ndm;
> > +     int br_idx = 0;
> > +     u8 *addr;
> > +     u16 vid;
> > +     int err;
> > +
> > +     err = nlmsg_parse(nlh, sizeof(*ndm), tb, NDA_MAX, NULL, extack);
>
> New stuff should go in with strict checking, so nlmsg_parse_strict and a
> check for any unsupported attributes (NDA) or ndm entries in the request.

makes sense.

>
> Also, please add an nla_policy for easier NDA attributes ...

yes agreed. NDA attrs have not had a policy.
maybe an incremental patch ?, NDA_* attributes are used in bridge
vxlan and neighbour code, need a common place to put the policy.
(suggestions ?)


>
> > +     if (err < 0)
> > +             return err;
> > +
> > +     ndm = nlmsg_data(nlh);
> > +     if (ndm->ndm_ifindex) {
> > +             dev = __dev_get_by_index(net, ndm->ndm_ifindex);
> > +             if (!dev) {
> > +                     NL_SET_ERR_MSG(extack, "unknown dev ifindex");
>
> General comment on all of the extack messages: No abbreviations in the
> message, and it is nice to always start with a capital letter. "Unknown
> device index"

ack,

will send a v2


>
> > +                     return -ENODEV;
> > +             }
> > +     }
> > +
> > +     if (!tb[NDA_LLADDR] || nla_len(tb[NDA_LLADDR]) != ETH_ALEN) {
> > +             NL_SET_ERR_MSG(extack, "invalid address");
> > +             return -EINVAL;
> > +     }
> > +
> > +     addr = nla_data(tb[NDA_LLADDR]);
> > +
> > +     err = fdb_vid_parse(tb[NDA_VLAN], &vid, extack);
> > +     if (err)
> > +             return err;
> > +
> > +     if (tb[NDA_MASTER]) {
> > +             if (dev) {
> > +                     NL_SET_ERR_MSG(extack, "master and dev are mutually exclusive");
> > +                     return -EINVAL;
> > +             }
> > +
> > +             br_idx = nla_get_u32(tb[NDA_MASTER]);
>
> ... so you know that NDA_MASTER is a u32.
>
> > +             br_dev = __dev_get_by_index(net, br_idx);
> > +             if (!br_dev) {
> > +                     NL_SET_ERR_MSG(extack, "invalid master ifindex");
> > +                     return -EINVAL;
> > +             }
> > +             ops = br_dev->netdev_ops;
> > +     }
> > +
>

  reply	other threads:[~2018-12-14 18:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-14 17:43 [PATCH net-next 0/4] rtnl fdb get Roopa Prabhu
2018-12-14 17:43 ` [PATCH net-next 1/4] net: rtnetlink: support for " Roopa Prabhu
2018-12-14 17:55   ` David Ahern
2018-12-14 18:09     ` Roopa Prabhu [this message]
2018-12-14 19:37       ` Jakub Kicinski
2018-12-14 19:42         ` David Ahern
2018-12-14 19:54           ` Jakub Kicinski
2018-12-14 19:58             ` David Ahern
2018-12-14 21:03               ` Jakub Kicinski
2018-12-14 18:17   ` Nikolay Aleksandrov
2018-12-14 17:43 ` [PATCH net-next 2/4] bridge: support for ndo_fdb_get Roopa Prabhu
2018-12-14 18:24   ` Nikolay Aleksandrov
2018-12-14 17:43 ` [PATCH net-next 3/4] vxlan: " Roopa Prabhu
2018-12-14 17:43 ` [PATCH net-next 4/4] selftests: net: rtnetlink.sh: add fdb get test Roopa Prabhu
2018-12-14 19:19 ` [PATCH net-next 0/4] rtnl fdb get David Miller

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='CAJieiUgSSXACJAsa9U5pnxYW0bwr-=Hgu1oUmqMxS6HbvciSXA@mail.gmail.com' \
    --to=roopa@cumulusnetworks.com \
    --cc=davem@davemloft.net \
    --cc=dsa@cumulusnetworks.com \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@cumulusnetworks.com \
    --cc=stephen@networkplumber.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 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.