From nobody Thu Oct 31 00:25:02 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 AF954D517 for ; Tue, 5 Sep 2023 13:54:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693922087; 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=w4MNXF1BnTmBzHS7Zyy/xarxtGV4NPFOIPfI3KzdnOM=; b=Hailu65BdSjC/NoUBdNemLMc96yZ2b4HicOjiThAm7siKxcNNHfJ7ntsTZ+EUf32XW1kYK 1nnpH0Kr63atNFcU7G4iVaaynin0BobPtCyUneO59akSCESGbVNHvFlMkPfrInkq46LHiM noixEsLEogsBcJdqTBX3MgSJkQCoGZY= 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-694-mtq6XxgVNHe1K4iqJyHnbA-1; Tue, 05 Sep 2023 09:54:44 -0400 X-MC-Unique: mtq6XxgVNHe1K4iqJyHnbA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3729B3C1ACDA; Tue, 5 Sep 2023 13:54:44 +0000 (UTC) Received: from dcaratti.users.ipa.redhat.com (unknown [10.32.181.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7DD340CF8EA; Tue, 5 Sep 2023 13:54:42 +0000 (UTC) From: Davide Caratti To: mptcp@lists.linux.dev Cc: pabeni@redhat.com, Matthieu Baerts Subject: [PATCH mptcp-next v3 6/6] net: mptcp: use policy generated by YAML spec Date: Tue, 5 Sep 2023 15:53:11 +0200 Message-Id: <5df77b5d2ee82333d6c1d7c6b3981c430b75c6da.1693921470.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.1 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 | 165 ++---------------------------------- net/mptcp/protocol.h | 6 +- 5 files changed, 250 insertions(+), 161 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..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-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_TOKEN] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_ADDR_REMOTE] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_pol= icy), +}; + +/* MPTCP_PM_CMD_ANNOUNCE - do */ +const struct nla_policy mptcp_pm_announce_nl_policy[MPTCP_PM_ATTR_TOKEN + = 1] =3D { + [MPTCP_PM_ATTR_ADDR] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, +}; + +/* 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] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_ADDR_REMOTE] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_pol= icy), +}; + +/* 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] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_ADDR_REMOTE] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_pol= icy), +}; + +/* 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 b9c0edde0083..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 =20 -static -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 / DEL / GET / FLUSH - do */ -static -const struct nla_policy mptcp_pm_endpoint_nl_policy[MPTCP_PM_ENDPOINT_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_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 */ -static -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_TOKEN] =3D { .type =3D NLA_U32, }, - [MPTCP_PM_ATTR_ADDR_REMOTE] =3D 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] =3D { - [MPTCP_PM_ATTR_ADDR] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), - [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, -}; - -/* 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_AD= DR_REMOTE + 1] =3D { - [MPTCP_PM_ATTR_ADDR] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), - [MPTCP_PM_ATTR_TOKEN] =3D { .type =3D NLA_U32, }, - [MPTCP_PM_ATTR_ADDR_REMOTE] =3D NLA_POLICY_NESTED(mptcp_pm_address_nl_pol= icy), -}; - 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; } =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); @@ -1515,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); @@ -1650,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); @@ -1706,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); @@ -1756,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; @@ -1814,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; @@ -1840,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; @@ -1950,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 }= , }; @@ -2314,97 +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