09 Oct, 2020

1 commit

  • This accidentally got wired up to the *get* policy instead
    of the *set* policy, causing operations to be rejected. Fix
    it by wiring up the correct policy instead.

    Fixes: 5028588b62cb ("ethtool: wire up set policies to ops")
    Reported-by: Leon Romanovsky
    Signed-off-by: Johannes Berg
    Tested-by: Leon Romanovsky
    Reviewed-by: Jakub Kicinski
    Signed-off-by: Jakub Kicinski

    Johannes Berg
     

06 Oct, 2020

5 commits

  • Perform header flags validation through the policy.

    Only pause command supports ETHTOOL_FLAG_STATS. Create a separate
    policy to be able to express that in policy dumps to user space.

    Note that even though the core will validate the header policy,
    it cannot record multiple layers of attributes and we have to
    re-parse header sub-attrs. When doing so we could skip attribute
    validation, or use most permissive policy. Opt for the former.

    We will no longer return the extack cookie for flags but since
    we only added first new flag in this release it's not expected
    that any user space had a chance to make use of it.

    v2: - remove the re-validation in ethnl_parse_header_dev_get()

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

    Jakub Kicinski
     
  • 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
     

29 Sep, 2020

1 commit

  • Like all genl families ethtool_genl_family needs to not
    be a straight up constant, because it's modified/initialized
    by genl_register_family(). After init, however, it's only
    passed to genlmsg_put() & co. therefore we can mark it
    as __ro_after_init.

    Since genl_family structure contains function pointers
    mark this as a fix.

    Fixes: 2b4a8990b7df ("ethtool: introduce ethtool netlink interface")
    Signed-off-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Jakub Kicinski
     

11 Jul, 2020

2 commits

  • All conflicts seemed rather trivial, with some guidance from
    Saeed Mameed on the tc_ct.c one.

    Signed-off-by: David S. Miller

    David S. Miller
     
  • Add an interface to report offloaded UDP ports via ethtool netlink.

    Now that core takes care of tracking which UDP tunnel ports the NICs
    are aware of we can quite easily export this information out to
    user space.

    The responsibility of writing the netlink dumps is split between
    ethtool code and udp_tunnel_nic.c - since udp_tunnel module may
    not always be loaded, yet we should always report the capabilities
    of the NIC.

    $ ethtool --show-tunnels eth0
    Tunnel information for eth0:
    UDP port table 0:
    Size: 4
    Types: vxlan
    No entries
    UDP port table 1:
    Size: 4
    Types: geneve, vxlan-gpe
    Entries (1):
    port 1230, vxlan-gpe

    v4:
    - back to v2, build fix is now directly in udp_tunnel.h
    v3:
    - don't compile ETHTOOL_MSG_TUNNEL_INFO_GET in if CONFIG_INET
    not set.
    v2:
    - fix string set count,
    - reorder enums in the uAPI,
    - fix type of ETHTOOL_A_TUNNEL_UDP_TABLE_TYPES to bitset
    in docs and comments.

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

    Jakub Kicinski
     

10 Jul, 2020

1 commit

  • If the genlmsg_put() call in ethnl_default_dumpit() fails, we bail out
    without checking if we already have some messages in current skb like we do
    with ethnl_default_dump_one() failure later. Therefore if existing messages
    almost fill up the buffer so that there is not enough space even for
    netlink and genetlink header, we lose all prepared messages and return and
    error.

    Rather than duplicating the skb->len check, move the genlmsg_put(),
    genlmsg_cancel() and genlmsg_end() calls into ethnl_default_dump_one().
    This is also more logical as all message composition will be in
    ethnl_default_dump_one() and only iteration logic will be left in
    ethnl_default_dumpit().

    Fixes: 728480f12442 ("ethtool: default handlers for GET requests")
    Reported-by: Jakub Kicinski
    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     

27 May, 2020

1 commit


25 May, 2020

1 commit


22 May, 2020

1 commit

  • As ethnl_request_ops::reply_size handlers do not include common header
    size into calculated/estimated reply size, it needs to be added in
    ethnl_default_doit() and ethnl_default_notify() before allocating the
    message. On the other hand, strset_reply_size() should not add common
    header size.

    Fixes: 728480f12442 ("ethtool: default handlers for GET requests")
    Reported-by: Oleksij Rempel
    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     

11 May, 2020

