From patchwork Tue Mar 26 02:43:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13603290 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 7E66A127B5C for ; Tue, 26 Mar 2024 02:44:05 +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=1711421046; cv=none; b=kaO7BU4wWDpxoXtDsDYe+xllY6o5XblCSyq9bl3e+WuA5p9CS7L2hkOooIABxp+vr9mIlCluSZHKItkbWIx+YIaN0n86yuc5zDbS1YSnj/7C2X83Dq0chGg/oTqmTeZauCC2Afv7EmTVtjBPWd+qLG9BS61WkMmIDzlhDcwbVrA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711421046; c=relaxed/simple; bh=JwyhqOUuKZOKFrfvgVM61vIBAoulNElhELpcyYx5DOw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qT3Doml+25Hy+Nhn9Q/L4jsPljArOyd3ZtnUOnDVCZrMj8Y0Bjy9FSLoaaxq0i9+hO/RS9KbjF+kKSv7mY4SjPUyamF5UpDuuHzOCuMbZYBUQlbLH3xYYVbbbNv2zTvtEWbAuvz0nYs6+wQX8xaZoLx17uCQ84+rFbQLMtcHe3U= 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=f/nV8T0v; arc=none smtp.client-ip=209.85.210.174 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="f/nV8T0v" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6ea9a616cc4so1581551b3a.1 for ; Mon, 25 Mar 2024 19:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711421044; x=1712025844; 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=DT99lkvQe8eUKR0KyLaQdNX0xa+XAlT3VwCE95rFMzA=; b=f/nV8T0vQVuqdzv+6r42AGJL88to3HCg6KCorty8VEeyRANiS/qh/z+6yWZVCPEN1n Jp3q0GM1T+POJ1UhNhaOTL9DL0rEvaIzCWyn40qutaA7BYGMt9hN7m2FqKBCp/Sh1FhK a1ye0fQOatk7LnCPeqp0BsjJ51jtocUePNYthCe3cYaYJ93Nkr59dTFL/iKGN/sK/v9U Bj50q20J+x9JC2ygRXTq4H6DFTGPmuqZkVUA9e5fCv2zFI8oGrHxGiQrNNQQKB5sXTlg Ltgl1oVyukI1LZWDwqOkzIvrpoKBsQvDUxgRc9K9b9l0teufSpjuB6zgTIGVKCzzAj7+ js8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711421044; x=1712025844; 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=DT99lkvQe8eUKR0KyLaQdNX0xa+XAlT3VwCE95rFMzA=; b=RNE7jpS/j40vppa0ZoUOiPD4IjFM45aeaHda9p6rGBXVRxY6rQh1+60yO0ljTjsvaj 5ZKYdRiVY7Ur4297RYg2AoUoeKpDV3OAlN1nvo/EzYLvuP2nuQEMecBuPGrFoLM2f3QG jAHmxTGmAyH0iyQIvWvaezz5dSDK/2mveEX8ezGh5wkcBYdHR+D+PiXClZ4cQDvPyNcy Q0La3vYoT+Iohbtkiclx03b12TgNpJwCDo853jYRSdsE/LBwkGxM7zsQvp9E4cv8+YKP F5bNBT0TMf1j/z7f44npVze8etWV8HhlXrU64xMYqPEUbaWlgV9jDPd3YZP245YA43n4 YCwA== X-Gm-Message-State: AOJu0Yxozn9w2rJ0zOPqH79EYeaYspb4c2eWru+Iaoo+OFZbSljRczYR Ulk/ePqt3DjEmfkagBP3YIHcPQOZPE5+XhFOO5282fNnFydqlwu9s6Tyiyi5jlM4A3od X-Google-Smtp-Source: AGHT+IEeJ+29GT5Ws5NPCaFzubOAjBYhYI7l1ySTY3N36t0QhJpw/0mpHzuXagHKSffQ/ZEJWfyHYQ== X-Received: by 2002:a05:6a20:92a9:b0:1a3:5fb7:42b5 with SMTP id q41-20020a056a2092a900b001a35fb742b5mr7308779pzg.16.1711421044265; Mon, 25 Mar 2024 19:44:04 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001def088c036sm5499193plg.19.2024.03.25.19.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 19:44:03 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Donald Hunter , Jiri Pirko , Jacob Keller , Stanislav Fomichev , Hangbin Liu Subject: [PATCHv2 net-next 1/2] ynl: support hex display_hint for integer Date: Tue, 26 Mar 2024 10:43:24 +0800 Message-ID: <20240326024325.2008639-2-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240326024325.2008639-1-liuhangbin@gmail.com> References: <20240326024325.2008639-1-liuhangbin@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 Some times it would be convenient to read the integer as hex, like mask values. Suggested-by: Donald Hunter Signed-off-by: Hangbin Liu Reviewed-by: Donald Hunter --- tools/net/ynl/lib/ynl.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index 5fa7957f6e0f..e73b027c5624 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -819,7 +819,10 @@ class YnlFamily(SpecFamily): if display_hint == 'mac': formatted = ':'.join('%02x' % b for b in raw) elif display_hint == 'hex': - formatted = bytes.hex(raw, ' ') + if isinstance(raw, int): + formatted = hex(raw) + else: + formatted = bytes.hex(raw, ' ') elif display_hint in [ 'ipv4', 'ipv6' ]: formatted = format(ipaddress.ip_address(raw)) elif display_hint == 'uuid': From patchwork Tue Mar 26 02:43:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 13603291 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 9E983127B5C for ; Tue, 26 Mar 2024 02:44:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711421050; cv=none; b=eDUOWQoZHXAopX6sJkitp0FsjIuhfGWQag0vOby/kdOPn8HNZViJfkU/EBG+xUR82GsfoxevJEUtUael0AId1wq1XjmzACDxdo+PoxRcIbe5S/A9AI9rBZfMvFjU+W/koWZNg48hIHx43s+pPxREMxDXjRYTcvFNVJSQWWQFca8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711421050; c=relaxed/simple; bh=+2h6UDoj+abyeTPA/SOoPTkVJck5zAVgAaweiJ5HNSM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T+e9FraUmdWl3BMlqTdqUhHhb30pVGWsuSuv3QCAZWQJ2s+CH+qhc76C7+1TSJscQ+qbnR5mw6Y3RlJIaXfdLSewcxBvyD0su/FZDgpjemvGspZ9w90opNewBb+jiYuglwK7o4Py/yPiLdHzOgLxTD3cvdOMKVVKuvZhQfDruVI= 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=kgCUriP5; arc=none smtp.client-ip=209.85.210.169 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="kgCUriP5" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6ea9a60f7f5so1988346b3a.3 for ; Mon, 25 Mar 2024 19:44:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711421047; x=1712025847; 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=1Z6GDA1U0Mv97zX08pGAQIqg+JHkvn/okL+baWjyxlw=; b=kgCUriP5qJ70YdRZwIdpHSNPbYK9zWE0QU1LL+7O1nHhCk2cJuFhOF5RhLHRzXsWEg /HANSRJzhFjLJy6DrgklVOXkJv4ZttnKB4SPzYjL2vNSCFrnb6fhjdWSPja8maQu8hDG ljfSLfvXAaj5efvuU+bcLPVRmzmss7xG0pHVTNDnwGx9zRxkkDAdOZBcuCPzkdkcqxvk +inWqGTgyv/ypq3BVjdAyFOyU2xhIc/p/4S/RvhM+M40NDZGp/7s5xMBZ9yA+s5qxGM0 K++LB/oD1oUOfa/yPB2QFMNlaWRWaLatp5pKd8pShYvRtWMdfZ1diRkaMYq4ezrqOP8s Gx+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711421047; x=1712025847; 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=1Z6GDA1U0Mv97zX08pGAQIqg+JHkvn/okL+baWjyxlw=; b=F67YbfeaVM4eNehR82ChS8h9T8NK0AnEmz4SEX5rEp6WfbMjXp0SALU8TqinIk4bF2 xKBfXn7m/mZcqvZlghLApMyaTzMSaIwFb0pyvCLaUNxe/sK/E11sOcLF8PoTOQWQbQ6L 1vQOyJPjmRk1nUNsn+2C99zIFcA3IiCRXUGmwLmAmQ9Z/sRyyc1uLJdP7QwrYpPz0Yqh gwX/jgomQUd4+EyWchCsi4GurCAJictJn5AvALgPJJfuc1qzS2suIUB+A1HqxlY4S2WB c+9d89ZOYWBPRWuMm+ETOJmgXnZzB7r8KMxpPNVI/wEZnO0GphkjYl4kuyO95A65w8gr PiGw== X-Gm-Message-State: AOJu0YyUbPrSaC2NXrbhg35uJjGyMBCPfs+OiRfG/JXz1/22i/opXuNF fmomCFMZqPiOZrIUKD3Gs0HjUEilItEiItC7HNrb1ExYQ1VoTe4UcAgvKrP0IEabMKJU X-Google-Smtp-Source: AGHT+IF84EM9Xyv6QN9GJtCfuuEoy1ALA2Q2ldK9lS07dqeIZER+PD/dLxDQVFyvTYKBLU76XzOUAw== X-Received: by 2002:a05:6a21:9210:b0:1a3:b619:4dad with SMTP id tl16-20020a056a21921000b001a3b6194dadmr7983826pzb.0.1711421047145; Mon, 25 Mar 2024 19:44:07 -0700 (PDT) Received: from Laptop-X1.redhat.com ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id x15-20020a170902ec8f00b001def088c036sm5499193plg.19.2024.03.25.19.44.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 19:44:06 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Donald Hunter , Jiri Pirko , Jacob Keller , Stanislav Fomichev , Hangbin Liu Subject: [PATCHv2 net-next 2/2] doc/netlink/specs: Add vlan attr in rt_link spec Date: Tue, 26 Mar 2024 10:43:25 +0800 Message-ID: <20240326024325.2008639-3-liuhangbin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240326024325.2008639-1-liuhangbin@gmail.com> References: <20240326024325.2008639-1-liuhangbin@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 With command: # ./tools/net/ynl/cli.py \ --spec Documentation/netlink/specs/rt_link.yaml \ --do getlink --json '{"ifname": "eno1.2"}' --output-json | \ jq -C '.linkinfo' Before: Exception: No message format for 'vlan' in sub-message spec 'linkinfo-data-msg' After: { "kind": "vlan", "data": { "protocol": "8021Q", "id": 2, "flag": { "flags": [ "reorder-hdr" ], "mask": "0xffffffff" } } } Signed-off-by: Hangbin Liu v2: - Add eth-protocols definitions, but only include vlan protocols (Donald Hunter) - Set protocol to big-endian (Donald Hunter) - Add display-hint for vlan flag mask (Donald Hunter) --- Documentation/netlink/specs/rt_link.yaml | 83 +++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/Documentation/netlink/specs/rt_link.yaml b/Documentation/netlink/specs/rt_link.yaml index 8e4d19adee8c..41b49f15236f 100644 --- a/Documentation/netlink/specs/rt_link.yaml +++ b/Documentation/netlink/specs/rt_link.yaml @@ -50,7 +50,16 @@ definitions: name: dormant - name: echo - + - + name: eth-protocols + type: enum + entries: + - + name: 8021Q + value: 33024 + - + name: 8021AD + value: 34984 - name: rtgenmsg type: struct @@ -729,6 +738,43 @@ definitions: - name: filter-mask type: u32 + - + name: ifla-vlan-flags + type: struct + members: + - + name: flags + type: u32 + enum: vlan-flags + enum-as-flags: true + - + name: mask + type: u32 + display-hint: hex + - + name: vlan-flags + type: flags + entries: + - + name: reorder-hdr + - + name: gvrp + - + name: loose-binding + - + name: mvrp + - + name: bridge-binding + - + name: ifla-vlan-qos-mapping + type: struct + members: + - + name: from + type: u32 + - + name: to + type: u32 attribute-sets: @@ -1507,6 +1553,38 @@ attribute-sets: - name: num-disabled-queues type: u32 + - + name: linkinfo-vlan-attrs + name-prefix: ifla-vlan- + attributes: + - + name: id + type: u16 + - + name: flag + type: binary + struct: ifla-vlan-flags + - + name: egress-qos + type: nest + nested-attributes: ifla-vlan-qos + - + name: ingress-qos + type: nest + nested-attributes: ifla-vlan-qos + - + name: protocol + type: u16 + enum: eth-protocols + byte-order: big-endian + - + name: ifla-vlan-qos + name-prefix: ifla-vlan-qos + attributes: + - + name: mapping + type: binary + struct: ifla-vlan-qos-mapping - name: linkinfo-vrf-attrs name-prefix: ifla-vrf- @@ -1666,6 +1744,9 @@ sub-messages: - value: tun attribute-set: linkinfo-tun-attrs + - + value: vlan + attribute-set: linkinfo-vlan-attrs - value: vrf attribute-set: linkinfo-vrf-attrs