06 Oct, 2020

4 commits

  • To get the most out of parsing by the core, and to allow dumping
    full policies we need to specify which policy applies to nested
    attrs. For headers it's ethnl_header_policy.

    $ sed -i 's@\(ETHTOOL_A_.*HEADER\].*=\) { .type = NLA_NESTED },@\1\n\t\tNLA_POLICY_NESTED(ethnl_header_policy),@' net/ethtool/*

    Signed-off-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • Since ethtool uses strict attribute validation there's no need
    to initialize all attributes in policy tables. 0 is NLA_UNSPEC
    which is going to be rejected. Remove the NLA_REJECTs.

    Similarly attributes above maxattrs are rejected, so there's
    no need to always size the policy tables to ETHTOOL_A_..._MAX.

    v2: - new patch

    Suggested-by: Johannes Berg
    Signed-off-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • Similarly to get commands wire up the policies of set commands
    to get parsing by the core and policy dumps.

    Signed-off-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Jakub Kicinski
     
  • Wire up policies for get commands in struct nla_policy of the ethtool
    family. Make use of genetlink code attr validation and parsing, as well
    as allow dumping policies to user space.

    For every ETHTOOL_MSG_*_GET:
    - add 'ethnl_' prefix to policy name
    - add extern declaration in net/ethtool/netlink.h
    - wire up the policy & attr in ethtool_genl_ops[].
    - remove .request_policy and .max_attr from ethnl_request_ops.

    Obviously core only records the first "layer" of parsed attrs
    so we still need to parse the sub-attrs of the nested header
    attribute.

    v2:
    - merge of patches 1 and 2 from v1
    - remove stray empty lines in ops
    - also remove .max_attr

    Signed-off-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Jakub Kicinski
     

26 Mar, 2020

1 commit


24 Mar, 2020

1 commit

  • Andrew noticed that some handlers for *_SET commands leak a netdev
    reference if required ethtool_ops callbacks do not exist. A simple
    reproducer would be e.g.

    ip link add veth1 type veth peer name veth2
    ethtool -s veth1 wol g
    ip link del veth1

    Make sure dev_put() is called when ethtool_ops check fails.

    v2: add Fixes tags

    Fixes: a53f3d41e4d3 ("ethtool: set link settings with LINKINFO_SET request")
    Fixes: bfbcfe2032e7 ("ethtool: set link modes related data with LINKMODES_SET request")
    Fixes: e54d04e3afea ("ethtool: set message mask with DEBUG_SET request")
    Fixes: 8d425b19b305 ("ethtool: set wake-on-lan settings with WOL_SET request")
    Reported-by: Andrew Lunn
    Signed-off-by: Michal Kubecek
    Reviewed-by: Andrew Lunn
    Reviewed-by: Florian Fainelli
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     

13 Mar, 2020

1 commit

  • Andrew Lunn pointed out that even if it's documented that
    ethnl_parse_header() takes reference to network device if it fills it
    into the target structure, its name doesn't make it apparent so that
    corresponding dev_put() looks like mismatched.

    Rename the function ethnl_parse_header_dev_get() to indicate that it
    takes a reference.

    Suggested-by: Andrew Lunn
    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     

27 Jan, 2020

3 commits

  • Send ETHTOOL_MSG_DEBUG_NTF notification message whenever debugging message
    mask for a device are modified using ETHTOOL_MSG_DEBUG_SET netlink message
    or ETHTOOL_SMSGLVL ioctl request.

    The notification message has the same format as reply to DEBUG_GET request.
    As with other ethtool notifications, netlink requests only trigger the
    notification if the mask is actually changed while ioctl request trigger it
    whenever the request results in calling the ethtool_ops handler.

    Signed-off-by: Michal Kubecek
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement DEBUG_SET netlink request to set debugging settings for a device.
    At the moment, only message mask corresponding to message level as set by
    ETHTOOL_SMSGLVL ioctl request can be set. (It is called message level in
    ioctl interface but almost all drivers interpret it as a bit mask.)

    Signed-off-by: Michal Kubecek
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement DEBUG_GET request to get debugging settings for a device. At the
    moment, only message mask corresponding to message level as reported by
    ETHTOOL_GMSGLVL ioctl request is provided. (It is called message level in
    ioctl interface but almost all drivers interpret it as a bit mask.)

    As part of the implementation, provide symbolic names for message mask bits
    as ETH_SS_MSG_CLASSES string set.

    Signed-off-by: Michal Kubecek
    Reviewed-by: Andrew Lunn
    Signed-off-by: David S. Miller

    Michal Kubecek