From patchwork Tue Oct 10 19:21:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13415916 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 70E702FE01; Tue, 10 Oct 2023 19:22:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZMhN2TCq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECB9AC433CA; Tue, 10 Oct 2023 19:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696965723; bh=FkJc0H6OMIzQhv7nVnzWu7KssuAvk/PqTWIo7TR0B2Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZMhN2TCq7x8MzAmed0YdfWJMvjxXy8vvn6DRMNJKqofdnPwSjzbUKDv0Mgd723V6d UDUOhgC7xYfBpWWcXZFSIlCenD0ODOXDa8tFMPZIfIJjU+Zu+ztW3dpi3a1CH9LLPi i75PJFVTyjMtm9uAaIs3i+LIZooFY1PE55yFQ6Bv26au1uR4mifmBUfuQM9eJVb4mn 0uZIu9Ud56zIreMc0hYtQIdEZpgbl7Pn6+GKnCO5SC5iHd32jYH6rXdDI5fMxmC9zF jZyzUpRVI+TqOVtVNxq4S38rigopzS38Kdy+vHPdUUd4+3iwMo09H6FWAZnajbndMB kmwft/mXNOtuA== From: Matthieu Baerts Date: Tue, 10 Oct 2023 21:21:42 +0200 Subject: [PATCH net-next 1/6] tools: ynl: add uns-admin-perm to genetlink legacy Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-1-18dd117e8f50@kernel.org> References: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-0-18dd117e8f50@kernel.org> In-Reply-To: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-0-18dd117e8f50@kernel.org> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Davide Caratti , Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=937; i=matttbe@kernel.org; h=from:subject:message-id; bh=CEeDuoKr4YsKIddFImJBrssE0bezdUIPrFAMqU2bEiA=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlJaRV+0vC8TF4WfZNftXeCyx5hCfO811Y6oY6y 5a9Ewv5TjWJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZSWkVQAKCRD2t4JPQmmg c7wnEACI2bsm/JE7+qvhFjq4ltf6+PDUF7ckVR3d3UqkYZoCcH858cbirCFjv19PW59InjdsUl2 fwWKdfoX4cLdaPIAIAkQo5ZwBJWd5h5VKM7nNaHyElv34sRKMzdGyiuJUYopB+buNlHRnRmbwT+ QroJ/7330TgX0ZPOR7HTz5opALlRsA8gpzMd0ziCHWOz3be1yqa2oKFTk/IX9qSl8fciuz0LEqY xES+Gu8sVUd5gn9lUSFI0flv6O0RGv6Vp+sj74z6V7yhO57/TKIXFVEFZ7wbfNinyU3CZtcpQlM xmDrkQtfbWIhCz/eMlD1XgeoU4m9sRKtIJw3mWSfIYg9k6o4dYfS6TKIFkXFg+qZkVDCGoolK16 FFG/8CPRWEBQYZrmgmb/rZLscoT9PRMRMMhHTC4S/pM2Em0QCS4d+bKD8Z/UWDIXI/mC+yLEg9y pt1tN7cfq/FBJNtk56/iwba1FDwouuE56c/6t463bQWJS05G/l5BiiWwmMPgxorcEIIQKiGlIGh fSB64jqqEhauXk2SfDIB/j85wm73hArRPN45V1a0Bd1NO49fIwj/yotA1Fyi8/rqPjBhKGYDFrb WkR1joNU1+ArSJrfSJ8fmMKy7w8w/Rf0yWZ+P8mSXB7+OVTg//Aaht2nf23tEVxPSYmS8ogXiY8 +wy90qiA9wt1heQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Davide Caratti this flag maps to GENL_UNS_ADMIN_PERM and will be used by future specs. Acked-by: Paolo Abeni Signed-off-by: Davide Caratti Signed-off-by: Matthieu Baerts --- Documentation/netlink/genetlink-legacy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml index 25fe1379b180..6b4eb4b2ec17 100644 --- a/Documentation/netlink/genetlink-legacy.yaml +++ b/Documentation/netlink/genetlink-legacy.yaml @@ -328,7 +328,7 @@ properties: description: Command flags. type: array items: - enum: [ admin-perm ] + enum: [ admin-perm, uns-admin-perm ] dont-validate: description: Kernel attribute validation flags. type: array From patchwork Tue Oct 10 19:21:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13415917 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 788D129CE1; Tue, 10 Oct 2023 19:22:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KX0HvAub" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2972C433C7; Tue, 10 Oct 2023 19:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696965726; bh=yM7KjXTObWwFAt0kkYCB/fRJosZ7h5UaoJgfYR7hptI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=KX0HvAubMonj4fEYMAnneanvzGUqUZlt5s/tjo02hIt45ev2Dwbs4BmmoMjlm1Bz9 Z/jHaTSIAKIuiOqK18i29ulpH9ftVd9WpONAqSn/qiQ6ScJQkSYX/gTzLqx0lm1E7n iwPQT7X5zxh8tvrfhthzcWUnN2WRaom/RaMqyiKvrZOLPCg9XhdLCCSiH171vANKcB l3hxWepJds8aRSVv54CQQ+03mvSpd26PEdlh+rLV0dRdxWRWG+5OuYtGMPQe3u1kzA QXIHEhwEr2d5O/H/YSr3VkTAocucpwhRM5EwG3tGFlmYRl0sjdy06rK36ccqjXSaTJ SU78vYi35eVrw== From: Matthieu Baerts Date: Tue, 10 Oct 2023 21:21:43 +0200 Subject: [PATCH net-next 2/6] net: mptcp: convert netlink from small_ops to ops Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-2-18dd117e8f50@kernel.org> References: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-0-18dd117e8f50@kernel.org> In-Reply-To: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-0-18dd117e8f50@kernel.org> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Davide Caratti , Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=11837; i=matttbe@kernel.org; h=from:subject:message-id; bh=xJIQUgvyWS794R7SPkEw/jyO1hGLyVubPRydeRZdkVw=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlJaRVaw8Aty37Yvxf6LD8AqCyqv5UFhiJqVPmw SGS8Ut+p/6JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZSWkVQAKCRD2t4JPQmmg c8MMD/45dq2QnSTNF7YeXnTDSdI37oBC5l4F9Gs5DudPJaFmBmcckRimTtl15un4xZIl+knbYAo xpfkTxXNnxgdTjNIuzo1GbzR2VL5UAbS/3Vvor16rDwKiorg6NRhG1hz/uQjXMlxR2MyW92m/h8 EN5pOEpqWEanmHYqzqfbyRu1DDCPfABVsW0gqtl+Z2jf+zMomyt045mbMfVdHLoqztdZvrIntnV CzQkHje17hk1Io7/FNj77bxvk3TfFyU5LsgXG7p1Ly4Lf0Ub4DYgkTYsuRL0+sS+jodN73S9DaY smzjsUlA5SYFwu4ojb71arn4J0LvBxzgVpoDJKUPQdpJLFMZA02FUEQyPu/Dvk9LWm/ItGFgkhS B1qSzda+lxi4cO0JCd5agjZiXXLTHfk+Tn0dsZUYlYRuxclTjv9ZTb2wmo5SdlGGvpQqS6G8L0G H1z0kfm+6sMBhGyyxmPuHa/4JXmPUuAeXq9K9UB1By5EUortt9lZxE/bG1rRtDOm3jDma+dX4P5 czFfRGoFAIKJxi4c9RbPJvx0d34r01J6PQBrfqJOUu8K4tArZsDuJFpoAuGlP3fSWbyybRzOsJ5 x0R5EwzYIb6Vyg1+6SmlJVdBb5E8E5q8FZ/mc1DLFp5l7SnweZ+MMsLC5q2PKpzeTG+16ezaaPZ hXJo+AddjrXARzA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Davide Caratti in the current MPTCP control plane, all operations use a netlink attribute of the same type "MPTCP_PM_ATTR". However, add/del/get/flush operations only parse the first element in the message _ the one that describes MPTCP endpoints (that was named MPTCP_PM_ATTR_ADDR and mostly used in ADD_ADDR operations _ probably the similarity of "attr", "addr" and "add" might cause some confusion to human readers). Convert MPTCP from 'small_ops' to 'ops', thus allowing different attributes for each single operation, hopefully makes all this clearer to human readers. - use a separate attribute set for add/del/get/flush address operation, binary compatible with the existing one, to store the endpoint address. MPTCP_PM_ENDPOINT_ADDR is added to the uAPI (with the same value as MPTCP_PM_ATTR_ADDR) for these operations. - convert mptcp_pm_ops[] and add policy files accordingly. this prepares MPTCP control plane to be described as YAML spec. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/340 Acked-by: Paolo Abeni Signed-off-by: Davide Caratti Signed-off-by: Matthieu Baerts --- include/uapi/linux/mptcp.h | 8 ++ net/mptcp/pm_netlink.c | 191 ++++++++++++++++++++++++++++++--------------- 2 files changed, 135 insertions(+), 64 deletions(-) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index ee9c49f949a2..0e62937ab17c 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -65,6 +65,14 @@ enum { #define MPTCP_PM_ATTR_MAX (__MPTCP_PM_ATTR_MAX - 1) +enum { + MPTCP_PM_ENDPOINT_ADDR = 1, + + __MPTCP_PM_ENDPOINT_MAX +}; + +#define MPTCP_PM_ENDPOINT_MAX (__MPTCP_PM_ENDPOINT_MAX - 1) + enum { MPTCP_PM_ADDR_ATTR_UNSPEC, diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 9661f3812682..32976cf7c82b 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -48,6 +48,60 @@ struct pm_nl_pernet { #define MPTCP_PM_ADDR_MAX 8 #define ADD_ADDR_RETRANS_MAX 3 +static +const struct nla_policy mptcp_pm_address_nl_policy[MPTCP_PM_ADDR_ATTR_IF_IDX + 1] = { + [MPTCP_PM_ADDR_ATTR_FAMILY] = { .type = NLA_U16, }, + [MPTCP_PM_ADDR_ATTR_ID] = { .type = NLA_U8, }, + [MPTCP_PM_ADDR_ATTR_ADDR4] = { .type = NLA_U32, }, + [MPTCP_PM_ADDR_ATTR_ADDR6] = { .len = 16, }, + [MPTCP_PM_ADDR_ATTR_PORT] = { .type = NLA_U16, }, + [MPTCP_PM_ADDR_ATTR_FLAGS] = { .type = NLA_U32, }, + [MPTCP_PM_ADDR_ATTR_IF_IDX] = { .type = NLA_S32, }, +}; + +/* MPTCP_PM_CMD_ADD_ADDR / DEL / GET / FLUSH - do */ +static +const struct nla_policy mptcp_pm_endpoint_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = { + [MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_SET_LIMITS - do */ +static +const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1] = { + [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, }, +}; + +/* MPTCP_PM_CMD_SET_FLAGS - do */ +static +const struct nla_policy mptcp_pm_set_flags_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = { + [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_ANNOUNCE - do */ +static +const struct nla_policy mptcp_pm_announce_nl_policy[MPTCP_PM_ATTR_TOKEN + 1] = { + [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, +}; + +/* MPTCP_PM_CMD_REMOVE - do */ +static +const struct nla_policy mptcp_pm_remove_nl_policy[MPTCP_PM_ATTR_LOC_ID + 1] = { + [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_LOC_ID] = { .type = NLA_U8, }, +}; + +/* MPTCP_PM_CMD_SUBFLOW_CREATE / DESTROY - do */ +static +const struct nla_policy mptcp_pm_subflow_create_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = { + [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + static struct pm_nl_pernet *pm_nl_get_pernet(const struct net *net) { return net_generic(net, pm_nl_pernet_id); @@ -1104,29 +1158,6 @@ static const struct genl_multicast_group mptcp_pm_mcgrps[] = { }, }; -static const struct nla_policy -mptcp_pm_addr_policy[MPTCP_PM_ADDR_ATTR_MAX + 1] = { - [MPTCP_PM_ADDR_ATTR_FAMILY] = { .type = NLA_U16, }, - [MPTCP_PM_ADDR_ATTR_ID] = { .type = NLA_U8, }, - [MPTCP_PM_ADDR_ATTR_ADDR4] = { .type = NLA_U32, }, - [MPTCP_PM_ADDR_ATTR_ADDR6] = - NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)), - [MPTCP_PM_ADDR_ATTR_PORT] = { .type = NLA_U16 }, - [MPTCP_PM_ADDR_ATTR_FLAGS] = { .type = NLA_U32 }, - [MPTCP_PM_ADDR_ATTR_IF_IDX] = { .type = NLA_S32 }, -}; - -static const struct nla_policy mptcp_pm_policy[MPTCP_PM_ATTR_MAX + 1] = { - [MPTCP_PM_ATTR_ADDR] = - NLA_POLICY_NESTED(mptcp_pm_addr_policy), - [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, }, - [MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, }, - [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, - [MPTCP_PM_ATTR_LOC_ID] = { .type = NLA_U8, }, - [MPTCP_PM_ATTR_ADDR_REMOTE] = - NLA_POLICY_NESTED(mptcp_pm_addr_policy), -}; - void mptcp_pm_nl_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) { struct mptcp_subflow_context *iter, *subflow = mptcp_subflow_ctx(ssk); @@ -1188,7 +1219,7 @@ static int mptcp_pm_parse_pm_addr_attr(struct nlattr *tb[], /* no validation needed - was already done via nested policy */ err = nla_parse_nested_deprecated(tb, MPTCP_PM_ADDR_ATTR_MAX, attr, - mptcp_pm_addr_policy, info->extack); + mptcp_pm_address_nl_policy, info->extack); if (err) return err; @@ -1305,7 +1336,7 @@ static int mptcp_nl_add_subflow_or_signal_addr(struct net *net) static int mptcp_nl_cmd_add_addr(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR]; + struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; int ret; @@ -1486,7 +1517,7 @@ static int mptcp_nl_remove_id_zero_address(struct net *net, static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR]; + struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; unsigned int addr_max; @@ -1677,7 +1708,7 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, static int mptcp_nl_cmd_get_addr(struct sk_buff *skb, struct genl_info *info) { - struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR]; + struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; struct sk_buff *msg; @@ -2283,72 +2314,104 @@ void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, nlmsg_free(skb); } -static const struct genl_small_ops mptcp_pm_ops[] = { +static const struct genl_ops mptcp_pm_ops[] = { { - .cmd = MPTCP_PM_CMD_ADD_ADDR, - .doit = mptcp_nl_cmd_add_addr, - .flags = GENL_UNS_ADMIN_PERM, + .cmd = MPTCP_PM_CMD_ADD_ADDR, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_nl_cmd_add_addr, + .policy = mptcp_pm_endpoint_nl_policy, + .maxattr = MPTCP_PM_ENDPOINT_ADDR, + .flags = GENL_UNS_ADMIN_PERM, }, { - .cmd = MPTCP_PM_CMD_DEL_ADDR, - .doit = mptcp_nl_cmd_del_addr, - .flags = GENL_UNS_ADMIN_PERM, + .cmd = MPTCP_PM_CMD_DEL_ADDR, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_nl_cmd_del_addr, + .policy = mptcp_pm_endpoint_nl_policy, + .maxattr = MPTCP_PM_ENDPOINT_ADDR, + .flags = GENL_UNS_ADMIN_PERM, }, { - .cmd = MPTCP_PM_CMD_FLUSH_ADDRS, - .doit = mptcp_nl_cmd_flush_addrs, - .flags = GENL_UNS_ADMIN_PERM, + .cmd = MPTCP_PM_CMD_GET_ADDR, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_nl_cmd_get_addr, + .dumpit = mptcp_nl_cmd_dump_addrs, + .policy = mptcp_pm_endpoint_nl_policy, + .maxattr = MPTCP_PM_ENDPOINT_ADDR, + .flags = GENL_UNS_ADMIN_PERM, }, { - .cmd = MPTCP_PM_CMD_GET_ADDR, - .doit = mptcp_nl_cmd_get_addr, - .dumpit = mptcp_nl_cmd_dump_addrs, + .cmd = MPTCP_PM_CMD_FLUSH_ADDRS, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_nl_cmd_flush_addrs, + .policy = mptcp_pm_endpoint_nl_policy, + .maxattr = MPTCP_PM_ENDPOINT_ADDR, + .flags = GENL_UNS_ADMIN_PERM, }, { - .cmd = MPTCP_PM_CMD_SET_LIMITS, - .doit = mptcp_nl_cmd_set_limits, - .flags = GENL_UNS_ADMIN_PERM, + .cmd = MPTCP_PM_CMD_SET_LIMITS, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_nl_cmd_set_limits, + .policy = mptcp_pm_set_limits_nl_policy, + .maxattr = MPTCP_PM_ATTR_SUBFLOWS, + .flags = GENL_UNS_ADMIN_PERM, }, { - .cmd = MPTCP_PM_CMD_GET_LIMITS, - .doit = mptcp_nl_cmd_get_limits, + .cmd = MPTCP_PM_CMD_GET_LIMITS, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_nl_cmd_get_limits, + .policy = mptcp_pm_set_limits_nl_policy, + .maxattr = MPTCP_PM_ATTR_SUBFLOWS, }, { - .cmd = MPTCP_PM_CMD_SET_FLAGS, - .doit = mptcp_nl_cmd_set_flags, - .flags = GENL_UNS_ADMIN_PERM, + .cmd = MPTCP_PM_CMD_SET_FLAGS, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_nl_cmd_set_flags, + .policy = mptcp_pm_set_flags_nl_policy, + .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, + .flags = GENL_UNS_ADMIN_PERM, }, { - .cmd = MPTCP_PM_CMD_ANNOUNCE, - .doit = mptcp_nl_cmd_announce, - .flags = GENL_UNS_ADMIN_PERM, + .cmd = MPTCP_PM_CMD_ANNOUNCE, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_nl_cmd_announce, + .policy = mptcp_pm_announce_nl_policy, + .maxattr = MPTCP_PM_ATTR_TOKEN, + .flags = GENL_UNS_ADMIN_PERM, }, { - .cmd = MPTCP_PM_CMD_REMOVE, - .doit = mptcp_nl_cmd_remove, - .flags = GENL_UNS_ADMIN_PERM, + .cmd = MPTCP_PM_CMD_REMOVE, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_nl_cmd_remove, + .policy = mptcp_pm_remove_nl_policy, + .maxattr = MPTCP_PM_ATTR_LOC_ID, + .flags = GENL_UNS_ADMIN_PERM, }, { - .cmd = MPTCP_PM_CMD_SUBFLOW_CREATE, - .doit = mptcp_nl_cmd_sf_create, - .flags = GENL_UNS_ADMIN_PERM, + .cmd = MPTCP_PM_CMD_SUBFLOW_CREATE, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_nl_cmd_sf_create, + .policy = mptcp_pm_subflow_create_nl_policy, + .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, + .flags = GENL_UNS_ADMIN_PERM, }, { - .cmd = MPTCP_PM_CMD_SUBFLOW_DESTROY, - .doit = mptcp_nl_cmd_sf_destroy, - .flags = GENL_UNS_ADMIN_PERM, + .cmd = MPTCP_PM_CMD_SUBFLOW_DESTROY, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_nl_cmd_sf_destroy, + .policy = mptcp_pm_subflow_create_nl_policy, + .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, + .flags = GENL_UNS_ADMIN_PERM, }, }; static struct genl_family mptcp_genl_family __ro_after_init = { .name = MPTCP_PM_NAME, .version = MPTCP_PM_VER, - .maxattr = MPTCP_PM_ATTR_MAX, - .policy = mptcp_pm_policy, .netnsok = true, .module = THIS_MODULE, - .small_ops = mptcp_pm_ops, - .n_small_ops = ARRAY_SIZE(mptcp_pm_ops), + .ops = mptcp_pm_ops, + .n_ops = ARRAY_SIZE(mptcp_pm_ops), .resv_start_op = MPTCP_PM_CMD_SUBFLOW_DESTROY + 1, .mcgrps = mptcp_pm_mcgrps, .n_mcgrps = ARRAY_SIZE(mptcp_pm_mcgrps), From patchwork Tue Oct 10 19:21:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13415918 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 4F57329CE1; Tue, 10 Oct 2023 19:22:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Q3GYPoDx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBE33C433CC; Tue, 10 Oct 2023 19:22:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696965729; bh=lsUvKMtLsJIj654EciF94nmsNpKkw3JX/6ih3ix4Eu4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Q3GYPoDx3z0kmpd/zfvvtaNatKmHt6/jTgoVqOTfsb+3Q8MmhefGYz+iRx37TPNn1 5WbaRh01nMbW9pZ3AgCBRqkqjbFUZ3Rntxe1UAG8+25VstWYKlrGlmtz/Vvki3Hpp4 NnuLrlQJx5EdKdv2xCrCSR5mJzbbG9voVexT3XPnJUXNTthj2P14s2LTerVN2wBsaA mMRLUEnsSgIYvqelO1juikXlju83Ca8J8THXKwzGtCgykjiqOxqMwidOc5I+GYs0ih pnYEd83xR0vNnEVs6rGlvqC7DPdRQHbLRrr7WOfWda4PFZ8uNBrAHV5yhTDVKTWJjC wQpmkZF781Rag== From: Matthieu Baerts Date: Tue, 10 Oct 2023 21:21:44 +0200 Subject: [PATCH net-next 3/6] Documentation: netlink: add a YAML spec for mptcp Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-3-18dd117e8f50@kernel.org> References: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-0-18dd117e8f50@kernel.org> In-Reply-To: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-0-18dd117e8f50@kernel.org> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Davide Caratti , Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=10437; i=matttbe@kernel.org; h=from:subject:message-id; bh=KP6EllSmqpqVAJ5AFwXvlJP9SnekCqaTFAtt+Vf1Fy8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlJaRVJk0P56bJhZb0UqWCW3B8bwRT8HAI+DAOj 6KDpoA+Em2JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZSWkVQAKCRD2t4JPQmmg c2QTEAC4jc/VvLwVtK6xx5I6z8D42c0HxpD5ko7NbnUDy1N4teYVaV+YPCMPiP78HG8VCm0iQhs Y8O5yHrR/Wvixzude9H2/4JSNvdcd4B3gQ7/VNxkac6eiBNLVR+Gozzg0TWWpsG3L94zHFFCkzi Jtn38nKH3vqinXkw8YbaKvyHkmx60LXBBCvr+b+Gy+MRJeqQClCk1xcLgR3X3hjLKDbN9Ze7n31 VknDjyDqsvk6diKCbuKx/QzWBCBlP/sY0d+6EH6blDbjuZKmyyoJ5XG+aLyf8xmuHDVRq1F1yl/ oXAxhztMHKs26PqOocYBWwj6zn0fXjwkdwmjShEbCINoRpnjOF+SLOQPRkCZjgxw5yIVPTfwfuO GOvFy8iSgHR1Tyjho0v/v4sMIvcO4xWKQIMdGTKUAzMb6d6pU0dDEhJ0XC5tXB0eqInxha+9aVO bNpRV0NI4kkynnyZhBVYQOiheHf66t2r9ZIvegKXx+JWr5/6iyXUvVtCo+5Zuer61UWnccGIw4U a/QaYlCJYv9b3dmp5Ma8/lOnRzYXPcMj6H0mPVVLP+qu8QiR27yvjUwD0S7V4yvgprHIfrgXtzd wT6MXjqJZcEydfyK/rsSQW+uoq4YAaw2OBXsTxtaqvhJOudhagHwI+GYJco3kScBQDy6OB3rvcL dhiT357SWaJk7Kg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Davide Caratti it describes most of the current netlink interface (uAPI definitions, doit/dumpit operations and attributes) Link: https://github.com/multipath-tcp/mptcp_net-next/issues/340 Acked-by: Paolo Abeni Signed-off-by: Davide Caratti Signed-off-by: Matthieu Baerts --- Documentation/netlink/specs/mptcp.yaml | 394 +++++++++++++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 395 insertions(+) diff --git a/Documentation/netlink/specs/mptcp.yaml b/Documentation/netlink/specs/mptcp.yaml new file mode 100644 index 000000000000..f8ebcd009592 --- /dev/null +++ b/Documentation/netlink/specs/mptcp.yaml @@ -0,0 +1,394 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) + +name: mptcp_pm +protocol: genetlink-legacy +doc: Multipath TCP. + +c-family-name: mptcp_pm_name +c-version-name: mptcp_pm_ver +max-by-define: true +kernel-policy: per-op + +definitions: + - + type: enum + name: event-type + enum-name: mptcp_event_type + name-prefix: mptcp_event_ + entries: + - + name: unspec + value: 0 + - + name: created + doc: + 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 + traffic-patterns it can take a long time until the + MPTCP_EVENT_ESTABLISHED is sent. + - + name: established + doc: + token, family, saddr4 | saddr6, daddr4 | daddr6, sport, dport + A MPTCP connection is established (can start new subflows). + - + name: closed + doc: + token + A MPTCP connection has stopped. + - + name: announced + value: 6 + doc: + token, rem_id, family, daddr4 | daddr6 [, dport] + 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 + value: 10 + doc: + token, family, loc_id, rem_id, saddr4 | saddr6, daddr4 | daddr6, sport, + dport, backup, if_idx [, error] + A new subflow has been established. 'error' should not be set. + - + name: sub_closed + value: 11 + doc: + token, family, loc_id, rem_id, saddr4 | saddr6, daddr4 | daddr6, sport, + 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 + value: 13 + doc: + token, family, loc_id, rem_id, saddr4 | saddr6, daddr4 | daddr6, sport, + dport, backup, if_idx [, error] + The priority of a subflow has changed. 'error' should not be set. + - + name: listener_created + value: 15 + doc: + family, sport, saddr4 | saddr6 + A new PM listener is created. + - + name: listener_closed + value: 16 + doc: + family, sport, saddr4 | saddr6 + A PM listener is closed. + +attribute-sets: + - + name: address + name-prefix: mptcp_pm_addr_attr_ + attributes: + - + name: unspec + type: unused + value: 0 + - + name: family + type: u16 + - + name: id + type: u8 + - + name: addr4 + type: u32 + byte-order: big-endian + - + name: addr6 + type: binary + checks: + min-len: 16 + - + name: port + type: u16 + byte-order: big-endian + - + name: flags + type: u32 + - + name: if_idx + type: s32 + - + name: subflow-attribute + name-prefix: mptcp_subflow_attr_ + attributes: + - + name: unspec + type: unused + value: 0 + - + name: token_rem + type: u32 + - + name: token_loc + type: u32 + - + name: relwrite_seq + type: u32 + - + name: map_seq + type: u64 + - + name: map_sfseq + type: u32 + - + name: ssn_offset + type: u32 + - + name: map_datalen + type: u16 + - + name: flags + type: u32 + - + name: id_rem + type: u8 + - + name: id_loc + type: u8 + - + name: pad + type: pad + - + name: endpoint + name-prefix: mptcp_pm_endpoint_ + attributes: + - + name: addr + type: nest + nested-attributes: address + - + name: attr + name-prefix: mptcp_pm_attr_ + attributes: + - + name: unspec + type: unused + value: 0 + - + name: addr + type: nest + nested-attributes: address + - + name: rcv_add_addrs + type: u32 + - + name: subflows + type: u32 + - + name: token + type: u32 + - + name: loc_id + type: u8 + - + name: addr_remote + type: nest + nested-attributes: address + - + name: event_attr + enum-name: mptcp_event_attr + name-prefix: mptcp_attr_ + attributes: + - + name: UNSPEC + type: unused + value: 0 + - + name: token + type: u32 + - + name: family + type: u16 + - + name: loc_id + type: u8 + - + name: rem_id + type: u8 + - + name: saddr4 + type: u32 + byte-order: big-endian + - + name: saddr6 + type: binary + checks: + min-len: 16 + - + name: daddr4 + type: u32 + byte-order: big-endian + - + name: daddr6 + type: binary + checks: + min-len: 16 + - + name: sport + type: u16 + byte-order: big-endian + - + name: dport + type: u16 + byte-order: big-endian + - + name: backup + type: u8 + - + name: error + type: u8 + - + name: flags + type: u16 + - + name: timeout + type: u32 + - + name: if_idx + type: u32 + - + name: reset_reason + type: u32 + - + name: reset_flags + type: u32 + - + name: server_side + type: u8 + +operations: + list: + - + name: unspec + doc: unused + value: 0 + - + name: add_addr + doc: Add endpoint + attribute-set: endpoint + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: &add_addr_attrs + request: + attributes: + - addr + - + name: del_addr + doc: Delete endpoint + attribute-set: endpoint + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: *add_addr_attrs + - + name: get_addr + doc: Get endpoint information + attribute-set: endpoint + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: &get_addr_attrs + request: + attributes: + - addr + reply: + attributes: + - addr + dump: + reply: + attributes: + - addr + - + name: flush_addrs + doc: flush addresses + attribute-set: endpoint + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: *add_addr_attrs + - + name: set_limits + doc: Set protocol limits + attribute-set: attr + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: &mptcp_limits + request: + attributes: + - rcv_add_addrs + - subflows + - + name: get_limits + doc: Get protocol limits + attribute-set: attr + dont-validate: [ strict ] + do: &mptcp_get_limits + request: + attributes: + - rcv_add_addrs + - subflows + reply: + attributes: + - rcv_add_addrs + - subflows + - + name: set_flags + doc: Change endpoint flags + attribute-set: attr + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: &mptcp_set_flags + request: + attributes: + - addr + - token + - addr_remote + - + name: announce + doc: announce new sf + attribute-set: attr + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: &announce_add + request: + attributes: + - addr + - token + - + name: remove + doc: announce removal + attribute-set: attr + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: + request: + attributes: + - token + - loc_id + - + name: subflow_create + doc: todo + attribute-set: attr + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: &sf_create + request: + attributes: + - addr + - token + - addr_remote + - + name: subflow_destroy + doc: todo + attribute-set: attr + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: *sf_create diff --git a/MAINTAINERS b/MAINTAINERS index 1bd96045beb8..ab699a697616 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14960,6 +14960,7 @@ W: https://github.com/multipath-tcp/mptcp_net-next/wiki B: https://github.com/multipath-tcp/mptcp_net-next/issues T: git https://github.com/multipath-tcp/mptcp_net-next.git export-net T: git https://github.com/multipath-tcp/mptcp_net-next.git export +F: Documentation/netlink/specs/mptcp.yaml F: Documentation/networking/mptcp-sysctl.rst F: include/net/mptcp.h F: include/trace/events/mptcp.h From patchwork Tue Oct 10 19:21:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13415919 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 77A1829CE2; Tue, 10 Oct 2023 19:22:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lPaklZDb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2522C433CD; Tue, 10 Oct 2023 19:22:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696965732; bh=GGNRVGhxamEUe+mJiuy77cRN6IbWcukesNH+WghlWA0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lPaklZDbfu3ehromaBe8gYy3tMNXPynDRoVjY540rbsXZDrSXK14jwT/kygUhYC8r 1JtXq4YH4FKdprdUtslbi2aeAc7OJLEuPNwq2I1SFuvq3O8bWuA0vS4D0h/dbmux7y 6IBPg9SOnRSS900tf/EYKipYYFmLnYFBabjiSfl0nqmDGVjGGrmv5QCVav2QMmgYey SQGBQddsYT9ESOrk0wdM33FmOVop/3XEG32Ifb0AoJpOg9kRAkAlm3wsS5gGi/Dc1R SRNtg0aQIh0q3cAtN2BvBie7vYLx4oJ9rYzK8u9S0adXuYU3vgSNLFFzTq7pcb19/W htBsO+zJ2w8dg== From: Matthieu Baerts Date: Tue, 10 Oct 2023 21:21:45 +0200 Subject: [PATCH net-next 4/6] uapi: mptcp: use header file generated from YAML spec Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-4-18dd117e8f50@kernel.org> References: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-0-18dd117e8f50@kernel.org> In-Reply-To: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-0-18dd117e8f50@kernel.org> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Davide Caratti , Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=12531; i=matttbe@kernel.org; h=from:subject:message-id; bh=iocgppS+/wVAdWSTWrLGaCc4r+55QRrVSnCsMDzeUyc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlJaRVnXUGtJ2ZD62pg4pm4tHhki3/HV8N/o2t5 5WKLpA64qOJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZSWkVQAKCRD2t4JPQmmg c4o/D/0c6gI/WN8paIk6wLOjYQ3HWq3bszJn2c1mleR7UojIBl5EuQUKy/bO/5k0eeV3hKiHD8z JyaZuj86xtX9goF0kPIgxGuxLXh4GYKKXT+YlEKf+SEokLnqv8jJs8NoqfrEMLBbIHYWFoF/wcW IQ8iu+WhrY66+V9qxX5jE6KQKkxAMhOVlzvez5ZiZzRHeyuN7qxYdxduMDjM3bSw53S5lC+qXQt 0MKUOBfNE+nc5ZvbIIFjDHBizEUUWVRz3dx7FVBIVice9H6rb/iOnKTlct5nZlaMCsd09XlLWD8 w2kcpb+vOPOe1GQOg7I7bxTJhdH6lrItqNTPFRnqQTLSXexNxvKDtWQU20L3DaAzAZLSbK36+2E DEBckY17l5deCongxXoB36UQGIoaTwrRL/AYcH6pLs9hh+Q2u0fZISXc5EuQRfmxewb+vuvJLPb cgjvBrQefTnWf4XCeXhWUG6HnFqf1j/cICeEDLXXqVCHuMhyOG5Yx2lZoMNoG8R61IR7nYGo3u7 N/fUelO6/sMOgjIOBWGxb1emrGTIeUk2BKLR8VZJGtjt9QZ9SaZBrN02Hx3t2jjE3DXL+ABqTQf Pg/9a9ssyKnXg+GxlC/dJstSoFwrFxW7vkVwdRgNWVbcD2qg8q4xMykHxnzy1Y0HbO0RCRR0pz4 HIlrt5lHJPBLVpg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Davide Caratti generated with: $ ./tools/net/ynl/ynl-gen-c.py --mode uapi \ > --spec Documentation/netlink/specs/mptcp.yaml \ > --header -o include/uapi/linux/mptcp_pm.h Link: https://github.com/multipath-tcp/mptcp_net-next/issues/340 Acked-by: Paolo Abeni Signed-off-by: Davide Caratti Signed-off-by: Matthieu Baerts --- MAINTAINERS | 2 +- include/uapi/linux/mptcp.h | 182 +++--------------------------------------- include/uapi/linux/mptcp_pm.h | 149 ++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+), 173 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index ab699a697616..9a6e5c4c537d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14964,7 +14964,7 @@ F: Documentation/netlink/specs/mptcp.yaml F: Documentation/networking/mptcp-sysctl.rst F: include/net/mptcp.h F: include/trace/events/mptcp.h -F: include/uapi/linux/mptcp.h +F: include/uapi/linux/mptcp*.h F: net/mptcp/ F: tools/testing/selftests/bpf/*/*mptcp*.c F: tools/testing/selftests/net/mptcp/ diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index 0e62937ab17c..64ecc8a3f9f2 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -23,99 +23,24 @@ #define MPTCP_SUBFLOW_FLAG_CONNECTED _BITUL(7) #define MPTCP_SUBFLOW_FLAG_MAPVALID _BITUL(8) -enum { - MPTCP_SUBFLOW_ATTR_UNSPEC, - MPTCP_SUBFLOW_ATTR_TOKEN_REM, - MPTCP_SUBFLOW_ATTR_TOKEN_LOC, - MPTCP_SUBFLOW_ATTR_RELWRITE_SEQ, - MPTCP_SUBFLOW_ATTR_MAP_SEQ, - MPTCP_SUBFLOW_ATTR_MAP_SFSEQ, - MPTCP_SUBFLOW_ATTR_SSN_OFFSET, - MPTCP_SUBFLOW_ATTR_MAP_DATALEN, - MPTCP_SUBFLOW_ATTR_FLAGS, - MPTCP_SUBFLOW_ATTR_ID_REM, - MPTCP_SUBFLOW_ATTR_ID_LOC, - MPTCP_SUBFLOW_ATTR_PAD, - __MPTCP_SUBFLOW_ATTR_MAX -}; - -#define MPTCP_SUBFLOW_ATTR_MAX (__MPTCP_SUBFLOW_ATTR_MAX - 1) - -/* netlink interface */ -#define MPTCP_PM_NAME "mptcp_pm" #define MPTCP_PM_CMD_GRP_NAME "mptcp_pm_cmds" #define MPTCP_PM_EV_GRP_NAME "mptcp_pm_events" -#define MPTCP_PM_VER 0x1 -/* - * ATTR types defined for MPTCP - */ -enum { - MPTCP_PM_ATTR_UNSPEC, +#include - MPTCP_PM_ATTR_ADDR, /* nested address */ - MPTCP_PM_ATTR_RCV_ADD_ADDRS, /* u32 */ - MPTCP_PM_ATTR_SUBFLOWS, /* u32 */ - MPTCP_PM_ATTR_TOKEN, /* u32 */ - MPTCP_PM_ATTR_LOC_ID, /* u8 */ - MPTCP_PM_ATTR_ADDR_REMOTE, /* nested address */ - - __MPTCP_PM_ATTR_MAX -}; - -#define MPTCP_PM_ATTR_MAX (__MPTCP_PM_ATTR_MAX - 1) - -enum { - MPTCP_PM_ENDPOINT_ADDR = 1, - - __MPTCP_PM_ENDPOINT_MAX -}; - -#define MPTCP_PM_ENDPOINT_MAX (__MPTCP_PM_ENDPOINT_MAX - 1) - -enum { - MPTCP_PM_ADDR_ATTR_UNSPEC, - - MPTCP_PM_ADDR_ATTR_FAMILY, /* u16 */ - MPTCP_PM_ADDR_ATTR_ID, /* u8 */ - MPTCP_PM_ADDR_ATTR_ADDR4, /* struct in_addr */ - MPTCP_PM_ADDR_ATTR_ADDR6, /* struct in6_addr */ - MPTCP_PM_ADDR_ATTR_PORT, /* u16 */ - MPTCP_PM_ADDR_ATTR_FLAGS, /* u32 */ - MPTCP_PM_ADDR_ATTR_IF_IDX, /* s32 */ - - __MPTCP_PM_ADDR_ATTR_MAX -}; - -#define MPTCP_PM_ADDR_ATTR_MAX (__MPTCP_PM_ADDR_ATTR_MAX - 1) - -#define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0) -#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1) -#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2) -#define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3) -#define MPTCP_PM_ADDR_FLAG_IMPLICIT (1 << 4) - -enum { - MPTCP_PM_CMD_UNSPEC, - - MPTCP_PM_CMD_ADD_ADDR, - MPTCP_PM_CMD_DEL_ADDR, - MPTCP_PM_CMD_GET_ADDR, - MPTCP_PM_CMD_FLUSH_ADDRS, - MPTCP_PM_CMD_SET_LIMITS, - MPTCP_PM_CMD_GET_LIMITS, - MPTCP_PM_CMD_SET_FLAGS, - MPTCP_PM_CMD_ANNOUNCE, - MPTCP_PM_CMD_REMOVE, - MPTCP_PM_CMD_SUBFLOW_CREATE, - MPTCP_PM_CMD_SUBFLOW_DESTROY, - - __MPTCP_PM_CMD_AFTER_LAST -}; +/* for backward compatibility */ +#define __MPTCP_PM_CMD_AFTER_LAST __MPTCP_PM_CMD_MAX +#define __MPTCP_ATTR_AFTER_LAST __MPTCP_ATTR_MAX #define MPTCP_INFO_FLAG_FALLBACK _BITUL(0) #define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED _BITUL(1) +#define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0) +#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1) +#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2) +#define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3) +#define MPTCP_PM_ADDR_FLAG_IMPLICIT (1 << 4) + struct mptcp_info { __u8 mptcpi_subflows; __u8 mptcpi_add_addr_signal; @@ -138,93 +63,6 @@ struct mptcp_info { __u64 mptcpi_bytes_acked; }; -/* - * 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 traffic-patterns - * it can take a long time until the MPTCP_EVENT_ESTABLISHED is sent. - * - * MPTCP_EVENT_ESTABLISHED: token, family, saddr4 | saddr6, daddr4 | daddr6, - * sport, dport - * A MPTCP connection is established (can start new subflows). - * - * MPTCP_EVENT_CLOSED: token - * A MPTCP connection has stopped. - * - * MPTCP_EVENT_ANNOUNCED: token, rem_id, family, daddr4 | daddr6 [, dport] - * A new address has been announced by the peer. - * - * MPTCP_EVENT_REMOVED: token, rem_id - * An address has been lost by the peer. - * - * MPTCP_EVENT_SUB_ESTABLISHED: token, family, loc_id, rem_id, - * saddr4 | saddr6, daddr4 | daddr6, sport, - * dport, backup, if_idx [, error] - * A new subflow has been established. 'error' should not be set. - * - * MPTCP_EVENT_SUB_CLOSED: token, family, loc_id, rem_id, saddr4 | saddr6, - * daddr4 | daddr6, sport, 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. - * - * MPTCP_EVENT_SUB_PRIORITY: token, family, loc_id, rem_id, saddr4 | saddr6, - * daddr4 | daddr6, sport, dport, backup, if_idx - * [, error] - * The priority of a subflow has changed. 'error' should not be set. - * - * MPTCP_EVENT_LISTENER_CREATED: family, sport, saddr4 | saddr6 - * A new PM listener is created. - * - * MPTCP_EVENT_LISTENER_CLOSED: family, sport, saddr4 | saddr6 - * A PM listener is closed. - */ -enum mptcp_event_type { - MPTCP_EVENT_UNSPEC = 0, - MPTCP_EVENT_CREATED = 1, - MPTCP_EVENT_ESTABLISHED = 2, - MPTCP_EVENT_CLOSED = 3, - - MPTCP_EVENT_ANNOUNCED = 6, - MPTCP_EVENT_REMOVED = 7, - - MPTCP_EVENT_SUB_ESTABLISHED = 10, - MPTCP_EVENT_SUB_CLOSED = 11, - - MPTCP_EVENT_SUB_PRIORITY = 13, - - MPTCP_EVENT_LISTENER_CREATED = 15, - MPTCP_EVENT_LISTENER_CLOSED = 16, -}; - -enum mptcp_event_attr { - MPTCP_ATTR_UNSPEC = 0, - - MPTCP_ATTR_TOKEN, /* u32 */ - MPTCP_ATTR_FAMILY, /* u16 */ - MPTCP_ATTR_LOC_ID, /* u8 */ - MPTCP_ATTR_REM_ID, /* u8 */ - MPTCP_ATTR_SADDR4, /* be32 */ - MPTCP_ATTR_SADDR6, /* struct in6_addr */ - MPTCP_ATTR_DADDR4, /* be32 */ - MPTCP_ATTR_DADDR6, /* struct in6_addr */ - MPTCP_ATTR_SPORT, /* be16 */ - MPTCP_ATTR_DPORT, /* be16 */ - MPTCP_ATTR_BACKUP, /* u8 */ - MPTCP_ATTR_ERROR, /* u8 */ - MPTCP_ATTR_FLAGS, /* u16 */ - MPTCP_ATTR_TIMEOUT, /* u32 */ - MPTCP_ATTR_IF_IDX, /* s32 */ - MPTCP_ATTR_RESET_REASON,/* u32 */ - MPTCP_ATTR_RESET_FLAGS, /* u32 */ - MPTCP_ATTR_SERVER_SIDE, /* u8 */ - - __MPTCP_ATTR_AFTER_LAST -}; - -#define MPTCP_ATTR_MAX (__MPTCP_ATTR_AFTER_LAST - 1) - /* MPTCP Reset reason codes, rfc8684 */ #define MPTCP_RST_EUNSPEC 0 #define MPTCP_RST_EMPTCP 1 diff --git a/include/uapi/linux/mptcp_pm.h b/include/uapi/linux/mptcp_pm.h new file mode 100644 index 000000000000..0c7206531eb1 --- /dev/null +++ b/include/uapi/linux/mptcp_pm.h @@ -0,0 +1,149 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/mptcp.yaml */ +/* YNL-GEN uapi header */ + +#ifndef _UAPI_LINUX_MPTCP_PM_H +#define _UAPI_LINUX_MPTCP_PM_H + +#define MPTCP_PM_NAME "mptcp_pm" +#define MPTCP_PM_VER 1 + +/** + * enum mptcp_event_type + * @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 + * traffic-patterns it can take a long time until the MPTCP_EVENT_ESTABLISHED + * is sent. + * @MPTCP_EVENT_ESTABLISHED: token, family, saddr4 | saddr6, daddr4 | daddr6, + * sport, dport A MPTCP connection is established (can start new subflows). + * @MPTCP_EVENT_CLOSED: token A MPTCP connection has stopped. + * @MPTCP_EVENT_ANNOUNCED: token, rem_id, family, daddr4 | daddr6 [, dport] A + * new address has been announced by the peer. + * @MPTCP_EVENT_REMOVED: token, rem_id An address has been lost by the peer. + * @MPTCP_EVENT_SUB_ESTABLISHED: token, family, loc_id, rem_id, saddr4 | + * saddr6, daddr4 | daddr6, sport, dport, backup, if_idx [, error] A new + * subflow has been established. 'error' should not be set. + * @MPTCP_EVENT_SUB_CLOSED: token, family, loc_id, rem_id, saddr4 | saddr6, + * daddr4 | daddr6, sport, 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. + * @MPTCP_EVENT_SUB_PRIORITY: token, family, loc_id, rem_id, saddr4 | saddr6, + * daddr4 | daddr6, sport, dport, backup, if_idx [, error] The priority of a + * subflow has changed. 'error' should not be set. + * @MPTCP_EVENT_LISTENER_CREATED: family, sport, saddr4 | saddr6 A new PM + * listener is created. + * @MPTCP_EVENT_LISTENER_CLOSED: family, sport, saddr4 | saddr6 A PM listener + * is closed. + */ +enum mptcp_event_type { + MPTCP_EVENT_UNSPEC, + MPTCP_EVENT_CREATED, + MPTCP_EVENT_ESTABLISHED, + MPTCP_EVENT_CLOSED, + MPTCP_EVENT_ANNOUNCED = 6, + MPTCP_EVENT_REMOVED, + MPTCP_EVENT_SUB_ESTABLISHED = 10, + MPTCP_EVENT_SUB_CLOSED, + MPTCP_EVENT_SUB_PRIORITY = 13, + MPTCP_EVENT_LISTENER_CREATED = 15, + MPTCP_EVENT_LISTENER_CLOSED, +}; + +enum { + MPTCP_PM_ADDR_ATTR_UNSPEC, + MPTCP_PM_ADDR_ATTR_FAMILY, + MPTCP_PM_ADDR_ATTR_ID, + MPTCP_PM_ADDR_ATTR_ADDR4, + MPTCP_PM_ADDR_ATTR_ADDR6, + MPTCP_PM_ADDR_ATTR_PORT, + MPTCP_PM_ADDR_ATTR_FLAGS, + MPTCP_PM_ADDR_ATTR_IF_IDX, + + __MPTCP_PM_ADDR_ATTR_MAX +}; +#define MPTCP_PM_ADDR_ATTR_MAX (__MPTCP_PM_ADDR_ATTR_MAX - 1) + +enum { + MPTCP_SUBFLOW_ATTR_UNSPEC, + MPTCP_SUBFLOW_ATTR_TOKEN_REM, + MPTCP_SUBFLOW_ATTR_TOKEN_LOC, + MPTCP_SUBFLOW_ATTR_RELWRITE_SEQ, + MPTCP_SUBFLOW_ATTR_MAP_SEQ, + MPTCP_SUBFLOW_ATTR_MAP_SFSEQ, + MPTCP_SUBFLOW_ATTR_SSN_OFFSET, + MPTCP_SUBFLOW_ATTR_MAP_DATALEN, + MPTCP_SUBFLOW_ATTR_FLAGS, + MPTCP_SUBFLOW_ATTR_ID_REM, + MPTCP_SUBFLOW_ATTR_ID_LOC, + MPTCP_SUBFLOW_ATTR_PAD, + + __MPTCP_SUBFLOW_ATTR_MAX +}; +#define MPTCP_SUBFLOW_ATTR_MAX (__MPTCP_SUBFLOW_ATTR_MAX - 1) + +enum { + MPTCP_PM_ENDPOINT_ADDR = 1, + + __MPTCP_PM_ENDPOINT_MAX +}; +#define MPTCP_PM_ENDPOINT_MAX (__MPTCP_PM_ENDPOINT_MAX - 1) + +enum { + MPTCP_PM_ATTR_UNSPEC, + MPTCP_PM_ATTR_ADDR, + MPTCP_PM_ATTR_RCV_ADD_ADDRS, + MPTCP_PM_ATTR_SUBFLOWS, + MPTCP_PM_ATTR_TOKEN, + MPTCP_PM_ATTR_LOC_ID, + MPTCP_PM_ATTR_ADDR_REMOTE, + + __MPTCP_PM_ATTR_MAX +}; +#define MPTCP_PM_ATTR_MAX (__MPTCP_PM_ATTR_MAX - 1) + +enum mptcp_event_attr { + MPTCP_ATTR_UNSPEC, + MPTCP_ATTR_TOKEN, + MPTCP_ATTR_FAMILY, + MPTCP_ATTR_LOC_ID, + MPTCP_ATTR_REM_ID, + MPTCP_ATTR_SADDR4, + MPTCP_ATTR_SADDR6, + MPTCP_ATTR_DADDR4, + MPTCP_ATTR_DADDR6, + MPTCP_ATTR_SPORT, + MPTCP_ATTR_DPORT, + MPTCP_ATTR_BACKUP, + MPTCP_ATTR_ERROR, + MPTCP_ATTR_FLAGS, + MPTCP_ATTR_TIMEOUT, + MPTCP_ATTR_IF_IDX, + MPTCP_ATTR_RESET_REASON, + MPTCP_ATTR_RESET_FLAGS, + MPTCP_ATTR_SERVER_SIDE, + + __MPTCP_ATTR_MAX +}; +#define MPTCP_ATTR_MAX (__MPTCP_ATTR_MAX - 1) + +enum { + MPTCP_PM_CMD_UNSPEC, + MPTCP_PM_CMD_ADD_ADDR, + MPTCP_PM_CMD_DEL_ADDR, + MPTCP_PM_CMD_GET_ADDR, + MPTCP_PM_CMD_FLUSH_ADDRS, + MPTCP_PM_CMD_SET_LIMITS, + MPTCP_PM_CMD_GET_LIMITS, + MPTCP_PM_CMD_SET_FLAGS, + MPTCP_PM_CMD_ANNOUNCE, + MPTCP_PM_CMD_REMOVE, + MPTCP_PM_CMD_SUBFLOW_CREATE, + MPTCP_PM_CMD_SUBFLOW_DESTROY, + + __MPTCP_PM_CMD_MAX +}; +#define MPTCP_PM_CMD_MAX (__MPTCP_PM_CMD_MAX - 1) + +#endif /* _UAPI_LINUX_MPTCP_PM_H */ From patchwork Tue Oct 10 19:21:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13415920 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 F15C429CE2; Tue, 10 Oct 2023 19:22:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OHA2VF4/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78F05C433BD; Tue, 10 Oct 2023 19:22:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696965734; bh=Ie7O/vWRffp+xW6oDBLzG/P6h5B/Uq4ksbSuheaQx5A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OHA2VF4/A5XdNoXbQsULqmbnog4ojpU1FFdKBLyRQkIsz7CgjUS0Qht/mQ1AKoqrR 39ccvzsqs9Apb0UcooY+zkWbb5layXJqWZ0YYHaSZy7Yc7sVZA5w7hUc0v6WsOk4UI u7JnRYpcBxKfS/1b9phWNcHalOG6Wn0TTqPW5sOwUJ/7N8Zvp9GHN5U3GinPMcaZZV h8ERfAyYAQDoe3GVlBYzsc8SUo5lSwZg98cO+qMO9C9Tc4StXr5mQ/pz9N3cmQfsst 7xHLDq9eQlvXhpMe83Xl7Jvx8ZNV7dm+zJWQQddFXnB3rIqY+puIljqvjPpcNRToF6 0C3JAHDbMDFNA== From: Matthieu Baerts Date: Tue, 10 Oct 2023 21:21:46 +0200 Subject: [PATCH net-next 5/6] net: mptcp: rename netlink handlers to mptcp_pm_nl__{doit,dumpit} Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-5-18dd117e8f50@kernel.org> References: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-0-18dd117e8f50@kernel.org> In-Reply-To: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-0-18dd117e8f50@kernel.org> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Davide Caratti , Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=11131; i=matttbe@kernel.org; h=from:subject:message-id; bh=yVRzO2/YTZEyfWc8rNLxsJ5c6xVbSMMP4stse3H/SRk=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlJaRVfGJd4xmDkoLBnFmg42SOhWqb6S8nahPlq 6yDyGVgaRuJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZSWkVQAKCRD2t4JPQmmg c5dEEACrNHZnA14m7dy8I6/paGfCLrIdboMX3xlU9s6+sppsZMB2x493OFW0uVHvHRm2FZh4fvV BVmQpmTfFzKXmAseNaV3MqGby8k1dNzW9PDVvlgmOA7U32mJT0bwMR6O4hmsQ6e8g+Qvbk0fTuT Wpfdc455jm9vjUb1ixfVLCmGi4bpjMRUa+mVvHoy/Ulkz6Nzowr5eQd0EpjLVq+E70NhyG7yNhy ZgZvexgDfC0B+9XIScSIoSo61cV00aptIenqGCkVCr5+TDh+boBmjVBe7TjFL2oHbjUuSMgq0UH mLU/Ubtr/mjnRiNC3sy8iJTRwgm6b6r1Evreaa/kFxDfwr3cTtDi2cWYbT69mhHppoW7GZlAJPu SyYL86qDsVveTSdQMdJuCS1r77xXzVVbw9jgcYZeLphgtK4CTtzJnmBc4yp4TfGrxb0wM+RXe8u H2u22VWdi94a0tY6mfyx7so3z4ohg1eWek+0wPcSDZYS4tHhn1rZQ2sGxxbCDknURXltd6ZKnYQ IOBkF60EGiDuGh7m4vG+rrLGPXOF+D/06C8lVe+4S7/eF5cV1HTmSKzHFW90AMxXTLomVc61cFe +XARIkEpJfs0wdTY741lbe4ZswcLG30t8mN/ESI3Eety1jDgnuGYXH7dRiuWda0ashyHHLUTARs eOulDCufgrs0m7w== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Davide Caratti so that they will match names generated from YAML spec. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/340 Suggested-by: Paolo Abeni Acked-by: Paolo Abeni Signed-off-by: Davide Caratti Signed-off-by: Matthieu Baerts --- net/mptcp/pm_netlink.c | 48 ++++++++++++++++++++++++------------------------ net/mptcp/pm_userspace.c | 8 ++++---- net/mptcp/protocol.h | 8 ++++---- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 32976cf7c82b..dc3ed337eb1f 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1334,7 +1334,7 @@ static int mptcp_nl_add_subflow_or_signal_addr(struct net *net) return 0; } -static int mptcp_nl_cmd_add_addr(struct sk_buff *skb, struct genl_info *info) +static int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); @@ -1515,7 +1515,7 @@ static int mptcp_nl_remove_id_zero_address(struct net *net, return 0; } -static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *info) +static int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); @@ -1650,7 +1650,7 @@ static void __reset_counters(struct pm_nl_pernet *pernet) pernet->addrs = 0; } -static int mptcp_nl_cmd_flush_addrs(struct sk_buff *skb, struct genl_info *info) +static int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info) { struct pm_nl_pernet *pernet = genl_info_pm_nl(info); LIST_HEAD(free_list); @@ -1706,7 +1706,7 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, return -EMSGSIZE; } -static int mptcp_nl_cmd_get_addr(struct sk_buff *skb, struct genl_info *info) +static int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); @@ -1756,8 +1756,8 @@ static int mptcp_nl_cmd_get_addr(struct sk_buff *skb, struct genl_info *info) return ret; } -static int mptcp_nl_cmd_dump_addrs(struct sk_buff *msg, - struct netlink_callback *cb) +static int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, + struct netlink_callback *cb) { struct net *net = sock_net(msg->sk); struct mptcp_pm_addr_entry *entry; @@ -1815,7 +1815,7 @@ static int parse_limit(struct genl_info *info, int id, unsigned int *limit) } static int -mptcp_nl_cmd_set_limits(struct sk_buff *skb, struct genl_info *info) +mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, struct genl_info *info) { struct pm_nl_pernet *pernet = genl_info_pm_nl(info); unsigned int rcv_addrs, subflows; @@ -1841,7 +1841,7 @@ mptcp_nl_cmd_set_limits(struct sk_buff *skb, struct genl_info *info) } static int -mptcp_nl_cmd_get_limits(struct sk_buff *skb, struct genl_info *info) +mptcp_pm_nl_get_limits_doit(struct sk_buff *skb, struct genl_info *info) { struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct sk_buff *msg; @@ -1950,7 +1950,7 @@ int mptcp_pm_nl_set_flags(struct net *net, struct mptcp_pm_addr_entry *addr, u8 return 0; } -static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) +static int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) { struct mptcp_pm_addr_entry remote = { .addr = { .family = AF_UNSPEC }, }; struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, }; @@ -2314,11 +2314,11 @@ void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, nlmsg_free(skb); } -static const struct genl_ops mptcp_pm_ops[] = { +static const struct genl_ops mptcp_pm_nl_ops[] = { { .cmd = MPTCP_PM_CMD_ADD_ADDR, .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_nl_cmd_add_addr, + .doit = mptcp_pm_nl_add_addr_doit, .policy = mptcp_pm_endpoint_nl_policy, .maxattr = MPTCP_PM_ENDPOINT_ADDR, .flags = GENL_UNS_ADMIN_PERM, @@ -2326,7 +2326,7 @@ static const struct genl_ops mptcp_pm_ops[] = { { .cmd = MPTCP_PM_CMD_DEL_ADDR, .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_nl_cmd_del_addr, + .doit = mptcp_pm_nl_del_addr_doit, .policy = mptcp_pm_endpoint_nl_policy, .maxattr = MPTCP_PM_ENDPOINT_ADDR, .flags = GENL_UNS_ADMIN_PERM, @@ -2334,8 +2334,8 @@ static const struct genl_ops mptcp_pm_ops[] = { { .cmd = MPTCP_PM_CMD_GET_ADDR, .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_nl_cmd_get_addr, - .dumpit = mptcp_nl_cmd_dump_addrs, + .doit = mptcp_pm_nl_get_addr_doit, + .dumpit = mptcp_pm_nl_get_addr_dumpit, .policy = mptcp_pm_endpoint_nl_policy, .maxattr = MPTCP_PM_ENDPOINT_ADDR, .flags = GENL_UNS_ADMIN_PERM, @@ -2343,7 +2343,7 @@ static const struct genl_ops mptcp_pm_ops[] = { { .cmd = MPTCP_PM_CMD_FLUSH_ADDRS, .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_nl_cmd_flush_addrs, + .doit = mptcp_pm_nl_flush_addrs_doit, .policy = mptcp_pm_endpoint_nl_policy, .maxattr = MPTCP_PM_ENDPOINT_ADDR, .flags = GENL_UNS_ADMIN_PERM, @@ -2351,7 +2351,7 @@ static const struct genl_ops mptcp_pm_ops[] = { { .cmd = MPTCP_PM_CMD_SET_LIMITS, .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_nl_cmd_set_limits, + .doit = mptcp_pm_nl_set_limits_doit, .policy = mptcp_pm_set_limits_nl_policy, .maxattr = MPTCP_PM_ATTR_SUBFLOWS, .flags = GENL_UNS_ADMIN_PERM, @@ -2359,14 +2359,14 @@ static const struct genl_ops mptcp_pm_ops[] = { { .cmd = MPTCP_PM_CMD_GET_LIMITS, .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_nl_cmd_get_limits, + .doit = mptcp_pm_nl_get_limits_doit, .policy = mptcp_pm_set_limits_nl_policy, .maxattr = MPTCP_PM_ATTR_SUBFLOWS, }, { .cmd = MPTCP_PM_CMD_SET_FLAGS, .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_nl_cmd_set_flags, + .doit = mptcp_pm_nl_set_flags_doit, .policy = mptcp_pm_set_flags_nl_policy, .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, .flags = GENL_UNS_ADMIN_PERM, @@ -2374,7 +2374,7 @@ static const struct genl_ops mptcp_pm_ops[] = { { .cmd = MPTCP_PM_CMD_ANNOUNCE, .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_nl_cmd_announce, + .doit = mptcp_pm_nl_announce_doit, .policy = mptcp_pm_announce_nl_policy, .maxattr = MPTCP_PM_ATTR_TOKEN, .flags = GENL_UNS_ADMIN_PERM, @@ -2382,7 +2382,7 @@ static const struct genl_ops mptcp_pm_ops[] = { { .cmd = MPTCP_PM_CMD_REMOVE, .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_nl_cmd_remove, + .doit = mptcp_pm_nl_remove_doit, .policy = mptcp_pm_remove_nl_policy, .maxattr = MPTCP_PM_ATTR_LOC_ID, .flags = GENL_UNS_ADMIN_PERM, @@ -2390,7 +2390,7 @@ static const struct genl_ops mptcp_pm_ops[] = { { .cmd = MPTCP_PM_CMD_SUBFLOW_CREATE, .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_nl_cmd_sf_create, + .doit = mptcp_pm_nl_subflow_create_doit, .policy = mptcp_pm_subflow_create_nl_policy, .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, .flags = GENL_UNS_ADMIN_PERM, @@ -2398,7 +2398,7 @@ static const struct genl_ops mptcp_pm_ops[] = { { .cmd = MPTCP_PM_CMD_SUBFLOW_DESTROY, .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_nl_cmd_sf_destroy, + .doit = mptcp_pm_nl_subflow_destroy_doit, .policy = mptcp_pm_subflow_create_nl_policy, .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, .flags = GENL_UNS_ADMIN_PERM, @@ -2410,8 +2410,8 @@ static struct genl_family mptcp_genl_family __ro_after_init = { .version = MPTCP_PM_VER, .netnsok = true, .module = THIS_MODULE, - .ops = mptcp_pm_ops, - .n_ops = ARRAY_SIZE(mptcp_pm_ops), + .ops = mptcp_pm_nl_ops, + .n_ops = ARRAY_SIZE(mptcp_pm_nl_ops), .resv_start_op = MPTCP_PM_CMD_SUBFLOW_DESTROY + 1, .mcgrps = mptcp_pm_mcgrps, .n_mcgrps = ARRAY_SIZE(mptcp_pm_mcgrps), diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index d042d32beb4d..0f92e5b13a8a 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -145,7 +145,7 @@ int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, return mptcp_userspace_pm_append_new_local_addr(msk, &new_entry); } -int mptcp_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN]; struct nlattr *addr = info->attrs[MPTCP_PM_ATTR_ADDR]; @@ -208,7 +208,7 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info) return err; } -int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN]; struct nlattr *id = info->attrs[MPTCP_PM_ATTR_LOC_ID]; @@ -270,7 +270,7 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info) return err; } -int mptcp_nl_cmd_sf_create(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN]; @@ -394,7 +394,7 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk, return NULL; } -int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN]; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 3612545fa62e..4d6e40416f84 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -877,10 +877,10 @@ void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, struct list_head *rm_list); void mptcp_free_local_addr_list(struct mptcp_sock *msk); -int mptcp_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info); -int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info); -int mptcp_nl_cmd_sf_create(struct sk_buff *skb, struct genl_info *info); -int mptcp_nl_cmd_sf_destroy(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info); void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, const struct sock *ssk, gfp_t gfp); From patchwork Tue Oct 10 19:21:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13415921 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2DA7B29CE1; Tue, 10 Oct 2023 19:22:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VxiPP7eU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F263C4339A; Tue, 10 Oct 2023 19:22:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696965737; bh=WzRXUUwS9m1a0U8d7UAQjJP9E67JgFPV0KFH7ZPXq5c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VxiPP7eUSPv1h6qEzguisBtJlqqqbNuI41pr20qDt02VcVcDvCHtsEftJZOYIVFYb 5tvFhJvE5usVnQ9xeX/WaiizKkYA5oRbcsFkAWzNZO5WHFglKlbqBCG7KpiGJyXVLo SuqUb4zzvoKqsTLDU5HlDRHW+NlSsiVGXwcob6mrjz+RTo5pN4rQBfHjOwt83UM8Qz MrNovBK7V1DCZnB2XAl5Hov0nQS8euhA6W+/7LoyAKXrping5ZriuDkuSfUyItYsI5 szYSOYtUxao+3amtpq/1lOsdKs0UlmPA/XP3LiUWLsD+g4VIHpjYc9qti9It63Y4qp vNAJOT2sCZUeA== From: Matthieu Baerts Date: Tue, 10 Oct 2023 21:21:47 +0200 Subject: [PATCH net-next 6/6] net: mptcp: use policy generated by YAML spec Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-6-18dd117e8f50@kernel.org> References: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-0-18dd117e8f50@kernel.org> In-Reply-To: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-0-18dd117e8f50@kernel.org> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Davide Caratti , Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=20691; i=matttbe@kernel.org; h=from:subject:message-id; bh=Q4zkiSxZDxxWhjFQgvV08qM+2CwZMM5SYj3P+JEtxlk=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlJaRVv4s2thphzXvxPLZCIFde5yz40b1aBE5hH beFS77ctzKJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZSWkVQAKCRD2t4JPQmmg cybMD/0cRyOOyfwGHtnoEv+R4G9f+cWQ+8p/Vh5P6ARtQ4bETVjp1hV+ENVKG005K7d9uJi/+jU mfEe7BVkUbpUaVCXmJpFIdY6QcFnvmGEeqQF0/+1TDYuksNuxKQXIJzfCUMI9eHxtwrzlyt5DZx YdeLfmtsrv6uQ4tyd6NVti8EbTJnDOyfAWSaSH6xnZc5rWUcqdmg7uKiB2zNpNw4nnXl0o1KvZn 7EsD1+94Y8ahqFpmmnXrLOQpQiKoYZmq5VckFGDnogzuKTOo2caOvoPhaRqIf75qXaOVpf8c6D6 ews1P+C5mkboXqojxuYIoxdBRV/+UXxI5gtJtPt31CB/vNgK4OpiWqwXrpDuSrVGYL3tfISWSO8 +pgApABDAboonX68WRlimhMTjSL8J2HlepQTQP+LIAdjl51tPsbZdQFrGtJ5lnKvrBOQV9sjT4K AmxECaXjOSXgPfhh60aOejNIO3TcUXbKMQYNRObcsr6IgOODCf8wJXxPXmHCilZFOGrKlHoigTb TEcW5+Bii2jfXlJx2KJrJHGijQO3fl6uTYtrdhB4+/TnAO2nXi7hyyadIeGIqQ6FpwgLLxNhrJd 4GvranketaG37NBDx/nPbCVQS6WIvqnKABspWVqKYfQqxZpFSzDeFMbra4MGZrmLZX04fM89WYD RZRIU+Lj56ZaHBw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Davide Caratti generated with: $ ./tools/net/ynl/ynl-gen-c.py --mode kernel \ > --spec Documentation/netlink/specs/mptcp.yaml --source \ > -o net/mptcp/mptcp_pm_gen.c $ ./tools/net/ynl/ynl-gen-c.py --mode kernel \ > --spec Documentation/netlink/specs/mptcp.yaml --header \ > -o net/mptcp/mptcp_pm_gen.h Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/340 Acked-by: Paolo Abeni Signed-off-by: Davide Caratti Signed-off-by: Matthieu Baerts --- net/mptcp/Makefile | 3 +- net/mptcp/mptcp_pm_gen.c | 179 +++++++++++++++++++++++++++++++++++++++++++++++ net/mptcp/mptcp_pm_gen.h | 58 +++++++++++++++ net/mptcp/pm_netlink.c | 165 +++---------------------------------------- net/mptcp/protocol.h | 6 +- 5 files changed, 250 insertions(+), 161 deletions(-) diff --git a/net/mptcp/Makefile b/net/mptcp/Makefile index 84e531f86b82..bcf1dbf3a432 100644 --- a/net/mptcp/Makefile +++ b/net/mptcp/Makefile @@ -2,7 +2,8 @@ obj-$(CONFIG_MPTCP) += mptcp.o mptcp-y := protocol.o subflow.o options.o token.o crypto.o ctrl.o pm.o diag.o \ - mib.o pm_netlink.o sockopt.o pm_userspace.o fastopen.o sched.o + mib.o pm_netlink.o sockopt.o pm_userspace.o fastopen.o sched.o \ + mptcp_pm_gen.o obj-$(CONFIG_SYN_COOKIES) += syncookies.o obj-$(CONFIG_INET_MPTCP_DIAG) += mptcp_diag.o diff --git a/net/mptcp/mptcp_pm_gen.c b/net/mptcp/mptcp_pm_gen.c new file mode 100644 index 000000000000..673b5167af6b --- /dev/null +++ b/net/mptcp/mptcp_pm_gen.c @@ -0,0 +1,179 @@ +// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/mptcp.yaml */ +/* YNL-GEN kernel source */ + +#include +#include + +#include "mptcp_pm_gen.h" + +#include + +/* Common nested types */ +const struct nla_policy mptcp_pm_address_nl_policy[MPTCP_PM_ADDR_ATTR_IF_IDX + 1] = { + [MPTCP_PM_ADDR_ATTR_FAMILY] = { .type = NLA_U16, }, + [MPTCP_PM_ADDR_ATTR_ID] = { .type = NLA_U8, }, + [MPTCP_PM_ADDR_ATTR_ADDR4] = { .type = NLA_U32, }, + [MPTCP_PM_ADDR_ATTR_ADDR6] = { .len = 16, }, + [MPTCP_PM_ADDR_ATTR_PORT] = { .type = NLA_U16, }, + [MPTCP_PM_ADDR_ATTR_FLAGS] = { .type = NLA_U32, }, + [MPTCP_PM_ADDR_ATTR_IF_IDX] = { .type = NLA_S32, }, +}; + +/* MPTCP_PM_CMD_ADD_ADDR - do */ +const struct nla_policy mptcp_pm_add_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = { + [MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_DEL_ADDR - do */ +const struct nla_policy mptcp_pm_del_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = { + [MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_GET_ADDR - do */ +const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = { + [MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_FLUSH_ADDRS - do */ +const struct nla_policy mptcp_pm_flush_addrs_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = { + [MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_SET_LIMITS - do */ +const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1] = { + [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, }, +}; + +/* MPTCP_PM_CMD_GET_LIMITS - do */ +const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1] = { + [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, }, +}; + +/* MPTCP_PM_CMD_SET_FLAGS - do */ +const struct nla_policy mptcp_pm_set_flags_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = { + [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_ANNOUNCE - do */ +const struct nla_policy mptcp_pm_announce_nl_policy[MPTCP_PM_ATTR_TOKEN + 1] = { + [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, +}; + +/* MPTCP_PM_CMD_REMOVE - do */ +const struct nla_policy mptcp_pm_remove_nl_policy[MPTCP_PM_ATTR_LOC_ID + 1] = { + [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_LOC_ID] = { .type = NLA_U8, }, +}; + +/* MPTCP_PM_CMD_SUBFLOW_CREATE - do */ +const struct nla_policy mptcp_pm_subflow_create_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = { + [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_SUBFLOW_DESTROY - do */ +const struct nla_policy mptcp_pm_subflow_destroy_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = { + [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* Ops table for mptcp_pm */ +const struct genl_ops mptcp_pm_nl_ops[11] = { + { + .cmd = MPTCP_PM_CMD_ADD_ADDR, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_add_addr_doit, + .policy = mptcp_pm_add_addr_nl_policy, + .maxattr = MPTCP_PM_ENDPOINT_ADDR, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_DEL_ADDR, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_del_addr_doit, + .policy = mptcp_pm_del_addr_nl_policy, + .maxattr = MPTCP_PM_ENDPOINT_ADDR, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_GET_ADDR, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_get_addr_doit, + .dumpit = mptcp_pm_nl_get_addr_dumpit, + .policy = mptcp_pm_get_addr_nl_policy, + .maxattr = MPTCP_PM_ENDPOINT_ADDR, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_FLUSH_ADDRS, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_flush_addrs_doit, + .policy = mptcp_pm_flush_addrs_nl_policy, + .maxattr = MPTCP_PM_ENDPOINT_ADDR, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_SET_LIMITS, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_set_limits_doit, + .policy = mptcp_pm_set_limits_nl_policy, + .maxattr = MPTCP_PM_ATTR_SUBFLOWS, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_GET_LIMITS, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_get_limits_doit, + .policy = mptcp_pm_get_limits_nl_policy, + .maxattr = MPTCP_PM_ATTR_SUBFLOWS, + }, + { + .cmd = MPTCP_PM_CMD_SET_FLAGS, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_set_flags_doit, + .policy = mptcp_pm_set_flags_nl_policy, + .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_ANNOUNCE, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_announce_doit, + .policy = mptcp_pm_announce_nl_policy, + .maxattr = MPTCP_PM_ATTR_TOKEN, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_REMOVE, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_remove_doit, + .policy = mptcp_pm_remove_nl_policy, + .maxattr = MPTCP_PM_ATTR_LOC_ID, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_SUBFLOW_CREATE, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_subflow_create_doit, + .policy = mptcp_pm_subflow_create_nl_policy, + .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_SUBFLOW_DESTROY, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_subflow_destroy_doit, + .policy = mptcp_pm_subflow_destroy_nl_policy, + .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, + .flags = GENL_UNS_ADMIN_PERM, + }, +}; diff --git a/net/mptcp/mptcp_pm_gen.h b/net/mptcp/mptcp_pm_gen.h new file mode 100644 index 000000000000..10579d184587 --- /dev/null +++ b/net/mptcp/mptcp_pm_gen.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/mptcp.yaml */ +/* YNL-GEN kernel header */ + +#ifndef _LINUX_MPTCP_PM_GEN_H +#define _LINUX_MPTCP_PM_GEN_H + +#include +#include + +#include + +/* Common nested types */ +extern const struct nla_policy mptcp_pm_address_nl_policy[MPTCP_PM_ADDR_ATTR_IF_IDX + 1]; + +extern const struct nla_policy mptcp_pm_add_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1]; + +extern const struct nla_policy mptcp_pm_del_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1]; + +extern const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1]; + +extern const struct nla_policy mptcp_pm_flush_addrs_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1]; + +extern const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1]; + +extern const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1]; + +extern const struct nla_policy mptcp_pm_set_flags_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1]; + +extern const struct nla_policy mptcp_pm_announce_nl_policy[MPTCP_PM_ATTR_TOKEN + 1]; + +extern const struct nla_policy mptcp_pm_remove_nl_policy[MPTCP_PM_ATTR_LOC_ID + 1]; + +extern const struct nla_policy mptcp_pm_subflow_create_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1]; + +extern const struct nla_policy mptcp_pm_subflow_destroy_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1]; + +/* Ops table for mptcp_pm */ +extern const struct genl_ops mptcp_pm_nl_ops[11]; + +int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *skb, + struct netlink_callback *cb); +int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_get_limits_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, + struct genl_info *info); +int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, + struct genl_info *info); + +#endif /* _LINUX_MPTCP_PM_GEN_H */ diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index dc3ed337eb1f..1529ec358815 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -48,60 +48,6 @@ struct pm_nl_pernet { #define MPTCP_PM_ADDR_MAX 8 #define ADD_ADDR_RETRANS_MAX 3 -static -const struct nla_policy mptcp_pm_address_nl_policy[MPTCP_PM_ADDR_ATTR_IF_IDX + 1] = { - [MPTCP_PM_ADDR_ATTR_FAMILY] = { .type = NLA_U16, }, - [MPTCP_PM_ADDR_ATTR_ID] = { .type = NLA_U8, }, - [MPTCP_PM_ADDR_ATTR_ADDR4] = { .type = NLA_U32, }, - [MPTCP_PM_ADDR_ATTR_ADDR6] = { .len = 16, }, - [MPTCP_PM_ADDR_ATTR_PORT] = { .type = NLA_U16, }, - [MPTCP_PM_ADDR_ATTR_FLAGS] = { .type = NLA_U32, }, - [MPTCP_PM_ADDR_ATTR_IF_IDX] = { .type = NLA_S32, }, -}; - -/* MPTCP_PM_CMD_ADD_ADDR / DEL / GET / FLUSH - do */ -static -const struct nla_policy mptcp_pm_endpoint_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = { - [MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), -}; - -/* MPTCP_PM_CMD_SET_LIMITS - do */ -static -const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1] = { - [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, }, - [MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, }, -}; - -/* MPTCP_PM_CMD_SET_FLAGS - do */ -static -const struct nla_policy mptcp_pm_set_flags_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = { - [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), - [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, - [MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), -}; - -/* MPTCP_PM_CMD_ANNOUNCE - do */ -static -const struct nla_policy mptcp_pm_announce_nl_policy[MPTCP_PM_ATTR_TOKEN + 1] = { - [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), - [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, -}; - -/* MPTCP_PM_CMD_REMOVE - do */ -static -const struct nla_policy mptcp_pm_remove_nl_policy[MPTCP_PM_ATTR_LOC_ID + 1] = { - [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, - [MPTCP_PM_ATTR_LOC_ID] = { .type = NLA_U8, }, -}; - -/* MPTCP_PM_CMD_SUBFLOW_CREATE / DESTROY - do */ -static -const struct nla_policy mptcp_pm_subflow_create_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = { - [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), - [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, - [MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), -}; - static struct pm_nl_pernet *pm_nl_get_pernet(const struct net *net) { return net_generic(net, pm_nl_pernet_id); @@ -1334,7 +1280,7 @@ static int mptcp_nl_add_subflow_or_signal_addr(struct net *net) return 0; } -static int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); @@ -1515,7 +1461,7 @@ static int mptcp_nl_remove_id_zero_address(struct net *net, return 0; } -static int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); @@ -1650,7 +1596,7 @@ static void __reset_counters(struct pm_nl_pernet *pernet) pernet->addrs = 0; } -static int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info) { struct pm_nl_pernet *pernet = genl_info_pm_nl(info); LIST_HEAD(free_list); @@ -1706,7 +1652,7 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, return -EMSGSIZE; } -static int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); @@ -1756,8 +1702,8 @@ static int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info return ret; } -static int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, - struct netlink_callback *cb) +int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, + struct netlink_callback *cb) { struct net *net = sock_net(msg->sk); struct mptcp_pm_addr_entry *entry; @@ -1814,8 +1760,7 @@ static int parse_limit(struct genl_info *info, int id, unsigned int *limit) return 0; } -static int -mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, struct genl_info *info) { struct pm_nl_pernet *pernet = genl_info_pm_nl(info); unsigned int rcv_addrs, subflows; @@ -1840,8 +1785,7 @@ mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, struct genl_info *info) return ret; } -static int -mptcp_pm_nl_get_limits_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_get_limits_doit(struct sk_buff *skb, struct genl_info *info) { struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct sk_buff *msg; @@ -1950,7 +1894,7 @@ int mptcp_pm_nl_set_flags(struct net *net, struct mptcp_pm_addr_entry *addr, u8 return 0; } -static int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) { struct mptcp_pm_addr_entry remote = { .addr = { .family = AF_UNSPEC }, }; struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, }; @@ -2314,97 +2258,6 @@ void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, nlmsg_free(skb); } -static const struct genl_ops mptcp_pm_nl_ops[] = { - { - .cmd = MPTCP_PM_CMD_ADD_ADDR, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_add_addr_doit, - .policy = mptcp_pm_endpoint_nl_policy, - .maxattr = MPTCP_PM_ENDPOINT_ADDR, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_DEL_ADDR, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_del_addr_doit, - .policy = mptcp_pm_endpoint_nl_policy, - .maxattr = MPTCP_PM_ENDPOINT_ADDR, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_GET_ADDR, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_get_addr_doit, - .dumpit = mptcp_pm_nl_get_addr_dumpit, - .policy = mptcp_pm_endpoint_nl_policy, - .maxattr = MPTCP_PM_ENDPOINT_ADDR, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_FLUSH_ADDRS, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_flush_addrs_doit, - .policy = mptcp_pm_endpoint_nl_policy, - .maxattr = MPTCP_PM_ENDPOINT_ADDR, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_SET_LIMITS, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_set_limits_doit, - .policy = mptcp_pm_set_limits_nl_policy, - .maxattr = MPTCP_PM_ATTR_SUBFLOWS, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_GET_LIMITS, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_get_limits_doit, - .policy = mptcp_pm_set_limits_nl_policy, - .maxattr = MPTCP_PM_ATTR_SUBFLOWS, - }, - { - .cmd = MPTCP_PM_CMD_SET_FLAGS, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_set_flags_doit, - .policy = mptcp_pm_set_flags_nl_policy, - .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_ANNOUNCE, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_announce_doit, - .policy = mptcp_pm_announce_nl_policy, - .maxattr = MPTCP_PM_ATTR_TOKEN, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_REMOVE, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_remove_doit, - .policy = mptcp_pm_remove_nl_policy, - .maxattr = MPTCP_PM_ATTR_LOC_ID, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_SUBFLOW_CREATE, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_subflow_create_doit, - .policy = mptcp_pm_subflow_create_nl_policy, - .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_SUBFLOW_DESTROY, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_subflow_destroy_doit, - .policy = mptcp_pm_subflow_create_nl_policy, - .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, - .flags = GENL_UNS_ADMIN_PERM, - }, -}; - static struct genl_family mptcp_genl_family __ro_after_init = { .name = MPTCP_PM_NAME, .version = MPTCP_PM_VER, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 4d6e40416f84..c4c05afdc48c 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -13,6 +13,8 @@ #include #include +#include "mptcp_pm_gen.h" + #define MPTCP_SUPPORTED_VERSION 1 /* MPTCP option bits */ @@ -877,10 +879,6 @@ void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, struct list_head *rm_list); void mptcp_free_local_addr_list(struct mptcp_sock *msk); -int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info); -int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info); -int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info); -int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info); void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, const struct sock *ssk, gfp_t gfp);