1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 
3 #include <netinet/in.h>
4 #include <sys/socket.h>
5 #include <linux/batman_adv.h>
6 #include <linux/can/netlink.h>
7 #include <linux/can/vxcan.h>
8 #include <linux/cfm_bridge.h>
9 #include <linux/fib_rules.h>
10 #include <linux/fou.h>
11 #include <linux/if.h>
12 #include <linux/if_addr.h>
13 #include <linux/if_addrlabel.h>
14 #include <linux/if_bridge.h>
15 #include <linux/if_link.h>
16 #include <linux/if_macsec.h>
17 #include <linux/if_tunnel.h>
18 #include <linux/ip.h>
19 #include <linux/l2tp.h>
20 #include <linux/netlink.h>
21 #include <linux/nexthop.h>
22 #include <linux/nl80211.h>
23 #include <linux/pkt_sched.h>
24 #include <linux/rtnetlink.h>
25 #include <linux/veth.h>
26 #include <linux/wireguard.h>
27 
28 #include "sd-netlink.h"
29 
30 #include "missing_network.h"
31 #include "netlink-types-internal.h"
32 #include "string-table.h"
33 
34 enum {
35         BOND_ARP_TARGETS_0,
36         BOND_ARP_TARGETS_1,
37         BOND_ARP_TARGETS_2,
38         BOND_ARP_TARGETS_3,
39         BOND_ARP_TARGETS_4,
40         BOND_ARP_TARGETS_5,
41         BOND_ARP_TARGETS_6,
42         BOND_ARP_TARGETS_7,
43         BOND_ARP_TARGETS_8,
44         BOND_ARP_TARGETS_9,
45         BOND_ARP_TARGETS_10,
46         BOND_ARP_TARGETS_11,
47         BOND_ARP_TARGETS_12,
48         BOND_ARP_TARGETS_13,
49         BOND_ARP_TARGETS_14,
50         BOND_ARP_TARGETS_15,
51         _BOND_ARP_TARGETS_MAX,
52 };
53 
54 assert_cc(_BOND_ARP_TARGETS_MAX == BOND_MAX_ARP_TARGETS);
55 
56 static const NLTypeSystem rtnl_link_type_system;
57 
58 static const NLType rtnl_link_info_data_bareudp_types[] = {
59         [IFLA_BAREUDP_PORT]            = { .type = NETLINK_TYPE_U16 },
60         [IFLA_BAREUDP_ETHERTYPE]       = { .type = NETLINK_TYPE_U16 },
61         [IFLA_BAREUDP_SRCPORT_MIN]     = { .type = NETLINK_TYPE_U16 },
62         [IFLA_BAREUDP_MULTIPROTO_MODE] = { .type = NETLINK_TYPE_FLAG },
63 };
64 
65 static const NLType rtnl_link_info_data_batadv_types[] = {
66         [IFLA_BATADV_ALGO_NAME] = { .type = NETLINK_TYPE_STRING, .size = 20 },
67 };
68 
69 static const NLType rtnl_bond_arp_ip_target_types[] = {
70         [BOND_ARP_TARGETS_0]        = { .type = NETLINK_TYPE_U32 },
71         [BOND_ARP_TARGETS_1]        = { .type = NETLINK_TYPE_U32 },
72         [BOND_ARP_TARGETS_2]        = { .type = NETLINK_TYPE_U32 },
73         [BOND_ARP_TARGETS_3]        = { .type = NETLINK_TYPE_U32 },
74         [BOND_ARP_TARGETS_4]        = { .type = NETLINK_TYPE_U32 },
75         [BOND_ARP_TARGETS_5]        = { .type = NETLINK_TYPE_U32 },
76         [BOND_ARP_TARGETS_6]        = { .type = NETLINK_TYPE_U32 },
77         [BOND_ARP_TARGETS_7]        = { .type = NETLINK_TYPE_U32 },
78         [BOND_ARP_TARGETS_8]        = { .type = NETLINK_TYPE_U32 },
79         [BOND_ARP_TARGETS_9]        = { .type = NETLINK_TYPE_U32 },
80         [BOND_ARP_TARGETS_10]       = { .type = NETLINK_TYPE_U32 },
81         [BOND_ARP_TARGETS_11]       = { .type = NETLINK_TYPE_U32 },
82         [BOND_ARP_TARGETS_12]       = { .type = NETLINK_TYPE_U32 },
83         [BOND_ARP_TARGETS_13]       = { .type = NETLINK_TYPE_U32 },
84         [BOND_ARP_TARGETS_14]       = { .type = NETLINK_TYPE_U32 },
85         [BOND_ARP_TARGETS_15]       = { .type = NETLINK_TYPE_U32 },
86 };
87 
88 DEFINE_TYPE_SYSTEM(rtnl_bond_arp_ip_target);
89 
90 static const NLType rtnl_bond_ad_info_types[] = {
91         [IFLA_BOND_AD_INFO_AGGREGATOR]  = { .type = NETLINK_TYPE_U16 },
92         [IFLA_BOND_AD_INFO_NUM_PORTS]   = { .type = NETLINK_TYPE_U16 },
93         [IFLA_BOND_AD_INFO_ACTOR_KEY]   = { .type = NETLINK_TYPE_U16 },
94         [IFLA_BOND_AD_INFO_PARTNER_KEY] = { .type = NETLINK_TYPE_U16 },
95         [IFLA_BOND_AD_INFO_PARTNER_MAC] = { .type = NETLINK_TYPE_ETHER_ADDR, .size = ETH_ALEN },
96 };
97 
98 DEFINE_TYPE_SYSTEM(rtnl_bond_ad_info);
99 
100 static const NLType rtnl_link_info_data_bond_types[] = {
101         [IFLA_BOND_MODE]                = { .type = NETLINK_TYPE_U8 },
102         [IFLA_BOND_ACTIVE_SLAVE]        = { .type = NETLINK_TYPE_U32 },
103         [IFLA_BOND_MIIMON]              = { .type = NETLINK_TYPE_U32 },
104         [IFLA_BOND_UPDELAY]             = { .type = NETLINK_TYPE_U32 },
105         [IFLA_BOND_DOWNDELAY]           = { .type = NETLINK_TYPE_U32 },
106         [IFLA_BOND_USE_CARRIER]         = { .type = NETLINK_TYPE_U8 },
107         [IFLA_BOND_ARP_INTERVAL]        = { .type = NETLINK_TYPE_U32 },
108         [IFLA_BOND_ARP_IP_TARGET]       = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bond_arp_ip_target_type_system },
109         [IFLA_BOND_ARP_VALIDATE]        = { .type = NETLINK_TYPE_U32 },
110         [IFLA_BOND_ARP_ALL_TARGETS]     = { .type = NETLINK_TYPE_U32 },
111         [IFLA_BOND_PRIMARY]             = { .type = NETLINK_TYPE_U32 },
112         [IFLA_BOND_PRIMARY_RESELECT]    = { .type = NETLINK_TYPE_U8 },
113         [IFLA_BOND_FAIL_OVER_MAC]       = { .type = NETLINK_TYPE_U8 },
114         [IFLA_BOND_XMIT_HASH_POLICY]    = { .type = NETLINK_TYPE_U8 },
115         [IFLA_BOND_RESEND_IGMP]         = { .type = NETLINK_TYPE_U32 },
116         [IFLA_BOND_NUM_PEER_NOTIF]      = { .type = NETLINK_TYPE_U8 },
117         [IFLA_BOND_ALL_SLAVES_ACTIVE]   = { .type = NETLINK_TYPE_U8 },
118         [IFLA_BOND_MIN_LINKS]           = { .type = NETLINK_TYPE_U32 },
119         [IFLA_BOND_LP_INTERVAL]         = { .type = NETLINK_TYPE_U32 },
120         [IFLA_BOND_PACKETS_PER_SLAVE]   = { .type = NETLINK_TYPE_U32 },
121         [IFLA_BOND_AD_LACP_RATE]        = { .type = NETLINK_TYPE_U8 },
122         [IFLA_BOND_AD_SELECT]           = { .type = NETLINK_TYPE_U8 },
123         [IFLA_BOND_AD_INFO]             = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bond_ad_info_type_system },
124         [IFLA_BOND_AD_ACTOR_SYS_PRIO]   = { .type = NETLINK_TYPE_U16 },
125         [IFLA_BOND_AD_USER_PORT_KEY]    = { .type = NETLINK_TYPE_U16 },
126         [IFLA_BOND_AD_ACTOR_SYSTEM]     = { .type = NETLINK_TYPE_ETHER_ADDR, .size = ETH_ALEN },
127         [IFLA_BOND_TLB_DYNAMIC_LB]      = { .type = NETLINK_TYPE_U8 },
128         [IFLA_BOND_PEER_NOTIF_DELAY]    = { .type = NETLINK_TYPE_U32 },
129 };
130 
131 static const NLType rtnl_link_info_data_bridge_types[] = {
132         [IFLA_BR_FORWARD_DELAY]              = { .type = NETLINK_TYPE_U32 },
133         [IFLA_BR_HELLO_TIME]                 = { .type = NETLINK_TYPE_U32 },
134         [IFLA_BR_MAX_AGE]                    = { .type = NETLINK_TYPE_U32 },
135         [IFLA_BR_AGEING_TIME]                = { .type = NETLINK_TYPE_U32 },
136         [IFLA_BR_STP_STATE]                  = { .type = NETLINK_TYPE_U32 },
137         [IFLA_BR_PRIORITY]                   = { .type = NETLINK_TYPE_U16 },
138         [IFLA_BR_VLAN_FILTERING]             = { .type = NETLINK_TYPE_U8 },
139         [IFLA_BR_VLAN_PROTOCOL]              = { .type = NETLINK_TYPE_U16 },
140         [IFLA_BR_GROUP_FWD_MASK]             = { .type = NETLINK_TYPE_U16 },
141         [IFLA_BR_ROOT_ID]                    = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_bridge_id) },
142         [IFLA_BR_BRIDGE_ID]                  = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_bridge_id) },
143         [IFLA_BR_ROOT_PORT]                  = { .type = NETLINK_TYPE_U16 },
144         [IFLA_BR_ROOT_PATH_COST]             = { .type = NETLINK_TYPE_U32 },
145         [IFLA_BR_TOPOLOGY_CHANGE]            = { .type = NETLINK_TYPE_U8 },
146         [IFLA_BR_TOPOLOGY_CHANGE_DETECTED]   = { .type = NETLINK_TYPE_U8 },
147         [IFLA_BR_HELLO_TIMER]                = { .type = NETLINK_TYPE_U64 },
148         [IFLA_BR_TCN_TIMER]                  = { .type = NETLINK_TYPE_U64 },
149         [IFLA_BR_TOPOLOGY_CHANGE_TIMER]      = { .type = NETLINK_TYPE_U64 },
150         [IFLA_BR_GC_TIMER]                   = { .type = NETLINK_TYPE_U64 },
151         [IFLA_BR_GROUP_ADDR]                 = { .type = NETLINK_TYPE_ETHER_ADDR, .size = ETH_ALEN },
152         [IFLA_BR_FDB_FLUSH]                  = { .type = NETLINK_TYPE_FLAG },
153         [IFLA_BR_MCAST_ROUTER]               = { .type = NETLINK_TYPE_U8 },
154         [IFLA_BR_MCAST_SNOOPING]             = { .type = NETLINK_TYPE_U8 },
155         [IFLA_BR_MCAST_QUERY_USE_IFADDR]     = { .type = NETLINK_TYPE_U8 },
156         [IFLA_BR_MCAST_QUERIER]              = { .type = NETLINK_TYPE_U8 },
157         [IFLA_BR_MCAST_HASH_ELASTICITY]      = { .type = NETLINK_TYPE_U32 },
158         [IFLA_BR_MCAST_HASH_MAX]             = { .type = NETLINK_TYPE_U32 },
159         [IFLA_BR_MCAST_LAST_MEMBER_CNT]      = { .type = NETLINK_TYPE_U32 },
160         [IFLA_BR_MCAST_STARTUP_QUERY_CNT]    = { .type = NETLINK_TYPE_U32 },
161         [IFLA_BR_MCAST_LAST_MEMBER_INTVL]    = { .type = NETLINK_TYPE_U64 },
162         [IFLA_BR_MCAST_MEMBERSHIP_INTVL]     = { .type = NETLINK_TYPE_U64 },
163         [IFLA_BR_MCAST_QUERIER_INTVL]        = { .type = NETLINK_TYPE_U64 },
164         [IFLA_BR_MCAST_QUERY_INTVL]          = { .type = NETLINK_TYPE_U64 },
165         [IFLA_BR_MCAST_QUERY_RESPONSE_INTVL] = { .type = NETLINK_TYPE_U64 },
166         [IFLA_BR_MCAST_STARTUP_QUERY_INTVL]  = { .type = NETLINK_TYPE_U64 },
167         [IFLA_BR_NF_CALL_IPTABLES]           = { .type = NETLINK_TYPE_U8 },
168         [IFLA_BR_NF_CALL_IP6TABLES]          = { .type = NETLINK_TYPE_U8 },
169         [IFLA_BR_NF_CALL_ARPTABLES]          = { .type = NETLINK_TYPE_U8 },
170         [IFLA_BR_VLAN_DEFAULT_PVID]          = { .type = NETLINK_TYPE_U16 },
171         [IFLA_BR_VLAN_STATS_ENABLED]         = { .type = NETLINK_TYPE_U8 },
172         [IFLA_BR_MCAST_STATS_ENABLED]        = { .type = NETLINK_TYPE_U8 },
173         [IFLA_BR_MCAST_IGMP_VERSION]         = { .type = NETLINK_TYPE_U8 },
174         [IFLA_BR_MCAST_MLD_VERSION]          = { .type = NETLINK_TYPE_U8 },
175         [IFLA_BR_VLAN_STATS_PER_PORT]        = { .type = NETLINK_TYPE_U8 },
176         [IFLA_BR_MULTI_BOOLOPT]              = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct br_boolopt_multi) },
177 };
178 
179 static const NLType rtnl_link_info_data_can_types[] = {
180         [IFLA_CAN_BITTIMING]            = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct can_bittiming) },
181         [IFLA_CAN_BITTIMING_CONST]      = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct can_bittiming_const) },
182         [IFLA_CAN_CLOCK]                = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct can_clock) },
183         [IFLA_CAN_STATE]                = { .type = NETLINK_TYPE_U32 },
184         [IFLA_CAN_CTRLMODE]             = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct can_ctrlmode) },
185         [IFLA_CAN_RESTART_MS]           = { .type = NETLINK_TYPE_U32 },
186         [IFLA_CAN_RESTART]              = { .type = NETLINK_TYPE_U32 },
187         [IFLA_CAN_BERR_COUNTER]         = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct can_berr_counter) },
188         [IFLA_CAN_DATA_BITTIMING]       = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct can_bittiming) },
189         [IFLA_CAN_DATA_BITTIMING_CONST] = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct can_bittiming_const) },
190         [IFLA_CAN_TERMINATION]          = { .type = NETLINK_TYPE_U16 },
191         [IFLA_CAN_TERMINATION_CONST]    = { .type = NETLINK_TYPE_BINARY }, /* size = termination_const_cnt * sizeof(u16) */
192         [IFLA_CAN_BITRATE_CONST]        = { .type = NETLINK_TYPE_BINARY }, /* size = bitrate_const_cnt * sizeof(u32) */
193         [IFLA_CAN_DATA_BITRATE_CONST]   = { .type = NETLINK_TYPE_BINARY }, /* size = data_bitrate_const_cnt * sizeof(u32) */
194         [IFLA_CAN_BITRATE_MAX]          = { .type = NETLINK_TYPE_U32 },
195 };
196 
197 static const NLType rtnl_link_info_data_geneve_types[] = {
198         [IFLA_GENEVE_ID]                = { .type = NETLINK_TYPE_U32 },
199         [IFLA_GENEVE_REMOTE]            = { .type = NETLINK_TYPE_IN_ADDR, .size = sizeof(struct in_addr) },
200         [IFLA_GENEVE_TTL]               = { .type = NETLINK_TYPE_U8 },
201         [IFLA_GENEVE_TOS]               = { .type = NETLINK_TYPE_U8 },
202         [IFLA_GENEVE_PORT]              = { .type = NETLINK_TYPE_U16 },
203         [IFLA_GENEVE_COLLECT_METADATA]  = { .type = NETLINK_TYPE_FLAG },
204         [IFLA_GENEVE_REMOTE6]           = { .type = NETLINK_TYPE_IN_ADDR, .size = sizeof(struct in6_addr) },
205         [IFLA_GENEVE_UDP_CSUM]          = { .type = NETLINK_TYPE_U8 },
206         [IFLA_GENEVE_UDP_ZERO_CSUM6_TX] = { .type = NETLINK_TYPE_U8 },
207         [IFLA_GENEVE_UDP_ZERO_CSUM6_RX] = { .type = NETLINK_TYPE_U8 },
208         [IFLA_GENEVE_LABEL]             = { .type = NETLINK_TYPE_U32 },
209         [IFLA_GENEVE_TTL_INHERIT]       = { .type = NETLINK_TYPE_U8 },
210         [IFLA_GENEVE_DF]                = { .type = NETLINK_TYPE_U8 },
211 };
212 
213 static const NLType rtnl_link_info_data_gre_types[] = {
214         [IFLA_GRE_LINK]             = { .type = NETLINK_TYPE_U32 },
215         [IFLA_GRE_IFLAGS]           = { .type = NETLINK_TYPE_U16 },
216         [IFLA_GRE_OFLAGS]           = { .type = NETLINK_TYPE_U16 },
217         [IFLA_GRE_IKEY]             = { .type = NETLINK_TYPE_U32 },
218         [IFLA_GRE_OKEY]             = { .type = NETLINK_TYPE_U32 },
219         [IFLA_GRE_LOCAL]            = { .type = NETLINK_TYPE_IN_ADDR },
220         [IFLA_GRE_REMOTE]           = { .type = NETLINK_TYPE_IN_ADDR },
221         [IFLA_GRE_TTL]              = { .type = NETLINK_TYPE_U8 },
222         [IFLA_GRE_TOS]              = { .type = NETLINK_TYPE_U8 },
223         [IFLA_GRE_PMTUDISC]         = { .type = NETLINK_TYPE_U8 },
224         [IFLA_GRE_ENCAP_LIMIT]      = { .type = NETLINK_TYPE_U8 },
225         [IFLA_GRE_FLOWINFO]         = { .type = NETLINK_TYPE_U32 },
226         [IFLA_GRE_FLAGS]            = { .type = NETLINK_TYPE_U32 },
227         [IFLA_GRE_ENCAP_TYPE]       = { .type = NETLINK_TYPE_U16 },
228         [IFLA_GRE_ENCAP_FLAGS]      = { .type = NETLINK_TYPE_U16 },
229         [IFLA_GRE_ENCAP_SPORT]      = { .type = NETLINK_TYPE_U16 },
230         [IFLA_GRE_ENCAP_DPORT]      = { .type = NETLINK_TYPE_U16 },
231         [IFLA_GRE_COLLECT_METADATA] = { .type = NETLINK_TYPE_FLAG },
232         [IFLA_GRE_IGNORE_DF]        = { .type = NETLINK_TYPE_U8 },
233         [IFLA_GRE_FWMARK]           = { .type = NETLINK_TYPE_U32 },
234         [IFLA_GRE_ERSPAN_INDEX]     = { .type = NETLINK_TYPE_U32 },
235         [IFLA_GRE_ERSPAN_VER]       = { .type = NETLINK_TYPE_U8 },
236         [IFLA_GRE_ERSPAN_DIR]       = { .type = NETLINK_TYPE_U8 },
237         [IFLA_GRE_ERSPAN_HWID]      = { .type = NETLINK_TYPE_U16 },
238 };
239 
240 static const NLType rtnl_link_info_data_ipoib_types[] = {
241         [IFLA_IPOIB_PKEY]           = { .type = NETLINK_TYPE_U16 },
242         [IFLA_IPOIB_MODE]           = { .type = NETLINK_TYPE_U16 },
243         [IFLA_IPOIB_UMCAST]         = { .type = NETLINK_TYPE_U16 },
244 };
245 
246 /* IFLA_IPTUN_ attributes are used in ipv4/ipip.c, ipv6/ip6_tunnel.c, and ipv6/sit.c. And unfortunately,
247  * IFLA_IPTUN_FLAGS is used with different types, ugh... */
248 #define DEFINE_IPTUN_TYPES(name, flags_type)                                            \
249         static const NLType rtnl_link_info_data_##name##_types[] = {                    \
250                 [IFLA_IPTUN_LINK]                = { .type = NETLINK_TYPE_U32 },        \
251                 [IFLA_IPTUN_LOCAL]               = { .type = NETLINK_TYPE_IN_ADDR },    \
252                 [IFLA_IPTUN_REMOTE]              = { .type = NETLINK_TYPE_IN_ADDR },    \
253                 [IFLA_IPTUN_TTL]                 = { .type = NETLINK_TYPE_U8 },         \
254                 [IFLA_IPTUN_TOS]                 = { .type = NETLINK_TYPE_U8 },         \
255                 [IFLA_IPTUN_ENCAP_LIMIT]         = { .type = NETLINK_TYPE_U8 },         \
256                 [IFLA_IPTUN_FLOWINFO]            = { .type = NETLINK_TYPE_U32 },        \
257                 [IFLA_IPTUN_FLAGS]               = { .type = flags_type },              \
258                 [IFLA_IPTUN_PROTO]               = { .type = NETLINK_TYPE_U8 },         \
259                 [IFLA_IPTUN_PMTUDISC]            = { .type = NETLINK_TYPE_U8 },         \
260                 [IFLA_IPTUN_6RD_PREFIX]          = { .type = NETLINK_TYPE_IN_ADDR,      \
261                                                      .size = sizeof(struct in6_addr) }, \
262                 [IFLA_IPTUN_6RD_RELAY_PREFIX]    = { .type = NETLINK_TYPE_U32 },        \
263                 [IFLA_IPTUN_6RD_PREFIXLEN]       = { .type = NETLINK_TYPE_U16 },        \
264                 [IFLA_IPTUN_6RD_RELAY_PREFIXLEN] = { .type = NETLINK_TYPE_U16 },        \
265                 [IFLA_IPTUN_ENCAP_TYPE]          = { .type = NETLINK_TYPE_U16 },        \
266                 [IFLA_IPTUN_ENCAP_FLAGS]         = { .type = NETLINK_TYPE_U16 },        \
267                 [IFLA_IPTUN_ENCAP_SPORT]         = { .type = NETLINK_TYPE_U16 },        \
268                 [IFLA_IPTUN_ENCAP_DPORT]         = { .type = NETLINK_TYPE_U16 },        \
269                 [IFLA_IPTUN_COLLECT_METADATA]    = { .type = NETLINK_TYPE_FLAG },       \
270                 [IFLA_IPTUN_FWMARK]              = { .type = NETLINK_TYPE_U32 },        \
271         }
272 
273 DEFINE_IPTUN_TYPES(iptun, NETLINK_TYPE_U32); /* for ipip and ip6tnl */
274 DEFINE_IPTUN_TYPES(sit, NETLINK_TYPE_U16); /* for sit */
275 
276 static const NLType rtnl_link_info_data_ipvlan_types[] = {
277         [IFLA_IPVLAN_MODE]  = { .type = NETLINK_TYPE_U16 },
278         [IFLA_IPVLAN_FLAGS] = { .type = NETLINK_TYPE_U16 },
279 };
280 
281 static const NLType rtnl_link_info_data_macsec_types[] = {
282         [IFLA_MACSEC_SCI]            = { .type = NETLINK_TYPE_U64 },
283         [IFLA_MACSEC_PORT]           = { .type = NETLINK_TYPE_U16 },
284         [IFLA_MACSEC_ICV_LEN]        = { .type = NETLINK_TYPE_U8 },
285         [IFLA_MACSEC_CIPHER_SUITE]   = { .type = NETLINK_TYPE_U64 },
286         [IFLA_MACSEC_WINDOW]         = { .type = NETLINK_TYPE_U32 },
287         [IFLA_MACSEC_ENCODING_SA]    = { .type = NETLINK_TYPE_U8 },
288         [IFLA_MACSEC_ENCRYPT]        = { .type = NETLINK_TYPE_U8 },
289         [IFLA_MACSEC_PROTECT]        = { .type = NETLINK_TYPE_U8 },
290         [IFLA_MACSEC_INC_SCI]        = { .type = NETLINK_TYPE_U8 },
291         [IFLA_MACSEC_ES]             = { .type = NETLINK_TYPE_U8 },
292         [IFLA_MACSEC_SCB]            = { .type = NETLINK_TYPE_U8 },
293         [IFLA_MACSEC_REPLAY_PROTECT] = { .type = NETLINK_TYPE_U8 },
294         [IFLA_MACSEC_VALIDATION]     = { .type = NETLINK_TYPE_U8 },
295         [IFLA_MACSEC_OFFLOAD]        = { .type = NETLINK_TYPE_U8 },
296 };
297 
298 static const NLType rtnl_macvlan_macaddr_types[] = {
299         [IFLA_MACVLAN_MACADDR] = { .type = NETLINK_TYPE_ETHER_ADDR, .size = ETH_ALEN },
300 };
301 
302 DEFINE_TYPE_SYSTEM(rtnl_macvlan_macaddr);
303 
304 static const NLType rtnl_link_info_data_macvlan_types[] = {
305         [IFLA_MACVLAN_MODE]              = { .type = NETLINK_TYPE_U32 },
306         [IFLA_MACVLAN_FLAGS]             = { .type = NETLINK_TYPE_U16 },
307         [IFLA_MACVLAN_MACADDR_MODE]      = { .type = NETLINK_TYPE_U32 },
308         [IFLA_MACVLAN_MACADDR_DATA]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_macvlan_macaddr_type_system },
309         [IFLA_MACVLAN_MACADDR_COUNT]     = { .type = NETLINK_TYPE_U32 },
310         [IFLA_MACVLAN_BC_QUEUE_LEN]      = { .type = NETLINK_TYPE_U32 },
311         [IFLA_MACVLAN_BC_QUEUE_LEN_USED] = { .type = NETLINK_TYPE_U32 },
312 };
313 
314 static const NLType rtnl_link_info_data_tun_types[] = {
315         [IFLA_TUN_OWNER]               = { .type = NETLINK_TYPE_U32 },
316         [IFLA_TUN_GROUP]               = { .type = NETLINK_TYPE_U32 },
317         [IFLA_TUN_TYPE]                = { .type = NETLINK_TYPE_U8 },
318         [IFLA_TUN_PI]                  = { .type = NETLINK_TYPE_U8 },
319         [IFLA_TUN_VNET_HDR]            = { .type = NETLINK_TYPE_U8 },
320         [IFLA_TUN_PERSIST]             = { .type = NETLINK_TYPE_U8 },
321         [IFLA_TUN_MULTI_QUEUE]         = { .type = NETLINK_TYPE_U8 },
322         [IFLA_TUN_NUM_QUEUES]          = { .type = NETLINK_TYPE_U32 },
323         [IFLA_TUN_NUM_DISABLED_QUEUES] = { .type = NETLINK_TYPE_U32 },
324 };
325 
326 static const NLType rtnl_link_info_data_veth_types[] = {
327         [VETH_INFO_PEER]  = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
328 };
329 
330 static const NLType rtnl_vlan_qos_map_types[] = {
331         [IFLA_VLAN_QOS_MAPPING]        = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_vlan_qos_mapping) },
332 };
333 
334 DEFINE_TYPE_SYSTEM(rtnl_vlan_qos_map);
335 
336 static const NLType rtnl_link_info_data_vlan_types[] = {
337         [IFLA_VLAN_ID]          = { .type = NETLINK_TYPE_U16 },
338         [IFLA_VLAN_FLAGS]       = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_vlan_flags) },
339         [IFLA_VLAN_EGRESS_QOS]  = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_vlan_qos_map_type_system },
340         [IFLA_VLAN_INGRESS_QOS] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_vlan_qos_map_type_system },
341         [IFLA_VLAN_PROTOCOL]    = { .type = NETLINK_TYPE_U16 },
342 };
343 
344 static const NLType rtnl_link_info_data_vrf_types[] = {
345         [IFLA_VRF_TABLE]                 = { .type = NETLINK_TYPE_U32 },
346 };
347 
348 static const NLType rtnl_link_info_data_vti_types[] = {
349         [IFLA_VTI_LINK]         = { .type = NETLINK_TYPE_U32 },
350         [IFLA_VTI_IKEY]         = { .type = NETLINK_TYPE_U32 },
351         [IFLA_VTI_OKEY]         = { .type = NETLINK_TYPE_U32 },
352         [IFLA_VTI_LOCAL]        = { .type = NETLINK_TYPE_IN_ADDR },
353         [IFLA_VTI_REMOTE]       = { .type = NETLINK_TYPE_IN_ADDR },
354         [IFLA_VTI_FWMARK]       = { .type = NETLINK_TYPE_U32 },
355 };
356 
357 static const NLType rtnl_link_info_data_vxcan_types[] = {
358         [VXCAN_INFO_PEER]  = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) },
359 };
360 
361 static const NLType rtnl_link_info_data_vxlan_types[] = {
362         [IFLA_VXLAN_ID]                = { .type = NETLINK_TYPE_U32 },
363         [IFLA_VXLAN_GROUP]             = { .type = NETLINK_TYPE_IN_ADDR, .size = sizeof(struct in_addr) },
364         [IFLA_VXLAN_LINK]              = { .type = NETLINK_TYPE_U32 },
365         [IFLA_VXLAN_LOCAL]             = { .type = NETLINK_TYPE_IN_ADDR, .size = sizeof(struct in_addr) },
366         [IFLA_VXLAN_TTL]               = { .type = NETLINK_TYPE_U8 },
367         [IFLA_VXLAN_TOS]               = { .type = NETLINK_TYPE_U8 },
368         [IFLA_VXLAN_LEARNING]          = { .type = NETLINK_TYPE_U8 },
369         [IFLA_VXLAN_AGEING]            = { .type = NETLINK_TYPE_U32 },
370         [IFLA_VXLAN_LIMIT]             = { .type = NETLINK_TYPE_U32 },
371         [IFLA_VXLAN_PORT_RANGE]        = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_vxlan_port_range) },
372         [IFLA_VXLAN_PROXY]             = { .type = NETLINK_TYPE_U8 },
373         [IFLA_VXLAN_RSC]               = { .type = NETLINK_TYPE_U8 },
374         [IFLA_VXLAN_L2MISS]            = { .type = NETLINK_TYPE_U8 },
375         [IFLA_VXLAN_L3MISS]            = { .type = NETLINK_TYPE_U8 },
376         [IFLA_VXLAN_PORT]              = { .type = NETLINK_TYPE_U16 },
377         [IFLA_VXLAN_GROUP6]            = { .type = NETLINK_TYPE_IN_ADDR, .size = sizeof(struct in6_addr) },
378         [IFLA_VXLAN_LOCAL6]            = { .type = NETLINK_TYPE_IN_ADDR, .size = sizeof(struct in6_addr) },
379         [IFLA_VXLAN_UDP_CSUM]          = { .type = NETLINK_TYPE_U8 },
380         [IFLA_VXLAN_UDP_ZERO_CSUM6_TX] = { .type = NETLINK_TYPE_U8 },
381         [IFLA_VXLAN_UDP_ZERO_CSUM6_RX] = { .type = NETLINK_TYPE_U8 },
382         [IFLA_VXLAN_REMCSUM_TX]        = { .type = NETLINK_TYPE_U8 },
383         [IFLA_VXLAN_REMCSUM_RX]        = { .type = NETLINK_TYPE_U8 },
384         [IFLA_VXLAN_GBP]               = { .type = NETLINK_TYPE_FLAG },
385         [IFLA_VXLAN_REMCSUM_NOPARTIAL] = { .type = NETLINK_TYPE_FLAG },
386         [IFLA_VXLAN_COLLECT_METADATA]  = { .type = NETLINK_TYPE_U8 },
387         [IFLA_VXLAN_LABEL]             = { .type = NETLINK_TYPE_U32 },
388         [IFLA_VXLAN_GPE]               = { .type = NETLINK_TYPE_FLAG },
389         [IFLA_VXLAN_TTL_INHERIT]       = { .type = NETLINK_TYPE_FLAG },
390         [IFLA_VXLAN_DF]                = { .type = NETLINK_TYPE_U8 },
391 };
392 
393 static const NLType rtnl_link_info_data_xfrm_types[] = {
394         [IFLA_XFRM_LINK]         = { .type = NETLINK_TYPE_U32 },
395         [IFLA_XFRM_IF_ID]        = { .type = NETLINK_TYPE_U32 }
396 };
397 
398 static const NLTypeSystemUnionElement rtnl_link_info_data_type_systems[] = {
399         { .name = "bareudp",   .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_bareudp), },
400         { .name = "batadv",    .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_batadv),  },
401         { .name = "bond",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_bond),    },
402         { .name = "bridge",    .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_bridge),  },
403 /*
404         { .name = "caif",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_caif),    },
405 */
406         { .name = "can",       .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_can),     },
407         { .name = "erspan",    .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_gre),     },
408         { .name = "geneve",    .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_geneve),  },
409         { .name = "gre",       .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_gre),     },
410         { .name = "gretap",    .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_gre),     },
411 /*
412         { .name = "gtp",       .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_gtp),     },
413         { .name = "hsr",       .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_hsr),     },
414 */
415         { .name = "ip6erspan", .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_gre),     },
416         { .name = "ip6gre",    .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_gre),     },
417         { .name = "ip6gretap", .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_gre),     },
418         { .name = "ip6tnl",    .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_iptun),   },
419         { .name = "ipoib",     .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_ipoib),   },
420         { .name = "ipip",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_iptun),   },
421         { .name = "ipvlan",    .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_ipvlan),  },
422         { .name = "ipvtap",    .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_ipvlan),  },
423         { .name = "macsec",    .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_macsec),  },
424         { .name = "macvlan",   .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_macvlan), },
425         { .name = "macvtap",   .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_macvlan), },
426 /*
427         { .name = "ppp",       .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_ppp),     },
428         { .name = "rmnet",     .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_rmnet),   },
429 */
430         { .name = "sit",       .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_sit),     },
431         { .name = "tun",       .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_tun),     },
432         { .name = "veth",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_veth),    },
433         { .name = "vlan",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_vlan),    },
434         { .name = "vrf",       .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_vrf),     },
435         { .name = "vti",       .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_vti),     },
436         { .name = "vti6",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_vti),     },
437         { .name = "vxcan",     .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_vxcan),   },
438         { .name = "vxlan",     .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_vxlan),   },
439 /*
440         { .name = "wwan",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_wwan),    },
441 */
442         { .name = "xfrm",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_link_info_data_xfrm),    },
443 };
444 
445 DEFINE_TYPE_SYSTEM_UNION_MATCH_SIBLING(rtnl_link_info_data, IFLA_INFO_KIND);
446 
447 static const struct NLType rtnl_bridge_port_types[] = {
448         [IFLA_BRPORT_STATE]                 = { .type = NETLINK_TYPE_U8 },
449         [IFLA_BRPORT_COST]                  = { .type = NETLINK_TYPE_U32 },
450         [IFLA_BRPORT_PRIORITY]              = { .type = NETLINK_TYPE_U16 },
451         [IFLA_BRPORT_MODE]                  = { .type = NETLINK_TYPE_U8 },
452         [IFLA_BRPORT_GUARD]                 = { .type = NETLINK_TYPE_U8 },
453         [IFLA_BRPORT_PROTECT]               = { .type = NETLINK_TYPE_U8 },
454         [IFLA_BRPORT_FAST_LEAVE]            = { .type = NETLINK_TYPE_U8 },
455         [IFLA_BRPORT_LEARNING]              = { .type = NETLINK_TYPE_U8 },
456         [IFLA_BRPORT_UNICAST_FLOOD]         = { .type = NETLINK_TYPE_U8 },
457         [IFLA_BRPORT_PROXYARP]              = { .type = NETLINK_TYPE_U8 },
458         [IFLA_BRPORT_LEARNING_SYNC]         = { .type = NETLINK_TYPE_U8 },
459         [IFLA_BRPORT_PROXYARP_WIFI]         = { .type = NETLINK_TYPE_U8 },
460         [IFLA_BRPORT_ROOT_ID]               = { .type = NETLINK_TYPE_U8 },
461         [IFLA_BRPORT_BRIDGE_ID]             = { .type = NETLINK_TYPE_U8 },
462         [IFLA_BRPORT_DESIGNATED_PORT]       = { .type = NETLINK_TYPE_U16 },
463         [IFLA_BRPORT_DESIGNATED_COST]       = { .type = NETLINK_TYPE_U16 },
464         [IFLA_BRPORT_ID]                    = { .type = NETLINK_TYPE_U16 },
465         [IFLA_BRPORT_NO]                    = { .type = NETLINK_TYPE_U16 },
466         [IFLA_BRPORT_TOPOLOGY_CHANGE_ACK]   = { .type = NETLINK_TYPE_U8 },
467         [IFLA_BRPORT_CONFIG_PENDING]        = { .type = NETLINK_TYPE_U8 },
468         [IFLA_BRPORT_MESSAGE_AGE_TIMER]     = { .type = NETLINK_TYPE_U64 },
469         [IFLA_BRPORT_FORWARD_DELAY_TIMER]   = { .type = NETLINK_TYPE_U64 },
470         [IFLA_BRPORT_HOLD_TIMER]            = { .type = NETLINK_TYPE_U64 },
471         [IFLA_BRPORT_FLUSH]                 = { .type = NETLINK_TYPE_U8 },
472         [IFLA_BRPORT_MULTICAST_ROUTER]      = { .type = NETLINK_TYPE_U8 },
473         [IFLA_BRPORT_PAD]                   = { .type = NETLINK_TYPE_U8 },
474         [IFLA_BRPORT_MCAST_FLOOD]           = { .type = NETLINK_TYPE_U8 },
475         [IFLA_BRPORT_MCAST_TO_UCAST]        = { .type = NETLINK_TYPE_U8 },
476         [IFLA_BRPORT_VLAN_TUNNEL]           = { .type = NETLINK_TYPE_U8 },
477         [IFLA_BRPORT_BCAST_FLOOD]           = { .type = NETLINK_TYPE_U8 },
478         [IFLA_BRPORT_GROUP_FWD_MASK]        = { .type = NETLINK_TYPE_U16 },
479         [IFLA_BRPORT_NEIGH_SUPPRESS]        = { .type = NETLINK_TYPE_U8 },
480         [IFLA_BRPORT_ISOLATED]              = { .type = NETLINK_TYPE_U8 },
481         [IFLA_BRPORT_BACKUP_PORT]           = { .type = NETLINK_TYPE_U32 },
482         [IFLA_BRPORT_MRP_RING_OPEN]         = { .type = NETLINK_TYPE_U8 },
483         [IFLA_BRPORT_MRP_IN_OPEN]           = { .type = NETLINK_TYPE_U8 },
484         [IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT] = { .type = NETLINK_TYPE_U32 },
485         [IFLA_BRPORT_MCAST_EHT_HOSTS_CNT]   = { .type = NETLINK_TYPE_U32 },
486 };
487 
488 static const NLTypeSystemUnionElement rtnl_link_info_slave_data_type_systems[] = {
489         { .name = "bridge",    .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_bridge_port), },
490 };
491 
492 DEFINE_TYPE_SYSTEM_UNION_MATCH_SIBLING(rtnl_link_info_slave_data, IFLA_INFO_SLAVE_KIND);
493 
494 static const NLType rtnl_link_info_types[] = {
495         [IFLA_INFO_KIND]        = { .type = NETLINK_TYPE_STRING },
496         [IFLA_INFO_DATA]        = { .type = NETLINK_TYPE_UNION, .type_system_union = &rtnl_link_info_data_type_system_union },
497         /* TODO: Currently IFLA_INFO_XSTATS is used only when IFLA_INFO_KIND is "can". In the future,
498          * when multiple kinds of netdevs use this attribute, then convert its type to NETLINK_TYPE_UNION. */
499         [IFLA_INFO_XSTATS]      = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct can_device_stats) },
500         [IFLA_INFO_SLAVE_KIND]  = { .type = NETLINK_TYPE_STRING },
501         [IFLA_INFO_SLAVE_DATA]  = { .type = NETLINK_TYPE_NESTED, .type_system_union = &rtnl_link_info_slave_data_type_system_union },
502 };
503 
504 DEFINE_TYPE_SYSTEM(rtnl_link_info);
505 
506 static const struct NLType rtnl_inet_types[] = {
507         [IFLA_INET_CONF] = { .type = NETLINK_TYPE_BINARY }, /* size = IPV4_DEVCONF_MAX * 4 */
508 };
509 
510 DEFINE_TYPE_SYSTEM(rtnl_inet);
511 
512 static const struct NLType rtnl_inet6_types[] = {
513         [IFLA_INET6_FLAGS]         = { .type = NETLINK_TYPE_U32 },
514         [IFLA_INET6_CONF]          = { .type = NETLINK_TYPE_BINARY }, /* size = DEVCONF_MAX * sizeof(s32) */
515         [IFLA_INET6_STATS]         = { .type = NETLINK_TYPE_BINARY }, /* size = IPSTATS_MIB_MAX * sizeof(u64) */
516         [IFLA_INET6_MCAST]         = {}, /* unused. */
517         [IFLA_INET6_CACHEINFO]     = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_cacheinfo) },
518         [IFLA_INET6_ICMP6STATS]    = { .type = NETLINK_TYPE_BINARY }, /* size = ICMP6_MIB_MAX * sizeof(u64) */
519         [IFLA_INET6_TOKEN]         = { .type = NETLINK_TYPE_IN_ADDR, .size = sizeof(struct in6_addr) },
520         [IFLA_INET6_ADDR_GEN_MODE] = { .type = NETLINK_TYPE_U8 },
521 };
522 
523 DEFINE_TYPE_SYSTEM(rtnl_inet6);
524 
525 static const NLTypeSystemUnionElement rtnl_prot_info_type_systems[] = {
526         { .protocol = AF_BRIDGE, .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_bridge_port), },
527         { .protocol = AF_INET6,  .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_inet6), },
528 };
529 
530 DEFINE_TYPE_SYSTEM_UNION_MATCH_PROTOCOL(rtnl_prot_info);
531 
532 static const NLType rtnl_af_spec_unspec_types[] = {
533         [AF_INET]  = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_inet_type_system },
534         [AF_INET6] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_inet6_type_system },
535 };
536 
537 static const NLType rtnl_bridge_vlan_tunnel_info_types[] = {
538         [IFLA_BRIDGE_VLAN_TUNNEL_ID]    = { .type = NETLINK_TYPE_U32 },
539         [IFLA_BRIDGE_VLAN_TUNNEL_VID]   = { .type = NETLINK_TYPE_U16 },
540         [IFLA_BRIDGE_VLAN_TUNNEL_FLAGS] = { .type = NETLINK_TYPE_U16 },
541 };
542 
543 DEFINE_TYPE_SYSTEM(rtnl_bridge_vlan_tunnel_info);
544 
545 static const NLType rtnl_bridge_mrp_instance_types[] = {
546         [IFLA_BRIDGE_MRP_INSTANCE_RING_ID]      = { .type = NETLINK_TYPE_U32 },
547         [IFLA_BRIDGE_MRP_INSTANCE_P_IFINDEX]    = { .type = NETLINK_TYPE_U32 },
548         [IFLA_BRIDGE_MRP_INSTANCE_S_IFINDEX]    = { .type = NETLINK_TYPE_U32 },
549         [IFLA_BRIDGE_MRP_INSTANCE_PRIO]         = { .type = NETLINK_TYPE_U16 },
550 };
551 
552 DEFINE_TYPE_SYSTEM(rtnl_bridge_mrp_instance);
553 
554 static const NLType rtnl_bridge_mrp_port_state_types[] = {
555         [IFLA_BRIDGE_MRP_PORT_STATE_STATE]      = { .type = NETLINK_TYPE_U32 },
556 };
557 
558 DEFINE_TYPE_SYSTEM(rtnl_bridge_mrp_port_state);
559 
560 static const NLType rtnl_bridge_mrp_port_role_types[] = {
561         [IFLA_BRIDGE_MRP_PORT_ROLE_ROLE]        = { .type = NETLINK_TYPE_U32 },
562 };
563 
564 DEFINE_TYPE_SYSTEM(rtnl_bridge_mrp_port_role);
565 
566 static const NLType rtnl_bridge_mrp_ring_state_types[] = {
567         [IFLA_BRIDGE_MRP_RING_STATE_RING_ID]    = { .type = NETLINK_TYPE_U32 },
568         [IFLA_BRIDGE_MRP_RING_STATE_STATE]      = { .type = NETLINK_TYPE_U32 },
569 };
570 
571 DEFINE_TYPE_SYSTEM(rtnl_bridge_mrp_ring_state);
572 
573 static const NLType rtnl_bridge_mrp_ring_role_types[] = {
574         [IFLA_BRIDGE_MRP_RING_ROLE_RING_ID]     = { .type = NETLINK_TYPE_U32 },
575         [IFLA_BRIDGE_MRP_RING_ROLE_ROLE]        = { .type = NETLINK_TYPE_U32 },
576 };
577 
578 DEFINE_TYPE_SYSTEM(rtnl_bridge_mrp_ring_role);
579 
580 static const NLType rtnl_bridge_mrp_start_test_types[] = {
581         [IFLA_BRIDGE_MRP_START_TEST_RING_ID]    = { .type = NETLINK_TYPE_U32 },
582         [IFLA_BRIDGE_MRP_START_TEST_INTERVAL]   = { .type = NETLINK_TYPE_U32 },
583         [IFLA_BRIDGE_MRP_START_TEST_MAX_MISS]   = { .type = NETLINK_TYPE_U32 },
584         [IFLA_BRIDGE_MRP_START_TEST_PERIOD]     = { .type = NETLINK_TYPE_U32 },
585         [IFLA_BRIDGE_MRP_START_TEST_MONITOR]    = { .type = NETLINK_TYPE_U32 },
586 };
587 
588 DEFINE_TYPE_SYSTEM(rtnl_bridge_mrp_start_test);
589 
590 static const NLType rtnl_bridge_mrp_info_types[] = {
591         [IFLA_BRIDGE_MRP_INFO_RING_ID]          = { .type = NETLINK_TYPE_U32 },
592         [IFLA_BRIDGE_MRP_INFO_P_IFINDEX]        = { .type = NETLINK_TYPE_U32 },
593         [IFLA_BRIDGE_MRP_INFO_S_IFINDEX]        = { .type = NETLINK_TYPE_U32 },
594         [IFLA_BRIDGE_MRP_INFO_PRIO]             = { .type = NETLINK_TYPE_U16 },
595         [IFLA_BRIDGE_MRP_INFO_RING_STATE]       = { .type = NETLINK_TYPE_U32 },
596         [IFLA_BRIDGE_MRP_INFO_RING_ROLE]        = { .type = NETLINK_TYPE_U32 },
597         [IFLA_BRIDGE_MRP_INFO_TEST_INTERVAL]    = { .type = NETLINK_TYPE_U32 },
598         [IFLA_BRIDGE_MRP_INFO_TEST_MAX_MISS]    = { .type = NETLINK_TYPE_U32 },
599         [IFLA_BRIDGE_MRP_INFO_TEST_MONITOR]     = { .type = NETLINK_TYPE_U32 },
600         [IFLA_BRIDGE_MRP_INFO_I_IFINDEX]        = { .type = NETLINK_TYPE_U32 },
601         [IFLA_BRIDGE_MRP_INFO_IN_STATE]         = { .type = NETLINK_TYPE_U32 },
602         [IFLA_BRIDGE_MRP_INFO_IN_ROLE]          = { .type = NETLINK_TYPE_U32 },
603         [IFLA_BRIDGE_MRP_INFO_IN_TEST_INTERVAL] = { .type = NETLINK_TYPE_U32 },
604         [IFLA_BRIDGE_MRP_INFO_IN_TEST_MAX_MISS] = { .type = NETLINK_TYPE_U32 },
605 };
606 
607 DEFINE_TYPE_SYSTEM(rtnl_bridge_mrp_info);
608 
609 static const NLType rtnl_bridge_mrp_in_role_types[] = {
610         [IFLA_BRIDGE_MRP_IN_ROLE_RING_ID]       = { .type = NETLINK_TYPE_U32 },
611         [IFLA_BRIDGE_MRP_IN_ROLE_IN_ID]         = { .type = NETLINK_TYPE_U16 },
612         [IFLA_BRIDGE_MRP_IN_ROLE_ROLE]          = { .type = NETLINK_TYPE_U32 },
613         [IFLA_BRIDGE_MRP_IN_ROLE_I_IFINDEX]     = { .type = NETLINK_TYPE_U32 },
614 };
615 
616 DEFINE_TYPE_SYSTEM(rtnl_bridge_mrp_in_role);
617 
618 static const NLType rtnl_bridge_mrp_in_state_types[] = {
619         [IFLA_BRIDGE_MRP_IN_STATE_IN_ID]        = { .type = NETLINK_TYPE_U32 },
620         [IFLA_BRIDGE_MRP_IN_STATE_STATE]        = { .type = NETLINK_TYPE_U32 },
621 };
622 
623 DEFINE_TYPE_SYSTEM(rtnl_bridge_mrp_in_state);
624 
625 static const NLType rtnl_bridge_mrp_start_in_test_types[] = {
626         [IFLA_BRIDGE_MRP_START_IN_TEST_IN_ID]    = { .type = NETLINK_TYPE_U32 },
627         [IFLA_BRIDGE_MRP_START_IN_TEST_INTERVAL] = { .type = NETLINK_TYPE_U32 },
628         [IFLA_BRIDGE_MRP_START_IN_TEST_MAX_MISS] = { .type = NETLINK_TYPE_U32 },
629         [IFLA_BRIDGE_MRP_START_IN_TEST_PERIOD]   = { .type = NETLINK_TYPE_U32 },
630 };
631 
632 DEFINE_TYPE_SYSTEM(rtnl_bridge_mrp_start_in_test);
633 
634 static const NLType rtnl_bridge_mrp_types[] = {
635         [IFLA_BRIDGE_MRP_INSTANCE]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_mrp_instance_type_system },
636         [IFLA_BRIDGE_MRP_PORT_STATE]    = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_mrp_port_state_type_system },
637         [IFLA_BRIDGE_MRP_PORT_ROLE]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_mrp_port_role_type_system },
638         [IFLA_BRIDGE_MRP_RING_STATE]    = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_mrp_ring_state_type_system },
639         [IFLA_BRIDGE_MRP_RING_ROLE]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_mrp_ring_role_type_system },
640         [IFLA_BRIDGE_MRP_START_TEST]    = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_mrp_start_test_type_system },
641         [IFLA_BRIDGE_MRP_INFO]          = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_mrp_info_type_system },
642         [IFLA_BRIDGE_MRP_IN_ROLE]       = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_mrp_in_role_type_system },
643         [IFLA_BRIDGE_MRP_IN_STATE]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_mrp_in_state_type_system },
644         [IFLA_BRIDGE_MRP_START_IN_TEST] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_mrp_start_in_test_type_system },
645 };
646 
647 DEFINE_TYPE_SYSTEM(rtnl_bridge_mrp);
648 
649 static const NLType rtnl_bridge_cfm_mep_create_types[] = {
650         [IFLA_BRIDGE_CFM_MEP_CREATE_INSTANCE]   = { .type = NETLINK_TYPE_U32 },
651         [IFLA_BRIDGE_CFM_MEP_CREATE_DOMAIN]     = { .type = NETLINK_TYPE_U32 },
652         [IFLA_BRIDGE_CFM_MEP_CREATE_DIRECTION]  = { .type = NETLINK_TYPE_U32 },
653         [IFLA_BRIDGE_CFM_MEP_CREATE_IFINDEX]    = { .type = NETLINK_TYPE_U32 },
654 };
655 
656 DEFINE_TYPE_SYSTEM(rtnl_bridge_cfm_mep_create);
657 
658 static const NLType rtnl_bridge_cfm_mep_delete_types[] = {
659         [IFLA_BRIDGE_CFM_MEP_DELETE_INSTANCE]   = { .type = NETLINK_TYPE_U32 },
660 };
661 
662 DEFINE_TYPE_SYSTEM(rtnl_bridge_cfm_mep_delete);
663 
664 static const NLType rtnl_bridge_cfm_mep_config_types[] = {
665         [IFLA_BRIDGE_CFM_MEP_CONFIG_INSTANCE]    = { .type = NETLINK_TYPE_U32 },
666         [IFLA_BRIDGE_CFM_MEP_CONFIG_UNICAST_MAC] = { .type = NETLINK_TYPE_ETHER_ADDR },
667         [IFLA_BRIDGE_CFM_MEP_CONFIG_MDLEVEL]     = { .type = NETLINK_TYPE_U32 },
668         [IFLA_BRIDGE_CFM_MEP_CONFIG_MEPID]       = { .type = NETLINK_TYPE_U32 },
669 };
670 
671 DEFINE_TYPE_SYSTEM(rtnl_bridge_cfm_mep_config);
672 
673 static const NLType rtnl_bridge_cfm_cc_config_types[] = {
674         [IFLA_BRIDGE_CFM_CC_CONFIG_INSTANCE]     = { .type = NETLINK_TYPE_U32 },
675         [IFLA_BRIDGE_CFM_CC_CONFIG_ENABLE]       = { .type = NETLINK_TYPE_U32 },
676         [IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL] = { .type = NETLINK_TYPE_U32 },
677         [IFLA_BRIDGE_CFM_CC_CONFIG_EXP_MAID]     = { .type = NETLINK_TYPE_BINARY, .size = CFM_MAID_LENGTH },
678 };
679 
680 DEFINE_TYPE_SYSTEM(rtnl_bridge_cfm_cc_config);
681 
682 static const NLType rtnl_bridge_cfm_cc_peer_mep_types[] = {
683         [IFLA_BRIDGE_CFM_CC_PEER_MEP_INSTANCE]  = { .type = NETLINK_TYPE_U32 },
684         [IFLA_BRIDGE_CFM_CC_PEER_MEPID]         = { .type = NETLINK_TYPE_U32 },
685 };
686 
687 DEFINE_TYPE_SYSTEM(rtnl_bridge_cfm_cc_peer_mep);
688 
689 static const NLType rtnl_bridge_cfm_cc_rdi_types[] = {
690         [IFLA_BRIDGE_CFM_CC_RDI_INSTANCE]       = { .type = NETLINK_TYPE_U32 },
691         [IFLA_BRIDGE_CFM_CC_RDI_RDI]            = { .type = NETLINK_TYPE_U32 },
692 };
693 
694 DEFINE_TYPE_SYSTEM(rtnl_bridge_cfm_cc_rdi);
695 
696 static const NLType rtnl_bridge_cfm_cc_ccm_tx_types[] = {
697         [IFLA_BRIDGE_CFM_CC_CCM_TX_INSTANCE]       = { .type = NETLINK_TYPE_U32 },
698         [IFLA_BRIDGE_CFM_CC_CCM_TX_DMAC]           = { .type = NETLINK_TYPE_ETHER_ADDR },
699         [IFLA_BRIDGE_CFM_CC_CCM_TX_SEQ_NO_UPDATE]  = { .type = NETLINK_TYPE_U32 },
700         [IFLA_BRIDGE_CFM_CC_CCM_TX_PERIOD]         = { .type = NETLINK_TYPE_U32 },
701         [IFLA_BRIDGE_CFM_CC_CCM_TX_IF_TLV]         = { .type = NETLINK_TYPE_U32 },
702         [IFLA_BRIDGE_CFM_CC_CCM_TX_IF_TLV_VALUE]   = { .type = NETLINK_TYPE_U8 },
703         [IFLA_BRIDGE_CFM_CC_CCM_TX_PORT_TLV]       = { .type = NETLINK_TYPE_U32 },
704         [IFLA_BRIDGE_CFM_CC_CCM_TX_PORT_TLV_VALUE] = { .type = NETLINK_TYPE_U8 },
705 };
706 
707 DEFINE_TYPE_SYSTEM(rtnl_bridge_cfm_cc_ccm_tx);
708 
709 static const NLType rtnl_bridge_cfm_mep_status_types[] = {
710         [IFLA_BRIDGE_CFM_MEP_STATUS_INSTANCE]           = { .type = NETLINK_TYPE_U32 },
711         [IFLA_BRIDGE_CFM_MEP_STATUS_OPCODE_UNEXP_SEEN]  = { .type = NETLINK_TYPE_U32 },
712         [IFLA_BRIDGE_CFM_MEP_STATUS_VERSION_UNEXP_SEEN] = { .type = NETLINK_TYPE_U32 },
713         [IFLA_BRIDGE_CFM_MEP_STATUS_RX_LEVEL_LOW_SEEN]  = { .type = NETLINK_TYPE_U32 },
714 };
715 
716 DEFINE_TYPE_SYSTEM(rtnl_bridge_cfm_mep_status);
717 
718 static const NLType rtnl_bridge_cfm_cc_peer_status_types[] = {
719         [IFLA_BRIDGE_CFM_CC_PEER_STATUS_INSTANCE]       = { .type = NETLINK_TYPE_U32 },
720         [IFLA_BRIDGE_CFM_CC_PEER_STATUS_PEER_MEPID]     = { .type = NETLINK_TYPE_U32 },
721         [IFLA_BRIDGE_CFM_CC_PEER_STATUS_CCM_DEFECT]     = { .type = NETLINK_TYPE_U32 },
722         [IFLA_BRIDGE_CFM_CC_PEER_STATUS_RDI]            = { .type = NETLINK_TYPE_U32 },
723         [IFLA_BRIDGE_CFM_CC_PEER_STATUS_PORT_TLV_VALUE] = { .type = NETLINK_TYPE_U8 },
724         [IFLA_BRIDGE_CFM_CC_PEER_STATUS_IF_TLV_VALUE]   = { .type = NETLINK_TYPE_U8 },
725         [IFLA_BRIDGE_CFM_CC_PEER_STATUS_SEEN]           = { .type = NETLINK_TYPE_U32 },
726         [IFLA_BRIDGE_CFM_CC_PEER_STATUS_TLV_SEEN]       = { .type = NETLINK_TYPE_U32 },
727         [IFLA_BRIDGE_CFM_CC_PEER_STATUS_SEQ_UNEXP_SEEN] = { .type = NETLINK_TYPE_U32 },
728 };
729 
730 DEFINE_TYPE_SYSTEM(rtnl_bridge_cfm_cc_peer_status);
731 
732 static const NLType rtnl_bridge_cfm_types[] = {
733         [IFLA_BRIDGE_CFM_MEP_CREATE]          = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_mep_create_type_system },
734         [IFLA_BRIDGE_CFM_MEP_DELETE]          = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_mep_delete_type_system },
735         [IFLA_BRIDGE_CFM_MEP_CONFIG]          = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_mep_config_type_system },
736         [IFLA_BRIDGE_CFM_CC_CONFIG]           = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_cc_config_type_system },
737         [IFLA_BRIDGE_CFM_CC_PEER_MEP_ADD]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_cc_peer_mep_type_system },
738         [IFLA_BRIDGE_CFM_CC_PEER_MEP_REMOVE]  = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_cc_peer_mep_type_system },
739         [IFLA_BRIDGE_CFM_CC_RDI]              = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_cc_rdi_type_system },
740         [IFLA_BRIDGE_CFM_CC_CCM_TX]           = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_cc_ccm_tx_type_system },
741         [IFLA_BRIDGE_CFM_MEP_CREATE_INFO]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_mep_create_type_system },
742         [IFLA_BRIDGE_CFM_MEP_CONFIG_INFO]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_mep_config_type_system },
743         [IFLA_BRIDGE_CFM_CC_CONFIG_INFO]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_cc_config_type_system },
744         [IFLA_BRIDGE_CFM_CC_RDI_INFO]         = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_cc_rdi_type_system },
745         [IFLA_BRIDGE_CFM_CC_CCM_TX_INFO]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_cc_ccm_tx_type_system },
746         [IFLA_BRIDGE_CFM_CC_PEER_MEP_INFO]    = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_cc_peer_mep_type_system },
747         [IFLA_BRIDGE_CFM_MEP_STATUS_INFO]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_mep_status_type_system },
748         [IFLA_BRIDGE_CFM_CC_PEER_STATUS_INFO] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_cc_peer_status_type_system },
749 };
750 
751 DEFINE_TYPE_SYSTEM(rtnl_bridge_cfm);
752 
753 static const NLType rtnl_af_spec_bridge_types[] = {
754         [IFLA_BRIDGE_FLAGS]            = { .type = NETLINK_TYPE_U16 },
755         [IFLA_BRIDGE_MODE]             = { .type = NETLINK_TYPE_U16 },
756         [IFLA_BRIDGE_VLAN_INFO]        = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct bridge_vlan_info) },
757         [IFLA_BRIDGE_VLAN_TUNNEL_INFO] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_vlan_tunnel_info_type_system },
758         [IFLA_BRIDGE_MRP]              = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_mrp_type_system },
759         [IFLA_BRIDGE_CFM]              = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bridge_cfm_type_system },
760 };
761 
762 static const NLTypeSystemUnionElement rtnl_af_spec_type_systems[] = {
763         { .protocol = AF_UNSPEC, .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_af_spec_unspec), },
764         { .protocol = AF_BRIDGE, .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_af_spec_bridge), },
765 };
766 
767 DEFINE_TYPE_SYSTEM_UNION_MATCH_PROTOCOL(rtnl_af_spec);
768 
769 static const NLType rtnl_prop_list_types[] = {
770         [IFLA_ALT_IFNAME]       = { .type = NETLINK_TYPE_STRING, .size = ALTIFNAMSIZ - 1 },
771 };
772 
773 DEFINE_TYPE_SYSTEM(rtnl_prop_list);
774 
775 static const NLType rtnl_vf_vlan_list_types[] = {
776         [IFLA_VF_VLAN_INFO]  = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_vf_vlan_info) },
777 };
778 
779 DEFINE_TYPE_SYSTEM(rtnl_vf_vlan_list);
780 
781 static const NLType rtnl_vf_info_types[] = {
782         [IFLA_VF_MAC]           = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_vf_mac) },
783         [IFLA_VF_VLAN]          = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_vf_vlan) },
784         [IFLA_VF_VLAN_LIST]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_vf_vlan_list_type_system },
785         [IFLA_VF_TX_RATE]       = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_vf_tx_rate) },
786         [IFLA_VF_SPOOFCHK]      = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_vf_spoofchk) },
787         [IFLA_VF_RATE]          = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_vf_rate) },
788         [IFLA_VF_LINK_STATE]    = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_vf_link_state) },
789         [IFLA_VF_RSS_QUERY_EN]  = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_vf_rss_query_en) },
790         [IFLA_VF_TRUST]         = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_vf_trust) },
791         [IFLA_VF_IB_NODE_GUID]  = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_vf_guid) },
792         [IFLA_VF_IB_PORT_GUID]  = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_vf_guid) },
793 };
794 
795 DEFINE_TYPE_SYSTEM(rtnl_vf_info);
796 
797 static const NLType rtnl_vfinfo_list_types[] = {
798         [IFLA_VF_INFO] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_vf_info_type_system },
799 };
800 
801 DEFINE_TYPE_SYSTEM(rtnl_vfinfo_list);
802 
803 static const NLType rtnl_vf_port_types[] = {
804         [IFLA_PORT_VF]            = { .type = NETLINK_TYPE_U32 },
805         [IFLA_PORT_PROFILE]       = { .type = NETLINK_TYPE_STRING },
806         [IFLA_PORT_VSI_TYPE]      = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct ifla_port_vsi) },
807         [IFLA_PORT_INSTANCE_UUID] = { .type = NETLINK_TYPE_BINARY, .size = PORT_UUID_MAX },
808         [IFLA_PORT_HOST_UUID]     = { .type = NETLINK_TYPE_BINARY, .size = PORT_UUID_MAX },
809         [IFLA_PORT_REQUEST]       = { .type = NETLINK_TYPE_U8 },
810         [IFLA_PORT_RESPONSE]      = { .type = NETLINK_TYPE_U16 },
811 };
812 
813 DEFINE_TYPE_SYSTEM(rtnl_vf_port);
814 
815 static const NLType rtnl_vf_ports_types[] = {
816         [IFLA_VF_PORT] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_vf_port_type_system },
817 };
818 
819 DEFINE_TYPE_SYSTEM(rtnl_vf_ports);
820 
821 static const NLType rtnl_xdp_types[] = {
822         [IFLA_XDP_FD]          = { .type = NETLINK_TYPE_S32 },
823         [IFLA_XDP_ATTACHED]    = { .type = NETLINK_TYPE_U8 },
824         [IFLA_XDP_FLAGS]       = { .type = NETLINK_TYPE_U32 },
825         [IFLA_XDP_PROG_ID]     = { .type = NETLINK_TYPE_U32 },
826         [IFLA_XDP_DRV_PROG_ID] = { .type = NETLINK_TYPE_U32 },
827         [IFLA_XDP_SKB_PROG_ID] = { .type = NETLINK_TYPE_U32 },
828         [IFLA_XDP_HW_PROG_ID]  = { .type = NETLINK_TYPE_U32 },
829         [IFLA_XDP_EXPECTED_FD] = { .type = NETLINK_TYPE_S32 },
830 };
831 
832 DEFINE_TYPE_SYSTEM(rtnl_xdp);
833 
834 static const NLType rtnl_proto_down_reason_types[] = {
835         [IFLA_PROTO_DOWN_REASON_MASK]  = { .type = NETLINK_TYPE_U32 },
836         [IFLA_PROTO_DOWN_REASON_VALUE] = { .type = NETLINK_TYPE_U32 },
837 };
838 
839 DEFINE_TYPE_SYSTEM(rtnl_proto_down_reason);
840 
841 static const NLType rtnl_link_types[] = {
842         [IFLA_ADDRESS]             = { .type = NETLINK_TYPE_ETHER_ADDR },
843         [IFLA_BROADCAST]           = { .type = NETLINK_TYPE_ETHER_ADDR },
844         [IFLA_IFNAME]              = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ - 1 },
845         [IFLA_MTU]                 = { .type = NETLINK_TYPE_U32 },
846         [IFLA_LINK]                = { .type = NETLINK_TYPE_U32 },
847         [IFLA_QDISC]               = { .type = NETLINK_TYPE_STRING },
848         [IFLA_STATS]               = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct rtnl_link_stats) },
849         [IFLA_COST]                = { /* Not used. */ },
850         [IFLA_PRIORITY]            = { /* Not used. */ },
851         [IFLA_MASTER]              = { .type = NETLINK_TYPE_U32 },
852         [IFLA_WIRELESS]            = { /* Used only by wext. */ },
853         [IFLA_PROTINFO]            = { .type = NETLINK_TYPE_UNION, .type_system_union = &rtnl_prot_info_type_system_union },
854         [IFLA_TXQLEN]              = { .type = NETLINK_TYPE_U32 },
855         [IFLA_MAP]                 = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct rtnl_link_ifmap) },
856         [IFLA_WEIGHT]              = { .type = NETLINK_TYPE_U32 },
857         [IFLA_OPERSTATE]           = { .type = NETLINK_TYPE_U8 },
858         [IFLA_LINKMODE]            = { .type = NETLINK_TYPE_U8 },
859         [IFLA_LINKINFO]            = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_info_type_system },
860         [IFLA_NET_NS_PID]          = { .type = NETLINK_TYPE_U32 },
861         [IFLA_IFALIAS]             = { .type = NETLINK_TYPE_STRING, .size = IFALIASZ - 1 },
862         [IFLA_NUM_VF]              = { .type = NETLINK_TYPE_U32 },
863         [IFLA_VFINFO_LIST]         = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_vfinfo_list_type_system },
864         [IFLA_STATS64]             = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct rtnl_link_stats64) },
865         [IFLA_VF_PORTS]            = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_vf_ports_type_system },
866         [IFLA_PORT_SELF]           = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_vf_port_type_system },
867         [IFLA_AF_SPEC]             = { .type = NETLINK_TYPE_UNION, .type_system_union = &rtnl_af_spec_type_system_union },
868         [IFLA_GROUP]               = { .type = NETLINK_TYPE_U32 },
869         [IFLA_NET_NS_FD]           = { .type = NETLINK_TYPE_U32 },
870         [IFLA_EXT_MASK]            = { .type = NETLINK_TYPE_U32 },
871         [IFLA_PROMISCUITY]         = { .type = NETLINK_TYPE_U32 },
872         [IFLA_NUM_TX_QUEUES]       = { .type = NETLINK_TYPE_U32 },
873         [IFLA_NUM_RX_QUEUES]       = { .type = NETLINK_TYPE_U32 },
874         [IFLA_CARRIER]             = { .type = NETLINK_TYPE_U8 },
875         [IFLA_PHYS_PORT_ID]        = { .type = NETLINK_TYPE_BINARY, .size = MAX_PHYS_ITEM_ID_LEN },
876         [IFLA_CARRIER_CHANGES]     = { .type = NETLINK_TYPE_U32 },
877         [IFLA_PHYS_SWITCH_ID]      = { .type = NETLINK_TYPE_BINARY, .size = MAX_PHYS_ITEM_ID_LEN },
878         [IFLA_LINK_NETNSID]        = { .type = NETLINK_TYPE_S32 },
879         [IFLA_PHYS_PORT_NAME]      = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ - 1 },
880         [IFLA_PROTO_DOWN]          = { .type = NETLINK_TYPE_U8 },
881         [IFLA_GSO_MAX_SEGS]        = { .type = NETLINK_TYPE_U32 },
882         [IFLA_GSO_MAX_SIZE]        = { .type = NETLINK_TYPE_U32 },
883         [IFLA_XDP]                 = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_xdp_type_system },
884         [IFLA_EVENT]               = { .type = NETLINK_TYPE_U32 },
885         [IFLA_NEW_NETNSID]         = { .type = NETLINK_TYPE_S32 },
886         [IFLA_TARGET_NETNSID]      = { .type = NETLINK_TYPE_S32 },
887         [IFLA_CARRIER_UP_COUNT]    = { .type = NETLINK_TYPE_U32 },
888         [IFLA_CARRIER_DOWN_COUNT]  = { .type = NETLINK_TYPE_U32 },
889         [IFLA_NEW_IFINDEX]         = { .type = NETLINK_TYPE_S32 },
890         [IFLA_MIN_MTU]             = { .type = NETLINK_TYPE_U32 },
891         [IFLA_MAX_MTU]             = { .type = NETLINK_TYPE_U32 },
892         [IFLA_PROP_LIST]           = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_prop_list_type_system },
893         [IFLA_ALT_IFNAME]          = { .type = NETLINK_TYPE_STRING, .size = ALTIFNAMSIZ - 1 },
894         [IFLA_PERM_ADDRESS]        = { .type = NETLINK_TYPE_ETHER_ADDR },
895         [IFLA_PROTO_DOWN_REASON]   = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_proto_down_reason_type_system },
896         [IFLA_PARENT_DEV_NAME]     = { .type = NETLINK_TYPE_STRING, },
897         [IFLA_PARENT_DEV_BUS_NAME] = { .type = NETLINK_TYPE_STRING, },
898 };
899 
900 DEFINE_TYPE_SYSTEM(rtnl_link);
901 
902 /* IFA_FLAGS was defined in kernel 3.14, but we still support older
903  * kernels where IFA_MAX is lower. */
904 static const NLType rtnl_address_types[] = {
905         [IFA_ADDRESS]           = { .type = NETLINK_TYPE_IN_ADDR },
906         [IFA_LOCAL]             = { .type = NETLINK_TYPE_IN_ADDR },
907         [IFA_LABEL]             = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ - 1 },
908         [IFA_BROADCAST]         = { .type = NETLINK_TYPE_IN_ADDR },
909         [IFA_ANYCAST]           = { .type = NETLINK_TYPE_IN_ADDR },
910         [IFA_CACHEINFO]         = { .type = NETLINK_TYPE_CACHE_INFO, .size = sizeof(struct ifa_cacheinfo) },
911         [IFA_MULTICAST]         = { .type = NETLINK_TYPE_IN_ADDR },
912         [IFA_FLAGS]             = { .type = NETLINK_TYPE_U32 },
913         [IFA_RT_PRIORITY]       = { .type = NETLINK_TYPE_U32 },
914         [IFA_TARGET_NETNSID]    = { .type = NETLINK_TYPE_S32 },
915 };
916 
917 DEFINE_TYPE_SYSTEM(rtnl_address);
918 
919 /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
920 
921 static const NLType rtnl_route_metrics_types[] = {
922         [RTAX_MTU]                = { .type = NETLINK_TYPE_U32 },
923         [RTAX_WINDOW]             = { .type = NETLINK_TYPE_U32 },
924         [RTAX_RTT]                = { .type = NETLINK_TYPE_U32 },
925         [RTAX_RTTVAR]             = { .type = NETLINK_TYPE_U32 },
926         [RTAX_SSTHRESH]           = { .type = NETLINK_TYPE_U32 },
927         [RTAX_CWND]               = { .type = NETLINK_TYPE_U32 },
928         [RTAX_ADVMSS]             = { .type = NETLINK_TYPE_U32 },
929         [RTAX_REORDERING]         = { .type = NETLINK_TYPE_U32 },
930         [RTAX_HOPLIMIT]           = { .type = NETLINK_TYPE_U32 },
931         [RTAX_INITCWND]           = { .type = NETLINK_TYPE_U32 },
932         [RTAX_FEATURES]           = { .type = NETLINK_TYPE_U32 },
933         [RTAX_RTO_MIN]            = { .type = NETLINK_TYPE_U32 },
934         [RTAX_INITRWND]           = { .type = NETLINK_TYPE_U32 },
935         [RTAX_QUICKACK]           = { .type = NETLINK_TYPE_U32 },
936         [RTAX_CC_ALGO]            = { .type = NETLINK_TYPE_U32 },
937         [RTAX_FASTOPEN_NO_COOKIE] = { .type = NETLINK_TYPE_U32 },
938 };
939 
940 DEFINE_TYPE_SYSTEM(rtnl_route_metrics);
941 
942 static const NLType rtnl_route_types[] = {
943         [RTA_DST]               = { .type = NETLINK_TYPE_IN_ADDR }, /* 6? */
944         [RTA_SRC]               = { .type = NETLINK_TYPE_IN_ADDR }, /* 6? */
945         [RTA_IIF]               = { .type = NETLINK_TYPE_U32 },
946         [RTA_OIF]               = { .type = NETLINK_TYPE_U32 },
947         [RTA_GATEWAY]           = { .type = NETLINK_TYPE_IN_ADDR },
948         [RTA_PRIORITY]          = { .type = NETLINK_TYPE_U32 },
949         [RTA_PREFSRC]           = { .type = NETLINK_TYPE_IN_ADDR }, /* 6? */
950         [RTA_METRICS]           = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_metrics_type_system },
951         [RTA_MULTIPATH]         = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct rtnexthop) },
952         [RTA_FLOW]              = { .type = NETLINK_TYPE_U32 }, /* 6? */
953         [RTA_CACHEINFO]         = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct rta_cacheinfo) },
954         [RTA_TABLE]             = { .type = NETLINK_TYPE_U32 },
955         [RTA_MARK]              = { .type = NETLINK_TYPE_U32 },
956         [RTA_MFC_STATS]         = { .type = NETLINK_TYPE_U64 },
957         [RTA_VIA]               = { /* See struct rtvia */ },
958         [RTA_NEWDST]            = { .type = NETLINK_TYPE_U32 },
959         [RTA_PREF]              = { .type = NETLINK_TYPE_U8 },
960         [RTA_ENCAP_TYPE]        = { .type = NETLINK_TYPE_U16 },
961         [RTA_ENCAP]             = { .type = NETLINK_TYPE_NESTED }, /* Multiple type systems i.e. LWTUNNEL_ENCAP_MPLS/LWTUNNEL_ENCAP_IP/LWTUNNEL_ENCAP_ILA etc... */
962         [RTA_EXPIRES]           = { .type = NETLINK_TYPE_U32 },
963         [RTA_UID]               = { .type = NETLINK_TYPE_U32 },
964         [RTA_TTL_PROPAGATE]     = { .type = NETLINK_TYPE_U8 },
965         [RTA_IP_PROTO]          = { .type = NETLINK_TYPE_U8 },
966         [RTA_SPORT]             = { .type = NETLINK_TYPE_U16 },
967         [RTA_DPORT]             = { .type = NETLINK_TYPE_U16 },
968         [RTA_NH_ID]             = { .type = NETLINK_TYPE_U32 },
969 };
970 
971 DEFINE_TYPE_SYSTEM(rtnl_route);
972 
973 static const NLType rtnl_neigh_types[] = {
974         [NDA_DST]               = { .type = NETLINK_TYPE_IN_ADDR },
975         [NDA_LLADDR]            = { .type = NETLINK_TYPE_ETHER_ADDR },
976         [NDA_CACHEINFO]         = { .type = NETLINK_TYPE_CACHE_INFO, .size = sizeof(struct nda_cacheinfo) },
977         [NDA_PROBES]            = { .type = NETLINK_TYPE_U32 },
978         [NDA_VLAN]              = { .type = NETLINK_TYPE_U16 },
979         [NDA_PORT]              = { .type = NETLINK_TYPE_U16 },
980         [NDA_VNI]               = { .type = NETLINK_TYPE_U32 },
981         [NDA_IFINDEX]           = { .type = NETLINK_TYPE_U32 },
982 };
983 
984 DEFINE_TYPE_SYSTEM(rtnl_neigh);
985 
986 static const NLType rtnl_addrlabel_types[] = {
987         [IFAL_ADDRESS]         = { .type = NETLINK_TYPE_IN_ADDR, .size = sizeof(struct in6_addr) },
988         [IFAL_LABEL]           = { .type = NETLINK_TYPE_U32 },
989 };
990 
991 DEFINE_TYPE_SYSTEM(rtnl_addrlabel);
992 
993 static const NLType rtnl_routing_policy_rule_types[] = {
994         [FRA_DST]                 = { .type = NETLINK_TYPE_IN_ADDR },
995         [FRA_SRC]                 = { .type = NETLINK_TYPE_IN_ADDR },
996         [FRA_IIFNAME]             = { .type = NETLINK_TYPE_STRING },
997         [FRA_GOTO]                = { .type = NETLINK_TYPE_U32 },
998         [FRA_PRIORITY]            = { .type = NETLINK_TYPE_U32 },
999         [FRA_FWMARK]              = { .type = NETLINK_TYPE_U32 },
1000         [FRA_FLOW]                = { .type = NETLINK_TYPE_U32 },
1001         [FRA_TUN_ID]              = { .type = NETLINK_TYPE_U64 },
1002         [FRA_SUPPRESS_IFGROUP]    = { .type = NETLINK_TYPE_U32 },
1003         [FRA_SUPPRESS_PREFIXLEN]  = { .type = NETLINK_TYPE_U32 },
1004         [FRA_TABLE]               = { .type = NETLINK_TYPE_U32 },
1005         [FRA_FWMASK]              = { .type = NETLINK_TYPE_U32 },
1006         [FRA_OIFNAME]             = { .type = NETLINK_TYPE_STRING },
1007         [FRA_PAD]                 = { .type = NETLINK_TYPE_U32 },
1008         [FRA_L3MDEV]              = { .type = NETLINK_TYPE_U8 },
1009         [FRA_UID_RANGE]           = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct fib_rule_uid_range) },
1010         [FRA_PROTOCOL]            = { .type = NETLINK_TYPE_U8 },
1011         [FRA_IP_PROTO]            = { .type = NETLINK_TYPE_U8 },
1012         [FRA_SPORT_RANGE]         = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct fib_rule_port_range) },
1013         [FRA_DPORT_RANGE]         = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct fib_rule_port_range) },
1014 };
1015 
1016 DEFINE_TYPE_SYSTEM(rtnl_routing_policy_rule);
1017 
1018 static const NLType rtnl_nexthop_types[] = {
1019         [NHA_ID]                  = { .type = NETLINK_TYPE_U32 },
1020         [NHA_GROUP]               = { /* array of struct nexthop_grp */ },
1021         [NHA_GROUP_TYPE]          = { .type = NETLINK_TYPE_U16 },
1022         [NHA_BLACKHOLE]           = { .type = NETLINK_TYPE_FLAG },
1023         [NHA_OIF]                 = { .type = NETLINK_TYPE_U32 },
1024         [NHA_GATEWAY]             = { .type = NETLINK_TYPE_IN_ADDR },
1025         [NHA_ENCAP_TYPE]          = { .type = NETLINK_TYPE_U16 },
1026         [NHA_ENCAP]               = { .type = NETLINK_TYPE_NESTED },
1027         [NHA_GROUPS]              = { .type = NETLINK_TYPE_FLAG },
1028         [NHA_MASTER]              = { .type = NETLINK_TYPE_U32 },
1029         [NHA_FDB]                 = { .type = NETLINK_TYPE_FLAG },
1030 };
1031 
1032 DEFINE_TYPE_SYSTEM(rtnl_nexthop);
1033 
1034 static const NLType rtnl_tca_option_data_cake_types[] = {
1035         [TCA_CAKE_BASE_RATE64]   = { .type = NETLINK_TYPE_U64 },
1036         [TCA_CAKE_DIFFSERV_MODE] = { .type = NETLINK_TYPE_U32 },
1037         [TCA_CAKE_ATM]           = { .type = NETLINK_TYPE_U32 },
1038         [TCA_CAKE_FLOW_MODE]     = { .type = NETLINK_TYPE_U32 },
1039         [TCA_CAKE_OVERHEAD]      = { .type = NETLINK_TYPE_S32 },
1040         [TCA_CAKE_RTT]           = { .type = NETLINK_TYPE_U32 },
1041         [TCA_CAKE_TARGET]        = { .type = NETLINK_TYPE_U32 },
1042         [TCA_CAKE_AUTORATE]      = { .type = NETLINK_TYPE_U32 },
1043         [TCA_CAKE_MEMORY]        = { .type = NETLINK_TYPE_U32 },
1044         [TCA_CAKE_NAT]           = { .type = NETLINK_TYPE_U32 },
1045         [TCA_CAKE_RAW]           = { .type = NETLINK_TYPE_U32 },
1046         [TCA_CAKE_WASH]          = { .type = NETLINK_TYPE_U32 },
1047         [TCA_CAKE_MPU]           = { .type = NETLINK_TYPE_U32 },
1048         [TCA_CAKE_INGRESS]       = { .type = NETLINK_TYPE_U32 },
1049         [TCA_CAKE_ACK_FILTER]    = { .type = NETLINK_TYPE_U32 },
1050         [TCA_CAKE_SPLIT_GSO]     = { .type = NETLINK_TYPE_U32 },
1051         [TCA_CAKE_FWMARK]        = { .type = NETLINK_TYPE_U32 },
1052 };
1053 
1054 static const NLType rtnl_tca_option_data_codel_types[] = {
1055         [TCA_CODEL_TARGET]        = { .type = NETLINK_TYPE_U32 },
1056         [TCA_CODEL_LIMIT]         = { .type = NETLINK_TYPE_U32 },
1057         [TCA_CODEL_INTERVAL]      = { .type = NETLINK_TYPE_U32 },
1058         [TCA_CODEL_ECN]           = { .type = NETLINK_TYPE_U32 },
1059         [TCA_CODEL_CE_THRESHOLD]  = { .type = NETLINK_TYPE_U32 },
1060 };
1061 
1062 static const NLType rtnl_tca_option_data_drr_types[] = {
1063         [TCA_DRR_QUANTUM] = { .type = NETLINK_TYPE_U32 },
1064 };
1065 
1066 static const NLType rtnl_tca_option_data_ets_quanta_types[] = {
1067         [TCA_ETS_QUANTA_BAND] = { .type = NETLINK_TYPE_U32, },
1068 };
1069 
1070 DEFINE_TYPE_SYSTEM(rtnl_tca_option_data_ets_quanta);
1071 
1072 static const NLType rtnl_tca_option_data_ets_prio_types[] = {
1073         [TCA_ETS_PRIOMAP_BAND] = { .type = NETLINK_TYPE_U8, },
1074 };
1075 
1076 DEFINE_TYPE_SYSTEM(rtnl_tca_option_data_ets_prio);
1077 
1078 static const NLType rtnl_tca_option_data_ets_types[] = {
1079         [TCA_ETS_NBANDS]      = { .type = NETLINK_TYPE_U8 },
1080         [TCA_ETS_NSTRICT]     = { .type = NETLINK_TYPE_U8 },
1081         [TCA_ETS_QUANTA]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_option_data_ets_quanta_type_system },
1082         [TCA_ETS_PRIOMAP]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_option_data_ets_prio_type_system },
1083         [TCA_ETS_QUANTA_BAND] = { .type = NETLINK_TYPE_U32 },
1084 };
1085 
1086 static const NLType rtnl_tca_option_data_fq_types[] = {
1087         [TCA_FQ_PLIMIT]             = { .type = NETLINK_TYPE_U32 },
1088         [TCA_FQ_FLOW_PLIMIT]        = { .type = NETLINK_TYPE_U32 },
1089         [TCA_FQ_QUANTUM]            = { .type = NETLINK_TYPE_U32 },
1090         [TCA_FQ_INITIAL_QUANTUM]    = { .type = NETLINK_TYPE_U32 },
1091         [TCA_FQ_RATE_ENABLE]        = { .type = NETLINK_TYPE_U32 },
1092         [TCA_FQ_FLOW_DEFAULT_RATE]  = { .type = NETLINK_TYPE_U32 },
1093         [TCA_FQ_FLOW_MAX_RATE]      = { .type = NETLINK_TYPE_U32 },
1094         [TCA_FQ_BUCKETS_LOG]        = { .type = NETLINK_TYPE_U32 },
1095         [TCA_FQ_FLOW_REFILL_DELAY]  = { .type = NETLINK_TYPE_U32 },
1096         [TCA_FQ_LOW_RATE_THRESHOLD] = { .type = NETLINK_TYPE_U32 },
1097         [TCA_FQ_CE_THRESHOLD]       = { .type = NETLINK_TYPE_U32 },
1098         [TCA_FQ_ORPHAN_MASK]        = { .type = NETLINK_TYPE_U32 },
1099 };
1100 
1101 static const NLType rtnl_tca_option_data_fq_codel_types[] = {
1102         [TCA_FQ_CODEL_TARGET]          = { .type = NETLINK_TYPE_U32 },
1103         [TCA_FQ_CODEL_LIMIT]           = { .type = NETLINK_TYPE_U32 },
1104         [TCA_FQ_CODEL_INTERVAL]        = { .type = NETLINK_TYPE_U32 },
1105         [TCA_FQ_CODEL_ECN]             = { .type = NETLINK_TYPE_U32 },
1106         [TCA_FQ_CODEL_FLOWS]           = { .type = NETLINK_TYPE_U32 },
1107         [TCA_FQ_CODEL_QUANTUM]         = { .type = NETLINK_TYPE_U32 },
1108         [TCA_FQ_CODEL_CE_THRESHOLD]    = { .type = NETLINK_TYPE_U32 },
1109         [TCA_FQ_CODEL_DROP_BATCH_SIZE] = { .type = NETLINK_TYPE_U32 },
1110         [TCA_FQ_CODEL_MEMORY_LIMIT]    = { .type = NETLINK_TYPE_U32 },
1111 };
1112 
1113 static const NLType rtnl_tca_option_data_fq_pie_types[] = {
1114         [TCA_FQ_PIE_LIMIT]   = { .type = NETLINK_TYPE_U32 },
1115 };
1116 
1117 static const NLType rtnl_tca_option_data_gred_types[] = {
1118         [TCA_GRED_DPS] = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct tc_gred_sopt) },
1119 };
1120 
1121 static const NLType rtnl_tca_option_data_hhf_types[] = {
1122         [TCA_HHF_BACKLOG_LIMIT] = { .type = NETLINK_TYPE_U32 },
1123 };
1124 
1125 static const NLType rtnl_tca_option_data_htb_types[] = {
1126         [TCA_HTB_PARMS]  = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct tc_htb_opt) },
1127         [TCA_HTB_INIT]   = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct tc_htb_glob) },
1128         [TCA_HTB_CTAB]   = { .type = NETLINK_TYPE_BINARY, .size = TC_RTAB_SIZE },
1129         [TCA_HTB_RTAB]   = { .type = NETLINK_TYPE_BINARY, .size = TC_RTAB_SIZE },
1130         [TCA_HTB_RATE64] = { .type = NETLINK_TYPE_U64 },
1131         [TCA_HTB_CEIL64] = { .type = NETLINK_TYPE_U64 },
1132 };
1133 
1134 static const NLType rtnl_tca_option_data_pie_types[] = {
1135         [TCA_PIE_LIMIT]   = { .type = NETLINK_TYPE_U32 },
1136 };
1137 
1138 static const NLType rtnl_tca_option_data_qfq_types[] = {
1139         [TCA_QFQ_WEIGHT] = { .type = NETLINK_TYPE_U32 },
1140         [TCA_QFQ_LMAX]   = { .type = NETLINK_TYPE_U32 },
1141 };
1142 
1143 static const NLType rtnl_tca_option_data_sfb_types[] = {
1144         [TCA_SFB_PARMS] = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct tc_sfb_qopt) },
1145 };
1146 
1147 static const NLType rtnl_tca_option_data_tbf_types[] = {
1148         [TCA_TBF_PARMS]   = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct tc_tbf_qopt) },
1149         [TCA_TBF_RTAB]    = { .type = NETLINK_TYPE_BINARY, .size = TC_RTAB_SIZE },
1150         [TCA_TBF_PTAB]    = { .type = NETLINK_TYPE_BINARY, .size = TC_RTAB_SIZE },
1151         [TCA_TBF_RATE64]  = { .type = NETLINK_TYPE_U64 },
1152         [TCA_TBF_PRATE64] = { .type = NETLINK_TYPE_U64 },
1153         [TCA_TBF_BURST]   = { .type = NETLINK_TYPE_U32 },
1154         [TCA_TBF_PBURST]  = { .type = NETLINK_TYPE_U32 },
1155 };
1156 
1157 static const NLTypeSystemUnionElement rtnl_tca_option_data_type_systems[] = {
1158         { .name = "cake",     .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_tca_option_data_cake),     },
1159         { .name = "codel",    .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_tca_option_data_codel),    },
1160         { .name = "drr",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_tca_option_data_drr),      },
1161         { .name = "ets",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_tca_option_data_ets),      },
1162         { .name = "fq",       .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_tca_option_data_fq),       },
1163         { .name = "fq_codel", .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_tca_option_data_fq_codel), },
1164         { .name = "fq_pie",   .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_tca_option_data_fq_pie),   },
1165         { .name = "gred",     .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_tca_option_data_gred),     },
1166         { .name = "hhf",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_tca_option_data_hhf),      },
1167         { .name = "htb",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_tca_option_data_htb),      },
1168         { .name = "pie",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_tca_option_data_pie),      },
1169         { .name = "qfq",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_tca_option_data_qfq),      },
1170         { .name = "sfb",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_tca_option_data_sfb),      },
1171         { .name = "tbf",      .type_system = TYPE_SYSTEM_FROM_TYPE(rtnl_tca_option_data_tbf),      },
1172 };
1173 
1174 DEFINE_TYPE_SYSTEM_UNION_MATCH_SIBLING(rtnl_tca_option_data, TCA_KIND);
1175 
1176 static const NLType rtnl_tca_types[] = {
1177         [TCA_KIND]           = { .type = NETLINK_TYPE_STRING },
1178         [TCA_OPTIONS]        = { .type = NETLINK_TYPE_UNION, .type_system_union = &rtnl_tca_option_data_type_system_union },
1179         [TCA_INGRESS_BLOCK]  = { .type = NETLINK_TYPE_U32 },
1180         [TCA_EGRESS_BLOCK]   = { .type = NETLINK_TYPE_U32 },
1181 };
1182 
1183 DEFINE_TYPE_SYSTEM(rtnl_tca);
1184 
1185 static const NLType rtnl_mdb_types[] = {
1186         [MDBA_SET_ENTRY]     = { .type = NETLINK_TYPE_BINARY, .size = sizeof(struct br_port_msg) },
1187 };
1188 
1189 DEFINE_TYPE_SYSTEM(rtnl_mdb);
1190 
1191 static const NLType rtnl_types[] = {
1192         [RTM_NEWLINK]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system,                .size = sizeof(struct ifinfomsg) },
1193         [RTM_DELLINK]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system,                .size = sizeof(struct ifinfomsg) },
1194         [RTM_GETLINK]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system,                .size = sizeof(struct ifinfomsg) },
1195         [RTM_SETLINK]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system,                .size = sizeof(struct ifinfomsg) },
1196         [RTM_NEWLINKPROP]  = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system,                .size = sizeof(struct ifinfomsg) },
1197         [RTM_DELLINKPROP]  = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system,                .size = sizeof(struct ifinfomsg) },
1198         [RTM_GETLINKPROP]  = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system,                .size = sizeof(struct ifinfomsg) },
1199         [RTM_NEWADDR]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system,             .size = sizeof(struct ifaddrmsg) },
1200         [RTM_DELADDR]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system,             .size = sizeof(struct ifaddrmsg) },
1201         [RTM_GETADDR]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system,             .size = sizeof(struct ifaddrmsg) },
1202         [RTM_NEWROUTE]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_type_system,               .size = sizeof(struct rtmsg) },
1203         [RTM_DELROUTE]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_type_system,               .size = sizeof(struct rtmsg) },
1204         [RTM_GETROUTE]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_type_system,               .size = sizeof(struct rtmsg) },
1205         [RTM_NEWNEIGH]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_neigh_type_system,               .size = sizeof(struct ndmsg) },
1206         [RTM_DELNEIGH]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_neigh_type_system,               .size = sizeof(struct ndmsg) },
1207         [RTM_GETNEIGH]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_neigh_type_system,               .size = sizeof(struct ndmsg) },
1208         [RTM_NEWADDRLABEL] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_addrlabel_type_system,           .size = sizeof(struct ifaddrlblmsg) },
1209         [RTM_DELADDRLABEL] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_addrlabel_type_system,           .size = sizeof(struct ifaddrlblmsg) },
1210         [RTM_GETADDRLABEL] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_addrlabel_type_system,           .size = sizeof(struct ifaddrlblmsg) },
1211         [RTM_NEWRULE]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_routing_policy_rule_type_system, .size = sizeof(struct fib_rule_hdr) },
1212         [RTM_DELRULE]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_routing_policy_rule_type_system, .size = sizeof(struct fib_rule_hdr) },
1213         [RTM_GETRULE]      = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_routing_policy_rule_type_system, .size = sizeof(struct fib_rule_hdr) },
1214         [RTM_NEWNEXTHOP]   = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_nexthop_type_system,             .size = sizeof(struct nhmsg) },
1215         [RTM_DELNEXTHOP]   = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_nexthop_type_system,             .size = sizeof(struct nhmsg) },
1216         [RTM_GETNEXTHOP]   = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_nexthop_type_system,             .size = sizeof(struct nhmsg) },
1217         [RTM_NEWQDISC]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system,                 .size = sizeof(struct tcmsg) },
1218         [RTM_DELQDISC]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system,                 .size = sizeof(struct tcmsg) },
1219         [RTM_GETQDISC]     = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system,                 .size = sizeof(struct tcmsg) },
1220         [RTM_NEWTCLASS]    = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system,                 .size = sizeof(struct tcmsg) },
1221         [RTM_DELTCLASS]    = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system,                 .size = sizeof(struct tcmsg) },
1222         [RTM_GETTCLASS]    = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system,                 .size = sizeof(struct tcmsg) },
1223         [RTM_NEWMDB]       = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_mdb_type_system,                 .size = sizeof(struct br_port_msg) },
1224         [RTM_DELMDB]       = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_mdb_type_system,                 .size = sizeof(struct br_port_msg) },
1225         [RTM_GETMDB]       = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_mdb_type_system,                 .size = sizeof(struct br_port_msg) },
1226 };
1227 
1228 DEFINE_TYPE_SYSTEM(rtnl);
1229 
rtnl_get_type(uint16_t nlmsg_type)1230 const NLType *rtnl_get_type(uint16_t nlmsg_type) {
1231         return type_system_get_type(&rtnl_type_system, nlmsg_type);
1232 }
1233