1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 #include <netinet/in.h>
5 #include <sys/socket.h>
6 #include <linux/can/vxcan.h>
7 #include <linux/netlink.h>
8 #include <linux/rtnetlink.h>
9 #include <linux/genetlink.h>
12 #include <linux/can/netlink.h>
13 #include <linux/fib_rules.h>
14 #include <linux/fou.h>
15 #include <linux/if_addr.h>
16 #include <linux/if_addrlabel.h>
17 #include <linux/if_bridge.h>
18 #include <linux/if_link.h>
19 #include <linux/if_macsec.h>
20 #include <linux/if_tunnel.h>
21 #include <linux/l2tp.h>
22 #include <linux/nexthop.h>
23 #include <linux/nl80211.h>
24 #include <linux/pkt_sched.h>
25 #include <linux/veth.h>
26 #include <linux/wireguard.h>
28 #include "sd-netlink.h"
30 #include "generic-netlink.h"
33 #include "netlink-internal.h"
34 #include "netlink-types.h"
35 #include "string-table.h"
38 /* Maximum ARP IP target defined in kernel */
39 #define BOND_MAX_ARP_TARGETS 16
57 BOND_ARP_TARGETS_MAX
= BOND_MAX_ARP_TARGETS
,
63 const NLTypeSystem
*type_system
;
64 const NLTypeSystemUnion
*type_system_union
;
72 static const NLTypeSystem rtnl_link_type_system
;
74 static const NLType empty_types
[1] = {
75 /* fake array to avoid .types==NULL, which denotes invalid type-systems */
78 static const NLTypeSystem empty_type_system
= {
83 static const NLType rtnl_link_info_data_veth_types
[] = {
84 [VETH_INFO_PEER
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
87 static const NLType rtnl_link_info_data_vxcan_types
[] = {
88 [VXCAN_INFO_PEER
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
91 static const NLType rtnl_link_info_data_ipvlan_types
[] = {
92 [IFLA_IPVLAN_MODE
] = { .type
= NETLINK_TYPE_U16
},
93 [IFLA_IPVLAN_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
96 static const NLType rtnl_macvlan_macaddr_types
[] = {
97 [IFLA_MACVLAN_MACADDR
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
100 static const NLTypeSystem rtnl_macvlan_macaddr_type_system
= {
101 .count
= ELEMENTSOF(rtnl_macvlan_macaddr_types
),
102 .types
= rtnl_macvlan_macaddr_types
,
105 static const NLType rtnl_link_info_data_macvlan_types
[] = {
106 [IFLA_MACVLAN_MODE
] = { .type
= NETLINK_TYPE_U32
},
107 [IFLA_MACVLAN_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
108 [IFLA_MACVLAN_MACADDR_MODE
] = { .type
= NETLINK_TYPE_U32
},
109 [IFLA_MACVLAN_MACADDR_DATA
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_macvlan_macaddr_type_system
},
112 static const NLType rtnl_link_info_data_bridge_types
[] = {
113 [IFLA_BR_FORWARD_DELAY
] = { .type
= NETLINK_TYPE_U32
},
114 [IFLA_BR_HELLO_TIME
] = { .type
= NETLINK_TYPE_U32
},
115 [IFLA_BR_MAX_AGE
] = { .type
= NETLINK_TYPE_U32
},
116 [IFLA_BR_AGEING_TIME
] = { .type
= NETLINK_TYPE_U32
},
117 [IFLA_BR_STP_STATE
] = { .type
= NETLINK_TYPE_U32
},
118 [IFLA_BR_PRIORITY
] = { .type
= NETLINK_TYPE_U16
},
119 [IFLA_BR_VLAN_FILTERING
] = { .type
= NETLINK_TYPE_U8
},
120 [IFLA_BR_VLAN_PROTOCOL
] = { .type
= NETLINK_TYPE_U16
},
121 [IFLA_BR_GROUP_FWD_MASK
] = { .type
= NETLINK_TYPE_U16
},
122 [IFLA_BR_ROOT_PORT
] = { .type
= NETLINK_TYPE_U16
},
123 [IFLA_BR_ROOT_PATH_COST
] = { .type
= NETLINK_TYPE_U32
},
124 [IFLA_BR_TOPOLOGY_CHANGE
] = { .type
= NETLINK_TYPE_U8
},
125 [IFLA_BR_TOPOLOGY_CHANGE_DETECTED
] = { .type
= NETLINK_TYPE_U8
},
126 [IFLA_BR_HELLO_TIMER
] = { .type
= NETLINK_TYPE_U16
},
127 [IFLA_BR_TCN_TIMER
] = { .type
= NETLINK_TYPE_U16
},
128 [IFLA_BR_TOPOLOGY_CHANGE_TIMER
] = { .type
= NETLINK_TYPE_U16
},
129 [IFLA_BR_GC_TIMER
] = { .type
= NETLINK_TYPE_U64
},
130 [IFLA_BR_GROUP_ADDR
] = { .type
= NETLINK_TYPE_U16
},
131 [IFLA_BR_FDB_FLUSH
] = { .type
= NETLINK_TYPE_U16
},
132 [IFLA_BR_MCAST_ROUTER
] = { .type
= NETLINK_TYPE_U8
},
133 [IFLA_BR_MCAST_SNOOPING
] = { .type
= NETLINK_TYPE_U8
},
134 [IFLA_BR_MCAST_QUERY_USE_IFADDR
] = { .type
= NETLINK_TYPE_U8
},
135 [IFLA_BR_MCAST_QUERIER
] = { .type
= NETLINK_TYPE_U8
},
136 [IFLA_BR_MCAST_HASH_ELASTICITY
] = { .type
= NETLINK_TYPE_U32
},
137 [IFLA_BR_MCAST_HASH_MAX
] = { .type
= NETLINK_TYPE_U16
},
138 [IFLA_BR_MCAST_LAST_MEMBER_CNT
] = { .type
= NETLINK_TYPE_U32
},
139 [IFLA_BR_MCAST_STARTUP_QUERY_CNT
] = { .type
= NETLINK_TYPE_U16
},
140 [IFLA_BR_MCAST_LAST_MEMBER_INTVL
] = { .type
= NETLINK_TYPE_U64
},
141 [IFLA_BR_MCAST_MEMBERSHIP_INTVL
] = { .type
= NETLINK_TYPE_U64
},
142 [IFLA_BR_MCAST_QUERIER_INTVL
] = { .type
= NETLINK_TYPE_U64
},
143 [IFLA_BR_MCAST_QUERY_INTVL
] = { .type
= NETLINK_TYPE_U64
},
144 [IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
] = { .type
= NETLINK_TYPE_U64
},
145 [IFLA_BR_MCAST_STARTUP_QUERY_INTVL
] = { .type
= NETLINK_TYPE_U64
},
146 [IFLA_BR_NF_CALL_IPTABLES
] = { .type
= NETLINK_TYPE_U8
},
147 [IFLA_BR_NF_CALL_IP6TABLES
] = { .type
= NETLINK_TYPE_U8
},
148 [IFLA_BR_NF_CALL_ARPTABLES
] = { .type
= NETLINK_TYPE_U8
},
149 [IFLA_BR_VLAN_DEFAULT_PVID
] = { .type
= NETLINK_TYPE_U16
},
150 [IFLA_BR_MCAST_IGMP_VERSION
] = { .type
= NETLINK_TYPE_U8
},
153 static const NLType rtnl_link_info_data_vlan_types
[] = {
154 [IFLA_VLAN_ID
] = { .type
= NETLINK_TYPE_U16
},
156 [IFLA_VLAN_FLAGS] = { .len = sizeof(struct ifla_vlan_flags) },
157 [IFLA_VLAN_EGRESS_QOS] = { .type = NETLINK_TYPE_NESTED },
158 [IFLA_VLAN_INGRESS_QOS] = { .type = NETLINK_TYPE_NESTED },
160 [IFLA_VLAN_PROTOCOL
] = { .type
= NETLINK_TYPE_U16
},
163 static const NLType rtnl_link_info_data_vxlan_types
[] = {
164 [IFLA_VXLAN_ID
] = { .type
= NETLINK_TYPE_U32
},
165 [IFLA_VXLAN_GROUP
] = { .type
= NETLINK_TYPE_IN_ADDR
},
166 [IFLA_VXLAN_LINK
] = { .type
= NETLINK_TYPE_U32
},
167 [IFLA_VXLAN_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
168 [IFLA_VXLAN_TTL
] = { .type
= NETLINK_TYPE_U8
},
169 [IFLA_VXLAN_TOS
] = { .type
= NETLINK_TYPE_U8
},
170 [IFLA_VXLAN_LEARNING
] = { .type
= NETLINK_TYPE_U8
},
171 [IFLA_VXLAN_AGEING
] = { .type
= NETLINK_TYPE_U32
},
172 [IFLA_VXLAN_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
173 [IFLA_VXLAN_PORT_RANGE
] = { .type
= NETLINK_TYPE_U32
},
174 [IFLA_VXLAN_PROXY
] = { .type
= NETLINK_TYPE_U8
},
175 [IFLA_VXLAN_RSC
] = { .type
= NETLINK_TYPE_U8
},
176 [IFLA_VXLAN_L2MISS
] = { .type
= NETLINK_TYPE_U8
},
177 [IFLA_VXLAN_L3MISS
] = { .type
= NETLINK_TYPE_U8
},
178 [IFLA_VXLAN_PORT
] = { .type
= NETLINK_TYPE_U16
},
179 [IFLA_VXLAN_GROUP6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
180 [IFLA_VXLAN_LOCAL6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
181 [IFLA_VXLAN_UDP_CSUM
] = { .type
= NETLINK_TYPE_U8
},
182 [IFLA_VXLAN_UDP_ZERO_CSUM6_TX
] = { .type
= NETLINK_TYPE_U8
},
183 [IFLA_VXLAN_UDP_ZERO_CSUM6_RX
] = { .type
= NETLINK_TYPE_U8
},
184 [IFLA_VXLAN_REMCSUM_TX
] = { .type
= NETLINK_TYPE_U8
},
185 [IFLA_VXLAN_REMCSUM_RX
] = { .type
= NETLINK_TYPE_U8
},
186 [IFLA_VXLAN_GBP
] = { .type
= NETLINK_TYPE_FLAG
},
187 [IFLA_VXLAN_REMCSUM_NOPARTIAL
] = { .type
= NETLINK_TYPE_FLAG
},
188 [IFLA_VXLAN_COLLECT_METADATA
] = { .type
= NETLINK_TYPE_U8
},
189 [IFLA_VXLAN_LABEL
] = { .type
= NETLINK_TYPE_U32
},
190 [IFLA_VXLAN_GPE
] = { .type
= NETLINK_TYPE_FLAG
},
191 [IFLA_VXLAN_TTL_INHERIT
] = { .type
= NETLINK_TYPE_FLAG
},
192 [IFLA_VXLAN_DF
] = { .type
= NETLINK_TYPE_U8
},
195 static const NLType rtnl_bond_arp_target_types
[] = {
196 [BOND_ARP_TARGETS_0
] = { .type
= NETLINK_TYPE_U32
},
197 [BOND_ARP_TARGETS_1
] = { .type
= NETLINK_TYPE_U32
},
198 [BOND_ARP_TARGETS_2
] = { .type
= NETLINK_TYPE_U32
},
199 [BOND_ARP_TARGETS_3
] = { .type
= NETLINK_TYPE_U32
},
200 [BOND_ARP_TARGETS_4
] = { .type
= NETLINK_TYPE_U32
},
201 [BOND_ARP_TARGETS_5
] = { .type
= NETLINK_TYPE_U32
},
202 [BOND_ARP_TARGETS_6
] = { .type
= NETLINK_TYPE_U32
},
203 [BOND_ARP_TARGETS_7
] = { .type
= NETLINK_TYPE_U32
},
204 [BOND_ARP_TARGETS_8
] = { .type
= NETLINK_TYPE_U32
},
205 [BOND_ARP_TARGETS_9
] = { .type
= NETLINK_TYPE_U32
},
206 [BOND_ARP_TARGETS_10
] = { .type
= NETLINK_TYPE_U32
},
207 [BOND_ARP_TARGETS_11
] = { .type
= NETLINK_TYPE_U32
},
208 [BOND_ARP_TARGETS_12
] = { .type
= NETLINK_TYPE_U32
},
209 [BOND_ARP_TARGETS_13
] = { .type
= NETLINK_TYPE_U32
},
210 [BOND_ARP_TARGETS_14
] = { .type
= NETLINK_TYPE_U32
},
211 [BOND_ARP_TARGETS_MAX
] = { .type
= NETLINK_TYPE_U32
},
214 static const NLTypeSystem rtnl_bond_arp_type_system
= {
215 .count
= ELEMENTSOF(rtnl_bond_arp_target_types
),
216 .types
= rtnl_bond_arp_target_types
,
219 static const NLType rtnl_link_info_data_bond_types
[] = {
220 [IFLA_BOND_MODE
] = { .type
= NETLINK_TYPE_U8
},
221 [IFLA_BOND_ACTIVE_SLAVE
] = { .type
= NETLINK_TYPE_U32
},
222 [IFLA_BOND_MIIMON
] = { .type
= NETLINK_TYPE_U32
},
223 [IFLA_BOND_UPDELAY
] = { .type
= NETLINK_TYPE_U32
},
224 [IFLA_BOND_DOWNDELAY
] = { .type
= NETLINK_TYPE_U32
},
225 [IFLA_BOND_USE_CARRIER
] = { .type
= NETLINK_TYPE_U8
},
226 [IFLA_BOND_ARP_INTERVAL
] = { .type
= NETLINK_TYPE_U32
},
227 [IFLA_BOND_ARP_IP_TARGET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_bond_arp_type_system
},
228 [IFLA_BOND_ARP_VALIDATE
] = { .type
= NETLINK_TYPE_U32
},
229 [IFLA_BOND_ARP_ALL_TARGETS
] = { .type
= NETLINK_TYPE_U32
},
230 [IFLA_BOND_PRIMARY
] = { .type
= NETLINK_TYPE_U32
},
231 [IFLA_BOND_PRIMARY_RESELECT
] = { .type
= NETLINK_TYPE_U8
},
232 [IFLA_BOND_FAIL_OVER_MAC
] = { .type
= NETLINK_TYPE_U8
},
233 [IFLA_BOND_XMIT_HASH_POLICY
] = { .type
= NETLINK_TYPE_U8
},
234 [IFLA_BOND_RESEND_IGMP
] = { .type
= NETLINK_TYPE_U32
},
235 [IFLA_BOND_NUM_PEER_NOTIF
] = { .type
= NETLINK_TYPE_U8
},
236 [IFLA_BOND_ALL_SLAVES_ACTIVE
] = { .type
= NETLINK_TYPE_U8
},
237 [IFLA_BOND_MIN_LINKS
] = { .type
= NETLINK_TYPE_U32
},
238 [IFLA_BOND_LP_INTERVAL
] = { .type
= NETLINK_TYPE_U32
},
239 [IFLA_BOND_PACKETS_PER_SLAVE
] = { .type
= NETLINK_TYPE_U32
},
240 [IFLA_BOND_AD_LACP_RATE
] = { .type
= NETLINK_TYPE_U8
},
241 [IFLA_BOND_AD_SELECT
] = { .type
= NETLINK_TYPE_U8
},
242 [IFLA_BOND_AD_INFO
] = { .type
= NETLINK_TYPE_NESTED
},
243 [IFLA_BOND_AD_ACTOR_SYS_PRIO
] = { .type
= NETLINK_TYPE_U16
},
244 [IFLA_BOND_AD_USER_PORT_KEY
] = { .type
= NETLINK_TYPE_U16
},
245 [IFLA_BOND_AD_ACTOR_SYSTEM
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
246 [IFLA_BOND_TLB_DYNAMIC_LB
] = { .type
= NETLINK_TYPE_U8
},
249 static const NLType rtnl_link_info_data_iptun_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_PMTUDISC
] = { .type
= NETLINK_TYPE_U8
},
256 [IFLA_IPTUN_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
257 [IFLA_IPTUN_PROTO
] = { .type
= NETLINK_TYPE_U8
},
258 [IFLA_IPTUN_6RD_PREFIX
] = { .type
= NETLINK_TYPE_IN_ADDR
},
259 [IFLA_IPTUN_6RD_RELAY_PREFIX
] = { .type
= NETLINK_TYPE_U32
},
260 [IFLA_IPTUN_6RD_PREFIXLEN
] = { .type
= NETLINK_TYPE_U16
},
261 [IFLA_IPTUN_6RD_RELAY_PREFIXLEN
] = { .type
= NETLINK_TYPE_U16
},
262 [IFLA_IPTUN_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
263 [IFLA_IPTUN_ENCAP_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
264 [IFLA_IPTUN_ENCAP_SPORT
] = { .type
= NETLINK_TYPE_U16
},
265 [IFLA_IPTUN_ENCAP_DPORT
] = { .type
= NETLINK_TYPE_U16
},
268 static const NLType rtnl_link_info_data_ipgre_types
[] = {
269 [IFLA_GRE_LINK
] = { .type
= NETLINK_TYPE_U32
},
270 [IFLA_GRE_IFLAGS
] = { .type
= NETLINK_TYPE_U16
},
271 [IFLA_GRE_OFLAGS
] = { .type
= NETLINK_TYPE_U16
},
272 [IFLA_GRE_IKEY
] = { .type
= NETLINK_TYPE_U32
},
273 [IFLA_GRE_OKEY
] = { .type
= NETLINK_TYPE_U32
},
274 [IFLA_GRE_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
275 [IFLA_GRE_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
276 [IFLA_GRE_TTL
] = { .type
= NETLINK_TYPE_U8
},
277 [IFLA_GRE_TOS
] = { .type
= NETLINK_TYPE_U8
},
278 [IFLA_GRE_PMTUDISC
] = { .type
= NETLINK_TYPE_U8
},
279 [IFLA_GRE_FLOWINFO
] = { .type
= NETLINK_TYPE_U32
},
280 [IFLA_GRE_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
281 [IFLA_GRE_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
282 [IFLA_GRE_ENCAP_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
283 [IFLA_GRE_ENCAP_SPORT
] = { .type
= NETLINK_TYPE_U16
},
284 [IFLA_GRE_ENCAP_DPORT
] = { .type
= NETLINK_TYPE_U16
},
285 [IFLA_GRE_ERSPAN_INDEX
] = { .type
= NETLINK_TYPE_U32
},
288 static const NLType rtnl_link_info_data_ipvti_types
[] = {
289 [IFLA_VTI_LINK
] = { .type
= NETLINK_TYPE_U32
},
290 [IFLA_VTI_IKEY
] = { .type
= NETLINK_TYPE_U32
},
291 [IFLA_VTI_OKEY
] = { .type
= NETLINK_TYPE_U32
},
292 [IFLA_VTI_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
293 [IFLA_VTI_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
296 static const NLType rtnl_link_info_data_ip6tnl_types
[] = {
297 [IFLA_IPTUN_LINK
] = { .type
= NETLINK_TYPE_U32
},
298 [IFLA_IPTUN_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
299 [IFLA_IPTUN_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
300 [IFLA_IPTUN_TTL
] = { .type
= NETLINK_TYPE_U8
},
301 [IFLA_IPTUN_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
302 [IFLA_IPTUN_PROTO
] = { .type
= NETLINK_TYPE_U8
},
303 [IFLA_IPTUN_ENCAP_LIMIT
] = { .type
= NETLINK_TYPE_U8
},
304 [IFLA_IPTUN_FLOWINFO
] = { .type
= NETLINK_TYPE_U32
},
307 static const NLType rtnl_link_info_data_vrf_types
[] = {
308 [IFLA_VRF_TABLE
] = { .type
= NETLINK_TYPE_U32
},
311 static const NLType rtnl_link_info_data_geneve_types
[] = {
312 [IFLA_GENEVE_ID
] = { .type
= NETLINK_TYPE_U32
},
313 [IFLA_GENEVE_TTL
] = { .type
= NETLINK_TYPE_U8
},
314 [IFLA_GENEVE_TOS
] = { .type
= NETLINK_TYPE_U8
},
315 [IFLA_GENEVE_PORT
] = { .type
= NETLINK_TYPE_U16
},
316 [IFLA_GENEVE_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
317 [IFLA_GENEVE_REMOTE6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
318 [IFLA_GENEVE_UDP_CSUM
] = { .type
= NETLINK_TYPE_U8
},
319 [IFLA_GENEVE_UDP_ZERO_CSUM6_TX
] = { .type
= NETLINK_TYPE_U8
},
320 [IFLA_GENEVE_UDP_ZERO_CSUM6_RX
] = { .type
= NETLINK_TYPE_U8
},
321 [IFLA_GENEVE_LABEL
] = { .type
= NETLINK_TYPE_U32
},
322 [IFLA_GENEVE_TTL_INHERIT
] = { .type
= NETLINK_TYPE_U8
},
323 [IFLA_GENEVE_DF
] = { .type
= NETLINK_TYPE_U8
},
326 static const NLType rtnl_link_info_data_can_types
[] = {
327 [IFLA_CAN_BITTIMING
] = { .size
= sizeof(struct can_bittiming
) },
328 [IFLA_CAN_RESTART_MS
] = { .type
= NETLINK_TYPE_U32
},
329 [IFLA_CAN_CTRLMODE
] = { .size
= sizeof(struct can_ctrlmode
) },
330 [IFLA_CAN_TERMINATION
] = { .type
= NETLINK_TYPE_U16
},
333 static const NLType rtnl_link_info_data_macsec_types
[] = {
334 [IFLA_MACSEC_SCI
] = { .type
= NETLINK_TYPE_U64
},
335 [IFLA_MACSEC_PORT
] = { .type
= NETLINK_TYPE_U16
},
336 [IFLA_MACSEC_ICV_LEN
] = { .type
= NETLINK_TYPE_U8
},
337 [IFLA_MACSEC_CIPHER_SUITE
] = { .type
= NETLINK_TYPE_U64
},
338 [IFLA_MACSEC_WINDOW
] = { .type
= NETLINK_TYPE_U32
},
339 [IFLA_MACSEC_ENCODING_SA
] = { .type
= NETLINK_TYPE_U8
},
340 [IFLA_MACSEC_ENCRYPT
] = { .type
= NETLINK_TYPE_U8
},
341 [IFLA_MACSEC_PROTECT
] = { .type
= NETLINK_TYPE_U8
},
342 [IFLA_MACSEC_INC_SCI
] = { .type
= NETLINK_TYPE_U8
},
343 [IFLA_MACSEC_ES
] = { .type
= NETLINK_TYPE_U8
},
344 [IFLA_MACSEC_SCB
] = { .type
= NETLINK_TYPE_U8
},
345 [IFLA_MACSEC_REPLAY_PROTECT
] = { .type
= NETLINK_TYPE_U8
},
346 [IFLA_MACSEC_VALIDATION
] = { .type
= NETLINK_TYPE_U8
},
349 static const NLType rtnl_link_info_data_xfrm_types
[] = {
350 [IFLA_XFRM_LINK
] = { .type
= NETLINK_TYPE_U32
},
351 [IFLA_XFRM_IF_ID
] = { .type
= NETLINK_TYPE_U32
}
354 static const NLType rtnl_link_info_data_bareudp_types
[] = {
355 [IFLA_BAREUDP_PORT
] = { .type
= NETLINK_TYPE_U16
},
356 [IFLA_BAREUDP_ETHERTYPE
] = { .type
= NETLINK_TYPE_U16
},
357 [IFLA_BAREUDP_SRCPORT_MIN
] = { .type
= NETLINK_TYPE_U16
},
358 [IFLA_BAREUDP_MULTIPROTO_MODE
] = { .type
= NETLINK_TYPE_FLAG
},
360 /* these strings must match the .kind entries in the kernel */
361 static const char* const nl_union_link_info_data_table
[] = {
362 [NL_UNION_LINK_INFO_DATA_BOND
] = "bond",
363 [NL_UNION_LINK_INFO_DATA_BRIDGE
] = "bridge",
364 [NL_UNION_LINK_INFO_DATA_VLAN
] = "vlan",
365 [NL_UNION_LINK_INFO_DATA_VETH
] = "veth",
366 [NL_UNION_LINK_INFO_DATA_DUMMY
] = "dummy",
367 [NL_UNION_LINK_INFO_DATA_MACVLAN
] = "macvlan",
368 [NL_UNION_LINK_INFO_DATA_MACVTAP
] = "macvtap",
369 [NL_UNION_LINK_INFO_DATA_IPVLAN
] = "ipvlan",
370 [NL_UNION_LINK_INFO_DATA_IPVTAP
] = "ipvtap",
371 [NL_UNION_LINK_INFO_DATA_VXLAN
] = "vxlan",
372 [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL
] = "ipip",
373 [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL
] = "gre",
374 [NL_UNION_LINK_INFO_DATA_ERSPAN
] = "erspan",
375 [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL
] = "gretap",
376 [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL
] = "ip6gre",
377 [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL
] = "ip6gretap",
378 [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL
] = "sit",
379 [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL
] = "vti",
380 [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL
] = "vti6",
381 [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL
] = "ip6tnl",
382 [NL_UNION_LINK_INFO_DATA_VRF
] = "vrf",
383 [NL_UNION_LINK_INFO_DATA_VCAN
] = "vcan",
384 [NL_UNION_LINK_INFO_DATA_GENEVE
] = "geneve",
385 [NL_UNION_LINK_INFO_DATA_VXCAN
] = "vxcan",
386 [NL_UNION_LINK_INFO_DATA_WIREGUARD
] = "wireguard",
387 [NL_UNION_LINK_INFO_DATA_NETDEVSIM
] = "netdevsim",
388 [NL_UNION_LINK_INFO_DATA_CAN
] = "can",
389 [NL_UNION_LINK_INFO_DATA_MACSEC
] = "macsec",
390 [NL_UNION_LINK_INFO_DATA_NLMON
] = "nlmon",
391 [NL_UNION_LINK_INFO_DATA_XFRM
] = "xfrm",
392 [NL_UNION_LINK_INFO_DATA_IFB
] = "ifb",
393 [NL_UNION_LINK_INFO_DATA_BAREUDP
] = "bareudp",
396 DEFINE_STRING_TABLE_LOOKUP(nl_union_link_info_data
, NLUnionLinkInfoData
);
398 static const NLTypeSystem rtnl_link_info_data_type_systems
[] = {
399 [NL_UNION_LINK_INFO_DATA_BOND
] = { .count
= ELEMENTSOF(rtnl_link_info_data_bond_types
),
400 .types
= rtnl_link_info_data_bond_types
},
401 [NL_UNION_LINK_INFO_DATA_BRIDGE
] = { .count
= ELEMENTSOF(rtnl_link_info_data_bridge_types
),
402 .types
= rtnl_link_info_data_bridge_types
},
403 [NL_UNION_LINK_INFO_DATA_VLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vlan_types
),
404 .types
= rtnl_link_info_data_vlan_types
},
405 [NL_UNION_LINK_INFO_DATA_VETH
] = { .count
= ELEMENTSOF(rtnl_link_info_data_veth_types
),
406 .types
= rtnl_link_info_data_veth_types
},
407 [NL_UNION_LINK_INFO_DATA_MACVLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_macvlan_types
),
408 .types
= rtnl_link_info_data_macvlan_types
},
409 [NL_UNION_LINK_INFO_DATA_MACVTAP
] = { .count
= ELEMENTSOF(rtnl_link_info_data_macvlan_types
),
410 .types
= rtnl_link_info_data_macvlan_types
},
411 [NL_UNION_LINK_INFO_DATA_IPVLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvlan_types
),
412 .types
= rtnl_link_info_data_ipvlan_types
},
413 [NL_UNION_LINK_INFO_DATA_IPVTAP
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvlan_types
),
414 .types
= rtnl_link_info_data_ipvlan_types
},
415 [NL_UNION_LINK_INFO_DATA_VXLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vxlan_types
),
416 .types
= rtnl_link_info_data_vxlan_types
},
417 [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_iptun_types
),
418 .types
= rtnl_link_info_data_iptun_types
},
419 [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
420 .types
= rtnl_link_info_data_ipgre_types
},
421 [NL_UNION_LINK_INFO_DATA_ERSPAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
422 .types
= rtnl_link_info_data_ipgre_types
},
423 [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
424 .types
= rtnl_link_info_data_ipgre_types
},
425 [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
426 .types
= rtnl_link_info_data_ipgre_types
},
427 [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
428 .types
= rtnl_link_info_data_ipgre_types
},
429 [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_iptun_types
),
430 .types
= rtnl_link_info_data_iptun_types
},
431 [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvti_types
),
432 .types
= rtnl_link_info_data_ipvti_types
},
433 [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvti_types
),
434 .types
= rtnl_link_info_data_ipvti_types
},
435 [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ip6tnl_types
),
436 .types
= rtnl_link_info_data_ip6tnl_types
},
437 [NL_UNION_LINK_INFO_DATA_VRF
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vrf_types
),
438 .types
= rtnl_link_info_data_vrf_types
},
439 [NL_UNION_LINK_INFO_DATA_GENEVE
] = { .count
= ELEMENTSOF(rtnl_link_info_data_geneve_types
),
440 .types
= rtnl_link_info_data_geneve_types
},
441 [NL_UNION_LINK_INFO_DATA_VXCAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vxcan_types
),
442 .types
= rtnl_link_info_data_vxcan_types
},
443 [NL_UNION_LINK_INFO_DATA_CAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_can_types
),
444 .types
= rtnl_link_info_data_can_types
},
445 [NL_UNION_LINK_INFO_DATA_MACSEC
] = { .count
= ELEMENTSOF(rtnl_link_info_data_macsec_types
),
446 .types
= rtnl_link_info_data_macsec_types
},
447 [NL_UNION_LINK_INFO_DATA_XFRM
] = { .count
= ELEMENTSOF(rtnl_link_info_data_xfrm_types
),
448 .types
= rtnl_link_info_data_xfrm_types
},
449 [NL_UNION_LINK_INFO_DATA_BAREUDP
] = { .count
= ELEMENTSOF(rtnl_link_info_data_bareudp_types
),
450 .types
= rtnl_link_info_data_bareudp_types
},
453 static const NLTypeSystemUnion rtnl_link_info_data_type_system_union
= {
454 .num
= _NL_UNION_LINK_INFO_DATA_MAX
,
455 .lookup
= nl_union_link_info_data_from_string
,
456 .type_systems
= rtnl_link_info_data_type_systems
,
457 .match_type
= NL_MATCH_SIBLING
,
458 .match
= IFLA_INFO_KIND
,
461 static const NLType rtnl_link_info_types
[] = {
462 [IFLA_INFO_KIND
] = { .type
= NETLINK_TYPE_STRING
},
463 [IFLA_INFO_DATA
] = { .type
= NETLINK_TYPE_UNION
, .type_system_union
= &rtnl_link_info_data_type_system_union
},
466 [IFLA_INFO_SLAVE_KIND] = { .type = NETLINK_TYPE_STRING },
467 [IFLA_INFO_SLAVE_DATA] = { .type = NETLINK_TYPE_NESTED },
471 static const NLTypeSystem rtnl_link_info_type_system
= {
472 .count
= ELEMENTSOF(rtnl_link_info_types
),
473 .types
= rtnl_link_info_types
,
476 static const struct NLType rtnl_prot_info_bridge_port_types
[] = {
477 [IFLA_BRPORT_STATE
] = { .type
= NETLINK_TYPE_U8
},
478 [IFLA_BRPORT_COST
] = { .type
= NETLINK_TYPE_U32
},
479 [IFLA_BRPORT_PRIORITY
] = { .type
= NETLINK_TYPE_U16
},
480 [IFLA_BRPORT_MODE
] = { .type
= NETLINK_TYPE_U8
},
481 [IFLA_BRPORT_GUARD
] = { .type
= NETLINK_TYPE_U8
},
482 [IFLA_BRPORT_PROTECT
] = { .type
= NETLINK_TYPE_U8
},
483 [IFLA_BRPORT_FAST_LEAVE
] = { .type
= NETLINK_TYPE_U8
},
484 [IFLA_BRPORT_LEARNING
] = { .type
= NETLINK_TYPE_U8
},
485 [IFLA_BRPORT_UNICAST_FLOOD
] = { .type
= NETLINK_TYPE_U8
},
486 [IFLA_BRPORT_PROXYARP
] = { .type
= NETLINK_TYPE_U8
},
487 [IFLA_BRPORT_LEARNING_SYNC
] = { .type
= NETLINK_TYPE_U8
},
488 [IFLA_BRPORT_PROXYARP_WIFI
] = { .type
= NETLINK_TYPE_U8
},
489 [IFLA_BRPORT_ROOT_ID
] = { .type
= NETLINK_TYPE_U8
},
490 [IFLA_BRPORT_BRIDGE_ID
] = { .type
= NETLINK_TYPE_U8
},
491 [IFLA_BRPORT_DESIGNATED_PORT
] = { .type
= NETLINK_TYPE_U16
},
492 [IFLA_BRPORT_DESIGNATED_COST
] = { .type
= NETLINK_TYPE_U16
},
493 [IFLA_BRPORT_ID
] = { .type
= NETLINK_TYPE_U16
},
494 [IFLA_BRPORT_NO
] = { .type
= NETLINK_TYPE_U16
},
495 [IFLA_BRPORT_TOPOLOGY_CHANGE_ACK
] = { .type
= NETLINK_TYPE_U8
},
496 [IFLA_BRPORT_CONFIG_PENDING
] = { .type
= NETLINK_TYPE_U8
},
497 [IFLA_BRPORT_MESSAGE_AGE_TIMER
] = { .type
= NETLINK_TYPE_U64
},
498 [IFLA_BRPORT_FORWARD_DELAY_TIMER
] = { .type
= NETLINK_TYPE_U64
},
499 [IFLA_BRPORT_HOLD_TIMER
] = { .type
= NETLINK_TYPE_U64
},
500 [IFLA_BRPORT_FLUSH
] = { .type
= NETLINK_TYPE_U8
},
501 [IFLA_BRPORT_MULTICAST_ROUTER
] = { .type
= NETLINK_TYPE_U8
},
502 [IFLA_BRPORT_PAD
] = { .type
= NETLINK_TYPE_U8
},
503 [IFLA_BRPORT_MCAST_FLOOD
] = { .type
= NETLINK_TYPE_U8
},
504 [IFLA_BRPORT_MCAST_TO_UCAST
] = { .type
= NETLINK_TYPE_U8
},
505 [IFLA_BRPORT_VLAN_TUNNEL
] = { .type
= NETLINK_TYPE_U8
},
506 [IFLA_BRPORT_BCAST_FLOOD
] = { .type
= NETLINK_TYPE_U8
},
507 [IFLA_BRPORT_GROUP_FWD_MASK
] = { .type
= NETLINK_TYPE_U16
},
508 [IFLA_BRPORT_NEIGH_SUPPRESS
] = { .type
= NETLINK_TYPE_U8
},
509 [IFLA_BRPORT_ISOLATED
] = { .type
= NETLINK_TYPE_U8
},
510 [IFLA_BRPORT_BACKUP_PORT
] = { .type
= NETLINK_TYPE_U32
},
513 static const NLTypeSystem rtnl_prot_info_type_systems
[] = {
514 [AF_BRIDGE
] = { .count
= ELEMENTSOF(rtnl_prot_info_bridge_port_types
),
515 .types
= rtnl_prot_info_bridge_port_types
},
518 static const NLTypeSystemUnion rtnl_prot_info_type_system_union
= {
520 .type_systems
= rtnl_prot_info_type_systems
,
521 .match_type
= NL_MATCH_PROTOCOL
,
524 static const struct NLType rtnl_af_spec_inet6_types
[] = {
525 [IFLA_INET6_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
530 IFLA_INET6_CACHEINFO,
531 IFLA_INET6_ICMP6STATS,
533 [IFLA_INET6_TOKEN
] = { .type
= NETLINK_TYPE_IN_ADDR
},
534 [IFLA_INET6_ADDR_GEN_MODE
] = { .type
= NETLINK_TYPE_U8
},
537 static const NLTypeSystem rtnl_af_spec_inet6_type_system
= {
538 .count
= ELEMENTSOF(rtnl_af_spec_inet6_types
),
539 .types
= rtnl_af_spec_inet6_types
,
542 static const NLType rtnl_af_spec_types
[] = {
543 [AF_INET6
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_af_spec_inet6_type_system
},
546 static const NLTypeSystem rtnl_af_spec_type_system
= {
547 .count
= ELEMENTSOF(rtnl_af_spec_types
),
548 .types
= rtnl_af_spec_types
,
551 static const NLType rtnl_prop_list_types
[] = {
552 [IFLA_ALT_IFNAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= ALTIFNAMSIZ
- 1 },
555 static const NLTypeSystem rtnl_prop_list_type_system
= {
556 .count
= ELEMENTSOF(rtnl_prop_list_types
),
557 .types
= rtnl_prop_list_types
,
560 static const NLType rtnl_vf_vlan_list_types
[] = {
561 [IFLA_VF_VLAN_INFO
] = { .size
= sizeof(struct ifla_vf_vlan_info
) },
564 static const NLTypeSystem rtnl_vf_vlan_type_system
= {
565 .count
= ELEMENTSOF(rtnl_vf_vlan_list_types
),
566 .types
= rtnl_vf_vlan_list_types
,
569 static const NLType rtnl_vf_vlan_info_types
[] = {
570 [IFLA_VF_MAC
] = { .size
= sizeof(struct ifla_vf_mac
) },
571 [IFLA_VF_VLAN
] = { .size
= sizeof(struct ifla_vf_vlan
) },
572 [IFLA_VF_VLAN_LIST
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_vf_vlan_type_system
},
573 [IFLA_VF_TX_RATE
] = { .size
= sizeof(struct ifla_vf_tx_rate
) },
574 [IFLA_VF_SPOOFCHK
] = { .size
= sizeof(struct ifla_vf_spoofchk
) },
575 [IFLA_VF_RATE
] = { .size
= sizeof(struct ifla_vf_rate
) },
576 [IFLA_VF_LINK_STATE
] = { .size
= sizeof(struct ifla_vf_link_state
) },
577 [IFLA_VF_RSS_QUERY_EN
] = { .size
= sizeof(struct ifla_vf_rss_query_en
) },
578 [IFLA_VF_TRUST
] = { .size
= sizeof(struct ifla_vf_trust
) },
579 [IFLA_VF_IB_NODE_GUID
] = { .size
= sizeof(struct ifla_vf_guid
) },
580 [IFLA_VF_IB_PORT_GUID
] = { .size
= sizeof(struct ifla_vf_guid
) },
583 static const NLTypeSystem rtnl_vf_vlan_info_type_system
= {
584 .count
= ELEMENTSOF(rtnl_vf_vlan_info_types
),
585 .types
= rtnl_vf_vlan_info_types
,
588 static const NLType rtnl_link_io_srv_types
[] = {
589 [IFLA_VF_INFO
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_vf_vlan_info_type_system
},
592 static const NLTypeSystem rtnl_io_srv_type_system
= {
593 .count
= ELEMENTSOF(rtnl_link_io_srv_types
),
594 .types
= rtnl_link_io_srv_types
,
597 static const NLType rtnl_link_types
[] = {
598 [IFLA_ADDRESS
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
599 [IFLA_BROADCAST
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
600 [IFLA_IFNAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFNAMSIZ
- 1 },
601 [IFLA_MTU
] = { .type
= NETLINK_TYPE_U32
},
602 [IFLA_LINK
] = { .type
= NETLINK_TYPE_U32
},
603 [IFLA_QDISC
] = { .type
= NETLINK_TYPE_STRING
},
604 [IFLA_STATS
] = { .size
= sizeof(struct rtnl_link_stats
) },
609 [IFLA_MASTER
] = { .type
= NETLINK_TYPE_U32
},
613 [IFLA_PROTINFO
] = { .type
= NETLINK_TYPE_UNION
, .type_system_union
= &rtnl_prot_info_type_system_union
},
614 [IFLA_TXQLEN
] = { .type
= NETLINK_TYPE_U32
},
616 [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) },
618 [IFLA_WEIGHT
] = { .type
= NETLINK_TYPE_U32
},
619 [IFLA_OPERSTATE
] = { .type
= NETLINK_TYPE_U8
},
620 [IFLA_LINKMODE
] = { .type
= NETLINK_TYPE_U8
},
621 [IFLA_LINKINFO
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_info_type_system
},
622 [IFLA_NET_NS_PID
] = { .type
= NETLINK_TYPE_U32
},
623 [IFLA_IFALIAS
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFALIASZ
- 1 },
624 [IFLA_NUM_VF
] = { .type
= NETLINK_TYPE_U32
},
625 [IFLA_VFINFO_LIST
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_io_srv_type_system
},
626 [IFLA_STATS64
] = { .size
= sizeof(struct rtnl_link_stats64
) },
628 [IFLA_VF_PORTS] = { .type = NETLINK_TYPE_NESTED },
629 [IFLA_PORT_SELF] = { .type = NETLINK_TYPE_NESTED },
631 [IFLA_AF_SPEC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_af_spec_type_system
},
637 [IFLA_GROUP
] = { .type
= NETLINK_TYPE_U32
},
638 [IFLA_NET_NS_FD
] = { .type
= NETLINK_TYPE_U32
},
639 [IFLA_EXT_MASK
] = { .type
= NETLINK_TYPE_U32
},
640 [IFLA_PROMISCUITY
] = { .type
= NETLINK_TYPE_U32
},
641 [IFLA_NUM_TX_QUEUES
] = { .type
= NETLINK_TYPE_U32
},
642 [IFLA_NUM_RX_QUEUES
] = { .type
= NETLINK_TYPE_U32
},
643 [IFLA_CARRIER
] = { .type
= NETLINK_TYPE_U8
},
645 [IFLA_PHYS_PORT_ID] = { .type = NETLINK_TYPE_BINARY, .len = MAX_PHYS_PORT_ID_LEN },
647 [IFLA_MIN_MTU
] = { .type
= NETLINK_TYPE_U32
},
648 [IFLA_MAX_MTU
] = { .type
= NETLINK_TYPE_U32
},
649 [IFLA_PROP_LIST
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_prop_list_type_system
},
650 [IFLA_ALT_IFNAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= ALTIFNAMSIZ
- 1 },
653 static const NLTypeSystem rtnl_link_type_system
= {
654 .count
= ELEMENTSOF(rtnl_link_types
),
655 .types
= rtnl_link_types
,
658 /* IFA_FLAGS was defined in kernel 3.14, but we still support older
659 * kernels where IFA_MAX is lower. */
660 static const NLType rtnl_address_types
[] = {
661 [IFA_ADDRESS
] = { .type
= NETLINK_TYPE_IN_ADDR
},
662 [IFA_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
663 [IFA_LABEL
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFNAMSIZ
- 1 },
664 [IFA_BROADCAST
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
665 [IFA_CACHEINFO
] = { .type
= NETLINK_TYPE_CACHE_INFO
, .size
= sizeof(struct ifa_cacheinfo
) },
670 [IFA_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
673 static const NLTypeSystem rtnl_address_type_system
= {
674 .count
= ELEMENTSOF(rtnl_address_types
),
675 .types
= rtnl_address_types
,
678 /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
680 static const NLType rtnl_route_metrics_types
[] = {
681 [RTAX_MTU
] = { .type
= NETLINK_TYPE_U32
},
682 [RTAX_WINDOW
] = { .type
= NETLINK_TYPE_U32
},
683 [RTAX_RTT
] = { .type
= NETLINK_TYPE_U32
},
684 [RTAX_RTTVAR
] = { .type
= NETLINK_TYPE_U32
},
685 [RTAX_SSTHRESH
] = { .type
= NETLINK_TYPE_U32
},
686 [RTAX_CWND
] = { .type
= NETLINK_TYPE_U32
},
687 [RTAX_ADVMSS
] = { .type
= NETLINK_TYPE_U32
},
688 [RTAX_REORDERING
] = { .type
= NETLINK_TYPE_U32
},
689 [RTAX_HOPLIMIT
] = { .type
= NETLINK_TYPE_U32
},
690 [RTAX_INITCWND
] = { .type
= NETLINK_TYPE_U32
},
691 [RTAX_FEATURES
] = { .type
= NETLINK_TYPE_U32
},
692 [RTAX_RTO_MIN
] = { .type
= NETLINK_TYPE_U32
},
693 [RTAX_INITRWND
] = { .type
= NETLINK_TYPE_U32
},
694 [RTAX_QUICKACK
] = { .type
= NETLINK_TYPE_U32
},
695 [RTAX_CC_ALGO
] = { .type
= NETLINK_TYPE_U32
},
696 [RTAX_FASTOPEN_NO_COOKIE
] = { .type
= NETLINK_TYPE_U32
},
699 static const NLTypeSystem rtnl_route_metrics_type_system
= {
700 .count
= ELEMENTSOF(rtnl_route_metrics_types
),
701 .types
= rtnl_route_metrics_types
,
704 static const NLType rtnl_route_types
[] = {
705 [RTA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
706 [RTA_SRC
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
707 [RTA_IIF
] = { .type
= NETLINK_TYPE_U32
},
708 [RTA_OIF
] = { .type
= NETLINK_TYPE_U32
},
709 [RTA_GATEWAY
] = { .type
= NETLINK_TYPE_IN_ADDR
},
710 [RTA_PRIORITY
] = { .type
= NETLINK_TYPE_U32
},
711 [RTA_PREFSRC
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
712 [RTA_METRICS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_metrics_type_system
},
713 [RTA_MULTIPATH
] = { .size
= sizeof(struct rtnexthop
) },
714 [RTA_FLOW
] = { .type
= NETLINK_TYPE_U32
}, /* 6? */
715 [RTA_CACHEINFO
] = { .size
= sizeof(struct rta_cacheinfo
) },
716 [RTA_TABLE
] = { .type
= NETLINK_TYPE_U32
},
717 [RTA_MARK
] = { .type
= NETLINK_TYPE_U32
},
718 [RTA_MFC_STATS
] = { .type
= NETLINK_TYPE_U64
},
719 [RTA_VIA
] = { /* See struct rtvia */ },
720 [RTA_NEWDST
] = { .type
= NETLINK_TYPE_U32
},
721 [RTA_PREF
] = { .type
= NETLINK_TYPE_U8
},
722 [RTA_EXPIRES
] = { .type
= NETLINK_TYPE_U32
},
723 [RTA_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
724 [RTA_ENCAP
] = { .type
= NETLINK_TYPE_NESTED
}, /* Multiple type systems i.e. LWTUNNEL_ENCAP_MPLS/LWTUNNEL_ENCAP_IP/LWTUNNEL_ENCAP_ILA etc... */
725 [RTA_UID
] = { .type
= NETLINK_TYPE_U32
},
726 [RTA_TTL_PROPAGATE
] = { .type
= NETLINK_TYPE_U8
},
727 [RTA_IP_PROTO
] = { .type
= NETLINK_TYPE_U8
},
728 [RTA_SPORT
] = { .type
= NETLINK_TYPE_U16
},
729 [RTA_DPORT
] = { .type
= NETLINK_TYPE_U16
},
732 static const NLTypeSystem rtnl_route_type_system
= {
733 .count
= ELEMENTSOF(rtnl_route_types
),
734 .types
= rtnl_route_types
,
737 static const NLType rtnl_neigh_types
[] = {
738 [NDA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
},
739 [NDA_LLADDR
] = { /* struct ether_addr, struct in_addr, or struct in6_addr */ },
740 [NDA_CACHEINFO
] = { .type
= NETLINK_TYPE_CACHE_INFO
, .size
= sizeof(struct nda_cacheinfo
) },
741 [NDA_PROBES
] = { .type
= NETLINK_TYPE_U32
},
742 [NDA_VLAN
] = { .type
= NETLINK_TYPE_U16
},
743 [NDA_PORT
] = { .type
= NETLINK_TYPE_U16
},
744 [NDA_VNI
] = { .type
= NETLINK_TYPE_U32
},
745 [NDA_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
748 static const NLTypeSystem rtnl_neigh_type_system
= {
749 .count
= ELEMENTSOF(rtnl_neigh_types
),
750 .types
= rtnl_neigh_types
,
753 static const NLType rtnl_addrlabel_types
[] = {
754 [IFAL_ADDRESS
] = { .type
= NETLINK_TYPE_IN_ADDR
, .size
= sizeof(struct in6_addr
) },
755 [IFAL_LABEL
] = { .type
= NETLINK_TYPE_U32
},
758 static const NLTypeSystem rtnl_addrlabel_type_system
= {
759 .count
= ELEMENTSOF(rtnl_addrlabel_types
),
760 .types
= rtnl_addrlabel_types
,
763 static const NLType rtnl_routing_policy_rule_types
[] = {
764 [FRA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
},
765 [FRA_SRC
] = { .type
= NETLINK_TYPE_IN_ADDR
},
766 [FRA_IIFNAME
] = { .type
= NETLINK_TYPE_STRING
},
767 [FRA_GOTO
] = { .type
= NETLINK_TYPE_U32
},
768 [FRA_PRIORITY
] = { .type
= NETLINK_TYPE_U32
},
769 [FRA_FWMARK
] = { .type
= NETLINK_TYPE_U32
},
770 [FRA_FLOW
] = { .type
= NETLINK_TYPE_U32
},
771 [FRA_TUN_ID
] = { .type
= NETLINK_TYPE_U64
},
772 [FRA_SUPPRESS_IFGROUP
] = { .type
= NETLINK_TYPE_U32
},
773 [FRA_SUPPRESS_PREFIXLEN
] = { .type
= NETLINK_TYPE_U32
},
774 [FRA_TABLE
] = { .type
= NETLINK_TYPE_U32
},
775 [FRA_FWMASK
] = { .type
= NETLINK_TYPE_U32
},
776 [FRA_OIFNAME
] = { .type
= NETLINK_TYPE_STRING
},
777 [FRA_PAD
] = { .type
= NETLINK_TYPE_U32
},
778 [FRA_L3MDEV
] = { .type
= NETLINK_TYPE_U8
},
779 [FRA_UID_RANGE
] = { .size
= sizeof(struct fib_rule_uid_range
) },
780 [FRA_PROTOCOL
] = { .type
= NETLINK_TYPE_U8
},
781 [FRA_IP_PROTO
] = { .type
= NETLINK_TYPE_U8
},
782 [FRA_SPORT_RANGE
] = { .size
= sizeof(struct fib_rule_port_range
) },
783 [FRA_DPORT_RANGE
] = { .size
= sizeof(struct fib_rule_port_range
) },
786 static const NLTypeSystem rtnl_routing_policy_rule_type_system
= {
787 .count
= ELEMENTSOF(rtnl_routing_policy_rule_types
),
788 .types
= rtnl_routing_policy_rule_types
,
791 static const NLType rtnl_nexthop_types
[] = {
792 [NHA_ID
] = { .type
= NETLINK_TYPE_U32
},
793 [NHA_OIF
] = { .type
= NETLINK_TYPE_U32
},
794 [NHA_GATEWAY
] = { .type
= NETLINK_TYPE_IN_ADDR
},
797 static const NLTypeSystem rtnl_nexthop_type_system
= {
798 .count
= ELEMENTSOF(rtnl_nexthop_types
),
799 .types
= rtnl_nexthop_types
,
802 static const NLType rtnl_tca_option_data_cake_types
[] = {
803 [TCA_CAKE_BASE_RATE64
] = { .type
= NETLINK_TYPE_U64
},
804 [TCA_CAKE_OVERHEAD
] = { .type
= NETLINK_TYPE_S32
},
805 [TCA_CAKE_MPU
] = { .type
= NETLINK_TYPE_U32
},
808 static const NLType rtnl_tca_option_data_codel_types
[] = {
809 [TCA_CODEL_TARGET
] = { .type
= NETLINK_TYPE_U32
},
810 [TCA_CODEL_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
811 [TCA_CODEL_INTERVAL
] = { .type
= NETLINK_TYPE_U32
},
812 [TCA_CODEL_ECN
] = { .type
= NETLINK_TYPE_U32
},
813 [TCA_CODEL_CE_THRESHOLD
] = { .type
= NETLINK_TYPE_U32
},
816 static const NLType rtnl_tca_option_data_drr_types
[] = {
817 [TCA_DRR_QUANTUM
] = { .type
= NETLINK_TYPE_U32
},
820 static const NLType rtnl_tca_option_data_ets_quanta_types
[] = {
821 [TCA_ETS_QUANTA_BAND
] = { .type
= NETLINK_TYPE_U32
, },
824 static const NLTypeSystem rtnl_tca_option_data_ets_quanta_type_system
= {
825 .count
= ELEMENTSOF(rtnl_tca_option_data_ets_quanta_types
),
826 .types
= rtnl_tca_option_data_ets_quanta_types
,
829 static const NLType rtnl_tca_option_data_ets_prio_types
[] = {
830 [TCA_ETS_PRIOMAP_BAND
] = { .type
= NETLINK_TYPE_U8
, },
833 static const NLTypeSystem rtnl_tca_option_data_ets_prio_type_system
= {
834 .count
= ELEMENTSOF(rtnl_tca_option_data_ets_prio_types
),
835 .types
= rtnl_tca_option_data_ets_prio_types
,
838 static const NLType rtnl_tca_option_data_ets_types
[] = {
839 [TCA_ETS_NBANDS
] = { .type
= NETLINK_TYPE_U8
},
840 [TCA_ETS_NSTRICT
] = { .type
= NETLINK_TYPE_U8
},
841 [TCA_ETS_QUANTA
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_option_data_ets_quanta_type_system
},
842 [TCA_ETS_PRIOMAP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_option_data_ets_prio_type_system
},
843 [TCA_ETS_QUANTA_BAND
] = { .type
= NETLINK_TYPE_U32
},
846 static const NLType rtnl_tca_option_data_fq_types
[] = {
847 [TCA_FQ_PLIMIT
] = { .type
= NETLINK_TYPE_U32
},
848 [TCA_FQ_FLOW_PLIMIT
] = { .type
= NETLINK_TYPE_U32
},
849 [TCA_FQ_QUANTUM
] = { .type
= NETLINK_TYPE_U32
},
850 [TCA_FQ_INITIAL_QUANTUM
] = { .type
= NETLINK_TYPE_U32
},
851 [TCA_FQ_RATE_ENABLE
] = { .type
= NETLINK_TYPE_U32
},
852 [TCA_FQ_FLOW_DEFAULT_RATE
] = { .type
= NETLINK_TYPE_U32
},
853 [TCA_FQ_FLOW_MAX_RATE
] = { .type
= NETLINK_TYPE_U32
},
854 [TCA_FQ_BUCKETS_LOG
] = { .type
= NETLINK_TYPE_U32
},
855 [TCA_FQ_FLOW_REFILL_DELAY
] = { .type
= NETLINK_TYPE_U32
},
856 [TCA_FQ_LOW_RATE_THRESHOLD
] = { .type
= NETLINK_TYPE_U32
},
857 [TCA_FQ_CE_THRESHOLD
] = { .type
= NETLINK_TYPE_U32
},
858 [TCA_FQ_ORPHAN_MASK
] = { .type
= NETLINK_TYPE_U32
},
861 static const NLType rtnl_tca_option_data_fq_codel_types
[] = {
862 [TCA_FQ_CODEL_TARGET
] = { .type
= NETLINK_TYPE_U32
},
863 [TCA_FQ_CODEL_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
864 [TCA_FQ_CODEL_INTERVAL
] = { .type
= NETLINK_TYPE_U32
},
865 [TCA_FQ_CODEL_ECN
] = { .type
= NETLINK_TYPE_U32
},
866 [TCA_FQ_CODEL_FLOWS
] = { .type
= NETLINK_TYPE_U32
},
867 [TCA_FQ_CODEL_QUANTUM
] = { .type
= NETLINK_TYPE_U32
},
868 [TCA_FQ_CODEL_CE_THRESHOLD
] = { .type
= NETLINK_TYPE_U32
},
869 [TCA_FQ_CODEL_DROP_BATCH_SIZE
] = { .type
= NETLINK_TYPE_U32
},
870 [TCA_FQ_CODEL_MEMORY_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
873 static const NLType rtnl_tca_option_data_fq_pie_types
[] = {
874 [TCA_FQ_PIE_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
877 static const NLType rtnl_tca_option_data_gred_types
[] = {
878 [TCA_GRED_DPS
] = { .size
= sizeof(struct tc_gred_sopt
) },
881 static const NLType rtnl_tca_option_data_hhf_types
[] = {
882 [TCA_HHF_BACKLOG_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
885 static const NLType rtnl_tca_option_data_htb_types
[] = {
886 [TCA_HTB_PARMS
] = { .size
= sizeof(struct tc_htb_opt
) },
887 [TCA_HTB_INIT
] = { .size
= sizeof(struct tc_htb_glob
) },
888 [TCA_HTB_CTAB
] = { .size
= TC_RTAB_SIZE
},
889 [TCA_HTB_RTAB
] = { .size
= TC_RTAB_SIZE
},
890 [TCA_HTB_RATE64
] = { .type
= NETLINK_TYPE_U64
},
891 [TCA_HTB_CEIL64
] = { .type
= NETLINK_TYPE_U64
},
894 static const NLType rtnl_tca_option_data_pie_types
[] = {
895 [TCA_PIE_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
898 static const NLType rtnl_tca_option_data_qfq_types
[] = {
899 [TCA_QFQ_WEIGHT
] = { .type
= NETLINK_TYPE_U32
},
900 [TCA_QFQ_LMAX
] = { .type
= NETLINK_TYPE_U32
},
903 static const NLType rtnl_tca_option_data_sfb_types
[] = {
904 [TCA_SFB_PARMS
] = { .size
= sizeof(struct tc_sfb_qopt
) },
907 static const NLType rtnl_tca_option_data_tbf_types
[] = {
908 [TCA_TBF_PARMS
] = { .size
= sizeof(struct tc_tbf_qopt
) },
909 [TCA_TBF_RTAB
] = { .size
= TC_RTAB_SIZE
},
910 [TCA_TBF_PTAB
] = { .size
= TC_RTAB_SIZE
},
911 [TCA_TBF_RATE64
] = { .type
= NETLINK_TYPE_U64
},
912 [TCA_TBF_PRATE64
] = { .type
= NETLINK_TYPE_U64
},
913 [TCA_TBF_BURST
] = { .type
= NETLINK_TYPE_U32
},
914 [TCA_TBF_PBURST
] = { .type
= NETLINK_TYPE_U32
},
917 static const char* const nl_union_tca_option_data_table
[] = {
918 [NL_UNION_TCA_OPTION_DATA_CAKE
] = "cake",
919 [NL_UNION_TCA_OPTION_DATA_CODEL
] = "codel",
920 [NL_UNION_TCA_OPTION_DATA_DRR
] = "drr",
921 [NL_UNION_TCA_OPTION_DATA_ETS
] = "ets",
922 [NL_UNION_TCA_OPTION_DATA_FQ
] = "fq",
923 [NL_UNION_TCA_OPTION_DATA_FQ_CODEL
] = "fq_codel",
924 [NL_UNION_TCA_OPTION_DATA_FQ_PIE
] = "fq_pie",
925 [NL_UNION_TCA_OPTION_DATA_GRED
] = "gred",
926 [NL_UNION_TCA_OPTION_DATA_HHF
] = "hhf",
927 [NL_UNION_TCA_OPTION_DATA_HTB
] = "htb",
928 [NL_UNION_TCA_OPTION_DATA_PIE
] = "pie",
929 [NL_UNION_TCA_OPTION_DATA_QFQ
] = "qfq",
930 [NL_UNION_TCA_OPTION_DATA_SFB
] = "sfb",
931 [NL_UNION_TCA_OPTION_DATA_TBF
] = "tbf",
934 DEFINE_STRING_TABLE_LOOKUP(nl_union_tca_option_data
, NLUnionTCAOptionData
);
936 static const NLTypeSystem rtnl_tca_option_data_type_systems
[] = {
937 [NL_UNION_TCA_OPTION_DATA_CAKE
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_cake_types
),
938 .types
= rtnl_tca_option_data_cake_types
},
939 [NL_UNION_TCA_OPTION_DATA_CODEL
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_codel_types
),
940 .types
= rtnl_tca_option_data_codel_types
},
941 [NL_UNION_TCA_OPTION_DATA_DRR
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_drr_types
),
942 .types
= rtnl_tca_option_data_drr_types
},
943 [NL_UNION_TCA_OPTION_DATA_ETS
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_ets_types
),
944 .types
= rtnl_tca_option_data_ets_types
},
945 [NL_UNION_TCA_OPTION_DATA_FQ
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_fq_types
),
946 .types
= rtnl_tca_option_data_fq_types
},
947 [NL_UNION_TCA_OPTION_DATA_FQ_CODEL
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_fq_codel_types
),
948 .types
= rtnl_tca_option_data_fq_codel_types
},
949 [NL_UNION_TCA_OPTION_DATA_FQ_PIE
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_fq_pie_types
),
950 .types
= rtnl_tca_option_data_fq_pie_types
},
951 [NL_UNION_TCA_OPTION_DATA_GRED
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_gred_types
),
952 .types
= rtnl_tca_option_data_gred_types
},
953 [NL_UNION_TCA_OPTION_DATA_HHF
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_hhf_types
),
954 .types
= rtnl_tca_option_data_hhf_types
},
955 [NL_UNION_TCA_OPTION_DATA_HTB
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_htb_types
),
956 .types
= rtnl_tca_option_data_htb_types
},
957 [NL_UNION_TCA_OPTION_DATA_PIE
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_pie_types
),
958 .types
= rtnl_tca_option_data_pie_types
},
959 [NL_UNION_TCA_OPTION_DATA_QFQ
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_qfq_types
),
960 .types
= rtnl_tca_option_data_qfq_types
},
961 [NL_UNION_TCA_OPTION_DATA_SFB
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_sfb_types
),
962 .types
= rtnl_tca_option_data_sfb_types
},
963 [NL_UNION_TCA_OPTION_DATA_TBF
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_tbf_types
),
964 .types
= rtnl_tca_option_data_tbf_types
},
967 static const NLTypeSystemUnion rtnl_tca_option_data_type_system_union
= {
968 .num
= _NL_UNION_TCA_OPTION_DATA_MAX
,
969 .lookup
= nl_union_tca_option_data_from_string
,
970 .type_systems
= rtnl_tca_option_data_type_systems
,
971 .match_type
= NL_MATCH_SIBLING
,
975 static const NLType rtnl_tca_types
[] = {
976 [TCA_KIND
] = { .type
= NETLINK_TYPE_STRING
},
977 [TCA_OPTIONS
] = { .type
= NETLINK_TYPE_UNION
, .type_system_union
= &rtnl_tca_option_data_type_system_union
},
978 [TCA_INGRESS_BLOCK
] = { .type
= NETLINK_TYPE_U32
},
979 [TCA_EGRESS_BLOCK
] = { .type
= NETLINK_TYPE_U32
},
982 static const NLTypeSystem rtnl_tca_type_system
= {
983 .count
= ELEMENTSOF(rtnl_tca_types
),
984 .types
= rtnl_tca_types
,
987 static const NLType mdb_types
[] = {
988 [MDBA_SET_ENTRY
] = { .size
= sizeof(struct br_port_msg
) },
991 static const NLTypeSystem rtnl_mdb_type_system
= {
992 .count
= ELEMENTSOF(mdb_types
),
996 static const NLType error_types
[] = {
997 [NLMSGERR_ATTR_MSG
] = { .type
= NETLINK_TYPE_STRING
},
998 [NLMSGERR_ATTR_OFFS
] = { .type
= NETLINK_TYPE_U32
},
1001 static const NLTypeSystem error_type_system
= {
1002 .count
= ELEMENTSOF(error_types
),
1003 .types
= error_types
,
1006 static const NLType rtnl_types
[] = {
1007 [NLMSG_DONE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &empty_type_system
, .size
= 0 },
1008 [NLMSG_ERROR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &error_type_system
, .size
= sizeof(struct nlmsgerr
) },
1009 [RTM_NEWLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
1010 [RTM_DELLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
1011 [RTM_GETLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
1012 [RTM_SETLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
1013 [RTM_NEWLINKPROP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
1014 [RTM_DELLINKPROP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
1015 [RTM_GETLINKPROP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
1016 [RTM_NEWADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
1017 [RTM_DELADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
1018 [RTM_GETADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
1019 [RTM_NEWROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
1020 [RTM_DELROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
1021 [RTM_GETROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
1022 [RTM_NEWNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
1023 [RTM_DELNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
1024 [RTM_GETNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
1025 [RTM_NEWADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
1026 [RTM_DELADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
1027 [RTM_GETADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
1028 [RTM_NEWRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct rtmsg
) },
1029 [RTM_DELRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct rtmsg
) },
1030 [RTM_GETRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct rtmsg
) },
1031 [RTM_NEWNEXTHOP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_nexthop_type_system
, .size
= sizeof(struct nhmsg
) },
1032 [RTM_DELNEXTHOP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_nexthop_type_system
, .size
= sizeof(struct nhmsg
) },
1033 [RTM_GETNEXTHOP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_nexthop_type_system
, .size
= sizeof(struct nhmsg
) },
1034 [RTM_NEWQDISC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_type_system
, .size
= sizeof(struct tcmsg
) },
1035 [RTM_DELQDISC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_type_system
, .size
= sizeof(struct tcmsg
) },
1036 [RTM_GETQDISC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_type_system
, .size
= sizeof(struct tcmsg
) },
1037 [RTM_NEWTCLASS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_type_system
, .size
= sizeof(struct tcmsg
) },
1038 [RTM_DELTCLASS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_type_system
, .size
= sizeof(struct tcmsg
) },
1039 [RTM_GETTCLASS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_type_system
, .size
= sizeof(struct tcmsg
) },
1040 [RTM_NEWMDB
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_mdb_type_system
, .size
= sizeof(struct br_port_msg
) },
1041 [RTM_DELMDB
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_mdb_type_system
, .size
= sizeof(struct br_port_msg
) },
1042 [RTM_GETMDB
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_mdb_type_system
, .size
= sizeof(struct br_port_msg
) },
1045 const NLTypeSystem rtnl_type_system_root
= {
1046 .count
= ELEMENTSOF(rtnl_types
),
1047 .types
= rtnl_types
,
1050 static const NLType genl_wireguard_allowedip_types
[] = {
1051 [WGALLOWEDIP_A_FAMILY
] = { .type
= NETLINK_TYPE_U16
},
1052 [WGALLOWEDIP_A_IPADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1053 [WGALLOWEDIP_A_CIDR_MASK
] = { .type
= NETLINK_TYPE_U8
},
1056 static const NLTypeSystem genl_wireguard_allowedip_type_system
= {
1057 .count
= ELEMENTSOF(genl_wireguard_allowedip_types
),
1058 .types
= genl_wireguard_allowedip_types
,
1061 static const NLType genl_wireguard_peer_types
[] = {
1062 [WGPEER_A_PUBLIC_KEY
] = { .size
= WG_KEY_LEN
},
1063 [WGPEER_A_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
1064 [WGPEER_A_PRESHARED_KEY
] = { .size
= WG_KEY_LEN
},
1065 [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL
] = { .type
= NETLINK_TYPE_U16
},
1066 [WGPEER_A_ENDPOINT
] = { .type
= NETLINK_TYPE_SOCKADDR
},
1067 [WGPEER_A_ALLOWEDIPS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_wireguard_allowedip_type_system
},
1070 static const NLTypeSystem genl_wireguard_peer_type_system
= {
1071 .count
= ELEMENTSOF(genl_wireguard_peer_types
),
1072 .types
= genl_wireguard_peer_types
,
1075 static const NLType genl_wireguard_set_device_types
[] = {
1076 [WGDEVICE_A_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
1077 [WGDEVICE_A_IFNAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFNAMSIZ
-1 },
1078 [WGDEVICE_A_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
1079 [WGDEVICE_A_PRIVATE_KEY
] = { .size
= WG_KEY_LEN
},
1080 [WGDEVICE_A_LISTEN_PORT
] = { .type
= NETLINK_TYPE_U16
},
1081 [WGDEVICE_A_FWMARK
] = { .type
= NETLINK_TYPE_U32
},
1082 [WGDEVICE_A_PEERS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_wireguard_peer_type_system
},
1085 static const NLTypeSystem genl_wireguard_set_device_type_system
= {
1086 .count
= ELEMENTSOF(genl_wireguard_set_device_types
),
1087 .types
= genl_wireguard_set_device_types
,
1090 static const NLType genl_wireguard_cmds
[] = {
1091 [WG_CMD_SET_DEVICE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_wireguard_set_device_type_system
},
1094 static const NLTypeSystem genl_wireguard_type_system
= {
1095 .count
= ELEMENTSOF(genl_wireguard_cmds
),
1096 .types
= genl_wireguard_cmds
,
1099 static const NLType genl_mcast_group_types
[] = {
1100 [CTRL_ATTR_MCAST_GRP_NAME
] = { .type
= NETLINK_TYPE_STRING
},
1101 [CTRL_ATTR_MCAST_GRP_ID
] = { .type
= NETLINK_TYPE_U32
},
1104 static const NLTypeSystem genl_mcast_group_type_system
= {
1105 .count
= ELEMENTSOF(genl_mcast_group_types
),
1106 .types
= genl_mcast_group_types
,
1109 static const NLType genl_get_family_types
[] = {
1110 [CTRL_ATTR_FAMILY_NAME
] = { .type
= NETLINK_TYPE_STRING
},
1111 [CTRL_ATTR_FAMILY_ID
] = { .type
= NETLINK_TYPE_U16
},
1112 [CTRL_ATTR_MCAST_GROUPS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_mcast_group_type_system
},
1115 static const NLTypeSystem genl_get_family_type_system
= {
1116 .count
= ELEMENTSOF(genl_get_family_types
),
1117 .types
= genl_get_family_types
,
1120 static const NLType genl_ctrl_id_ctrl_cmds
[] = {
1121 [CTRL_CMD_GETFAMILY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_get_family_type_system
},
1124 static const NLTypeSystem genl_ctrl_id_ctrl_type_system
= {
1125 .count
= ELEMENTSOF(genl_ctrl_id_ctrl_cmds
),
1126 .types
= genl_ctrl_id_ctrl_cmds
,
1129 static const NLType genl_fou_types
[] = {
1130 [FOU_ATTR_PORT
] = { .type
= NETLINK_TYPE_U16
},
1131 [FOU_ATTR_AF
] = { .type
= NETLINK_TYPE_U8
},
1132 [FOU_ATTR_IPPROTO
] = { .type
= NETLINK_TYPE_U8
},
1133 [FOU_ATTR_TYPE
] = { .type
= NETLINK_TYPE_U8
},
1134 [FOU_ATTR_REMCSUM_NOPARTIAL
] = { .type
= NETLINK_TYPE_FLAG
},
1135 [FOU_ATTR_LOCAL_V4
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1136 [FOU_ATTR_PEER_V4
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1137 [FOU_ATTR_LOCAL_V6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1138 [FOU_ATTR_PEER_V6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1139 [FOU_ATTR_PEER_PORT
] = { .type
= NETLINK_TYPE_U16
},
1140 [FOU_ATTR_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
1143 static const NLTypeSystem genl_fou_type_system
= {
1144 .count
= ELEMENTSOF(genl_fou_types
),
1145 .types
= genl_fou_types
,
1148 static const NLType genl_fou_cmds
[] = {
1149 [FOU_CMD_ADD
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_fou_type_system
},
1150 [FOU_CMD_DEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_fou_type_system
},
1151 [FOU_CMD_GET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_fou_type_system
},
1154 static const NLTypeSystem genl_fou_cmds_type_system
= {
1155 .count
= ELEMENTSOF(genl_fou_cmds
),
1156 .types
= genl_fou_cmds
,
1159 static const NLType genl_l2tp_types
[] = {
1160 [L2TP_ATTR_PW_TYPE
] = { .type
= NETLINK_TYPE_U16
},
1161 [L2TP_ATTR_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
1162 [L2TP_ATTR_OFFSET
] = { .type
= NETLINK_TYPE_U16
},
1163 [L2TP_ATTR_DATA_SEQ
] = { .type
= NETLINK_TYPE_U16
},
1164 [L2TP_ATTR_L2SPEC_TYPE
] = { .type
= NETLINK_TYPE_U8
},
1165 [L2TP_ATTR_L2SPEC_LEN
] = { .type
= NETLINK_TYPE_U8
},
1166 [L2TP_ATTR_PROTO_VERSION
] = { .type
= NETLINK_TYPE_U8
},
1167 [L2TP_ATTR_IFNAME
] = { .type
= NETLINK_TYPE_STRING
},
1168 [L2TP_ATTR_CONN_ID
] = { .type
= NETLINK_TYPE_U32
},
1169 [L2TP_ATTR_PEER_CONN_ID
] = { .type
= NETLINK_TYPE_U32
},
1170 [L2TP_ATTR_SESSION_ID
] = { .type
= NETLINK_TYPE_U32
},
1171 [L2TP_ATTR_PEER_SESSION_ID
] = { .type
= NETLINK_TYPE_U32
},
1172 [L2TP_ATTR_UDP_CSUM
] = { .type
= NETLINK_TYPE_U8
},
1173 [L2TP_ATTR_VLAN_ID
] = { .type
= NETLINK_TYPE_U16
},
1174 [L2TP_ATTR_RECV_SEQ
] = { .type
= NETLINK_TYPE_U8
},
1175 [L2TP_ATTR_SEND_SEQ
] = { .type
= NETLINK_TYPE_U8
},
1176 [L2TP_ATTR_LNS_MODE
] = { .type
= NETLINK_TYPE_U8
},
1177 [L2TP_ATTR_USING_IPSEC
] = { .type
= NETLINK_TYPE_U8
},
1178 [L2TP_ATTR_FD
] = { .type
= NETLINK_TYPE_U32
},
1179 [L2TP_ATTR_IP_SADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1180 [L2TP_ATTR_IP_DADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1181 [L2TP_ATTR_UDP_SPORT
] = { .type
= NETLINK_TYPE_U16
},
1182 [L2TP_ATTR_UDP_DPORT
] = { .type
= NETLINK_TYPE_U16
},
1183 [L2TP_ATTR_IP6_SADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1184 [L2TP_ATTR_IP6_DADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1185 [L2TP_ATTR_UDP_ZERO_CSUM6_TX
] = { .type
= NETLINK_TYPE_FLAG
},
1186 [L2TP_ATTR_UDP_ZERO_CSUM6_RX
] = { .type
= NETLINK_TYPE_FLAG
},
1189 static const NLTypeSystem genl_l2tp_type_system
= {
1190 .count
= ELEMENTSOF(genl_l2tp_types
),
1191 .types
= genl_l2tp_types
,
1194 static const NLType genl_l2tp
[] = {
1195 [L2TP_CMD_TUNNEL_CREATE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1196 [L2TP_CMD_TUNNEL_DELETE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1197 [L2TP_CMD_TUNNEL_MODIFY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1198 [L2TP_CMD_TUNNEL_GET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1199 [L2TP_CMD_SESSION_CREATE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1200 [L2TP_CMD_SESSION_DELETE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1201 [L2TP_CMD_SESSION_MODIFY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1202 [L2TP_CMD_SESSION_GET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1205 static const NLTypeSystem genl_l2tp_tunnel_session_type_system
= {
1206 .count
= ELEMENTSOF(genl_l2tp
),
1210 static const NLType genl_rxsc_types
[] = {
1211 [MACSEC_RXSC_ATTR_SCI
] = { .type
= NETLINK_TYPE_U64
},
1214 static const NLTypeSystem genl_rxsc_config_type_system
= {
1215 .count
= ELEMENTSOF(genl_rxsc_types
),
1216 .types
= genl_rxsc_types
,
1219 static const NLType genl_macsec_rxsc_types
[] = {
1220 [MACSEC_ATTR_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
1221 [MACSEC_ATTR_RXSC_CONFIG
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_rxsc_config_type_system
},
1224 static const NLTypeSystem genl_macsec_rxsc_type_system
= {
1225 .count
= ELEMENTSOF(genl_macsec_rxsc_types
),
1226 .types
= genl_macsec_rxsc_types
,
1229 static const NLType genl_macsec_sa_config_types
[] = {
1230 [MACSEC_SA_ATTR_AN
] = { .type
= NETLINK_TYPE_U8
},
1231 [MACSEC_SA_ATTR_ACTIVE
] = { .type
= NETLINK_TYPE_U8
},
1232 [MACSEC_SA_ATTR_PN
] = { .type
= NETLINK_TYPE_U32
},
1233 [MACSEC_SA_ATTR_KEYID
] = { .size
= MACSEC_KEYID_LEN
},
1234 [MACSEC_SA_ATTR_KEY
] = { .size
= MACSEC_MAX_KEY_LEN
},
1237 static const NLTypeSystem genl_macsec_sa_config_type_system
= {
1238 .count
= ELEMENTSOF(genl_macsec_sa_config_types
),
1239 .types
= genl_macsec_sa_config_types
,
1242 static const NLType genl_macsec_rxsa_types
[] = {
1243 [MACSEC_ATTR_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
1244 [MACSEC_ATTR_SA_CONFIG
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_sa_config_type_system
},
1247 static const NLTypeSystem genl_macsec_rxsa_type_system
= {
1248 .count
= ELEMENTSOF(genl_macsec_rxsa_types
),
1249 .types
= genl_macsec_rxsa_types
,
1252 static const NLType genl_macsec_sa_types
[] = {
1253 [MACSEC_ATTR_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
1254 [MACSEC_ATTR_RXSC_CONFIG
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_rxsc_config_type_system
},
1255 [MACSEC_ATTR_SA_CONFIG
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_sa_config_type_system
},
1258 static const NLTypeSystem genl_macsec_sa_type_system
= {
1259 .count
= ELEMENTSOF(genl_macsec_sa_types
),
1260 .types
= genl_macsec_sa_types
,
1263 static const NLType genl_macsec
[] = {
1264 [MACSEC_CMD_ADD_RXSC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_rxsc_type_system
},
1265 [MACSEC_CMD_ADD_TXSA
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_rxsa_type_system
},
1266 [MACSEC_CMD_ADD_RXSA
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_sa_type_system
},
1269 static const NLTypeSystem genl_macsec_device_type_system
= {
1270 .count
= ELEMENTSOF(genl_macsec
),
1271 .types
= genl_macsec
,
1274 static const NLType genl_nl80211_types
[] = {
1275 [NL80211_ATTR_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
1276 [NL80211_ATTR_MAC
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
1277 [NL80211_ATTR_SSID
] = { .type
= NETLINK_TYPE_STRING
},
1278 [NL80211_ATTR_IFTYPE
] = { .type
= NETLINK_TYPE_U32
},
1281 static const NLTypeSystem genl_nl80211_type_system
= {
1282 .count
= ELEMENTSOF(genl_nl80211_types
),
1283 .types
= genl_nl80211_types
,
1286 static const NLType genl_nl80211_cmds
[] = {
1287 [NL80211_CMD_GET_WIPHY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1288 [NL80211_CMD_SET_WIPHY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1289 [NL80211_CMD_NEW_WIPHY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1290 [NL80211_CMD_DEL_WIPHY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1291 [NL80211_CMD_GET_INTERFACE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1292 [NL80211_CMD_SET_INTERFACE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1293 [NL80211_CMD_NEW_INTERFACE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1294 [NL80211_CMD_DEL_INTERFACE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1295 [NL80211_CMD_GET_STATION
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1296 [NL80211_CMD_SET_STATION
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1297 [NL80211_CMD_NEW_STATION
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1298 [NL80211_CMD_DEL_STATION
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1301 static const NLTypeSystem genl_nl80211_cmds_type_system
= {
1302 .count
= ELEMENTSOF(genl_nl80211_cmds
),
1303 .types
= genl_nl80211_cmds
,
1306 static const NLType genl_families
[] = {
1307 [SD_GENL_ID_CTRL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_ctrl_id_ctrl_type_system
},
1308 [SD_GENL_WIREGUARD
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_wireguard_type_system
},
1309 [SD_GENL_FOU
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_fou_cmds_type_system
},
1310 [SD_GENL_L2TP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_tunnel_session_type_system
},
1311 [SD_GENL_MACSEC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_device_type_system
},
1312 [SD_GENL_NL80211
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_cmds_type_system
},
1315 /* Mainly used when sending message */
1316 const NLTypeSystem genl_family_type_system_root
= {
1317 .count
= ELEMENTSOF(genl_families
),
1318 .types
= genl_families
,
1321 static const NLType genl_types
[] = {
1322 [SD_GENL_ERROR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &error_type_system
, .size
= sizeof(struct nlmsgerr
) },
1323 [SD_GENL_DONE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &empty_type_system
},
1324 [SD_GENL_ID_CTRL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_get_family_type_system
, .size
= sizeof(struct genlmsghdr
) },
1325 [SD_GENL_NL80211
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
, .size
= sizeof(struct genlmsghdr
) },
1328 /* Mainly used when message received */
1329 const NLTypeSystem genl_type_system_root
= {
1330 .count
= ELEMENTSOF(genl_types
),
1331 .types
= genl_types
,
1334 uint16_t type_get_type(const NLType
*type
) {
1339 size_t type_get_size(const NLType
*type
) {
1344 void type_get_type_system(const NLType
*nl_type
, const NLTypeSystem
**ret
) {
1347 assert(nl_type
->type
== NETLINK_TYPE_NESTED
);
1348 assert(nl_type
->type_system
);
1350 *ret
= nl_type
->type_system
;
1353 void type_get_type_system_union(const NLType
*nl_type
, const NLTypeSystemUnion
**ret
) {
1356 assert(nl_type
->type
== NETLINK_TYPE_UNION
);
1357 assert(nl_type
->type_system_union
);
1359 *ret
= nl_type
->type_system_union
;
1362 uint16_t type_system_get_count(const NLTypeSystem
*type_system
) {
1363 assert(type_system
);
1364 return type_system
->count
;
1367 const NLTypeSystem
*type_system_get_root(int protocol
) {
1369 case NETLINK_GENERIC
:
1370 return &genl_type_system_root
;
1371 default: /* NETLINK_ROUTE: */
1372 return &rtnl_type_system_root
;
1376 int type_system_root_get_type(sd_netlink
*nl
, const NLType
**ret
, uint16_t type
) {
1377 sd_genl_family family
;
1378 const NLType
*nl_type
;
1381 if (!nl
|| nl
->protocol
!= NETLINK_GENERIC
)
1382 return type_system_get_type(&rtnl_type_system_root
, ret
, type
);
1384 r
= nlmsg_type_to_genl_family(nl
, type
, &family
);
1388 if (family
>= genl_type_system_root
.count
)
1391 nl_type
= &genl_type_system_root
.types
[family
];
1393 if (nl_type
->type
== NETLINK_TYPE_UNSPEC
)
1401 int type_system_get_type(const NLTypeSystem
*type_system
, const NLType
**ret
, uint16_t type
) {
1402 const NLType
*nl_type
;
1405 assert(type_system
);
1406 assert(type_system
->types
);
1408 if (type
>= type_system
->count
)
1411 nl_type
= &type_system
->types
[type
];
1413 if (nl_type
->type
== NETLINK_TYPE_UNSPEC
)
1421 int type_system_get_type_system(const NLTypeSystem
*type_system
, const NLTypeSystem
**ret
, uint16_t type
) {
1422 const NLType
*nl_type
;
1427 r
= type_system_get_type(type_system
, &nl_type
, type
);
1431 type_get_type_system(nl_type
, ret
);
1435 int type_system_get_type_system_union(const NLTypeSystem
*type_system
, const NLTypeSystemUnion
**ret
, uint16_t type
) {
1436 const NLType
*nl_type
;
1441 r
= type_system_get_type(type_system
, &nl_type
, type
);
1445 type_get_type_system_union(nl_type
, ret
);
1449 int type_system_union_get_type_system(const NLTypeSystemUnion
*type_system_union
, const NLTypeSystem
**ret
, const char *key
) {
1452 assert(type_system_union
);
1453 assert(type_system_union
->match_type
== NL_MATCH_SIBLING
);
1454 assert(type_system_union
->lookup
);
1455 assert(type_system_union
->type_systems
);
1459 type
= type_system_union
->lookup(key
);
1463 assert(type
< type_system_union
->num
);
1465 *ret
= &type_system_union
->type_systems
[type
];
1470 int type_system_union_protocol_get_type_system(const NLTypeSystemUnion
*type_system_union
, const NLTypeSystem
**ret
, uint16_t protocol
) {
1471 const NLTypeSystem
*type_system
;
1473 assert(type_system_union
);
1474 assert(type_system_union
->type_systems
);
1475 assert(type_system_union
->match_type
== NL_MATCH_PROTOCOL
);
1478 if (protocol
>= type_system_union
->num
)
1481 type_system
= &type_system_union
->type_systems
[protocol
];
1482 if (!type_system
->types
)