2 commits

  • Make some helpers for building ethtool netlink messages available
    outside the compilation unit, so they can be used for building
    messages which are not simple get/set.

    Signed-off-by: Andrew Lunn
    Reviewed-by: Michal Kubecek
    Signed-off-by: Jakub Kicinski

    Andrew Lunn
     
  • Add new ethtool netlink calls to trigger the starting of a PHY cable
    test.

    Add Kconfig'ury to ETHTOOL_NETLINK so that PHYLIB is not a module when
    ETHTOOL_NETLINK is builtin, which would result in kernel linking errors.

    v2:
    Remove unwanted white space change
    Remove ethnl_cable_test_act_ops and use doit handler
    Rename cable_test_set_policy cable_test_act_policy
    Remove ETHTOOL_MSG_CABLE_TEST_ACT_REPLY

    v3:
    Remove ETHTOOL_MSG_CABLE_TEST_ACT_REPLY from documentation
    Remove unused cable_test_get_policy
    Add Reviewed-by tags

    v4:
    Remove unwanted blank line

    Signed-off-by: Andrew Lunn
    Reviewed-by: Michal Kubecek
    Reviewed-by: Florian Fainelli
    Signed-off-by: Jakub Kicinski

    Andrew Lunn
     

30 Mar, 2020

10 commits

  • Implement TSINFO_GET request to get timestamping information for a network
    device. This is traditionally available via ETHTOOL_GET_TS_INFO ioctl
    request.

    Move part of ethtool_get_ts_info() into common.c so that ioctl and netlink
    code use the same logic to get timestamping information from the device.

    v3: use "TSINFO" rather than "TIMESTAMP", suggested by Richard Cochran

    Signed-off-by: Michal Kubecek
    Acked-by: Richard Cochran
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Send ETHTOOL_MSG_EEE_NTF notification whenever EEE settings of a network
    device are modified using ETHTOOL_MSG_EEE_SET netlink message or
    ETHTOOL_SEEE ioctl request.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement EEE_SET netlink request to set EEE settings of a network device.
    These are traditionally set with ETHTOOL_SEEE ioctl request.

    The netlink interface allows setting the EEE status for all link modes
    supported by kernel but only first 32 link modes can be set at the moment
    as only those are supported by the ethtool_ops callback.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement EEE_GET request to get EEE settings of a network device. These
    are traditionally available via ETHTOOL_GEEE ioctl request.

    The netlink interface allows reporting EEE status for all link modes
    supported by kernel but only first 32 link modes are provided at the moment
    as only those are reported by the ethtool_ops callback and drivers.

    v2: fix alignment (whitespace only)

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Send ETHTOOL_MSG_PAUSE_NTF notification whenever pause parameters of
    a network device are modified using ETHTOOL_MSG_PAUSE_SET netlink message
    or ETHTOOL_SPAUSEPARAM ioctl request.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement PAUSE_SET netlink request to set pause parameters of a network
    device. Thease are traditionally set with ETHTOOL_SPAUSEPARAM ioctl
    request.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement PAUSE_GET request to get pause parameters of a network device.
    These are traditionally available via ETHTOOL_GPAUSEPARAM ioctl request.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Send ETHTOOL_MSG_COALESCE_NTF notification whenever coalescing parameters
    of a network device are modified using ETHTOOL_MSG_COALESCE_SET netlink
    message or ETHTOOL_SCOALESCE ioctl request.

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement COALESCE_SET netlink request to set coalescing parameters of
    a network device. These are traditionally set with ETHTOOL_SCOALESCE ioctl
    request. This commit adds only support for device coalescing parameters,
    not per queue coalescing parameters.

    Like the ioctl implementation, the generic ethtool code checks if only
    supported parameters are modified; if not, first offending attribute is
    reported using extack.

    v2: fix alignment (whitespace only)

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement COALESCE_GET request to get coalescing parameters of a network
    device. These are traditionally available via ETHTOOL_GCOALESCE ioctl
    request. This commit adds only support for device coalescing parameters,
    not per queue coalescing parameters.

    Omit attributes with zero values unless they are declared as supported
    (i.e. the corresponding bit in ethtool_ops::supported_coalesce_params is
    set).

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     

26 Mar, 2020

1 commit


16 Mar, 2020

