18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * net/tipc/netlink.c: TIPC configuration handling
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * Copyright (c) 2005-2006, 2014, Ericsson AB
58c2ecf20Sopenharmony_ci * Copyright (c) 2005-2007, Wind River Systems
68c2ecf20Sopenharmony_ci * All rights reserved.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
98c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions are met:
108c2ecf20Sopenharmony_ci *
118c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
128c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer.
138c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright
148c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in the
158c2ecf20Sopenharmony_ci *    documentation and/or other materials provided with the distribution.
168c2ecf20Sopenharmony_ci * 3. Neither the names of the copyright holders nor the names of its
178c2ecf20Sopenharmony_ci *    contributors may be used to endorse or promote products derived from
188c2ecf20Sopenharmony_ci *    this software without specific prior written permission.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the
218c2ecf20Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free
228c2ecf20Sopenharmony_ci * Software Foundation.
238c2ecf20Sopenharmony_ci *
248c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
258c2ecf20Sopenharmony_ci * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
268c2ecf20Sopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
278c2ecf20Sopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
288c2ecf20Sopenharmony_ci * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
298c2ecf20Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
308c2ecf20Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
318c2ecf20Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
328c2ecf20Sopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
338c2ecf20Sopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
348c2ecf20Sopenharmony_ci * POSSIBILITY OF SUCH DAMAGE.
358c2ecf20Sopenharmony_ci */
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci#include "core.h"
388c2ecf20Sopenharmony_ci#include "socket.h"
398c2ecf20Sopenharmony_ci#include "name_table.h"
408c2ecf20Sopenharmony_ci#include "bearer.h"
418c2ecf20Sopenharmony_ci#include "link.h"
428c2ecf20Sopenharmony_ci#include "node.h"
438c2ecf20Sopenharmony_ci#include "net.h"
448c2ecf20Sopenharmony_ci#include "udp_media.h"
458c2ecf20Sopenharmony_ci#include <net/genetlink.h>
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_cistatic const struct nla_policy tipc_nl_policy[TIPC_NLA_MAX + 1] = {
488c2ecf20Sopenharmony_ci	[TIPC_NLA_UNSPEC]	= { .type = NLA_UNSPEC, },
498c2ecf20Sopenharmony_ci	[TIPC_NLA_BEARER]	= { .type = NLA_NESTED, },
508c2ecf20Sopenharmony_ci	[TIPC_NLA_SOCK]		= { .type = NLA_NESTED, },
518c2ecf20Sopenharmony_ci	[TIPC_NLA_PUBL]		= { .type = NLA_NESTED, },
528c2ecf20Sopenharmony_ci	[TIPC_NLA_LINK]		= { .type = NLA_NESTED, },
538c2ecf20Sopenharmony_ci	[TIPC_NLA_MEDIA]	= { .type = NLA_NESTED, },
548c2ecf20Sopenharmony_ci	[TIPC_NLA_NODE]		= { .type = NLA_NESTED, },
558c2ecf20Sopenharmony_ci	[TIPC_NLA_NET]		= { .type = NLA_NESTED, },
568c2ecf20Sopenharmony_ci	[TIPC_NLA_NAME_TABLE]	= { .type = NLA_NESTED, },
578c2ecf20Sopenharmony_ci	[TIPC_NLA_MON]		= { .type = NLA_NESTED, },
588c2ecf20Sopenharmony_ci};
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ciconst struct nla_policy
618c2ecf20Sopenharmony_citipc_nl_name_table_policy[TIPC_NLA_NAME_TABLE_MAX + 1] = {
628c2ecf20Sopenharmony_ci	[TIPC_NLA_NAME_TABLE_UNSPEC]	= { .type = NLA_UNSPEC },
638c2ecf20Sopenharmony_ci	[TIPC_NLA_NAME_TABLE_PUBL]	= { .type = NLA_NESTED }
648c2ecf20Sopenharmony_ci};
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ciconst struct nla_policy tipc_nl_monitor_policy[TIPC_NLA_MON_MAX + 1] = {
678c2ecf20Sopenharmony_ci	[TIPC_NLA_MON_UNSPEC]			= { .type = NLA_UNSPEC },
688c2ecf20Sopenharmony_ci	[TIPC_NLA_MON_REF]			= { .type = NLA_U32 },
698c2ecf20Sopenharmony_ci	[TIPC_NLA_MON_ACTIVATION_THRESHOLD]	= { .type = NLA_U32 },
708c2ecf20Sopenharmony_ci};
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ciconst struct nla_policy tipc_nl_sock_policy[TIPC_NLA_SOCK_MAX + 1] = {
738c2ecf20Sopenharmony_ci	[TIPC_NLA_SOCK_UNSPEC]		= { .type = NLA_UNSPEC },
748c2ecf20Sopenharmony_ci	[TIPC_NLA_SOCK_ADDR]		= { .type = NLA_U32 },
758c2ecf20Sopenharmony_ci	[TIPC_NLA_SOCK_REF]		= { .type = NLA_U32 },
768c2ecf20Sopenharmony_ci	[TIPC_NLA_SOCK_CON]		= { .type = NLA_NESTED },
778c2ecf20Sopenharmony_ci	[TIPC_NLA_SOCK_HAS_PUBL]	= { .type = NLA_FLAG }
788c2ecf20Sopenharmony_ci};
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ciconst struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = {
818c2ecf20Sopenharmony_ci	[TIPC_NLA_NET_UNSPEC]		= { .type = NLA_UNSPEC },
828c2ecf20Sopenharmony_ci	[TIPC_NLA_NET_ID]		= { .type = NLA_U32 },
838c2ecf20Sopenharmony_ci	[TIPC_NLA_NET_ADDR]		= { .type = NLA_U32 },
848c2ecf20Sopenharmony_ci	[TIPC_NLA_NET_NODEID]		= { .type = NLA_U64 },
858c2ecf20Sopenharmony_ci	[TIPC_NLA_NET_NODEID_W1]	= { .type = NLA_U64 },
868c2ecf20Sopenharmony_ci	[TIPC_NLA_NET_ADDR_LEGACY]	= { .type = NLA_FLAG }
878c2ecf20Sopenharmony_ci};
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ciconst struct nla_policy tipc_nl_link_policy[TIPC_NLA_LINK_MAX + 1] = {
908c2ecf20Sopenharmony_ci	[TIPC_NLA_LINK_UNSPEC]		= { .type = NLA_UNSPEC },
918c2ecf20Sopenharmony_ci	[TIPC_NLA_LINK_NAME]		= { .type = NLA_NUL_STRING,
928c2ecf20Sopenharmony_ci					    .len = TIPC_MAX_LINK_NAME },
938c2ecf20Sopenharmony_ci	[TIPC_NLA_LINK_MTU]		= { .type = NLA_U32 },
948c2ecf20Sopenharmony_ci	[TIPC_NLA_LINK_BROADCAST]	= { .type = NLA_FLAG },
958c2ecf20Sopenharmony_ci	[TIPC_NLA_LINK_UP]		= { .type = NLA_FLAG },
968c2ecf20Sopenharmony_ci	[TIPC_NLA_LINK_ACTIVE]		= { .type = NLA_FLAG },
978c2ecf20Sopenharmony_ci	[TIPC_NLA_LINK_PROP]		= { .type = NLA_NESTED },
988c2ecf20Sopenharmony_ci	[TIPC_NLA_LINK_STATS]		= { .type = NLA_NESTED },
998c2ecf20Sopenharmony_ci	[TIPC_NLA_LINK_RX]		= { .type = NLA_U32 },
1008c2ecf20Sopenharmony_ci	[TIPC_NLA_LINK_TX]		= { .type = NLA_U32 }
1018c2ecf20Sopenharmony_ci};
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ciconst struct nla_policy tipc_nl_node_policy[TIPC_NLA_NODE_MAX + 1] = {
1048c2ecf20Sopenharmony_ci	[TIPC_NLA_NODE_UNSPEC]		= { .type = NLA_UNSPEC },
1058c2ecf20Sopenharmony_ci	[TIPC_NLA_NODE_ADDR]		= { .type = NLA_U32 },
1068c2ecf20Sopenharmony_ci	[TIPC_NLA_NODE_UP]		= { .type = NLA_FLAG },
1078c2ecf20Sopenharmony_ci	[TIPC_NLA_NODE_ID]		= { .type = NLA_BINARY,
1088c2ecf20Sopenharmony_ci					    .len = TIPC_NODEID_LEN},
1098c2ecf20Sopenharmony_ci	[TIPC_NLA_NODE_KEY]		= { .type = NLA_BINARY,
1108c2ecf20Sopenharmony_ci					    .len = TIPC_AEAD_KEY_SIZE_MAX},
1118c2ecf20Sopenharmony_ci	[TIPC_NLA_NODE_KEY_MASTER]	= { .type = NLA_FLAG },
1128c2ecf20Sopenharmony_ci	[TIPC_NLA_NODE_REKEYING]	= { .type = NLA_U32 },
1138c2ecf20Sopenharmony_ci};
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci/* Properties valid for media, bearer and link */
1168c2ecf20Sopenharmony_ciconst struct nla_policy tipc_nl_prop_policy[TIPC_NLA_PROP_MAX + 1] = {
1178c2ecf20Sopenharmony_ci	[TIPC_NLA_PROP_UNSPEC]		= { .type = NLA_UNSPEC },
1188c2ecf20Sopenharmony_ci	[TIPC_NLA_PROP_PRIO]		= { .type = NLA_U32 },
1198c2ecf20Sopenharmony_ci	[TIPC_NLA_PROP_TOL]		= { .type = NLA_U32 },
1208c2ecf20Sopenharmony_ci	[TIPC_NLA_PROP_WIN]		= { .type = NLA_U32 },
1218c2ecf20Sopenharmony_ci	[TIPC_NLA_PROP_MTU]		= { .type = NLA_U32 },
1228c2ecf20Sopenharmony_ci	[TIPC_NLA_PROP_BROADCAST]	= { .type = NLA_U32 },
1238c2ecf20Sopenharmony_ci	[TIPC_NLA_PROP_BROADCAST_RATIO]	= { .type = NLA_U32 }
1248c2ecf20Sopenharmony_ci};
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ciconst struct nla_policy tipc_nl_bearer_policy[TIPC_NLA_BEARER_MAX + 1]	= {
1278c2ecf20Sopenharmony_ci	[TIPC_NLA_BEARER_UNSPEC]	= { .type = NLA_UNSPEC },
1288c2ecf20Sopenharmony_ci	[TIPC_NLA_BEARER_NAME]		= { .type = NLA_NUL_STRING,
1298c2ecf20Sopenharmony_ci					    .len = TIPC_MAX_BEARER_NAME },
1308c2ecf20Sopenharmony_ci	[TIPC_NLA_BEARER_PROP]		= { .type = NLA_NESTED },
1318c2ecf20Sopenharmony_ci	[TIPC_NLA_BEARER_DOMAIN]	= { .type = NLA_U32 }
1328c2ecf20Sopenharmony_ci};
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ciconst struct nla_policy tipc_nl_media_policy[TIPC_NLA_MEDIA_MAX + 1] = {
1358c2ecf20Sopenharmony_ci	[TIPC_NLA_MEDIA_UNSPEC]		= { .type = NLA_UNSPEC },
1368c2ecf20Sopenharmony_ci	[TIPC_NLA_MEDIA_NAME]		= { .type = NLA_STRING },
1378c2ecf20Sopenharmony_ci	[TIPC_NLA_MEDIA_PROP]		= { .type = NLA_NESTED }
1388c2ecf20Sopenharmony_ci};
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ciconst struct nla_policy tipc_nl_udp_policy[TIPC_NLA_UDP_MAX + 1] = {
1418c2ecf20Sopenharmony_ci	[TIPC_NLA_UDP_UNSPEC]	= {.type = NLA_UNSPEC},
1428c2ecf20Sopenharmony_ci	[TIPC_NLA_UDP_LOCAL]	= {.type = NLA_BINARY,
1438c2ecf20Sopenharmony_ci				   .len = sizeof(struct sockaddr_storage)},
1448c2ecf20Sopenharmony_ci	[TIPC_NLA_UDP_REMOTE]	= {.type = NLA_BINARY,
1458c2ecf20Sopenharmony_ci				   .len = sizeof(struct sockaddr_storage)},
1468c2ecf20Sopenharmony_ci};
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci/* Users of the legacy API (tipc-config) can't handle that we add operations,
1498c2ecf20Sopenharmony_ci * so we have a separate genl handling for the new API.
1508c2ecf20Sopenharmony_ci */
1518c2ecf20Sopenharmony_cistatic const struct genl_ops tipc_genl_v2_ops[] = {
1528c2ecf20Sopenharmony_ci	{
1538c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_BEARER_DISABLE,
1548c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
1558c2ecf20Sopenharmony_ci		.doit	= tipc_nl_bearer_disable,
1568c2ecf20Sopenharmony_ci	},
1578c2ecf20Sopenharmony_ci	{
1588c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_BEARER_ENABLE,
1598c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
1608c2ecf20Sopenharmony_ci		.doit	= tipc_nl_bearer_enable,
1618c2ecf20Sopenharmony_ci	},
1628c2ecf20Sopenharmony_ci	{
1638c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_BEARER_GET,
1648c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
1658c2ecf20Sopenharmony_ci		.doit	= tipc_nl_bearer_get,
1668c2ecf20Sopenharmony_ci		.dumpit	= tipc_nl_bearer_dump,
1678c2ecf20Sopenharmony_ci	},
1688c2ecf20Sopenharmony_ci	{
1698c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_BEARER_ADD,
1708c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
1718c2ecf20Sopenharmony_ci		.doit	= tipc_nl_bearer_add,
1728c2ecf20Sopenharmony_ci	},
1738c2ecf20Sopenharmony_ci	{
1748c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_BEARER_SET,
1758c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
1768c2ecf20Sopenharmony_ci		.doit	= tipc_nl_bearer_set,
1778c2ecf20Sopenharmony_ci	},
1788c2ecf20Sopenharmony_ci	{
1798c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_SOCK_GET,
1808c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
1818c2ecf20Sopenharmony_ci		.start = tipc_dump_start,
1828c2ecf20Sopenharmony_ci		.dumpit	= tipc_nl_sk_dump,
1838c2ecf20Sopenharmony_ci		.done	= tipc_dump_done,
1848c2ecf20Sopenharmony_ci	},
1858c2ecf20Sopenharmony_ci	{
1868c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_PUBL_GET,
1878c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT |
1888c2ecf20Sopenharmony_ci			    GENL_DONT_VALIDATE_DUMP_STRICT,
1898c2ecf20Sopenharmony_ci		.dumpit	= tipc_nl_publ_dump,
1908c2ecf20Sopenharmony_ci	},
1918c2ecf20Sopenharmony_ci	{
1928c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_LINK_GET,
1938c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT,
1948c2ecf20Sopenharmony_ci		.doit   = tipc_nl_node_get_link,
1958c2ecf20Sopenharmony_ci		.dumpit	= tipc_nl_node_dump_link,
1968c2ecf20Sopenharmony_ci	},
1978c2ecf20Sopenharmony_ci	{
1988c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_LINK_SET,
1998c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
2008c2ecf20Sopenharmony_ci		.doit	= tipc_nl_node_set_link,
2018c2ecf20Sopenharmony_ci	},
2028c2ecf20Sopenharmony_ci	{
2038c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_LINK_RESET_STATS,
2048c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
2058c2ecf20Sopenharmony_ci		.doit   = tipc_nl_node_reset_link_stats,
2068c2ecf20Sopenharmony_ci	},
2078c2ecf20Sopenharmony_ci	{
2088c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_MEDIA_GET,
2098c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
2108c2ecf20Sopenharmony_ci		.doit	= tipc_nl_media_get,
2118c2ecf20Sopenharmony_ci		.dumpit	= tipc_nl_media_dump,
2128c2ecf20Sopenharmony_ci	},
2138c2ecf20Sopenharmony_ci	{
2148c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_MEDIA_SET,
2158c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
2168c2ecf20Sopenharmony_ci		.doit	= tipc_nl_media_set,
2178c2ecf20Sopenharmony_ci	},
2188c2ecf20Sopenharmony_ci	{
2198c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_NODE_GET,
2208c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
2218c2ecf20Sopenharmony_ci		.dumpit	= tipc_nl_node_dump,
2228c2ecf20Sopenharmony_ci	},
2238c2ecf20Sopenharmony_ci	{
2248c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_NET_GET,
2258c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
2268c2ecf20Sopenharmony_ci		.dumpit	= tipc_nl_net_dump,
2278c2ecf20Sopenharmony_ci	},
2288c2ecf20Sopenharmony_ci	{
2298c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_NET_SET,
2308c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
2318c2ecf20Sopenharmony_ci		.doit	= tipc_nl_net_set,
2328c2ecf20Sopenharmony_ci	},
2338c2ecf20Sopenharmony_ci	{
2348c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_NAME_TABLE_GET,
2358c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
2368c2ecf20Sopenharmony_ci		.dumpit	= tipc_nl_name_table_dump,
2378c2ecf20Sopenharmony_ci	},
2388c2ecf20Sopenharmony_ci	{
2398c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_MON_SET,
2408c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
2418c2ecf20Sopenharmony_ci		.doit	= tipc_nl_node_set_monitor,
2428c2ecf20Sopenharmony_ci	},
2438c2ecf20Sopenharmony_ci	{
2448c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_MON_GET,
2458c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
2468c2ecf20Sopenharmony_ci		.doit	= tipc_nl_node_get_monitor,
2478c2ecf20Sopenharmony_ci		.dumpit	= tipc_nl_node_dump_monitor,
2488c2ecf20Sopenharmony_ci	},
2498c2ecf20Sopenharmony_ci	{
2508c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_MON_PEER_GET,
2518c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT |
2528c2ecf20Sopenharmony_ci			    GENL_DONT_VALIDATE_DUMP_STRICT,
2538c2ecf20Sopenharmony_ci		.dumpit	= tipc_nl_node_dump_monitor_peer,
2548c2ecf20Sopenharmony_ci	},
2558c2ecf20Sopenharmony_ci	{
2568c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_PEER_REMOVE,
2578c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
2588c2ecf20Sopenharmony_ci		.doit	= tipc_nl_peer_rm,
2598c2ecf20Sopenharmony_ci	},
2608c2ecf20Sopenharmony_ci#ifdef CONFIG_TIPC_MEDIA_UDP
2618c2ecf20Sopenharmony_ci	{
2628c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_UDP_GET_REMOTEIP,
2638c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT |
2648c2ecf20Sopenharmony_ci			    GENL_DONT_VALIDATE_DUMP_STRICT,
2658c2ecf20Sopenharmony_ci		.dumpit	= tipc_udp_nl_dump_remoteip,
2668c2ecf20Sopenharmony_ci	},
2678c2ecf20Sopenharmony_ci#endif
2688c2ecf20Sopenharmony_ci#ifdef CONFIG_TIPC_CRYPTO
2698c2ecf20Sopenharmony_ci	{
2708c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_KEY_SET,
2718c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
2728c2ecf20Sopenharmony_ci		.doit	= tipc_nl_node_set_key,
2738c2ecf20Sopenharmony_ci	},
2748c2ecf20Sopenharmony_ci	{
2758c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_KEY_FLUSH,
2768c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
2778c2ecf20Sopenharmony_ci		.doit	= tipc_nl_node_flush_key,
2788c2ecf20Sopenharmony_ci	},
2798c2ecf20Sopenharmony_ci#endif
2808c2ecf20Sopenharmony_ci	{
2818c2ecf20Sopenharmony_ci		.cmd	= TIPC_NL_ADDR_LEGACY_GET,
2828c2ecf20Sopenharmony_ci		.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
2838c2ecf20Sopenharmony_ci		.doit	= tipc_nl_net_addr_legacy_get,
2848c2ecf20Sopenharmony_ci	},
2858c2ecf20Sopenharmony_ci};
2868c2ecf20Sopenharmony_ci
2878c2ecf20Sopenharmony_cistruct genl_family tipc_genl_family __ro_after_init = {
2888c2ecf20Sopenharmony_ci	.name		= TIPC_GENL_V2_NAME,
2898c2ecf20Sopenharmony_ci	.version	= TIPC_GENL_V2_VERSION,
2908c2ecf20Sopenharmony_ci	.hdrsize	= 0,
2918c2ecf20Sopenharmony_ci	.maxattr	= TIPC_NLA_MAX,
2928c2ecf20Sopenharmony_ci	.policy		= tipc_nl_policy,
2938c2ecf20Sopenharmony_ci	.netnsok	= true,
2948c2ecf20Sopenharmony_ci	.module		= THIS_MODULE,
2958c2ecf20Sopenharmony_ci	.ops		= tipc_genl_v2_ops,
2968c2ecf20Sopenharmony_ci	.n_ops		= ARRAY_SIZE(tipc_genl_v2_ops),
2978c2ecf20Sopenharmony_ci};
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ciint __init tipc_netlink_start(void)
3008c2ecf20Sopenharmony_ci{
3018c2ecf20Sopenharmony_ci	int res;
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci	res = genl_register_family(&tipc_genl_family);
3048c2ecf20Sopenharmony_ci	if (res) {
3058c2ecf20Sopenharmony_ci		pr_err("Failed to register netlink interface\n");
3068c2ecf20Sopenharmony_ci		return res;
3078c2ecf20Sopenharmony_ci	}
3088c2ecf20Sopenharmony_ci	return 0;
3098c2ecf20Sopenharmony_ci}
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_civoid tipc_netlink_stop(void)
3128c2ecf20Sopenharmony_ci{
3138c2ecf20Sopenharmony_ci	genl_unregister_family(&tipc_genl_family);
3148c2ecf20Sopenharmony_ci}
315