From patchwork Wed Feb 21 15:57:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13565797 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0E3B823CB for ; Wed, 21 Feb 2024 15:58:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708531124; cv=none; b=XtSKW/SUXE4k1D5PCBSAVOtNLYwjKHnKDTezwjNxTg4BVv2fTPXxFQKa1/By4Cqy3HlZhu4fqgK2RKoq2KY9Kg7ur+bxuVtYNbEWvnDBANIt2cmOessJxH2DZaBat+jyadUgBkyr+3umg6Iw/IZEmCzm3fFrI4i2nHCcl3NVQZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708531124; c=relaxed/simple; bh=b3I8DtEPynqthfDKMzjPijqG7ifvwN2QGor5pJwwtFs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=tPU3LP98zdQpQ26c604W6xRnv67VelU8JqNFaEw9CLIEteWHm7it8vMHXMQtYT6KSa6z/j/Z3lJ2yIqhhCgKgd9V+WdKQ29C8jxmqCqjETrEYZjQDeqwTGkItkx9GTWekNe85U8D19Wwq5R04likyheHzQlf1o64ZIs7+KvmESg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=lSb3bVQd; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="lSb3bVQd" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6e4c359e48aso178247b3a.1 for ; Wed, 21 Feb 2024 07:58:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1708531118; x=1709135918; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=4XNkLiaptlpOdgR8Lz2aXc5/cIA8mvoaalETxdH3pHc=; b=lSb3bVQdFNV5mWZVm6FPosSkw0o53PNt+pIe6I2s4h/XNnJNWxE5OSsKxRgAi6LeeB dwmRNn2puLPQny3HkXD/VKXfzEh25EckQSEpIh0v56K/l+0ZEK7cfZsY16/G1Qt1Y1Ef gTDoy3ntxlMm1/p/qNuYUsXRMXAuumFlczIiI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708531118; x=1709135918; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4XNkLiaptlpOdgR8Lz2aXc5/cIA8mvoaalETxdH3pHc=; b=kfKpsxtI3ZX8MV3VpKAmbiE8YiYIsHG9XgrqjqtPCAbEi30fpKBGdyH9x749KbHeSw QgBaEobIxas/EcRmt5xxDiQhmBDSYCRrvcIRYLqvZvEH4ITZeir+XI4LZElI6slyLnFc 0mZrJzJdx1oqs749Bir6NUzP7KsN3Z8xmYVyDt2BH0+XC8czGiSpAuLIEDpFI/hCuppt ywA1M4mzjstPxLFGKJflJHdyoYZAVSSPgX96xhLVh+HjtNRM9PvLK+gDI+UTgHW/5COZ SOPnKQkL1zL90GCfsWd7iDPG5SR8V9v4RSHPPf/pvRR8kqhV/BV2NsgWBwvf8cwFztac V7cw== X-Gm-Message-State: AOJu0Yw37gXCiMH+qVLInJCXw0UArUeyplpML6mHhC8zXrerTIAyXIpf rY7Ma+Re8GhdR9XEFdweqliqKmgSGJFvWCTxXZ1YND5oss7+NuBzCzGvnXngsTtU2wfDmG1M/UP +1RBPgaxN32wBV1QgXFqqssDt2ztSdIe8i1CzqgRU9eRqAxM68x0xwIircvsFJZbN+uQ5Fb6vqc SE6AedhL/uK1x3xIRiq76aFZPpzBNC1kNuP3s63Q== X-Google-Smtp-Source: AGHT+IF+vDfxJ3DnJY6wSQD6PeQS1l8LjdA4qL1jcqD6EP3+78/zLpI/XgbO73FX3fYDmYBzDED78A== X-Received: by 2002:a05:6a00:2f81:b0:6e4:688e:2072 with SMTP id fm1-20020a056a002f8100b006e4688e2072mr6922023pfb.34.1708531118043; Wed, 21 Feb 2024 07:58:38 -0800 (PST) Received: from localhost.localdomain (c-24-6-151-244.hsd1.ca.comcast.net. [24.6.151.244]) by smtp.gmail.com with ESMTPSA id du17-20020a056a002b5100b006e46672df97sm5751327pfb.75.2024.02.21.07.58.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2024 07:58:37 -0800 (PST) From: Joe Damato To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jesper Dangaard Brouer , Stanislav Fomichev , Amritha Nambiar , Larysa Zaremba , Lorenzo Bianconi , Tariq Toukan , Sridhar Samudrala , Alexei Starovoitov , Maciej Fijalkowski Subject: [PATCH net-next 1/2] netdev-genl: Add ifname for queue and NAPI APIs Date: Wed, 21 Feb 2024 07:57:29 -0800 Message-Id: <1708531057-67392-2-git-send-email-jdamato@fastly.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1708531057-67392-1-git-send-email-jdamato@fastly.com> References: <1708531057-67392-1-git-send-email-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-Patchwork-Delegate: kuba@kernel.org Expose the netdevice name when queue and NAPI netdev-genl APIs are used Signed-off-by: Joe Damato --- include/uapi/linux/netdev.h | 2 ++ net/core/netdev-genl.c | 22 +++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/include/uapi/linux/netdev.h b/include/uapi/linux/netdev.h index 93cb411..80762bc 100644 --- a/include/uapi/linux/netdev.h +++ b/include/uapi/linux/netdev.h @@ -117,6 +117,7 @@ enum { NETDEV_A_NAPI_ID, NETDEV_A_NAPI_IRQ, NETDEV_A_NAPI_PID, + NETDEV_A_NAPI_IFNAME, __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX = (__NETDEV_A_NAPI_MAX - 1) @@ -127,6 +128,7 @@ enum { NETDEV_A_QUEUE_IFINDEX, NETDEV_A_QUEUE_TYPE, NETDEV_A_QUEUE_NAPI_ID, + NETDEV_A_QUEUE_IFNAME, __NETDEV_A_QUEUE_MAX, NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1) diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index fd98936..a886e6a 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -181,6 +181,9 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct napi_struct *napi, if (nla_put_u32(rsp, NETDEV_A_NAPI_IFINDEX, napi->dev->ifindex)) goto nla_put_failure; + if (nla_put_string(rsp, NETDEV_A_NAPI_IFNAME, napi->dev->name)) + goto nla_put_failure; + if (napi->irq >= 0 && nla_put_u32(rsp, NETDEV_A_NAPI_IRQ, napi->irq)) goto nla_put_failure; @@ -307,7 +310,8 @@ netdev_nl_queue_fill_one(struct sk_buff *rsp, struct net_device *netdev, if (nla_put_u32(rsp, NETDEV_A_QUEUE_ID, q_idx) || nla_put_u32(rsp, NETDEV_A_QUEUE_TYPE, q_type) || - nla_put_u32(rsp, NETDEV_A_QUEUE_IFINDEX, netdev->ifindex)) + nla_put_u32(rsp, NETDEV_A_QUEUE_IFINDEX, netdev->ifindex) || + nla_put_string(rsp, NETDEV_A_QUEUE_IFNAME, netdev->name)) goto nla_put_failure; switch (q_type) { @@ -369,16 +373,19 @@ int netdev_nl_queue_get_doit(struct sk_buff *skb, struct genl_info *info) u32 q_id, q_type, ifindex; struct net_device *netdev; struct sk_buff *rsp; + char *ifname; int err; if (GENL_REQ_ATTR_CHECK(info, NETDEV_A_QUEUE_ID) || GENL_REQ_ATTR_CHECK(info, NETDEV_A_QUEUE_TYPE) || - GENL_REQ_ATTR_CHECK(info, NETDEV_A_QUEUE_IFINDEX)) + GENL_REQ_ATTR_CHECK(info, NETDEV_A_QUEUE_IFINDEX) || + GENL_REQ_ATTR_CHECK(info, NETDEV_A_QUEUE_IFNAME)) return -EINVAL; q_id = nla_get_u32(info->attrs[NETDEV_A_QUEUE_ID]); q_type = nla_get_u32(info->attrs[NETDEV_A_QUEUE_TYPE]); ifindex = nla_get_u32(info->attrs[NETDEV_A_QUEUE_IFINDEX]); + nla_strscpy(ifname, info->attrs[NETDEV_A_QUEUE_IFNAME], IFNAMSIZ); rsp = genlmsg_new(GENLMSG_DEFAULT_SIZE, GFP_KERNEL); if (!rsp) @@ -387,10 +394,15 @@ int netdev_nl_queue_get_doit(struct sk_buff *skb, struct genl_info *info) rtnl_lock(); netdev = __dev_get_by_index(genl_info_net(info), ifindex); - if (netdev) - err = netdev_nl_queue_fill(rsp, netdev, q_id, q_type, info); - else + + if (strcmp(netdev->name, ifname)) { err = -ENODEV; + } else { + if (netdev) + err = netdev_nl_queue_fill(rsp, netdev, q_id, q_type, info); + else + err = -ENODEV; + } rtnl_unlock(); From patchwork Wed Feb 21 15:57:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Damato X-Patchwork-Id: 13565798 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0475C8286A for ; Wed, 21 Feb 2024 15:58:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708531125; cv=none; b=bLAJA9jo3SEsJyg91vVX11Xp2M/058B8CppJnrQWZq8EEphZcG69NwqqSS7qtQaO9gpyMYzCZ3ZqgIdYSL9LVFYN4xLr8TBGJE2EWD1s5vHSsFlxNrovE+RghJ3EfwKxG+KCOgn7ikmGXOFmeU6EWn8AjKvTQeDzqNzOFiH5Zjs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708531125; c=relaxed/simple; bh=Nj1mtaX5eAfgwf0WZLLiG/Ms4DFiuQOrm99GPUUsJYw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=RovgUKSTXz71b0Se0xCVIWp345nZy2xXO/KkbywTuro/kE+x3uFAiH5Rx7zVq1YEKdoV1+9FE+dJn5zC6BntELqA9mTRKKb3yEi5Afyi2suUtpmIx5gfNeACoYSVPDqdFcVkvAS82vmDPtmoHWHmSEPOP02Zq0eF/7Vf/Jhq0zg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com; spf=pass smtp.mailfrom=fastly.com; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b=mPfWMdlu; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=fastly.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastly.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=fastly.com header.i=@fastly.com header.b="mPfWMdlu" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-5ce2aada130so5997886a12.1 for ; Wed, 21 Feb 2024 07:58:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastly.com; s=google; t=1708531123; x=1709135923; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=1LIWWe2AXJk8XZ9/FCqtCbXVReSA1Du2dj5i3r+vvHk=; b=mPfWMdlu4lKgpaWCCwc95Y5nJClBpAoEurNQoSzo4OqlFyu+nAWYfbSjpGPpVp1fJF DSnlqL52keBnP1E0UiLWy9ZTr+mTUgGmLsTg5+QXQWHlgN4N8kNDjiPigD3abPi6hoKt 7ICEk/C2VsnhwefS3zcn5kSk3s6niIjK4eDy0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708531123; x=1709135923; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1LIWWe2AXJk8XZ9/FCqtCbXVReSA1Du2dj5i3r+vvHk=; b=hvkbpKzuUcEJcZjdA86BNpNekpFrUcm98SOjuVMpR4s9LkpfGqJcaXy1TD9XiqB+Qw XsBnhDcyKIbsZoRsb3vt5p6fHqCq9I6sBjUxTlItAo+2ni3dDU32OnA/BP85DJsso89l IeNlBugizb8kozmbbv0QFJZ6Lj9gZbvEKly9RHpeqm0XPEnNuKIndbp3rDsqfqjNLIcj 1IUk/rKQmn9G4Nds06lmW+nUOWW2JMVyxyaRsbUpt5xzA+SPRM/+wtcDZPSuUy997fae MthD30Wk2ENiWsizWXsOKfgRngJy8LsCs9vNERXmqkhumjLfslbkN2YeCKd/oV/P0TyH fbmg== X-Gm-Message-State: AOJu0Yzo5b6jU/00wptGk5/nDvGmx1kHe+OlkvDo4Fp5wSrOdo/2opnv Sl5Oaa5TJBigXAqGIQ+sJe7glGtKJvxSnR93jGj8dueNzHqf8NXHrILR+H+IKQG47v1MuyEfvBe iKomeFHlmXLT5nvZrAXnuwfMSXPybI350u/WU3QQ3dVSzdEZ+vIDrEac6QRgoDcfmZQqiVB7ZtQ yObxvB5GmD1/s37T14MtTNih5SH3vPBbJqSJJ0pg== X-Google-Smtp-Source: AGHT+IEraZJQ0KZ8Ftb1yJdFO06Lcoi5jxU5GoHVGFqg+BCUcYEomQVbUPhFqLtfTnvmTs46iZbhbw== X-Received: by 2002:a05:6a21:670b:b0:19c:9b7b:66a with SMTP id wh11-20020a056a21670b00b0019c9b7b066amr18671389pzb.49.1708531122923; Wed, 21 Feb 2024 07:58:42 -0800 (PST) Received: from localhost.localdomain (c-24-6-151-244.hsd1.ca.comcast.net. [24.6.151.244]) by smtp.gmail.com with ESMTPSA id du17-20020a056a002b5100b006e46672df97sm5751327pfb.75.2024.02.21.07.58.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Feb 2024 07:58:42 -0800 (PST) From: Joe Damato To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Joe Damato , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jesper Dangaard Brouer , Stanislav Fomichev , Amritha Nambiar , Tariq Toukan , Sridhar Samudrala , Alexei Starovoitov , Larysa Zaremba Subject: [PATCH net-next 2/2] netdev-genl: spec: Add ifname to netdev nl YAML spec Date: Wed, 21 Feb 2024 07:57:30 -0800 Message-Id: <1708531057-67392-3-git-send-email-jdamato@fastly.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1708531057-67392-1-git-send-email-jdamato@fastly.com> References: <1708531057-67392-1-git-send-email-jdamato@fastly.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: X-Patchwork-Delegate: kuba@kernel.org Add support to netdev netlink spec (netdev.yaml) for the ifname of the net device. Signed-off-by: Joe Damato --- Documentation/netlink/specs/netdev.yaml | 10 ++++++++++ tools/include/uapi/linux/netdev.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/Documentation/netlink/specs/netdev.yaml b/Documentation/netlink/specs/netdev.yaml index 3addac9..9a92d04 100644 --- a/Documentation/netlink/specs/netdev.yaml +++ b/Documentation/netlink/specs/netdev.yaml @@ -240,6 +240,10 @@ attribute-sets: threaded mode. If NAPI is not in threaded mode (i.e. uses normal softirq context), the attribute will be absent. type: u32 + - + name: ifname + doc: name of the netdevice to which NAPI instance belongs. + type: string - name: queue attributes: @@ -264,6 +268,10 @@ attribute-sets: name: napi-id doc: ID of the NAPI instance which services this queue. type: u32 + - + name: ifname + doc: name of the netdevice to which the queue belongs. + type: string operations: list: @@ -381,6 +389,7 @@ operations: - type - napi-id - ifindex + - ifname dump: request: attributes: @@ -400,6 +409,7 @@ operations: - ifindex - irq - pid + - ifname dump: request: attributes: diff --git a/tools/include/uapi/linux/netdev.h b/tools/include/uapi/linux/netdev.h index 93cb411..80762bc 100644 --- a/tools/include/uapi/linux/netdev.h +++ b/tools/include/uapi/linux/netdev.h @@ -117,6 +117,7 @@ enum { NETDEV_A_NAPI_ID, NETDEV_A_NAPI_IRQ, NETDEV_A_NAPI_PID, + NETDEV_A_NAPI_IFNAME, __NETDEV_A_NAPI_MAX, NETDEV_A_NAPI_MAX = (__NETDEV_A_NAPI_MAX - 1) @@ -127,6 +128,7 @@ enum { NETDEV_A_QUEUE_IFINDEX, NETDEV_A_QUEUE_TYPE, NETDEV_A_QUEUE_NAPI_ID, + NETDEV_A_QUEUE_IFNAME, __NETDEV_A_QUEUE_MAX, NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1)