From nobody Thu Dec 26 11:48:13 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 C8618BA2D for ; Fri, 1 Sep 2023 18:10:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693591842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1XFz8O0h1/UIQcqpzp/wVukbL+cKGC8tV1Rfmt2IPbQ=; b=eQPKRagJKZ3yvab5Wk/zbu4m9ppRhjeW1lfmQB2HJV+WDy+edoD+cWd4ONPp2L2tpqN/s7 2sRBaPct3PAc/EXf3G3kNaqZ7ewzRjtqqs0rt4/1HYhSj+tnKI841UaSjqcLkqnnlRDpg9 WEuRvhL3m7wh6tOccUKYz5C6rtNuhis= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-122-x4O20hgfOyyQHznlqAxSJg-1; Fri, 01 Sep 2023 14:10:40 -0400 X-MC-Unique: x4O20hgfOyyQHznlqAxSJg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DCCD5381DC8E; Fri, 1 Sep 2023 18:10:39 +0000 (UTC) Received: from dcaratti.users.ipa.redhat.com (unknown [10.45.225.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E991D47819; Fri, 1 Sep 2023 18:10:39 +0000 (UTC) From: Davide Caratti To: mptcp@lists.linux.dev Cc: pabeni@redhat.com, Matthieu Baerts Subject: [PATCH mptcp-next v2 1/6] tools: ynl: add uns-admin-perm to genetlink legacy Date: Fri, 1 Sep 2023 20:10:30 +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.1 on 10.11.54.8 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" this flag maps to GENL_UNS_ADMIN_PERM and will be used by future specs. Signed-off-by: Davide Caratti --- Documentation/netlink/genetlink-legacy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/ne= tlink/genetlink-legacy.yaml index 12a0a045605d..c08e5e3a0aaa 100644 --- a/Documentation/netlink/genetlink-legacy.yaml +++ b/Documentation/netlink/genetlink-legacy.yaml @@ -316,7 +316,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 --=20 2.40.1 From nobody Thu Dec 26 11:48:13 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 CB72EC2D8 for ; Fri, 1 Sep 2023 18:10:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693591843; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oV+hNRiZy6P8ys0NG5XiZ/6wkPGZBJmdd7pP5lQHvsk=; b=TNf5l+2SU/cOXqhfZnjOwFVjbAM7UQb+lpnNS/1jvgczOInbkvC2v1a0SYu1gBbkJ4DLTG U/e6rzqzW/phlqFvr/b1a1+Ypph5XW83e5ODXsSViyqlCWQq7fgSXSeEFUatvLQMKiHoMn 5XLth6vyqgsv7vDrJ9PVanITDSwqlCM= 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-118-RU1usTDwP3O1BYyNB_txGw-1; Fri, 01 Sep 2023 14:10:41 -0400 X-MC-Unique: RU1usTDwP3O1BYyNB_txGw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 03927800193; Fri, 1 Sep 2023 18:10:41 +0000 (UTC) Received: from dcaratti.users.ipa.redhat.com (unknown [10.45.225.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 296ADD4781C; Fri, 1 Sep 2023 18:10:40 +0000 (UTC) From: Davide Caratti To: mptcp@lists.linux.dev Cc: pabeni@redhat.com, Matthieu Baerts Subject: [PATCH mptcp-next v2 2/6] mptcp: convert netlink from small_ops to ops Date: Fri, 1 Sep 2023 20:10:31 +0200 Message-Id: <9079cf99466869474845cf89b55de5dfa7e01326.1693591676.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.1 on 10.11.54.8 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" 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 Signed-off-by: Davide Caratti --- include/uapi/linux/mptcp.h | 8 ++ net/mptcp/pm_netlink.c | 185 ++++++++++++++++++++++++------------- 2 files changed, 129 insertions(+), 64 deletions(-) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index ee9c49f949a2..34082c14c89b 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -65,6 +65,14 @@ enum { =20 #define MPTCP_PM_ATTR_MAX (__MPTCP_PM_ATTR_MAX - 1) =20 +enum { + MPTCP_PM_ENDPOINT_ADDR =3D 1, + + __MPTCP_PM_ENDPOINT_MAX +}; + +#define MPTCP_PM_ENDPOINT_MAX (__MPTCP_PM_ENDPOINT_MAX - 1) + enum { MPTCP_PM_ADDR_ATTR_UNSPEC, =20 diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 9661f3812682..3859a206c298 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -48,6 +48,53 @@ struct pm_nl_pernet { #define MPTCP_PM_ADDR_MAX 8 #define ADD_ADDR_RETRANS_MAX 3 =20 +const struct nla_policy mptcp_pm_address_nl_policy[MPTCP_PM_ADDR_ATTR_IF_I= DX + 1] =3D { + [MPTCP_PM_ADDR_ATTR_FAMILY] =3D { .type =3D NLA_U16, }, + [MPTCP_PM_ADDR_ATTR_ADDR4] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ADDR_ATTR_ADDR6] =3D { .len =3D 16, }, + [MPTCP_PM_ADDR_ATTR_ID] =3D { .type =3D NLA_U8, }, + [MPTCP_PM_ADDR_ATTR_PORT] =3D { .type =3D NLA_U16, }, + [MPTCP_PM_ADDR_ATTR_IF_IDX] =3D { .type =3D NLA_S32, }, + [MPTCP_PM_ADDR_ATTR_FLAGS] =3D { .type =3D NLA_U32, }, +}; + +/* MPTCP_PM_CMD_ADD_ADDR / DEL / GET / FLUSH - do */ +static const struct nla_policy mptcp_pm_endpoint_nl_policy[MPTCP_PM_ENDPOI= NT_ADDR + 1] =3D { + [MPTCP_PM_ENDPOINT_ADDR] =3D 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] =3D { + [MPTCP_PM_ATTR_RCV_ADD_ADDRS] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_SUBFLOWS] =3D { .type =3D NLA_U32, }, +}; + +/* MPTCP_PM_CMD_SET_FLAGS - do */ +const struct nla_policy mptcp_pm_set_flags_nl_policy[MPTCP_PM_ATTR_ADDR_RE= MOTE + 1] =3D { + [MPTCP_PM_ATTR_ADDR] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_pol= icy), + [MPTCP_PM_ATTR_ADDR_REMOTE] =3D NLA_POLICY_NESTED(mptcp_pm_address= _nl_policy), + [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, +}; + +/* MPTCP_PM_CMD_ANNOUNCE - do */ +static const struct nla_policy mptcp_pm_announce_nl_policy[MPTCP_PM_ATTR_T= OKEN + 1] =3D { + [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_ADDR] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_REMOVE - do */ +static const struct nla_policy mptcp_pm_remove_nl_policy[MPTCP_PM_ATTR_LOC= _ID + 1] =3D { + [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_LOC_ID] =3D { .type =3D 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] =3D { + [MPTCP_PM_ATTR_ADDR_REMOTE] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_pol= icy), + [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_ADDR] =3D 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 +1151,6 @@ static const struct genl_multicast_group mptcp_pm_mc= grps[] =3D { }, }; =20 -static const struct nla_policy -mptcp_pm_addr_policy[MPTCP_PM_ADDR_ATTR_MAX + 1] =3D { - [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 - NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)), - [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 }, -}; - -static const struct nla_policy mptcp_pm_policy[MPTCP_PM_ATTR_MAX + 1] =3D { - [MPTCP_PM_ATTR_ADDR] =3D - NLA_POLICY_NESTED(mptcp_pm_addr_policy), - [MPTCP_PM_ATTR_RCV_ADD_ADDRS] =3D { .type =3D NLA_U32, }, - [MPTCP_PM_ATTR_SUBFLOWS] =3D { .type =3D NLA_U32, }, - [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, - [MPTCP_PM_ATTR_LOC_ID] =3D { .type =3D NLA_U8, }, - [MPTCP_PM_ATTR_ADDR_REMOTE] =3D - NLA_POLICY_NESTED(mptcp_pm_addr_policy), -}; - void mptcp_pm_nl_subflow_chk_stale(const struct mptcp_sock *msk, struct so= ck *ssk) { struct mptcp_subflow_context *iter, *subflow =3D mptcp_subflow_ctx(ssk); @@ -1188,7 +1212,7 @@ static int mptcp_pm_parse_pm_addr_attr(struct nlattr = *tb[], =20 /* no validation needed - was already done via nested policy */ err =3D 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; =20 @@ -1305,7 +1329,7 @@ static int mptcp_nl_add_subflow_or_signal_addr(struct= net *net) =20 static int mptcp_nl_cmd_add_addr(struct sk_buff *skb, struct genl_info *in= fo) { - struct nlattr *attr =3D info->attrs[MPTCP_PM_ATTR_ADDR]; + struct nlattr *attr =3D info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; int ret; @@ -1486,7 +1510,7 @@ static int mptcp_nl_remove_id_zero_address(struct net= *net, =20 static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *in= fo) { - struct nlattr *attr =3D info->attrs[MPTCP_PM_ATTR_ADDR]; + struct nlattr *attr =3D info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; unsigned int addr_max; @@ -1677,7 +1701,7 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, =20 static int mptcp_nl_cmd_get_addr(struct sk_buff *skb, struct genl_info *in= fo) { - struct nlattr *attr =3D info->attrs[MPTCP_PM_ATTR_ADDR]; + struct nlattr *attr =3D info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; struct sk_buff *msg; @@ -2283,72 +2307,105 @@ void mptcp_event(enum mptcp_event_type type, const= struct mptcp_sock *msk, nlmsg_free(skb); } =20 -static const struct genl_small_ops mptcp_pm_ops[] =3D { + +static const struct genl_ops mptcp_pm_ops[] =3D { { - .cmd =3D MPTCP_PM_CMD_ADD_ADDR, - .doit =3D mptcp_nl_cmd_add_addr, - .flags =3D GENL_UNS_ADMIN_PERM, + .cmd =3D MPTCP_PM_CMD_ADD_ADDR, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_nl_cmd_add_addr, + .policy =3D mptcp_pm_endpoint_nl_policy, + .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, + .flags =3D GENL_UNS_ADMIN_PERM, }, { - .cmd =3D MPTCP_PM_CMD_DEL_ADDR, - .doit =3D mptcp_nl_cmd_del_addr, - .flags =3D GENL_UNS_ADMIN_PERM, + .cmd =3D MPTCP_PM_CMD_DEL_ADDR, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_nl_cmd_del_addr, + .policy =3D mptcp_pm_endpoint_nl_policy, + .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, + .flags =3D GENL_UNS_ADMIN_PERM, }, { - .cmd =3D MPTCP_PM_CMD_FLUSH_ADDRS, - .doit =3D mptcp_nl_cmd_flush_addrs, - .flags =3D GENL_UNS_ADMIN_PERM, + .cmd =3D MPTCP_PM_CMD_GET_ADDR, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_nl_cmd_get_addr, + .dumpit =3D mptcp_nl_cmd_dump_addrs, + .policy =3D mptcp_pm_endpoint_nl_policy, + .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, + .flags =3D GENL_UNS_ADMIN_PERM, }, { - .cmd =3D MPTCP_PM_CMD_GET_ADDR, - .doit =3D mptcp_nl_cmd_get_addr, - .dumpit =3D mptcp_nl_cmd_dump_addrs, + .cmd =3D MPTCP_PM_CMD_FLUSH_ADDRS, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_nl_cmd_flush_addrs, + .policy =3D mptcp_pm_endpoint_nl_policy, + .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, + .flags =3D GENL_UNS_ADMIN_PERM, }, { - .cmd =3D MPTCP_PM_CMD_SET_LIMITS, - .doit =3D mptcp_nl_cmd_set_limits, - .flags =3D GENL_UNS_ADMIN_PERM, + .cmd =3D MPTCP_PM_CMD_SET_LIMITS, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_nl_cmd_set_limits, + .policy =3D mptcp_pm_set_limits_nl_policy, + .maxattr =3D MPTCP_PM_ATTR_SUBFLOWS, + .flags =3D GENL_UNS_ADMIN_PERM, }, { - .cmd =3D MPTCP_PM_CMD_GET_LIMITS, - .doit =3D mptcp_nl_cmd_get_limits, + .cmd =3D MPTCP_PM_CMD_GET_LIMITS, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_nl_cmd_get_limits, + .policy =3D mptcp_pm_set_limits_nl_policy, + .maxattr =3D MPTCP_PM_ATTR_SUBFLOWS, }, { - .cmd =3D MPTCP_PM_CMD_SET_FLAGS, - .doit =3D mptcp_nl_cmd_set_flags, - .flags =3D GENL_UNS_ADMIN_PERM, + .cmd =3D MPTCP_PM_CMD_SET_FLAGS, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_nl_cmd_set_flags, + .policy =3D mptcp_pm_set_flags_nl_policy, + .maxattr =3D MPTCP_PM_ATTR_ADDR_REMOTE, + .flags =3D GENL_UNS_ADMIN_PERM, }, { - .cmd =3D MPTCP_PM_CMD_ANNOUNCE, - .doit =3D mptcp_nl_cmd_announce, - .flags =3D GENL_UNS_ADMIN_PERM, + .cmd =3D MPTCP_PM_CMD_ANNOUNCE, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_nl_cmd_announce, + .policy =3D mptcp_pm_announce_nl_policy, + .maxattr =3D MPTCP_PM_ATTR_TOKEN, + .flags =3D GENL_UNS_ADMIN_PERM, }, { - .cmd =3D MPTCP_PM_CMD_REMOVE, - .doit =3D mptcp_nl_cmd_remove, - .flags =3D GENL_UNS_ADMIN_PERM, + .cmd =3D MPTCP_PM_CMD_REMOVE, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_nl_cmd_remove, + .policy =3D mptcp_pm_remove_nl_policy, + .maxattr =3D MPTCP_PM_ATTR_LOC_ID, + .flags =3D GENL_UNS_ADMIN_PERM, }, { - .cmd =3D MPTCP_PM_CMD_SUBFLOW_CREATE, - .doit =3D mptcp_nl_cmd_sf_create, - .flags =3D GENL_UNS_ADMIN_PERM, + .cmd =3D MPTCP_PM_CMD_SUBFLOW_CREATE, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_nl_cmd_sf_create, + .policy =3D mptcp_pm_subflow_create_nl_policy, + .maxattr =3D MPTCP_PM_ATTR_ADDR_REMOTE, + .flags =3D GENL_UNS_ADMIN_PERM, }, { - .cmd =3D MPTCP_PM_CMD_SUBFLOW_DESTROY, - .doit =3D mptcp_nl_cmd_sf_destroy, - .flags =3D GENL_UNS_ADMIN_PERM, + .cmd =3D MPTCP_PM_CMD_SUBFLOW_DESTROY, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_nl_cmd_sf_destroy, + .policy =3D mptcp_pm_subflow_create_nl_policy, + .maxattr =3D MPTCP_PM_ATTR_ADDR_REMOTE, + .flags =3D GENL_UNS_ADMIN_PERM, }, }; =20 static struct genl_family mptcp_genl_family __ro_after_init =3D { .name =3D MPTCP_PM_NAME, .version =3D MPTCP_PM_VER, - .maxattr =3D MPTCP_PM_ATTR_MAX, - .policy =3D mptcp_pm_policy, .netnsok =3D true, .module =3D THIS_MODULE, - .small_ops =3D mptcp_pm_ops, - .n_small_ops =3D ARRAY_SIZE(mptcp_pm_ops), + .ops =3D mptcp_pm_ops, + .n_ops =3D ARRAY_SIZE(mptcp_pm_ops), .resv_start_op =3D MPTCP_PM_CMD_SUBFLOW_DESTROY + 1, .mcgrps =3D mptcp_pm_mcgrps, .n_mcgrps =3D ARRAY_SIZE(mptcp_pm_mcgrps), --=20 2.40.1 From nobody Thu Dec 26 11:48:13 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 93806BA2D for ; Fri, 1 Sep 2023 18:10:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693591845; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vJOVT5L/zpAxGbhMoI921dzdPfzpGD2PDp1EJKJB//s=; b=FZFp2eFfywIyZXejhy1Fr2UMqY7WFxDMid1ipN7do7HOVQQq124tDycfVVwGgFEPFkXksX /qXAg2aXgFUW0Ifm7vwdpdYJZaJJD2eX4yk9Z2gm1aO+aV1xH09UHbpJGCXjGIprlGukF6 JPoqenSErxXZXXut0k4IxGaZ3MZnI9U= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-279-WoI-d_j9OsyxRaZ57Ra0Nw-1; Fri, 01 Sep 2023 14:10:42 -0400 X-MC-Unique: WoI-d_j9OsyxRaZ57Ra0Nw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 013DA3C0EAB0; Fri, 1 Sep 2023 18:10:42 +0000 (UTC) Received: from dcaratti.users.ipa.redhat.com (unknown [10.45.225.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45EACD4781A; Fri, 1 Sep 2023 18:10:41 +0000 (UTC) From: Davide Caratti To: mptcp@lists.linux.dev Cc: pabeni@redhat.com, Matthieu Baerts Subject: [PATCH mptcp-next v2 3/6] Documentation: netlink: add a YAML spec for mptcp Date: Fri, 1 Sep 2023 20:10:32 +0200 Message-Id: <368b97f901745b62cffdb1d1fec6a14a9cf3e3ec.1693591676.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.1 on 10.11.54.8 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" Link: https://github.com/multipath-tcp/mptcp_net-next/issues/340 Signed-off-by: Davide Caratti --- Documentation/netlink/specs/mptcp.yaml | 394 +++++++++++++++++++++++++ 1 file changed, 394 insertions(+) create mode 100644 Documentation/netlink/specs/mptcp.yaml diff --git a/Documentation/netlink/specs/mptcp.yaml b/Documentation/netlink= /specs/mptcp.yaml new file mode 100644 index 000000000000..35716638ec08 --- /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-Cla= use) + +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, s= port, + 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, 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 + 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 + 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 + - addr_remote + - token + - + name: announce + doc: announce new sf + attribute-set: attr + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: &announce_add + request: + attributes: + - token + - addr + - + 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_remote + - token + - addr + - + name: subflow_destroy + doc: todo + attribute-set: attr + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: *sf_create --=20 2.40.1 From nobody Thu Dec 26 11:48:13 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 DDA57C2D7 for ; Fri, 1 Sep 2023 18:10:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693591846; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rLsywGMFS3E2r0EwFRjL6u32+wJ0bxpdzgzjPRMggpk=; b=Yc9nPKMa0GctgVo1lMQD9C/t/3+T5OaIFNWLrEEMFFCS/J1F42ftNGnUxPFJrIh3XoUUD2 FeIGTMUuzd71Xg5lNargkGm0B/Xy9zuU0TQkd2OxWIqOWxKB+Zr7ctOOz/cwx1sajPaDjw hf2mRLGb7+Jd6/z23iS+vWcBlQB7F4Q= 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-392-HyJ-YkhQNAC1njMbXBcyFg-1; Fri, 01 Sep 2023 14:10:43 -0400 X-MC-Unique: HyJ-YkhQNAC1njMbXBcyFg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 000888008A4; Fri, 1 Sep 2023 18:10:42 +0000 (UTC) Received: from dcaratti.users.ipa.redhat.com (unknown [10.45.225.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 463EED47819; Fri, 1 Sep 2023 18:10:42 +0000 (UTC) From: Davide Caratti To: mptcp@lists.linux.dev Cc: pabeni@redhat.com, Matthieu Baerts Subject: [PATCH mptcp-next v2 4/6] mptcp: uapi: use header file generated from YAML spec Date: Fri, 1 Sep 2023 20:10:33 +0200 Message-Id: <963797f413d7a356dd9c18eee86097e20039e65b.1693591676.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.1 on 10.11.54.8 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" 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 Signed-off-by: Davide Caratti --- include/uapi/linux/mptcp.h | 182 ++-------------------------------- include/uapi/linux/mptcp_pm.h | 149 ++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+), 172 deletions(-) create mode 100644 include/uapi/linux/mptcp_pm.h diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index 34082c14c89b..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) =20 -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, - - 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 =3D 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 -}; =20 -#define MPTCP_PM_ADDR_ATTR_MAX (__MPTCP_PM_ADDR_ATTR_MAX - 1) +#include =20 -#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 =20 #define MPTCP_INFO_FLAG_FALLBACK _BITUL(0) #define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED _BITUL(1) =20 +#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; }; =20 -/* - * 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 | daddr= 6, - * 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 | saddr= 6, - * 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 =3D 0, - MPTCP_EVENT_CREATED =3D 1, - MPTCP_EVENT_ESTABLISHED =3D 2, - MPTCP_EVENT_CLOSED =3D 3, - - MPTCP_EVENT_ANNOUNCED =3D 6, - MPTCP_EVENT_REMOVED =3D 7, - - MPTCP_EVENT_SUB_ESTABLISHED =3D 10, - MPTCP_EVENT_SUB_CLOSED =3D 11, - - MPTCP_EVENT_SUB_PRIORITY =3D 13, - - MPTCP_EVENT_LISTENER_CREATED =3D 15, - MPTCP_EVENT_LISTENER_CLOSED =3D 16, -}; - -enum mptcp_event_attr { - MPTCP_ATTR_UNSPEC =3D 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-Cl= ause) */ +/* 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_ESTABL= ISHED + * is sent. + * @MPTCP_EVENT_ESTABLISHED: token, family, saddr4 | saddr6, daddr4 | dadd= r6, + * sport, dport A MPTCP connection is established (can start new subflow= s). + * @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 pee= r. + * @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 | sadd= r6, + * 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 liste= ner + * is closed. + */ +enum mptcp_event_type { + MPTCP_EVENT_UNSPEC, + MPTCP_EVENT_CREATED, + MPTCP_EVENT_ESTABLISHED, + MPTCP_EVENT_CLOSED, + MPTCP_EVENT_ANNOUNCED =3D 6, + MPTCP_EVENT_REMOVED, + MPTCP_EVENT_SUB_ESTABLISHED =3D 10, + MPTCP_EVENT_SUB_CLOSED, + MPTCP_EVENT_SUB_PRIORITY =3D 13, + MPTCP_EVENT_LISTENER_CREATED =3D 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 =3D 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 */ --=20 2.40.1 From nobody Thu Dec 26 11:48:13 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 23CB9C2D8 for ; Fri, 1 Sep 2023 18:10:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693591847; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VP/oJMTWaWyGzFoLwE2FPHHb/JhWoJTlydR2mj7Vzjk=; b=XuJAHBbJ+5vE6j5BpK5tkVTczAeF7bDll5ZPohLsduX1RMu6YL3tW9aBX2hMzyXE/yZQpy X+xuA0zgtGXw0J+hS+K7NTcKFEEp13GQL5DfQAkj5fIeiHRyI48OO96qUvPHSNj/sbo6s4 vl7cU0a70csmtafF0OC9z6o9AOKjNbI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-302-G27O70CeOPqI575Pz6JMsw-1; Fri, 01 Sep 2023 14:10:44 -0400 X-MC-Unique: G27O70CeOPqI575Pz6JMsw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EE0911C18C7D; Fri, 1 Sep 2023 18:10:43 +0000 (UTC) Received: from dcaratti.users.ipa.redhat.com (unknown [10.45.225.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 435BFD4781D; Fri, 1 Sep 2023 18:10:43 +0000 (UTC) From: Davide Caratti To: mptcp@lists.linux.dev Cc: pabeni@redhat.com, Matthieu Baerts Subject: [PATCH mptcp-next v2 5/6] net: mptcp: rename netlink handlers to mptcp_pm_nl__{doit,dumpit} Date: Fri, 1 Sep 2023 20:10:34 +0200 Message-Id: <5815cce617ba0d9a55d8dba6aca059d8a11dbedc.1693591676.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.1 on 10.11.54.8 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" 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 Signed-off-by: Davide Caratti --- 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 3859a206c298..b4463595ab45 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1327,7 +1327,7 @@ static int mptcp_nl_add_subflow_or_signal_addr(struct= net *net) return 0; } =20 -static int mptcp_nl_cmd_add_addr(struct sk_buff *skb, struct genl_info *in= fo) +static int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info= *info) { struct nlattr *attr =3D info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); @@ -1508,7 +1508,7 @@ static int mptcp_nl_remove_id_zero_address(struct net= *net, return 0; } =20 -static int mptcp_nl_cmd_del_addr(struct sk_buff *skb, struct genl_info *in= fo) +static int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info= *info) { struct nlattr *attr =3D info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); @@ -1643,7 +1643,7 @@ static void __reset_counters(struct pm_nl_pernet *per= net) pernet->addrs =3D 0; } =20 -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_i= nfo *info) { struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); LIST_HEAD(free_list); @@ -1699,7 +1699,7 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, return -EMSGSIZE; } =20 -static int mptcp_nl_cmd_get_addr(struct sk_buff *skb, struct genl_info *in= fo) +static int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info= *info) { struct nlattr *attr =3D info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); @@ -1749,8 +1749,8 @@ static int mptcp_nl_cmd_get_addr(struct sk_buff *skb,= struct genl_info *info) return ret; } =20 -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 =3D sock_net(msg->sk); struct mptcp_pm_addr_entry *entry; @@ -1808,7 +1808,7 @@ static int parse_limit(struct genl_info *info, int id= , unsigned int *limit) } =20 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 =3D genl_info_pm_nl(info); unsigned int rcv_addrs, subflows; @@ -1834,7 +1834,7 @@ mptcp_nl_cmd_set_limits(struct sk_buff *skb, struct g= enl_info *info) } =20 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 =3D genl_info_pm_nl(info); struct sk_buff *msg; @@ -1943,7 +1943,7 @@ int mptcp_pm_nl_set_flags(struct net *net, struct mpt= cp_pm_addr_entry *addr, u8 return 0; } =20 -static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *i= nfo) +static int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_inf= o *info) { struct mptcp_pm_addr_entry remote =3D { .addr =3D { .family =3D AF_UNSPEC= }, }; struct mptcp_pm_addr_entry addr =3D { .addr =3D { .family =3D AF_UNSPEC }= , }; @@ -2308,11 +2308,11 @@ void mptcp_event(enum mptcp_event_type type, const = struct mptcp_sock *msk, } =20 =20 -static const struct genl_ops mptcp_pm_ops[] =3D { +static const struct genl_ops mptcp_pm_nl_ops[] =3D { { .cmd =3D MPTCP_PM_CMD_ADD_ADDR, .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_nl_cmd_add_addr, + .doit =3D mptcp_pm_nl_add_addr_doit, .policy =3D mptcp_pm_endpoint_nl_policy, .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, .flags =3D GENL_UNS_ADMIN_PERM, @@ -2320,7 +2320,7 @@ static const struct genl_ops mptcp_pm_ops[] =3D { { .cmd =3D MPTCP_PM_CMD_DEL_ADDR, .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_nl_cmd_del_addr, + .doit =3D mptcp_pm_nl_del_addr_doit, .policy =3D mptcp_pm_endpoint_nl_policy, .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, .flags =3D GENL_UNS_ADMIN_PERM, @@ -2328,8 +2328,8 @@ static const struct genl_ops mptcp_pm_ops[] =3D { { .cmd =3D MPTCP_PM_CMD_GET_ADDR, .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_nl_cmd_get_addr, - .dumpit =3D mptcp_nl_cmd_dump_addrs, + .doit =3D mptcp_pm_nl_get_addr_doit, + .dumpit =3D mptcp_pm_nl_get_addr_dumpit, .policy =3D mptcp_pm_endpoint_nl_policy, .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, .flags =3D GENL_UNS_ADMIN_PERM, @@ -2337,7 +2337,7 @@ static const struct genl_ops mptcp_pm_ops[] =3D { { .cmd =3D MPTCP_PM_CMD_FLUSH_ADDRS, .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_nl_cmd_flush_addrs, + .doit =3D mptcp_pm_nl_flush_addrs_doit, .policy =3D mptcp_pm_endpoint_nl_policy, .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, .flags =3D GENL_UNS_ADMIN_PERM, @@ -2345,7 +2345,7 @@ static const struct genl_ops mptcp_pm_ops[] =3D { { .cmd =3D MPTCP_PM_CMD_SET_LIMITS, .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_nl_cmd_set_limits, + .doit =3D mptcp_pm_nl_set_limits_doit, .policy =3D mptcp_pm_set_limits_nl_policy, .maxattr =3D MPTCP_PM_ATTR_SUBFLOWS, .flags =3D GENL_UNS_ADMIN_PERM, @@ -2353,14 +2353,14 @@ static const struct genl_ops mptcp_pm_ops[] =3D { { .cmd =3D MPTCP_PM_CMD_GET_LIMITS, .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_nl_cmd_get_limits, + .doit =3D mptcp_pm_nl_get_limits_doit, .policy =3D mptcp_pm_set_limits_nl_policy, .maxattr =3D MPTCP_PM_ATTR_SUBFLOWS, }, { .cmd =3D MPTCP_PM_CMD_SET_FLAGS, .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_nl_cmd_set_flags, + .doit =3D mptcp_pm_nl_set_flags_doit, .policy =3D mptcp_pm_set_flags_nl_policy, .maxattr =3D MPTCP_PM_ATTR_ADDR_REMOTE, .flags =3D GENL_UNS_ADMIN_PERM, @@ -2368,7 +2368,7 @@ static const struct genl_ops mptcp_pm_ops[] =3D { { .cmd =3D MPTCP_PM_CMD_ANNOUNCE, .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_nl_cmd_announce, + .doit =3D mptcp_pm_nl_announce_doit, .policy =3D mptcp_pm_announce_nl_policy, .maxattr =3D MPTCP_PM_ATTR_TOKEN, .flags =3D GENL_UNS_ADMIN_PERM, @@ -2376,7 +2376,7 @@ static const struct genl_ops mptcp_pm_ops[] =3D { { .cmd =3D MPTCP_PM_CMD_REMOVE, .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_nl_cmd_remove, + .doit =3D mptcp_pm_nl_remove_doit, .policy =3D mptcp_pm_remove_nl_policy, .maxattr =3D MPTCP_PM_ATTR_LOC_ID, .flags =3D GENL_UNS_ADMIN_PERM, @@ -2384,7 +2384,7 @@ static const struct genl_ops mptcp_pm_ops[] =3D { { .cmd =3D MPTCP_PM_CMD_SUBFLOW_CREATE, .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_nl_cmd_sf_create, + .doit =3D mptcp_pm_nl_subflow_create_doit, .policy =3D mptcp_pm_subflow_create_nl_policy, .maxattr =3D MPTCP_PM_ATTR_ADDR_REMOTE, .flags =3D GENL_UNS_ADMIN_PERM, @@ -2392,7 +2392,7 @@ static const struct genl_ops mptcp_pm_ops[] =3D { { .cmd =3D MPTCP_PM_CMD_SUBFLOW_DESTROY, .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_nl_cmd_sf_destroy, + .doit =3D mptcp_pm_nl_subflow_destroy_doit, .policy =3D mptcp_pm_subflow_create_nl_policy, .maxattr =3D MPTCP_PM_ATTR_ADDR_REMOTE, .flags =3D GENL_UNS_ADMIN_PERM, @@ -2404,8 +2404,8 @@ static struct genl_family mptcp_genl_family __ro_afte= r_init =3D { .version =3D MPTCP_PM_VER, .netnsok =3D true, .module =3D THIS_MODULE, - .ops =3D mptcp_pm_ops, - .n_ops =3D ARRAY_SIZE(mptcp_pm_ops), + .ops =3D mptcp_pm_nl_ops, + .n_ops =3D ARRAY_SIZE(mptcp_pm_nl_ops), .resv_start_op =3D MPTCP_PM_CMD_SUBFLOW_DESTROY + 1, .mcgrps =3D mptcp_pm_mcgrps, .n_mcgrps =3D ARRAY_SIZE(mptcp_pm_mcgrps), diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index b5a8aa4c1ebd..07f602144d5e 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); } =20 -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 =3D info->attrs[MPTCP_PM_ATTR_TOKEN]; struct nlattr *addr =3D info->attrs[MPTCP_PM_ATTR_ADDR]; @@ -208,7 +208,7 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct g= enl_info *info) return err; } =20 -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 =3D info->attrs[MPTCP_PM_ATTR_TOKEN]; struct nlattr *id =3D info->attrs[MPTCP_PM_ATTR_LOC_ID]; @@ -270,7 +270,7 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct gen= l_info *info) return err; } =20 -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 =3D info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; struct nlattr *token =3D info->attrs[MPTCP_PM_ATTR_TOKEN]; @@ -400,7 +400,7 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock= *msk, return NULL; } =20 -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 =3D info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; struct nlattr *token =3D info->attrs[MPTCP_PM_ATTR_TOKEN]; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 12d70ce24843..fbe35b74f319 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -873,10 +873,10 @@ void mptcp_pm_remove_addrs_and_subflows(struct mptcp_= sock *msk, struct list_head *rm_list); =20 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); =20 void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, const struct sock *ssk, gfp_t gfp); --=20 2.40.1 From nobody Thu Dec 26 11:48:13 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 06B3BBA2D for ; Fri, 1 Sep 2023 18:10:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693591849; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PRkoqRVl2rNdQV8KHcWYsnXKt3BQlTb+g06tt/LrQLU=; b=R2qNH3mQINIIhyRZH53m/dwm2QGJpn315Ck/14WAsBOO/t6e5C/RtDoNwo0Lv15kWgWMdL tUUzYyahglRsK/sKRVazb2DkXESqWd/MTbNZYwb2494Bv6PHRG8ubicoPIYQQPLlukXsYU vWym3fO1mKdb9VawaH4B2RVKYmaXtK0= 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-354-YviOlFjGP7mW9WX9QHATqA-1; Fri, 01 Sep 2023 14:10:45 -0400 X-MC-Unique: YviOlFjGP7mW9WX9QHATqA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 16BA292ACE3; Fri, 1 Sep 2023 18:10:45 +0000 (UTC) Received: from dcaratti.users.ipa.redhat.com (unknown [10.45.225.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D0BED47819; Fri, 1 Sep 2023 18:10:44 +0000 (UTC) From: Davide Caratti To: mptcp@lists.linux.dev Cc: pabeni@redhat.com, Matthieu Baerts Subject: [PATCH mptcp-next v2 6/6] net: mptcp: use policy generated by YAML spec Date: Fri, 1 Sep 2023 20:10:35 +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.1 on 10.11.54.8 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" 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 Link: https://github.com/multipath-tcp/mptcp_net-next/issues/340 Signed-off-by: Davide Caratti --- net/mptcp/Makefile | 3 +- net/mptcp/mptcp_pm_gen.c | 179 +++++++++++++++++++++++++++++++++++++++ net/mptcp/mptcp_pm_gen.h | 58 +++++++++++++ net/mptcp/pm_netlink.c | 159 ++-------------------------------- net/mptcp/protocol.h | 6 +- 5 files changed, 250 insertions(+), 155 deletions(-) create mode 100644 net/mptcp/mptcp_pm_gen.c create mode 100644 net/mptcp/mptcp_pm_gen.h 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) +=3D mptcp.o =20 mptcp-y :=3D protocol.o subflow.o options.o token.o crypto.o ctrl.o pm.o d= iag.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 =20 obj-$(CONFIG_SYN_COOKIES) +=3D syncookies.o obj-$(CONFIG_INET_MPTCP_DIAG) +=3D 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..61de0a2dac8d --- /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-Cl= ause) +/* 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_I= DX + 1] =3D { + [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_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, }, +}; + +/* MPTCP_PM_CMD_ADD_ADDR - do */ +const struct nla_policy mptcp_pm_add_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR= + 1] =3D { + [MPTCP_PM_ENDPOINT_ADDR] =3D 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] =3D { + [MPTCP_PM_ENDPOINT_ADDR] =3D 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] =3D { + [MPTCP_PM_ENDPOINT_ADDR] =3D 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_A= DDR + 1] =3D { + [MPTCP_PM_ENDPOINT_ADDR] =3D 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_SUBFLO= WS + 1] =3D { + [MPTCP_PM_ATTR_RCV_ADD_ADDRS] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_SUBFLOWS] =3D { .type =3D NLA_U32, }, +}; + +/* MPTCP_PM_CMD_GET_LIMITS - do */ +const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLO= WS + 1] =3D { + [MPTCP_PM_ATTR_RCV_ADD_ADDRS] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_SUBFLOWS] =3D { .type =3D NLA_U32, }, +}; + +/* MPTCP_PM_CMD_SET_FLAGS - do */ +const struct nla_policy mptcp_pm_set_flags_nl_policy[MPTCP_PM_ATTR_ADDR_RE= MOTE + 1] =3D { + [MPTCP_PM_ATTR_ADDR] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_ADDR_REMOTE] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_pol= icy), + [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, +}; + +/* MPTCP_PM_CMD_ANNOUNCE - do */ +const struct nla_policy mptcp_pm_announce_nl_policy[MPTCP_PM_ATTR_TOKEN + = 1] =3D { + [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_ADDR] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_REMOVE - do */ +const struct nla_policy mptcp_pm_remove_nl_policy[MPTCP_PM_ATTR_LOC_ID + 1= ] =3D { + [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_LOC_ID] =3D { .type =3D NLA_U8, }, +}; + +/* MPTCP_PM_CMD_SUBFLOW_CREATE - do */ +const struct nla_policy mptcp_pm_subflow_create_nl_policy[MPTCP_PM_ATTR_AD= DR_REMOTE + 1] =3D { + [MPTCP_PM_ATTR_ADDR_REMOTE] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_pol= icy), + [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_ADDR] =3D 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_A= DDR_REMOTE + 1] =3D { + [MPTCP_PM_ATTR_ADDR_REMOTE] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_pol= icy), + [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_ADDR] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* Ops table for mptcp_pm */ +const struct genl_ops mptcp_pm_nl_ops[11] =3D { + { + .cmd =3D MPTCP_PM_CMD_ADD_ADDR, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_pm_nl_add_addr_doit, + .policy =3D mptcp_pm_add_addr_nl_policy, + .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, + .flags =3D GENL_UNS_ADMIN_PERM, + }, + { + .cmd =3D MPTCP_PM_CMD_DEL_ADDR, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_pm_nl_del_addr_doit, + .policy =3D mptcp_pm_del_addr_nl_policy, + .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, + .flags =3D GENL_UNS_ADMIN_PERM, + }, + { + .cmd =3D MPTCP_PM_CMD_GET_ADDR, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_pm_nl_get_addr_doit, + .dumpit =3D mptcp_pm_nl_get_addr_dumpit, + .policy =3D mptcp_pm_get_addr_nl_policy, + .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, + .flags =3D GENL_UNS_ADMIN_PERM, + }, + { + .cmd =3D MPTCP_PM_CMD_FLUSH_ADDRS, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_pm_nl_flush_addrs_doit, + .policy =3D mptcp_pm_flush_addrs_nl_policy, + .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, + .flags =3D GENL_UNS_ADMIN_PERM, + }, + { + .cmd =3D MPTCP_PM_CMD_SET_LIMITS, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_pm_nl_set_limits_doit, + .policy =3D mptcp_pm_set_limits_nl_policy, + .maxattr =3D MPTCP_PM_ATTR_SUBFLOWS, + .flags =3D GENL_UNS_ADMIN_PERM, + }, + { + .cmd =3D MPTCP_PM_CMD_GET_LIMITS, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_pm_nl_get_limits_doit, + .policy =3D mptcp_pm_get_limits_nl_policy, + .maxattr =3D MPTCP_PM_ATTR_SUBFLOWS, + }, + { + .cmd =3D MPTCP_PM_CMD_SET_FLAGS, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_pm_nl_set_flags_doit, + .policy =3D mptcp_pm_set_flags_nl_policy, + .maxattr =3D MPTCP_PM_ATTR_ADDR_REMOTE, + .flags =3D GENL_UNS_ADMIN_PERM, + }, + { + .cmd =3D MPTCP_PM_CMD_ANNOUNCE, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_pm_nl_announce_doit, + .policy =3D mptcp_pm_announce_nl_policy, + .maxattr =3D MPTCP_PM_ATTR_TOKEN, + .flags =3D GENL_UNS_ADMIN_PERM, + }, + { + .cmd =3D MPTCP_PM_CMD_REMOVE, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_pm_nl_remove_doit, + .policy =3D mptcp_pm_remove_nl_policy, + .maxattr =3D MPTCP_PM_ATTR_LOC_ID, + .flags =3D GENL_UNS_ADMIN_PERM, + }, + { + .cmd =3D MPTCP_PM_CMD_SUBFLOW_CREATE, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_pm_nl_subflow_create_doit, + .policy =3D mptcp_pm_subflow_create_nl_policy, + .maxattr =3D MPTCP_PM_ATTR_ADDR_REMOTE, + .flags =3D GENL_UNS_ADMIN_PERM, + }, + { + .cmd =3D MPTCP_PM_CMD_SUBFLOW_DESTROY, + .validate =3D GENL_DONT_VALIDATE_STRICT, + .doit =3D mptcp_pm_nl_subflow_destroy_doit, + .policy =3D mptcp_pm_subflow_destroy_nl_policy, + .maxattr =3D MPTCP_PM_ATTR_ADDR_REMOTE, + .flags =3D 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-Cl= ause) */ +/* 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_AT= TR_IF_IDX + 1]; + +extern const struct nla_policy mptcp_pm_add_addr_nl_policy[MPTCP_PM_ENDPOI= NT_ADDR + 1]; + +extern const struct nla_policy mptcp_pm_del_addr_nl_policy[MPTCP_PM_ENDPOI= NT_ADDR + 1]; + +extern const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ENDPOI= NT_ADDR + 1]; + +extern const struct nla_policy mptcp_pm_flush_addrs_nl_policy[MPTCP_PM_END= POINT_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_T= OKEN + 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 *in= fo); +int mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, struct genl_info *inf= o); +int mptcp_pm_nl_get_limits_doit(struct sk_buff *skb, struct genl_info *inf= o); +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 b4463595ab45..1529ec358815 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -48,53 +48,6 @@ struct pm_nl_pernet { #define MPTCP_PM_ADDR_MAX 8 #define ADD_ADDR_RETRANS_MAX 3 =20 -const struct nla_policy mptcp_pm_address_nl_policy[MPTCP_PM_ADDR_ATTR_IF_I= DX + 1] =3D { - [MPTCP_PM_ADDR_ATTR_FAMILY] =3D { .type =3D NLA_U16, }, - [MPTCP_PM_ADDR_ATTR_ADDR4] =3D { .type =3D NLA_U32, }, - [MPTCP_PM_ADDR_ATTR_ADDR6] =3D { .len =3D 16, }, - [MPTCP_PM_ADDR_ATTR_ID] =3D { .type =3D NLA_U8, }, - [MPTCP_PM_ADDR_ATTR_PORT] =3D { .type =3D NLA_U16, }, - [MPTCP_PM_ADDR_ATTR_IF_IDX] =3D { .type =3D NLA_S32, }, - [MPTCP_PM_ADDR_ATTR_FLAGS] =3D { .type =3D NLA_U32, }, -}; - -/* MPTCP_PM_CMD_ADD_ADDR / DEL / GET / FLUSH - do */ -static const struct nla_policy mptcp_pm_endpoint_nl_policy[MPTCP_PM_ENDPOI= NT_ADDR + 1] =3D { - [MPTCP_PM_ENDPOINT_ADDR] =3D 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] =3D { - [MPTCP_PM_ATTR_RCV_ADD_ADDRS] =3D { .type =3D NLA_U32, }, - [MPTCP_PM_ATTR_SUBFLOWS] =3D { .type =3D NLA_U32, }, -}; - -/* MPTCP_PM_CMD_SET_FLAGS - do */ -const struct nla_policy mptcp_pm_set_flags_nl_policy[MPTCP_PM_ATTR_ADDR_RE= MOTE + 1] =3D { - [MPTCP_PM_ATTR_ADDR] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_pol= icy), - [MPTCP_PM_ATTR_ADDR_REMOTE] =3D NLA_POLICY_NESTED(mptcp_pm_address= _nl_policy), - [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, -}; - -/* MPTCP_PM_CMD_ANNOUNCE - do */ -static const struct nla_policy mptcp_pm_announce_nl_policy[MPTCP_PM_ATTR_T= OKEN + 1] =3D { - [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, - [MPTCP_PM_ATTR_ADDR] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), -}; - -/* MPTCP_PM_CMD_REMOVE - do */ -static const struct nla_policy mptcp_pm_remove_nl_policy[MPTCP_PM_ATTR_LOC= _ID + 1] =3D { - [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, - [MPTCP_PM_ATTR_LOC_ID] =3D { .type =3D 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] =3D { - [MPTCP_PM_ATTR_ADDR_REMOTE] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_pol= icy), - [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, - [MPTCP_PM_ATTR_ADDR] =3D 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); @@ -1327,7 +1280,7 @@ static int mptcp_nl_add_subflow_or_signal_addr(struct= net *net) return 0; } =20 -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 =3D info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); @@ -1508,7 +1461,7 @@ static int mptcp_nl_remove_id_zero_address(struct net= *net, return 0; } =20 -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 =3D info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); @@ -1643,7 +1596,7 @@ static void __reset_counters(struct pm_nl_pernet *per= net) pernet->addrs =3D 0; } =20 -static int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_i= nfo *info) +int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *in= fo) { struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); LIST_HEAD(free_list); @@ -1699,7 +1652,7 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, return -EMSGSIZE; } =20 -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 =3D info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); @@ -1749,8 +1702,8 @@ static int mptcp_pm_nl_get_addr_doit(struct sk_buff *= skb, struct genl_info *info return ret; } =20 -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 =3D sock_net(msg->sk); struct mptcp_pm_addr_entry *entry; @@ -1807,8 +1760,7 @@ static int parse_limit(struct genl_info *info, int id= , unsigned int *limit) return 0; } =20 -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 *inf= o) { struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); unsigned int rcv_addrs, subflows; @@ -1833,8 +1785,7 @@ mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, stru= ct genl_info *info) return ret; } =20 -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 *inf= o) { struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); struct sk_buff *msg; @@ -1943,7 +1894,7 @@ int mptcp_pm_nl_set_flags(struct net *net, struct mpt= cp_pm_addr_entry *addr, u8 return 0; } =20 -static int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_inf= o *info) +int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) { struct mptcp_pm_addr_entry remote =3D { .addr =3D { .family =3D AF_UNSPEC= }, }; struct mptcp_pm_addr_entry addr =3D { .addr =3D { .family =3D AF_UNSPEC }= , }; @@ -2307,98 +2258,6 @@ void mptcp_event(enum mptcp_event_type type, const s= truct mptcp_sock *msk, nlmsg_free(skb); } =20 - -static const struct genl_ops mptcp_pm_nl_ops[] =3D { - { - .cmd =3D MPTCP_PM_CMD_ADD_ADDR, - .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_pm_nl_add_addr_doit, - .policy =3D mptcp_pm_endpoint_nl_policy, - .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, - .flags =3D GENL_UNS_ADMIN_PERM, - }, - { - .cmd =3D MPTCP_PM_CMD_DEL_ADDR, - .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_pm_nl_del_addr_doit, - .policy =3D mptcp_pm_endpoint_nl_policy, - .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, - .flags =3D GENL_UNS_ADMIN_PERM, - }, - { - .cmd =3D MPTCP_PM_CMD_GET_ADDR, - .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_pm_nl_get_addr_doit, - .dumpit =3D mptcp_pm_nl_get_addr_dumpit, - .policy =3D mptcp_pm_endpoint_nl_policy, - .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, - .flags =3D GENL_UNS_ADMIN_PERM, - }, - { - .cmd =3D MPTCP_PM_CMD_FLUSH_ADDRS, - .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_pm_nl_flush_addrs_doit, - .policy =3D mptcp_pm_endpoint_nl_policy, - .maxattr =3D MPTCP_PM_ENDPOINT_ADDR, - .flags =3D GENL_UNS_ADMIN_PERM, - }, - { - .cmd =3D MPTCP_PM_CMD_SET_LIMITS, - .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_pm_nl_set_limits_doit, - .policy =3D mptcp_pm_set_limits_nl_policy, - .maxattr =3D MPTCP_PM_ATTR_SUBFLOWS, - .flags =3D GENL_UNS_ADMIN_PERM, - }, - { - .cmd =3D MPTCP_PM_CMD_GET_LIMITS, - .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_pm_nl_get_limits_doit, - .policy =3D mptcp_pm_set_limits_nl_policy, - .maxattr =3D MPTCP_PM_ATTR_SUBFLOWS, - }, - { - .cmd =3D MPTCP_PM_CMD_SET_FLAGS, - .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_pm_nl_set_flags_doit, - .policy =3D mptcp_pm_set_flags_nl_policy, - .maxattr =3D MPTCP_PM_ATTR_ADDR_REMOTE, - .flags =3D GENL_UNS_ADMIN_PERM, - }, - { - .cmd =3D MPTCP_PM_CMD_ANNOUNCE, - .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_pm_nl_announce_doit, - .policy =3D mptcp_pm_announce_nl_policy, - .maxattr =3D MPTCP_PM_ATTR_TOKEN, - .flags =3D GENL_UNS_ADMIN_PERM, - }, - { - .cmd =3D MPTCP_PM_CMD_REMOVE, - .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_pm_nl_remove_doit, - .policy =3D mptcp_pm_remove_nl_policy, - .maxattr =3D MPTCP_PM_ATTR_LOC_ID, - .flags =3D GENL_UNS_ADMIN_PERM, - }, - { - .cmd =3D MPTCP_PM_CMD_SUBFLOW_CREATE, - .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_pm_nl_subflow_create_doit, - .policy =3D mptcp_pm_subflow_create_nl_policy, - .maxattr =3D MPTCP_PM_ATTR_ADDR_REMOTE, - .flags =3D GENL_UNS_ADMIN_PERM, - }, - { - .cmd =3D MPTCP_PM_CMD_SUBFLOW_DESTROY, - .validate =3D GENL_DONT_VALIDATE_STRICT, - .doit =3D mptcp_pm_nl_subflow_destroy_doit, - .policy =3D mptcp_pm_subflow_create_nl_policy, - .maxattr =3D MPTCP_PM_ATTR_ADDR_REMOTE, - .flags =3D GENL_UNS_ADMIN_PERM, - }, -}; - static struct genl_family mptcp_genl_family __ro_after_init =3D { .name =3D MPTCP_PM_NAME, .version =3D MPTCP_PM_VER, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index fbe35b74f319..761d3a34f9d3 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -13,6 +13,8 @@ #include #include =20 +#include "mptcp_pm_gen.h" + #define MPTCP_SUPPORTED_VERSION 1 =20 /* MPTCP option bits */ @@ -873,10 +875,6 @@ void mptcp_pm_remove_addrs_and_subflows(struct mptcp_s= ock *msk, struct list_head *rm_list); =20 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); =20 void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, const struct sock *ssk, gfp_t gfp); --=20 2.40.1