net: ethtool: don't require empty header nests

JIRA: https://issues.redhat.com/browse/RHEL-860

commit 500e1340d1d2695de3f15fc0b3781f593a77acc2
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Fri Jun 9 14:53:31 2023 -0700

    net: ethtool: don't require empty header nests

    Ethtool currently requires a header nest (which is used to carry
    the common family options) in all requests including dumps.

      $ cli.py --spec netlink/specs/ethtool.yaml --dump channels-get
      lib.ynl.NlError: Netlink error: Invalid argument
      nl_len = 64 (48) nl_flags = 0x300 nl_type = 2
            error: -22      extack: {'msg': 'request header missing'}

      $ cli.py --spec netlink/specs/ethtool.yaml --dump channels-get \
               --json '{"header":{}}';  )
      [{'combined-count': 1,
        'combined-max': 1,
        'header': {'dev-index': 2, 'dev-name': 'enp1s0'}}]

    Requiring the header nest to always be there may seem nice
    from the consistency perspective, but it's not serving any
    practical purpose. We shouldn't burden the user like this.

    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
This commit is contained in:
Michal Schmidt 2023-07-26 15:04:56 +02:00
parent ec44b35873
commit f0c90fee5e
1 changed files with 2 additions and 0 deletions

View File

@ -96,6 +96,8 @@ int ethnl_parse_header_dev_get(struct ethnl_req_info *req_info,
int ret;
if (!header) {
if (!require_dev)
return 0;
NL_SET_ERR_MSG(extack, "request header missing");
return -EINVAL;
}