Re: [PATCH net-next v6 05/15] ethtool: helper functions for netlink interface

From: Michal Kubecek
Date: Wed Jul 03 2019 - 03:23:30 EST


On Tue, Jul 02, 2019 at 06:37:24PM -0700, Jakub Kicinski wrote:
> On Tue, 2 Jul 2019 13:50:04 +0200 (CEST), Michal Kubecek wrote:
> > Add common request/reply header definition and helpers to parse request
> > header and fill reply header. Provide ethnl_update_* helpers to update
> > structure members from request attributes (to be used for *_SET requests).
> >
> > Signed-off-by: Michal Kubecek <mkubecek@xxxxxxx>
>
> > diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
> > index 3c98b41f04e5..e13f29bbd625 100644
> > --- a/net/ethtool/netlink.c
> > +++ b/net/ethtool/netlink.c
> > @@ -1,8 +1,181 @@
> > // SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
> >
> > +#include <net/sock.h>
> > #include <linux/ethtool_netlink.h>
> > #include "netlink.h"
> >
> > +static struct genl_family ethtool_genl_family;
> > +
> > +static const struct nla_policy dflt_header_policy[ETHTOOL_A_HEADER_MAX + 1] = {
> > + [ETHTOOL_A_HEADER_UNSPEC] = { .type = NLA_REJECT },
>
> I think we want strict checking on all new netlink interfaces, and
> unfortunately that feature is opt-in.. so you need to add:
>
> .strict_start_type = ETHTOOL_A_HEADER_UNSPEC + 1
>
> To the first attr.

Oops... I'll have to check again how this works. I thought using
nla_parse_nested() instead of nla_parse_nested_deprecated() is
sufficient to have everything strict checked.

Michal