From patchwork Wed Mar 6 23:10:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13584732 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 A4F9A1C6A6 for ; Wed, 6 Mar 2024 23:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709766655; cv=none; b=rTD5bIWhu86vP/AX81xLWAui7nPa6G+9TmdhxVe84/s8Aq1eI2uTwiSbpTrlUHLcL9HCTrEK4gCv7N3N3kXuf4y5q1Hm2ivrBm3rloBTS9s1BHo6/XLOGYK6U60UmrXGucUPza5PxolVb7WN6vPqRLHMbCwD9PK2QjUUGRJJIi0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709766655; c=relaxed/simple; bh=8WwVJgNy4P3Z/Ag/ZMIerfYfV5j6fPZzDtDP5EQy7q0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rJKRX1ruNHn9tY4dmyWTTWMsMc0TH3ihVEKunM7VMMgwoLLyn9xXfiyCxr0WjczqVXLpjPgf8LPWyUZXVxhXfILdEv+HoS5rNG7UlU+Va0B4tRPfUHDrFpD4NohekaRi9Ko/2CBEkATajsJJ2yAG34ZcYzDAWWh9Oz7UIaX5L7U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Rcn0Cqmq; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rcn0Cqmq" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-33d28468666so81831f8f.0 for ; Wed, 06 Mar 2024 15:10:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709766651; x=1710371451; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YaDnKoyJyMtHsYHBBHKzbFqgHt1VU3dMIO0PPWYYXBk=; b=Rcn0Cqmqr5QFBhRXBbjhNc7/rk0iWHGCbLgTvXLy/YVx2v3IWSCYTdjGZc78+BvCf9 DhGcyTGWd+Up1yzLfuzUFlChFUcaOueZ2NtCkLyAxj7VbKMucAv9aaEbfYWsKJ8triZH 8Y0SIiN6zibmUf8xICG5H5W7I2tA1PKlj1+QIilDFCy9bew62M9VktPd3+HhtipQ0WxF 3iQhmPBDtgO0yv7NCNIbb3hngbKQY+1qVhvrpDGjH8GiChn8icGZ2TG95AYfIbSTLxDM xAsBhyW96ZcdVF8scAX8AKktsYvuPNVijFIEoK71F7tbT/VM+zyvRJg+opDAzc23cqzX HfPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709766651; x=1710371451; h=content-transfer-encoding:mime-version: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=YaDnKoyJyMtHsYHBBHKzbFqgHt1VU3dMIO0PPWYYXBk=; b=g14vOzOq66T/GOXW4Iy9xqZA49mGa7VdA3vDAWSE0fbixPmZVJ26xlFkYmu2NIAFNC 12n1E9T0EJfvZJxB8geztX/vyHKw+WUYf3P/oWv4u3Ejr1d0tqddyUxZwpYkrjRhvTc4 L6Pr6fWKpkxXiHw3GLSMGIsf9x8ddotazcBPVaqH537XxMdPCYtCpGNUl+aM8+ibJ9TI stDndu7StJL2kneDgAq2MEN3/jLfmsxbuWWeNLtjiqZXDq5v7Y3Fh20dsslBm/dfwBTS CIpw/sXIDQp3Na38GYTKUBVY5qESH7d5c571ohStkbm7uOoF6xkgDa0MvIl15hRgEXar MHqA== X-Gm-Message-State: AOJu0YyJb+EcAavjNA5JyHgF/9jNhtxD3+5X/7lPHVoEVSrqaLi9XBKx UbDNBp97BBbAxxW/+o422tvJqZEOBJGFKx4vWokrlYXyCIu11qS5/MfM3Kzvm0o= X-Google-Smtp-Source: AGHT+IGURrvaQFObhcs3qR6s8nMReGcXp1y334pNtkx+HuHPHTw6a8QS4qPguc5YX5RArFj/ZFlWmA== X-Received: by 2002:adf:efd0:0:b0:33e:206b:8119 with SMTP id i16-20020adfefd0000000b0033e206b8119mr11625728wrp.24.1709766651327; Wed, 06 Mar 2024 15:10:51 -0800 (PST) Received: from imac.fritz.box ([2a02:8010:60a0:0:952f:caa6:b9c0:b4d8]) by smtp.gmail.com with ESMTPSA id q16-20020a5d6590000000b0033d56aa4f45sm18722810wru.112.2024.03.06.15.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 15:10:50 -0800 (PST) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jacob Keller , Jiri Pirko , Stanislav Fomichev Cc: donald.hunter@redhat.com, Donald Hunter Subject: [PATCH net-next v3 1/6] tools/net/ynl: Fix extack decoding for netlink-raw Date: Wed, 6 Mar 2024 23:10:41 +0000 Message-ID: <20240306231046.97158-2-donald.hunter@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240306231046.97158-1-donald.hunter@gmail.com> References: <20240306231046.97158-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Extack decoding was using a hard-coded msg header size of 20 but netlink-raw has a header size of 16. Use a protocol specific msghdr_size() when decoding the attr offssets. Signed-off-by: Donald Hunter Reviewed-by: Jakub Kicinski --- tools/net/ynl/lib/ynl.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index 239e22b7a85f..b810a478a304 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -353,6 +353,9 @@ class NetlinkProtocol: raise Exception(f'Multicast group "{mcast_name}" not present in the spec') return mcast_groups[mcast_name].value + def msghdr_size(self): + return 16 + class GenlProtocol(NetlinkProtocol): def __init__(self, family_name): @@ -378,6 +381,8 @@ class GenlProtocol(NetlinkProtocol): raise Exception(f'Multicast group "{mcast_name}" not present in the family') return self.genl_family['mcast'][mcast_name] + def msghdr_size(self): + return super().msghdr_size() + 4 class SpaceAttrs: @@ -721,7 +726,7 @@ class YnlFamily(SpecFamily): return msg = self.nlproto.decode(self, NlMsg(request, 0, op.attr_set)) - offset = 20 + self._struct_size(op.fixed_header) + offset = self.nlproto.msghdr_size() + self._struct_size(op.fixed_header) path = self._decode_extack_path(msg.raw_attrs, op.attr_set, offset, extack['bad-attr-offs']) if path: From patchwork Wed Mar 6 23:10:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13584733 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 CF62D1C6B8 for ; Wed, 6 Mar 2024 23:10:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709766656; cv=none; b=tScLOqT6tb9exLNckMR4jMEy72GcRHvuYkOS6pWA0EgwuopE/u69GtqfRNIwyjp06LYzd3+VCfg9NHpFtJaZMsgUUfXjlZtJN0PYhdawnOSXI55S7PVna8fM79TOI3wF0/SAPkQ0ssVmNmrhmuYHtBggfYOX5zjMA3gqHXpby0I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709766656; c=relaxed/simple; bh=KFAN5YWY+EsZQAqGMVpjlxXLzkOqIvT+Vuo+PDo+sL8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N3nAU6OZER4awJ5MlTHAbTfTgLctfJj1/NVgder3JeA9Gfw3GeZFLJ1jwSW1EnPCC2O2L1mWQaKSUd1bgIWusuvIm/etYZuRjhHHonVo2FQXGdybnAB+y/PDQ2JzcvxKCkL/3q4RE28tXa/3KZYcRGqVGUtZoN7bp1P35+bjrdI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RNItXwhI; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RNItXwhI" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-33e2268ed96so156966f8f.3 for ; Wed, 06 Mar 2024 15:10:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709766653; x=1710371453; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iRHnbXtB32cLDQSrOyTYKzXDyrTH/Qa1ZN7Ooz9+0cY=; b=RNItXwhIjBr1HyD7YiDnVSTOaexrsb3KYWVpfxjsEbRVGRK8mS6v4ILUlCN5EpIsXL IvV4pnQZD+xS6xbtx3xlaGdD9m7JH0yegU1zniyoaRO+gjzXZAiF+dMcrrwL55zGIqn5 IXWNikOk+wKx7tbnzGRXBl7zTnfYPsrb0EQaZIcd+Ii69hJb1rSnXuwkWGpgsd2/vThp F0V70qOBVVkiEIfNQTqhSOxSE7YcNSsBnADLP2wZWwJwjpprpdITY20fyyUya6AImtPC cnWPlVXH76eaQ9KD6H7WSTy2LAd05fMFAjgc03RAwxD9hb2fKk8yQlH47q96gR8i/fsa 3RHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709766653; x=1710371453; h=content-transfer-encoding:mime-version: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=iRHnbXtB32cLDQSrOyTYKzXDyrTH/Qa1ZN7Ooz9+0cY=; b=Lj0NbPlXayObIR5I/tYO+o3hkdi/fCoheR/yA49nXqZW9UPL3VEcupkGnNXB0M6lNw +jpPgMshUXFKqjTxH49GroMoAiUb/qG/Pf07Sp5wpTaBI4uErabapU0nZylIFveXIFs+ dOGrBwl7a3nHLHCtcKoE7jrOUQsKZUqVzetEBSRFkwida0hVacBeV4++/yWhys4lSmX/ i/LTqtUgZwLVgcopaf/eawnDq5G35xArTARA17YXQ99VVsH6GUxndltr/uMpYMhFW6a4 T9DOVrkO6G+A2f/bVfCE5rSE5bBO3/JMxFrs3xG4SUYKcqOj99BTdzyff8xRukoOIjjo utZw== X-Gm-Message-State: AOJu0YwTx6Clmj++FIbiE/cRGMoi57zlxO/whqVXD+O0Wm8aCfiLzihq tPgdTLSPtNQ8lOUHM6E1uYWPMCc+qzyMxc6bGiP1HTDe5gGLvNoACgg606hgSIc= X-Google-Smtp-Source: AGHT+IHIZ0cwp4riiSCOsaMtVTlXATGPCe7JjHA8N2Tx5VEx0VJR5z+MDUWdukgBs41hQAibfKO/KA== X-Received: by 2002:a5d:61c2:0:b0:33e:d27:4ed3 with SMTP id q2-20020a5d61c2000000b0033e0d274ed3mr10508875wrv.64.1709766652651; Wed, 06 Mar 2024 15:10:52 -0800 (PST) Received: from imac.fritz.box ([2a02:8010:60a0:0:952f:caa6:b9c0:b4d8]) by smtp.gmail.com with ESMTPSA id q16-20020a5d6590000000b0033d56aa4f45sm18722810wru.112.2024.03.06.15.10.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 15:10:51 -0800 (PST) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jacob Keller , Jiri Pirko , Stanislav Fomichev Cc: donald.hunter@redhat.com, Donald Hunter Subject: [PATCH net-next v3 2/6] tools/net/ynl: Report netlink errors without stacktrace Date: Wed, 6 Mar 2024 23:10:42 +0000 Message-ID: <20240306231046.97158-3-donald.hunter@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240306231046.97158-1-donald.hunter@gmail.com> References: <20240306231046.97158-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org ynl does not handle NlError exceptions so they get reported like program failures. Handle the NlError exceptions and report the netlink errors more cleanly. Example now: Netlink error: No such file or directory nl_len = 44 (28) nl_flags = 0x300 nl_type = 2 error: -2 extack: {'bad-attr': '.op'} Example before: Traceback (most recent call last): File "/home/donaldh/net-next/./tools/net/ynl/cli.py", line 81, in main() File "/home/donaldh/net-next/./tools/net/ynl/cli.py", line 69, in main reply = ynl.dump(args.dump, attrs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/donaldh/net-next/tools/net/ynl/lib/ynl.py", line 906, in dump return self._op(method, vals, [], dump=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/donaldh/net-next/tools/net/ynl/lib/ynl.py", line 872, in _op raise NlError(nl_msg) lib.ynl.NlError: Netlink error: No such file or directory nl_len = 44 (28) nl_flags = 0x300 nl_type = 2 error: -2 extack: {'bad-attr': '.op'} Signed-off-by: Donald Hunter Reviewed-by: Jakub Kicinski --- tools/net/ynl/cli.py | 18 +++++++++++------- tools/net/ynl/lib/__init__.py | 4 ++-- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/tools/net/ynl/cli.py b/tools/net/ynl/cli.py index e8a65fbc3698..f131e33ac3ee 100755 --- a/tools/net/ynl/cli.py +++ b/tools/net/ynl/cli.py @@ -6,7 +6,7 @@ import json import pprint import time -from lib import YnlFamily, Netlink +from lib import YnlFamily, Netlink, NlError class YnlEncoder(json.JSONEncoder): @@ -66,12 +66,16 @@ def main(): if args.sleep: time.sleep(args.sleep) - if args.do: - reply = ynl.do(args.do, attrs, args.flags) - output(reply) - if args.dump: - reply = ynl.dump(args.dump, attrs) - output(reply) + try: + if args.do: + reply = ynl.do(args.do, attrs, args.flags) + output(reply) + if args.dump: + reply = ynl.dump(args.dump, attrs) + output(reply) + except NlError as e: + print(e) + exit(1) if args.ntf: ynl.check_ntf() diff --git a/tools/net/ynl/lib/__init__.py b/tools/net/ynl/lib/__init__.py index f7eaa07783e7..9137b83e580a 100644 --- a/tools/net/ynl/lib/__init__.py +++ b/tools/net/ynl/lib/__init__.py @@ -2,7 +2,7 @@ from .nlspec import SpecAttr, SpecAttrSet, SpecEnumEntry, SpecEnumSet, \ SpecFamily, SpecOperation -from .ynl import YnlFamily, Netlink +from .ynl import YnlFamily, Netlink, NlError __all__ = ["SpecAttr", "SpecAttrSet", "SpecEnumEntry", "SpecEnumSet", - "SpecFamily", "SpecOperation", "YnlFamily", "Netlink"] + "SpecFamily", "SpecOperation", "YnlFamily", "Netlink", "NlError"] From patchwork Wed Mar 6 23:10:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13584734 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 F306D1CAA8 for ; Wed, 6 Mar 2024 23:10:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709766657; cv=none; b=sHhOeI5dFTHfUqUXzYlRuJ2ZqZCsZVr3HmLvMwNFCOxahN6OO/ETu2PTLaoeVvxuqq/DEBHvFJ2sha/oftGNWUP8iLds4rvg69yl55UyjqXS1QWq+np44J9YfAiovf/L7ve37ZYdAyr+35qFon3nCaIc60nXvEd8YMr1GSZV+wk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709766657; c=relaxed/simple; bh=jZrC7AfrDm2OZGxWir2yHKvxcTBBOS2qgbExbjdp3kw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IfO6k6STy0fZdzEo56JvDZNUb3c87XDa7UDwNlRVHlRI1mBy6VGzTXU7iRPpvoTevWgWPayEv0tcgedAzHjEu4v9rjCi5+p3Ecn06e3hblLkWA/xKELjZu7h8K8tXCxj1yCGUPc2L4sJ95w4Wne9+DFvej0k99CNzI7Vy5LeQHc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jKz7np/h; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jKz7np/h" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-412fe981ef1so1614125e9.1 for ; Wed, 06 Mar 2024 15:10:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709766654; x=1710371454; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SAwcvaCdQDvnfiKaCjMf0rpuBeB7Hk/62QhSDffm2p0=; b=jKz7np/hgD6PaljUl16JzYE4JQBEn2g5TnOl23pMRqOYAT31L04kuuNDEOFEjEp9jg sdeuEp9OBb5qxdeEqsKmhaLGWyQcUk7gEYqkfNTw2w0esOf3lMw4GBg+0lwLbooQL4GI Xu4ctIQU73IhLVmvSbdpJMzi4Z85jfsPYmkobdxmzXJSiiRpOqTPWzq/y3RQqdPiv+MV 2PnfdOgmI4I0iu/4hPN/PzhYIRKSvkE0e8COMkYjrKjekoe2xmSI4Iq8sKYjNa9uo2KI ccbd976IABNYRWp0YrrhkEFZ8K+7CTIKQWMYBcWZHS+VSTTrv2rAqJXU8880DdnXXz7Q kR/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709766654; x=1710371454; h=content-transfer-encoding:mime-version: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=SAwcvaCdQDvnfiKaCjMf0rpuBeB7Hk/62QhSDffm2p0=; b=e+7fkWdnQade87QbRpzpoMvt5Bx5a81k+IPLyM6n+Fl/glKDCYD/x4BF7IeoASqkKj 6j7TfeIL8MBRo88qLiQ5bFozYdDyeR/UoflRa5HwDjpKEq0iFYmwOZ38LduRxYnkJ/Eo yllKtyutVfJl50AtSqoXwhbKsWSK4DyoFq5DdHMQi9A2arpYgP9XH9miaK5TDRTRQLeI lZtXXWnXvnLhDu2UlmaWbeK7d52158rJTCenmzIp9EnSaeZndDjUYsrhhafojo9G+7Ds mZg0u5dkXPyL7UtaXELo8hJILDROfNuq2D2RSCfPB0sh0U/8qLB4iakO5WTsYRlYPpCe AOWQ== X-Gm-Message-State: AOJu0YzO5JP1noOiRc/q6TYjRS8CuyrbVcCVPAUQtdergAY4wXpNRaeG brNLRN/effkR+eUWlJAqYPNO1WxjhG/mZRUw1easlqztKO9DGC/bjC6GkfgbuoE= X-Google-Smtp-Source: AGHT+IFeumxey0ahKkHjqOCoKtRQD/DE48eLSKdaIl+hWb7NfWPJ6KuYpB3MZut0at0m7bNPfCXoRg== X-Received: by 2002:a05:600c:548b:b0:412:bb48:67da with SMTP id iv11-20020a05600c548b00b00412bb4867damr6730048wmb.0.1709766653869; Wed, 06 Mar 2024 15:10:53 -0800 (PST) Received: from imac.fritz.box ([2a02:8010:60a0:0:952f:caa6:b9c0:b4d8]) by smtp.gmail.com with ESMTPSA id q16-20020a5d6590000000b0033d56aa4f45sm18722810wru.112.2024.03.06.15.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 15:10:53 -0800 (PST) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jacob Keller , Jiri Pirko , Stanislav Fomichev Cc: donald.hunter@redhat.com, Donald Hunter Subject: [PATCH net-next v3 3/6] tools/net/ynl: Fix c codegen for array-nest Date: Wed, 6 Mar 2024 23:10:43 +0000 Message-ID: <20240306231046.97158-4-donald.hunter@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240306231046.97158-1-donald.hunter@gmail.com> References: <20240306231046.97158-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org ynl-gen-c generates e.g. 'calloc(mcast_groups, sizeof(*dst->mcast_groups))' for array-nest attrs when it should be 'n_mcast_groups'. Add a 'n_' prefix in the generated code for array-nests. Signed-off-by: Donald Hunter Reviewed-by: Jakub Kicinski --- tools/net/ynl/ynl-gen-c.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py index 2f5febfe66a1..67bfaff05154 100755 --- a/tools/net/ynl/ynl-gen-c.py +++ b/tools/net/ynl/ynl-gen-c.py @@ -1667,7 +1667,7 @@ def _multi_parse(ri, struct, init_lines, local_vars): aspec = struct[anest] ri.cw.block_start(line=f"if (n_{aspec.c_name})") - ri.cw.p(f"dst->{aspec.c_name} = calloc({aspec.c_name}, sizeof(*dst->{aspec.c_name}));") + ri.cw.p(f"dst->{aspec.c_name} = calloc(n_{aspec.c_name}, sizeof(*dst->{aspec.c_name}));") ri.cw.p(f"dst->n_{aspec.c_name} = n_{aspec.c_name};") ri.cw.p('i = 0;') ri.cw.p(f"parg.rsp_policy = &{aspec.nested_render_name}_nest;") From patchwork Wed Mar 6 23:10:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13584735 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 01DFE1CAB8 for ; Wed, 6 Mar 2024 23:10:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709766658; cv=none; b=j5M7bvVAn/SwL0mJ+YjnFNAWPYUJ+prFJ8C3tcyvCjXf0N8IWYc20qPSwPS8ZGGl4BYrS/DDuEEEBt0ACrxVcjGYRTASV8Mzz0+cRKu2YLruZ7CySgTzQOTvruzkmbP8nYksiGHvx5wkE+n3PcIXLszKy2+XQYjbqFWwv/SyMCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709766658; c=relaxed/simple; bh=CQzOdH5LGQzzZKXJvu0BEDJL1D56vPaWCxc02lFMW4o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aREgEAWJu9aRr3N97t9dBxl9Cna+ick2Ok/e+e5AdbdSF6sMaJDylDgAUqsp+mJ5ZyOIOXDpR8tmR+8gVMwzSlBqYxr/vA6P4K6iNv4zJbgZufBdoZ8CxJewpb5U7Z/pbpAdb8t/XzSPSXl3N1W/L81JNoaFo0iLUw0E5INr1oE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FeKdB5t6; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FeKdB5t6" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-412f1961101so3232365e9.0 for ; Wed, 06 Mar 2024 15:10:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709766655; x=1710371455; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4dYKe4wgfR1A7xFuxidWludRAQ/v6RU7P/FuweFX8oE=; b=FeKdB5t6TRZSv0QNmvQ/OLwcHoyWfmKTkdAx84IT1qthTz1HnqzcTyzJ4SGekxrdUs o/RgTjK++FhUZiF0z6dZn9lxFLpVv3SeIrJaDIZcOE4ni5PnEQk65DVpogwdmPWv6wDo F/9ZEo66D31a0fR/pLSZLCdfoWx1J/lswdh6Z8SLsna/kYnnDf+uLTKzHIjjK+yKTiye 6fIGTdu1XI1OfYhEFYKouHstDDjku5Qa9sonTIE3Z3OBaDu9DNsiMh+23XXP2fjTkcdc vKWDooZ7iG9DaE85GKvRExFcL+gfido0RCUF5CgR2foOhGa0j9rfx5wMEM7hdgc5DKG6 sFBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709766655; x=1710371455; h=content-transfer-encoding:mime-version: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=4dYKe4wgfR1A7xFuxidWludRAQ/v6RU7P/FuweFX8oE=; b=NzHHeFcnssMBWri6mKrt1RXwLgikMp3hV6tPJ5NDDM26Jb9FUlsMYSn/99jKU9Ub3f iBpaJFN96rRsXq5h81erqoo9B2VgwkRMeey44m5x9R7KXeWyJX0aecT1QBcLn1/Zf0s8 uRcHg6sNTMoQ+gN2PH10afZ5qxQzHp15dX5wPyw8uyN7+DJBsmnu/Tj1P7Z327jqvjJg YQnHNgqBJqDE/O7HSe5MGHhXN3XZJqUm+erswcjKsZt1LIemLUz4ryI3VO/QzRgrvsoN bm5X8HDsh7IfSEHcoUil5b8a9wKF41+WluSjYz+wJXVwS0z6WpULyafXLJeaLFhGzvDe dCvQ== X-Gm-Message-State: AOJu0YysG+abm0WQXsUqH4xj1RlwZXiEyXQychaojfj1bw1rTndpPXmD MWicnwRH5eGWeHocSDCnhf/sPmgl8zMYo/m5NTeFaLZ3SSHMnQ/wPSFM4vrBQN4= X-Google-Smtp-Source: AGHT+IE+vuEZ8XFhDcWXlc7va2loFCw/Ce/ImirO5MQcOAt8ujV4Rm+pVRa314soNDLzXjSx/3hZhA== X-Received: by 2002:a05:6000:1751:b0:33e:3462:f6d6 with SMTP id m17-20020a056000175100b0033e3462f6d6mr7241346wrf.64.1709766654945; Wed, 06 Mar 2024 15:10:54 -0800 (PST) Received: from imac.fritz.box ([2a02:8010:60a0:0:952f:caa6:b9c0:b4d8]) by smtp.gmail.com with ESMTPSA id q16-20020a5d6590000000b0033d56aa4f45sm18722810wru.112.2024.03.06.15.10.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 15:10:54 -0800 (PST) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jacob Keller , Jiri Pirko , Stanislav Fomichev Cc: donald.hunter@redhat.com, Donald Hunter Subject: [PATCH net-next v3 4/6] tools/net/ynl: Add nest-type-value decoding Date: Wed, 6 Mar 2024 23:10:44 +0000 Message-ID: <20240306231046.97158-5-donald.hunter@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240306231046.97158-1-donald.hunter@gmail.com> References: <20240306231046.97158-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org The nlctrl genetlink-legacy family uses nest-type-value encoding as described in Documentation/userspace-api/netlink/genetlink-legacy.rst Add nest-type-value decoding to ynl. Signed-off-by: Donald Hunter Reviewed-by: Jakub Kicinski --- tools/net/ynl/lib/ynl.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index b810a478a304..2d7fdd903d9e 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -595,6 +595,16 @@ class YnlFamily(SpecFamily): decoded.append({ item.type: subattrs }) return decoded + def _decode_nest_type_value(self, attr, attr_spec): + decoded = {} + value = attr + for name in attr_spec['type-value']: + value = NlAttr(value.raw, 0) + decoded[name] = value.type + subattrs = self._decode(NlAttrs(value.raw), attr_spec['nested-attributes']) + decoded.update(subattrs) + return decoded + def _decode_unknown(self, attr): if attr.is_nest: return self._decode(NlAttrs(attr.raw), None) @@ -686,6 +696,8 @@ class YnlFamily(SpecFamily): decoded = {"value": value, "selector": selector} elif attr_spec["type"] == 'sub-message': decoded = self._decode_sub_msg(attr, attr_spec, search_attrs) + elif attr_spec["type"] == 'nest-type-value': + decoded = self._decode_nest_type_value(attr, attr_spec) else: if not self.process_unknown: raise Exception(f'Unknown {attr_spec["type"]} with name {attr_spec["name"]}') From patchwork Wed Mar 6 23:10:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13584736 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 39AF51CD16 for ; Wed, 6 Mar 2024 23:10:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709766660; cv=none; b=czUIX41cPdirTNRo6pu0uQ7wM8Dj+HxstR6er/yfGR/cDU6sQq2B3NQhRTjOxcYu3M082oT9Y77Mur46Mg37X676ydEs6xktwMYfmNwqp/V63Iqz7tHK7JxqQekKCTd051Of4ZdIv6UvQuvDNUYXPIbe1NiA78ivI8N4CEvdQ0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709766660; c=relaxed/simple; bh=0MKVABzlWNmbqJxZGdlvnuejy6g57xqzbcUe5hFUFjY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=i6mnSoJcLve9E1O1rJNiabWzM0hD3stgR0LA4kawPNxXdU2NQXBY1GtO3i+kq8Lm3xU7rD0MkHiQfxRHpiMxdnCRfsZuR4af8NQBkugSukQUiXJix2C4U5eW2V5b/WAQTXMcr+hd0xutSjjiW6sqq7dQa3DtM+BXJqFERwoR10w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gthuaaJA; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gthuaaJA" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-33d9c3f36c2so73018f8f.2 for ; Wed, 06 Mar 2024 15:10:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709766656; x=1710371456; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=VBPut+azW4VgeZF5AoeAaAZK5YIORL8YBqXmq2t1sBU=; b=gthuaaJA5IVZdtErFwGeP8KPxGdKzlQvUkt/UB37U5pyrQxwDunXYJEH9JPkZt61p9 PArGfvhfU9eydvubhWwQF76sN9ZUE+JgSObrTWeHrmZCjgYNKv18/dyn1gVtSzEMkHzi k8ElY0op5+QAN0UkJYIcDa1/DIe32KMnPn1Q8iHAZjPLlM0pPJaFgaK39bfvQo8u/eIz /5U3z2KN1YqJRzDgZNd3F/buVhnQ4xqxd4O+QESjvFvYX2WEtoilSjeFabhgQZrOKUf1 PiQeakygFrNvdNosKOWOPEttJaISgPgKlxgI44WwJQSiTcJZruaUibl5gUs2GJeD4YFw kEBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709766656; x=1710371456; h=content-transfer-encoding:mime-version: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=VBPut+azW4VgeZF5AoeAaAZK5YIORL8YBqXmq2t1sBU=; b=XqOyegS8qjdo6uNzmuUbGpRwaKNGKmJbodl7Wc3OUQvl2gLV6tjbaH7bkVtiOacRSL XReilUZfEs9wNE9d4W7hJnpVzQTgs4sWmcy2eqSkvgbPwYOSNUXjSpqlmgVkl1KJlgM6 xjGN5rn9G5kmYS2L6e218w23m0DPhFfoJ12UlWoKahXHPR1dT9xmnS05iSZCi57YHfvP c+8Qv8P6ZRvVVVl3GALl/+KQ6WJMebhPEhXcAvvmIinFjZp1Du3eXWVO75qEQ0r9qItc xz5xItHVvAedDowe7pYqA+AjlWZ1W8QyMDKqzXUceTFoR8SxCAw5UJtExbbmr2qfSciP leqA== X-Gm-Message-State: AOJu0Yxh8JNtmcsT/MdxtA1aXkb18BiRZcg31T7QxptNN7lLDGwQrwv6 4Z1hAd1ZvevLJWo3Xajsae6/0sgQqbxZxdaPedqogs9egTm3VPmHNhRd81h6G6A= X-Google-Smtp-Source: AGHT+IGvoS4INHBakPvguKSDC7cJ6YsMEKXVSRXuBTVMat32hY0MbMiVYbnbnS2YnMoRkMv7zx3loQ== X-Received: by 2002:adf:f94a:0:b0:33d:579e:f462 with SMTP id q10-20020adff94a000000b0033d579ef462mr12303076wrr.36.1709766655940; Wed, 06 Mar 2024 15:10:55 -0800 (PST) Received: from imac.fritz.box ([2a02:8010:60a0:0:952f:caa6:b9c0:b4d8]) by smtp.gmail.com with ESMTPSA id q16-20020a5d6590000000b0033d56aa4f45sm18722810wru.112.2024.03.06.15.10.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 15:10:55 -0800 (PST) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jacob Keller , Jiri Pirko , Stanislav Fomichev Cc: donald.hunter@redhat.com, Donald Hunter Subject: [PATCH net-next v3 5/6] doc/netlink: Allow empty enum-name in ynl specs Date: Wed, 6 Mar 2024 23:10:45 +0000 Message-ID: <20240306231046.97158-6-donald.hunter@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240306231046.97158-1-donald.hunter@gmail.com> References: <20240306231046.97158-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Update the ynl schemas to allow the specification of empty enum names for all enum code generation. Signed-off-by: Donald Hunter --- Documentation/netlink/genetlink-c.yaml | 15 +++++++++------ Documentation/netlink/genetlink-legacy.yaml | 15 +++++++++------ Documentation/netlink/netlink-raw.yaml | 15 +++++++++------ 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Documentation/netlink/genetlink-c.yaml b/Documentation/netlink/genetlink-c.yaml index c58f7153fcf8..3ebd50d78820 100644 --- a/Documentation/netlink/genetlink-c.yaml +++ b/Documentation/netlink/genetlink-c.yaml @@ -126,8 +126,9 @@ properties: Prefix for the C enum name of the attributes. Default family[name]-set[name]-a- type: string enum-name: - description: Name for the enum type of the attribute. - type: string + description: | + Name for the enum type of the attribute, if empty no name will be used. + type: [ string, "null" ] doc: description: Documentation of the space. type: string @@ -261,14 +262,16 @@ properties: the prefix with the upper case name of the command, with dashes replaced by underscores. type: string enum-name: - description: Name for the enum type with commands. - type: string + description: | + Name for the enum type with commands, if empty no name will be used. + type: [ string, "null" ] async-prefix: description: Same as name-prefix but used to render notifications and events to separate enum. type: string async-enum: - description: Name for the enum type with notifications/events. - type: string + description: | + Name for the enum type with commands, if empty no name will be used. + type: [ string, "null" ] list: description: List of commands type: array diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml index 938703088306..1d3fe3637707 100644 --- a/Documentation/netlink/genetlink-legacy.yaml +++ b/Documentation/netlink/genetlink-legacy.yaml @@ -168,8 +168,9 @@ properties: Prefix for the C enum name of the attributes. Default family[name]-set[name]-a- type: string enum-name: - description: Name for the enum type of the attribute. - type: string + description: | + Name for the enum type of the attribute, if empty no name will be used. + type: [ string, "null" ] doc: description: Documentation of the space. type: string @@ -304,14 +305,16 @@ properties: the prefix with the upper case name of the command, with dashes replaced by underscores. type: string enum-name: - description: Name for the enum type with commands. - type: string + description: | + Name for the enum type with commands, if empty no name will be used. + type: [ string, "null" ] async-prefix: description: Same as name-prefix but used to render notifications and events to separate enum. type: string async-enum: - description: Name for the enum type with notifications/events. - type: string + description: | + Name for the enum type with commands, if empty no name will be used. + type: [ string, "null" ] # Start genetlink-legacy fixed-header: &fixed-header description: | diff --git a/Documentation/netlink/netlink-raw.yaml b/Documentation/netlink/netlink-raw.yaml index ac4e05415f2f..40fc8ab1ee44 100644 --- a/Documentation/netlink/netlink-raw.yaml +++ b/Documentation/netlink/netlink-raw.yaml @@ -189,8 +189,9 @@ properties: Prefix for the C enum name of the attributes. Default family[name]-set[name]-a- type: string enum-name: - description: Name for the enum type of the attribute. - type: string + description: | + Name for the enum type of the attribute, if empty no name will be used. + type: [ string, "null" ] doc: description: Documentation of the space. type: string @@ -371,14 +372,16 @@ properties: the prefix with the upper case name of the command, with dashes replaced by underscores. type: string enum-name: - description: Name for the enum type with commands. - type: string + description: | + Name for the enum type with commands, if empty no name will be used. + type: [ string, "null" ] async-prefix: description: Same as name-prefix but used to render notifications and events to separate enum. type: string async-enum: - description: Name for the enum type with notifications/events. - type: string + description: | + Name for the enum type with commands, if empty no name will be used. + type: [ string, "null" ] # Start genetlink-legacy fixed-header: &fixed-header description: | From patchwork Wed Mar 6 23:10:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Donald Hunter X-Patchwork-Id: 13584737 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 302081C686 for ; Wed, 6 Mar 2024 23:10:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709766660; cv=none; b=b14WQl/gr97d6UFd9v7yNzrndvzCuRx3qDK7u5l9WySAqAhlK3b7Vq40wTFGboJ953kW1GIDmYvU23ixRyhiC0m/zKOIH3v7hG/k1FfQWwTrhJCScorOIt67zD2DtfYudcsELPAyoCOPlGR3Z/jwzNcdmZrPI6YfoJquHPzooZc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709766660; c=relaxed/simple; bh=29aUZT8E0ju1Siywvpe+Fh9wAAO2Ozhk/7WLxcb5lbI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tHS5c4VB/qkyVcH4V573U40KMDFzZe+J+Ml2JH4MJ7ZsIwXtDPZjwb+CV6ZvjR5rBvqExz1TUNKEe7z16nYEmMhUaeq47nPAEcrGy7CmCTLkkEyrXc7nCxKCqTdgV4br23F9Vuc8YIOFMTD9u67Y5gJcdY/YYiY45SyJvPVk3sg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gQiP5ajf; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gQiP5ajf" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-33d36736d4eso132078f8f.1 for ; Wed, 06 Mar 2024 15:10:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709766657; x=1710371457; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m2rb8FJpdUlgnKyLunPhnVB+zpD2moOgEHsxFgiazMo=; b=gQiP5ajfGoLjrPNmr1nLU1c4XPgeq8R8H/vEziLVvM0BPvHvKJa4u8vgcsAxJAKrJe bwFUlNfh6VgwtZyCIQRgQJSCWra6a96x+aWDtyFKDPJDir3d/UfwRxaG8+Pqw7/vIQVn MLmMJZ12nHk2rmQyLdCcaAuN1tymO5gdPvlWOaGKOkh6aYbPn5scBnAEtkZB/D0iuSEg 938giS1wZ5J2L1WaqVk6X3gHKaKgRDNQ/EgHDnOD+mhuRbg+5pNfai8HfcG/42Y+EaDF f8VM+9//Del4MS4R/y01ACwJGMG48ydnIAUIcO5DHqMTQ34O9YJWuXHg/lCkIRTx6WSa stJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709766657; x=1710371457; h=content-transfer-encoding:mime-version: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=m2rb8FJpdUlgnKyLunPhnVB+zpD2moOgEHsxFgiazMo=; b=BFnODI/hRIMVeBd8jZeE6qpVBp3cDmxr018SAyIWl1oVYNpFuDDjrg1OM/PJ7jRf8G vf2q4lK5/BvgfZpaPo8rRAqZFX2Ay2y2VvCk54DrsMZkKmgZDAvMek0U5vW0V1gB407b sq5a1LRfpGL/EzX1QAPfMAEFK6MQ2f3hQLzxvlJXj/kAY1PvOBBoAUOI8H/fmoGYpIaI +5g4txqQvHwizNK2sK/58flNZQO+G0WOpqj+Yc8AA894nl7EmqTmoB6GESHjzN71i920 9DpLlCqUEREV00Tb3vwYYejafvOPM9hrhgBmuBkqMghEvIeAj6N6wi2o8ufKFeHmg2Nv qADA== X-Gm-Message-State: AOJu0YwHWyOMXajUWv1CmllN/z90tKAiEMmsMPUvQgSh+efq7SRsNvwr GQB+Kg5CiijouuBgH6wdL2pqnRUE8E83/A0KHDoSH6ElF3mhI9RbPTpcFQsej/E= X-Google-Smtp-Source: AGHT+IHmX2COSyabeZFWKrQ5LKpIr0FyW7wg2iYDYhE0YQH8ab9+8voNmHwsf6MoMQ51ee2/vetJ/Q== X-Received: by 2002:adf:9c8a:0:b0:33d:c5c7:459e with SMTP id d10-20020adf9c8a000000b0033dc5c7459emr12327245wre.12.1709766657146; Wed, 06 Mar 2024 15:10:57 -0800 (PST) Received: from imac.fritz.box ([2a02:8010:60a0:0:952f:caa6:b9c0:b4d8]) by smtp.gmail.com with ESMTPSA id q16-20020a5d6590000000b0033d56aa4f45sm18722810wru.112.2024.03.06.15.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 15:10:56 -0800 (PST) From: Donald Hunter To: netdev@vger.kernel.org, Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Jacob Keller , Jiri Pirko , Stanislav Fomichev Cc: donald.hunter@redhat.com, Donald Hunter Subject: [PATCH net-next v3 6/6] doc/netlink/specs: Add spec for nlctrl netlink family Date: Wed, 6 Mar 2024 23:10:46 +0000 Message-ID: <20240306231046.97158-7-donald.hunter@gmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240306231046.97158-1-donald.hunter@gmail.com> References: <20240306231046.97158-1-donald.hunter@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add a spec for the nlctrl family. Example usage: ./tools/net/ynl/cli.py \ --spec Documentation/netlink/specs/nlctrl.yaml \ --do getfamily --json '{"family-name": "nlctrl"}' ./tools/net/ynl/cli.py \ --spec Documentation/netlink/specs/nlctrl.yaml \ --dump getpolicy --json '{"family-name": "nlctrl"}' Signed-off-by: Donald Hunter --- Documentation/netlink/specs/nlctrl.yaml | 207 ++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 Documentation/netlink/specs/nlctrl.yaml diff --git a/Documentation/netlink/specs/nlctrl.yaml b/Documentation/netlink/specs/nlctrl.yaml new file mode 100644 index 000000000000..08a8d047d52d --- /dev/null +++ b/Documentation/netlink/specs/nlctrl.yaml @@ -0,0 +1,206 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) + +name: nlctrl +protocol: genetlink-legacy +uapi-header: linux/genetlink.h + +doc: | + genetlink meta-family that exposes information about all genetlink + families registered in the kernel (including itself). + +definitions: + - + name: op-flags + type: flags + enum-name: + entries: + - admin-perm + - cmd-cap-do + - cmd-cap-dump + - cmd-cap-haspol + - uns-admin-perm + - + name: attr-type + enum-name: netlink-attribute-type + type: enum + entries: + - invalid + - flag + - u8 + - u16 + - u32 + - u64 + - s8 + - s16 + - s32 + - s64 + - binary + - string + - nul-string + - nested + - nested-array + - bitfield32 + - sint + - uint + +attribute-sets: + - + name: ctrl-attrs + name-prefix: ctrl-attr- + attributes: + - + name: family-id + type: u16 + - + name: family-name + type: string + - + name: version + type: u32 + - + name: hdrsize + type: u32 + - + name: maxattr + type: u32 + - + name: ops + type: array-nest + nested-attributes: op-attrs + - + name: mcast-groups + type: array-nest + nested-attributes: mcast-group-attrs + - + name: policy + type: nest-type-value + type-value: [ policy-id, attr-id ] + nested-attributes: policy-attrs + - + name: op-policy + type: nest-type-value + type-value: [ op-id ] + nested-attributes: op-policy-attrs + - + name: op + type: u32 + - + name: mcast-group-attrs + name-prefix: ctrl-attr-mcast-grp- + enum-name: + attributes: + - + name: name + type: string + - + name: id + type: u32 + - + name: op-attrs + name-prefix: ctrl-attr-op- + enum-name: + attributes: + - + name: id + type: u32 + - + name: flags + type: u32 + enum: op-flags + enum-as-flags: true + - + name: policy-attrs + name-prefix: nl-policy-type-attr- + enum-name: + attributes: + - + name: type + type: u32 + enum: attr-type + - + name: min-value-s + type: s64 + - + name: max-value-s + type: s64 + - + name: min-value-u + type: u64 + - + name: max-value-u + type: u64 + - + name: min-length + type: u32 + - + name: max-length + type: u32 + - + name: policy-idx + type: u32 + - + name: policy-maxtype + type: u32 + - + name: bitfield32-mask + type: u32 + - + name: mask + type: u64 + - + name: pad + type: pad + - + name: op-policy-attrs + name-prefix: ctrl-attr-policy- + enum-name: + attributes: + - + name: do + type: u32 + - + name: dump + type: u32 + +operations: + enum-model: directional + name-prefix: ctrl-cmd- + list: + - + name: getfamily + doc: Get / dump genetlink families + attribute-set: ctrl-attrs + do: + request: + value: 3 + attributes: + - family-name + reply: &all-attrs + value: 1 + attributes: + - family-id + - family-name + - hdrsize + - maxattr + - mcast-groups + - ops + - version + dump: + reply: *all-attrs + - + name: getpolicy + doc: Get / dump genetlink policies + attribute-set: ctrl-attrs + dump: + request: + value: 10 + attributes: + - family-name + - family-id + - op + reply: + value: 10 + attributes: + - family-id + - op-policy + - policy