From nobody Sun May 12 17:09:31 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9D6C27EFB for ; Mon, 16 Oct 2023 13:43:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="L+IWKwp4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697463820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VgOFhuezaA3luEvym+AcVt4JaVtufAN+xse4n419UAE=; b=L+IWKwp4UVel1mI+iJ5sB65+7VKvkiH7XdTB941tQbHWL2dVjF2rRN3FtvoFvL7HiduB8M w266RQQqlTMGJ+DPDmo7q1jfyJFdht2iYvg445YpyYbLtIvbKmj5LuBP1MZ8E+VXbkidHb J/TpGaiI479IwdXqqLwMFHucp3Dtt+Y= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-335-RjrlGYPtPHess2nfSgzIuQ-1; Mon, 16 Oct 2023 09:43:29 -0400 X-MC-Unique: RjrlGYPtPHess2nfSgzIuQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 020338ECF66 for ; Mon, 16 Oct 2023 13:43:29 +0000 (UTC) Received: from dcaratti.users.ipa.redhat.com (unknown [10.45.224.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FFC5492BFA for ; Mon, 16 Oct 2023 13:43:28 +0000 (UTC) From: Davide Caratti To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 1/5] Squash-to: "net: mptcp: convert netlink from small_ops to ops" Date: Mon, 16 Oct 2023 15:43:07 +0200 Message-ID: <00f6df700d4a314dd67048ff584fe81a345ab283.1697463031.git.dcaratti@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Davide Caratti --- net/mptcp/pm_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 32976cf7c82b..fd4e843505e5 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -53,7 +53,7 @@ const struct nla_policy mptcp_pm_address_nl_policy[MPTCP_= PM_ADDR_ATTR_IF_IDX + 1 [MPTCP_PM_ADDR_ATTR_FAMILY] =3D { .type =3D NLA_U16, }, [MPTCP_PM_ADDR_ATTR_ID] =3D { .type =3D NLA_U8, }, [MPTCP_PM_ADDR_ATTR_ADDR4] =3D { .type =3D NLA_U32, }, - [MPTCP_PM_ADDR_ATTR_ADDR6] =3D { .len =3D 16, }, + [MPTCP_PM_ADDR_ATTR_ADDR6] =3D NLA_POLICY_EXACT_LEN(16), [MPTCP_PM_ADDR_ATTR_PORT] =3D { .type =3D NLA_U16, }, [MPTCP_PM_ADDR_ATTR_FLAGS] =3D { .type =3D NLA_U32, }, [MPTCP_PM_ADDR_ATTR_IF_IDX] =3D { .type =3D NLA_S32, }, --=20 2.41.0 From nobody Sun May 12 17:09:31 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2009326E16 for ; Mon, 16 Oct 2023 13:43:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fIVCHfi2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697463811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hWp4IvsZO2p2hwMOV0wajiEAv0RWxvi9Q/sJog859Ow=; b=fIVCHfi2umYbo+5/O4mzZzKCNg+s57w7mTkXRO24Qkdcz8u0chWmoGoVUtuBlQzg0KEDIC tbgON0JsvMRo4SkGIl2eVNXZKk5ceRlwNqVzpkx+B2zRvD4ll88VI+60IFkIh/Y6kLyQKj 2EOuRb1zv/QYxgNaw1FLedQAm0rpTwo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-159-6R4TLT7rPSaOJPF--BSKqQ-1; Mon, 16 Oct 2023 09:43:30 -0400 X-MC-Unique: 6R4TLT7rPSaOJPF--BSKqQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 223FF858F19 for ; Mon, 16 Oct 2023 13:43:30 +0000 (UTC) Received: from dcaratti.users.ipa.redhat.com (unknown [10.45.224.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EE26492BFA for ; Mon, 16 Oct 2023 13:43:29 +0000 (UTC) From: Davide Caratti To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 2/5] Squash-to: "Documentation: netlink: add a YAML spec for mptcp" Date: Mon, 16 Oct 2023 15:43:08 +0200 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Davide Caratti --- Documentation/netlink/specs/mptcp.yaml | 127 ++++++++++++------------- 1 file changed, 62 insertions(+), 65 deletions(-) diff --git a/Documentation/netlink/specs/mptcp.yaml b/Documentation/netlink= /specs/mptcp.yaml index f8ebcd009592..ec5c454a87ea 100644 --- a/Documentation/netlink/specs/mptcp.yaml +++ b/Documentation/netlink/specs/mptcp.yaml @@ -4,8 +4,8 @@ name: mptcp_pm protocol: genetlink-legacy doc: Multipath TCP. =20 -c-family-name: mptcp_pm_name -c-version-name: mptcp_pm_ver +c-family-name: mptcp-pm-name +c-version-name: mptcp-pm-ver max-by-define: true kernel-policy: per-op =20 @@ -13,12 +13,12 @@ definitions: - type: enum name: event-type - enum-name: mptcp_event_type - name-prefix: mptcp_event_ + enum-name: mptcp-event-type + name-prefix: mptcp-event- entries: - name: unspec - value: 0 + doc: unused event - name: created doc: @@ -45,41 +45,38 @@ definitions: A new address has been announced by the peer. - name: removed - value: 7 doc: token, rem_id An address has been lost by the peer. - - name: sub_established + name: sub-established value: 10 doc: token, family, loc_id, rem_id, saddr4 | saddr6, daddr4 | daddr6, s= port, dport, backup, if_idx [, error] A new subflow has been established. 'error' should not be set. - - name: sub_closed - value: 11 + name: sub-closed doc: token, family, loc_id, rem_id, saddr4 | saddr6, daddr4 | daddr6, s= port, dport, backup, if_idx [, error] A subflow has been closed. An error (copy of sk_err) could be set = if an error has been detected for this subflow. - - name: sub_priority + name: sub-priority value: 13 doc: token, family, loc_id, rem_id, saddr4 | saddr6, daddr4 | daddr6, s= port, dport, backup, if_idx [, error] The priority of a subflow has changed. 'error' should not be set. - - name: listener_created + name: listener-created value: 15 doc: family, sport, saddr4 | saddr6 A new PM listener is created. - - name: listener_closed - value: 16 + name: listener-closed doc: family, sport, saddr4 | saddr6 A PM listener is closed. @@ -87,7 +84,7 @@ definitions: attribute-sets: - name: address - name-prefix: mptcp_pm_addr_attr_ + name-prefix: mptcp-pm-addr-attr- attributes: - name: unspec @@ -107,7 +104,7 @@ attribute-sets: name: addr6 type: binary checks: - min-len: 16 + exact-len: 16 - name: port type: u16 @@ -116,52 +113,52 @@ attribute-sets: name: flags type: u32 - - name: if_idx + name: if-idx type: s32 - name: subflow-attribute - name-prefix: mptcp_subflow_attr_ + name-prefix: mptcp-subflow-attr- attributes: - name: unspec type: unused value: 0 - - name: token_rem + name: token-rem type: u32 - - name: token_loc + name: token-loc type: u32 - - name: relwrite_seq + name: relwrite-seq type: u32 - - name: map_seq + name: map-seq type: u64 - - name: map_sfseq + name: map-sfseq type: u32 - - name: ssn_offset + name: ssn-offset type: u32 - - name: map_datalen + name: map-datalen type: u16 - name: flags type: u32 - - name: id_rem + name: id-rem type: u8 - - name: id_loc + name: id-loc type: u8 - name: pad type: pad - name: endpoint - name-prefix: mptcp_pm_endpoint_ + name-prefix: mptcp-pm-endpoint- attributes: - name: addr @@ -169,7 +166,7 @@ attribute-sets: nested-attributes: address - name: attr - name-prefix: mptcp_pm_attr_ + name-prefix: mptcp-pm-attr- attributes: - name: unspec @@ -180,7 +177,7 @@ attribute-sets: type: nest nested-attributes: address - - name: rcv_add_addrs + name: rcv-add-addrs type: u32 - name: subflows @@ -189,19 +186,19 @@ attribute-sets: name: token type: u32 - - name: loc_id + name: loc-id type: u8 - - name: addr_remote + name: addr-remote type: nest nested-attributes: address - - name: event_attr - enum-name: mptcp_event_attr - name-prefix: mptcp_attr_ + name: event-attr + enum-name: mptcp-event-attr + name-prefix: mptcp-attr- attributes: - - name: UNSPEC + name: unspec type: unused value: 0 - @@ -211,10 +208,10 @@ attribute-sets: name: family type: u16 - - name: loc_id + name: loc-id type: u8 - - name: rem_id + name: rem-id type: u8 - name: saddr4 @@ -258,13 +255,13 @@ attribute-sets: name: if_idx type: u32 - - name: reset_reason + name: reset-reason type: u32 - - name: reset_flags + name: reset-flags type: u32 - - name: server_side + name: server-side type: u8 =20 operations: @@ -274,29 +271,29 @@ operations: doc: unused value: 0 - - name: add_addr + name: add-addr doc: Add endpoint attribute-set: endpoint dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: &add_addr_attrs + do: &add-addr-attrs request: attributes: - addr - - name: del_addr + name: del-addr doc: Delete endpoint attribute-set: endpoint dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: *add_addr_attrs + do: *add-addr-attrs - - name: get_addr + name: get-addr doc: Get endpoint information attribute-set: endpoint dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: &get_addr_attrs + do: &get-addr-attrs request: attributes: - addr @@ -308,56 +305,56 @@ operations: attributes: - addr - - name: flush_addrs + name: flush-addrs doc: flush addresses attribute-set: endpoint dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: *add_addr_attrs + do: *add-addr-attrs - - name: set_limits + name: set-limits doc: Set protocol limits attribute-set: attr dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: &mptcp_limits + do: &mptcp-limits request: attributes: - - rcv_add_addrs + - rcv-add-addrs - subflows - - name: get_limits + name: get-limits doc: Get protocol limits attribute-set: attr dont-validate: [ strict ] - do: &mptcp_get_limits + do: &mptcp-get-limits request: attributes: - - rcv_add_addrs + - rcv-add-addrs - subflows reply: attributes: - - rcv_add_addrs + - rcv-add-addrs - subflows - - name: set_flags + name: set-flags doc: Change endpoint flags attribute-set: attr dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: &mptcp_set_flags + do: &mptcp-set-flags request: attributes: - addr - token - - addr_remote + - addr-remote - name: announce doc: announce new sf attribute-set: attr dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: &announce_add + do: &announce-add request: attributes: - addr @@ -372,23 +369,23 @@ operations: request: attributes: - token - - loc_id + - loc-id - - name: subflow_create + name: subflow-create doc: todo attribute-set: attr dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: &sf_create + do: &sf-create request: attributes: - addr - token - - addr_remote + - addr-remote - - name: subflow_destroy + name: subflow-destroy doc: todo attribute-set: attr dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: *sf_create + do: *sf-create --=20 2.41.0 From nobody Sun May 12 17:09:31 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91DDF27EFB for ; Mon, 16 Oct 2023 13:43:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GjZjQeSi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697463812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ucbB0GphtoiwpQWdgSKDLmgGYenIfGFtJtw2GklnKV0=; b=GjZjQeSiDHYHrfJN6T9cDKbWVzvX58z+QGMU7xea5c0MhKgahZnD0ds1R+GfxBWn8pCl5T PjQrso3FeTcMZScuAmAy5WB+T0Qa+hy1zj1X/Av84lRcAu8j9DO82k5U37ab+Lrtn1QcW3 ptebLtY3LPnsTAb1XLq809Gd/S3chS8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-179--poz674APVOHEZWyAuQxbA-1; Mon, 16 Oct 2023 09:43:31 -0400 X-MC-Unique: -poz674APVOHEZWyAuQxbA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C4A64185A790 for ; Mon, 16 Oct 2023 13:43:30 +0000 (UTC) Received: from dcaratti.users.ipa.redhat.com (unknown [10.45.224.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60098492BFA for ; Mon, 16 Oct 2023 13:43:30 +0000 (UTC) From: Davide Caratti To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 3/5] Squash-to: "uapi: mptcp: use header file generated from YAML spec" Date: Mon, 16 Oct 2023 15:43:09 +0200 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Davide Caratti --- include/uapi/linux/mptcp_pm.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/mptcp_pm.h b/include/uapi/linux/mptcp_pm.h index 0c7206531eb1..0ad598fe940b 100644 --- a/include/uapi/linux/mptcp_pm.h +++ b/include/uapi/linux/mptcp_pm.h @@ -11,6 +11,7 @@ =20 /** * enum mptcp_event_type + * @MPTCP_EVENT_UNSPEC: unused event * @MPTCP_EVENT_CREATED: token, family, saddr4 | saddr6, daddr4 | daddr6, * sport, dport A new MPTCP connection has been created. It is the good = time * to allocate memory and send ADD_ADDR if needed. Depending on the --=20 2.41.0 From nobody Sun May 12 17:09:31 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D740528680 for ; Mon, 16 Oct 2023 13:43:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VJ9qYoqH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697463812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mWH5bBtPLsRqkYF2m7QH+8PmhDxvJCZJudFb07XM1Lw=; b=VJ9qYoqHEj7mNnw4fpC2TrJl6GLlvhUgwZJsRodKwwCgNCCWuSEl47deJ73YvIBtnI3PFK Vwd93XaA9eXi1XA/rUdlP7xTo9CAt2LuHIZwPHNIdySw2/zC6Jgyrkd2XpzPleHHXgWsLH Y1iPkrHF6QqZ4B9FvGQH5XdHDwANIsE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-526-LiVFjQ0uMWKlbEq8yCgpPw-1; Mon, 16 Oct 2023 09:43:31 -0400 X-MC-Unique: LiVFjQ0uMWKlbEq8yCgpPw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7170B185A7B6 for ; Mon, 16 Oct 2023 13:43:31 +0000 (UTC) Received: from dcaratti.users.ipa.redhat.com (unknown [10.45.224.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D888492BFA for ; Mon, 16 Oct 2023 13:43:30 +0000 (UTC) From: Davide Caratti To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 4/5] Squash to: "net: mptcp: use policy generated by YAML spec" Date: Mon, 16 Oct 2023 15:43:10 +0200 Message-ID: <3271dfdc25950f8edd1d8da8ba4b03bc1b878079.1697463031.git.dcaratti@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" as per Jakub's review, a newer YAML spec is going to validate addr6 with NLA_POLICY_EXACT_LEN(16) Signed-off-by: Davide Caratti --- net/mptcp/mptcp_pm_gen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/mptcp/mptcp_pm_gen.c b/net/mptcp/mptcp_pm_gen.c index 673b5167af6b..a2325e70ddab 100644 --- a/net/mptcp/mptcp_pm_gen.c +++ b/net/mptcp/mptcp_pm_gen.c @@ -15,7 +15,7 @@ const struct nla_policy mptcp_pm_address_nl_policy[MPTCP_= PM_ADDR_ATTR_IF_IDX + 1 [MPTCP_PM_ADDR_ATTR_FAMILY] =3D { .type =3D NLA_U16, }, [MPTCP_PM_ADDR_ATTR_ID] =3D { .type =3D NLA_U8, }, [MPTCP_PM_ADDR_ATTR_ADDR4] =3D { .type =3D NLA_U32, }, - [MPTCP_PM_ADDR_ATTR_ADDR6] =3D { .len =3D 16, }, + [MPTCP_PM_ADDR_ATTR_ADDR6] =3D NLA_POLICY_EXACT_LEN(16), [MPTCP_PM_ADDR_ATTR_PORT] =3D { .type =3D NLA_U16, }, [MPTCP_PM_ADDR_ATTR_FLAGS] =3D { .type =3D NLA_U32, }, [MPTCP_PM_ADDR_ATTR_IF_IDX] =3D { .type =3D NLA_S32, }, --=20 2.41.0 From nobody Sun May 12 17:09:31 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAE0A28682 for ; Mon, 16 Oct 2023 13:43:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KhiCopyK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1697463813; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VIpimx9Otqnw08mq0i/EKDc3wFzSc03rrUUIgtg8QCg=; b=KhiCopyKCt7GAXs0500nUL2cG2xiD1sDP3djjH1e5INFNvTl3lmXTuDXeojy7gBKg3DZaj CBE62LItEEJTiMY6NqqiDNbqnZ/5RYEVt3rjqYiH5uGxl9OcxWzZ4G51H8xOsvxmXa9K3F CwpFzWEJ0UCLBUl250BzsuN7arI1bgU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-425-HECBFAcrNBuH3WDDa0hRlA-1; Mon, 16 Oct 2023 09:43:32 -0400 X-MC-Unique: HECBFAcrNBuH3WDDa0hRlA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1FC3681DAA1 for ; Mon, 16 Oct 2023 13:43:32 +0000 (UTC) Received: from dcaratti.users.ipa.redhat.com (unknown [10.45.224.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF882492BFA for ; Mon, 16 Oct 2023 13:43:31 +0000 (UTC) From: Davide Caratti To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 5/5] tools: ynl-gen: add support for exact-len validation Date: Mon, 16 Oct 2023 15:43:11 +0200 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" add support for 'exact-len' validation on netlink attributes. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/340 Signed-off-by: Davide Caratti --- Documentation/netlink/genetlink-c.yaml | 3 +++ Documentation/netlink/genetlink-legacy.yaml | 3 +++ Documentation/netlink/genetlink.yaml | 3 +++ Documentation/netlink/netlink-raw.yaml | 3 +++ tools/net/ynl/ynl-gen-c.py | 28 +++++++++++++-------- 5 files changed, 29 insertions(+), 11 deletions(-) diff --git a/Documentation/netlink/genetlink-c.yaml b/Documentation/netlink= /genetlink-c.yaml index 9806c44f604c..812113280148 100644 --- a/Documentation/netlink/genetlink-c.yaml +++ b/Documentation/netlink/genetlink-c.yaml @@ -194,6 +194,9 @@ properties: max-len: description: Max length for a string or a binary attri= bute. $ref: '#/$defs/len-or-define' + exact-len: + description: Exact length for a string or a binary att= ribute. + $ref: '#/$defs/len-or-define' sub-type: *attr-type display-hint: &display-hint description: | diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/ne= tlink/genetlink-legacy.yaml index c08e5e3a0aaa..aa32649e20e9 100644 --- a/Documentation/netlink/genetlink-legacy.yaml +++ b/Documentation/netlink/genetlink-legacy.yaml @@ -233,6 +233,9 @@ properties: max-len: description: Max length for a string or a binary attri= bute. $ref: '#/$defs/len-or-define' + exact-len: + description: Exact length for a string or a binary att= ribute. + $ref: '#/$defs/len-or-define' sub-type: *attr-type display-hint: *display-hint # Start genetlink-c diff --git a/Documentation/netlink/genetlink.yaml b/Documentation/netlink/g= enetlink.yaml index 3d338c48bf21..3f179f8b95b3 100644 --- a/Documentation/netlink/genetlink.yaml +++ b/Documentation/netlink/genetlink.yaml @@ -167,6 +167,9 @@ properties: max-len: description: Max length for a string or a binary attri= bute. $ref: '#/$defs/len-or-define' + exact-len: + description: Exact length for a string or a binary att= ribute. + $ref: '#/$defs/len-or-define' sub-type: *attr-type display-hint: &display-hint description: | diff --git a/Documentation/netlink/netlink-raw.yaml b/Documentation/netlink= /netlink-raw.yaml index 896797876414..96913857ac71 100644 --- a/Documentation/netlink/netlink-raw.yaml +++ b/Documentation/netlink/netlink-raw.yaml @@ -240,6 +240,9 @@ properties: max-len: description: Max length for a string or a binary attri= bute. $ref: '#/$defs/len-or-define' + exact-len: + description: Exact length for a string or a binary att= ribute. + $ref: '#/$defs/len-or-define' sub-type: *attr-type display-hint: *display-hint # Start genetlink-c diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py index 897af958cee8..c58bca967fc1 100755 --- a/tools/net/ynl/ynl-gen-c.py +++ b/tools/net/ynl/ynl-gen-c.py @@ -355,10 +355,13 @@ class TypeString(Type): return f'.type =3D YNL_PT_NUL_STR, ' =20 def _attr_policy(self, policy): - mem =3D '{ .type =3D ' + policy - if 'max-len' in self.checks: - mem +=3D ', .len =3D ' + str(self.checks['max-len']) - mem +=3D ', }' + if 'exact-len' in self.checks: + mem =3D 'NLA_POLICY_EXACT_LEN(' + str(self.checks['exact-len']= ) + ')' + else: + mem =3D '{ .type =3D ' + policy + if 'max-len' in self.checks: + mem +=3D ', .len =3D ' + str(self.checks['max-len']) + mem +=3D ', }' return mem =20 def attr_policy(self, cw): @@ -404,14 +407,17 @@ class TypeBinary(Type): return f'.type =3D YNL_PT_BINARY,' =20 def _attr_policy(self, policy): - mem =3D '{ ' - if len(self.checks) =3D=3D 1 and 'min-len' in self.checks: - mem +=3D '.len =3D ' + str(self.checks['min-len']) - elif len(self.checks) =3D=3D 0: - mem +=3D '.type =3D NLA_BINARY' + if 'exact-len' in self.checks: + mem =3D 'NLA_POLICY_EXACT_LEN(' + str(self.checks['exact-len']= ) + ')' else: - raise Exception('One or more of binary type checks not impleme= nted, yet') - mem +=3D ', }' + mem =3D '{ ' + if len(self.checks) =3D=3D 1 and 'min-len' in self.checks: + mem +=3D '.len =3D ' + str(self.checks['min-len']) + elif len(self.checks) =3D=3D 0: + mem +=3D '.type =3D NLA_BINARY' + else: + raise Exception('One or more of binary type checks not imp= lemented, yet') + mem +=3D ', }' return mem =20 def attr_put(self, ri, var): --=20 2.41.0