1 commit

  • As pointed out by Jakub Kicinski, we ethtool netlink code should respond
    with an error if request head has flags set which are not recognized by
    kernel, either as a mistake or because it expects functionality introduced
    in later kernel versions.

    To avoid unnecessary roundtrips, use extack cookie to provide the
    information about supported request flags.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     

13 Mar, 2020

13 commits

  • Send ETHTOOL_MSG_CHANNELS_NTF notification whenever channel counts of
    a network device are modified using ETHTOOL_MSG_CHANNELS_SET netlink
    message or ETHTOOL_SCHANNELS ioctl request.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement CHANNELS_SET netlink request to set channel counts of a network
    device. These are traditionally set with ETHTOOL_SCHANNELS ioctl request.

    Like the ioctl implementation, the generic ethtool code checks if supplied
    values do not exceed driver defined limits; if they do, first offending
    attribute is reported using extack. Checks preventing removing channels
    used for RX indirection table or zerocopy AF_XDP socket are also
    implemented.

    Move ethtool_get_max_rxfh_channel() helper into common.c so that it can be
    used by both ioctl and netlink code.

    v2:
    - fix netdev reference leak in error path (found by Jakub Kicinsky)

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement CHANNELS_GET request to get channel counts of a network device.
    These are traditionally available via ETHTOOL_GCHANNELS ioctl request.

    Omit attributes for channel types which are not supported by driver or
    device (zero reported for maximum).

    v2: (all suggested by Jakub Kicinski)
    - minor cleanup in channels_prepare_data()
    - more descriptive channels_reply_size()
    - omit attributes with zero max count

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Send ETHTOOL_MSG_RINGS_NTF notification whenever ring sizes of a network
    device are modified using ETHTOOL_MSG_RINGS_SET netlink message or
    ETHTOOL_SRINGPARAM ioctl request.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement RINGS_SET netlink request to set ring sizes of a network device.
    These are traditionally set with ETHTOOL_SRINGPARAM ioctl request.

    Like the ioctl implementation, the generic ethtool code checks if supplied
    values do not exceed driver defined limits; if they do, first offending
    attribute is reported using extack.

    v2:
    - fix netdev reference leak in error path (found by Jakub Kicinsky)

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement RINGS_GET request to get ring sizes of a network device. These
    are traditionally available via ETHTOOL_GRINGPARAM ioctl request.

    Omit attributes for ring types which are not supported by driver or device
    (zero reported for maximum).

    v2: (all suggested by Jakub Kicinski)
    - minor cleanup in rings_prepare_data()
    - more descriptive rings_reply_size()
    - omit attributes with zero max size

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Send ETHTOOL_MSG_PRIVFLAGS_NTF notification whenever private flags of
    a network device are modified using ETHTOOL_MSG_PRIVFLAGS_SET netlink
    message or ETHTOOL_SPFLAGS ioctl request.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement PRIVFLAGS_SET netlink request to set private flags of a network
    device. These are traditionally set with ETHTOOL_SPFLAGS ioctl request.

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement PRIVFLAGS_GET request to get private flags for a network device.
    These are traditionally available via ETHTOOL_GPFLAGS ioctl request.

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Send ETHTOOL_MSG_FEATURES_NTF notification whenever network device features
    are modified using ETHTOOL_MSG_FEATURES_SET netlink message, ethtool ioctl
    request or any other way resulting in call to netdev_update_features() or
    netdev_change_features()

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement FEATURES_SET netlink request to set network device features.
    These are traditionally set using ETHTOOL_SFEATURES ioctl request.

    Actual change is subject to netdev_change_features() sanity checks so that
    it can differ from what was requested. Unlike with most other SET requests,
    in addition to error code and optional extack, kernel provides an optional
    reply message (ETHTOOL_MSG_FEATURES_SET_REPLY) in the same format but with
    different semantics: information about difference between user request and
    actual result and difference between old and new state of dev->features.
    This reply message can be suppressed by setting ETHTOOL_FLAG_OMIT_REPLY
    flag in request header.

    Signed-off-by: Michal Kubecek
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • Implement FEATURES_GET request to get network device features. These are
    traditionally available via ETHTOOL_GFEATURES ioctl request.

    v2:
    - style cleanup suggested by Jakub Kicinski

    Signed-off-by: Michal Kubecek
    Reviewed-by: Jakub Kicinski
    Signed-off-by: David S. Miller

    Michal Kubecek
     
  • 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