1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
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/netfilter/nf_tables.h>
23 #include <linux/netfilter/nfnetlink.h>
24 #include <linux/nexthop.h>
25 #include <linux/nl80211.h>
26 #include <linux/pkt_sched.h>
27 #include <linux/veth.h>
28 #include <linux/wireguard.h>
30 #include "sd-netlink.h"
32 #include "generic-netlink.h"
35 #include "netlink-internal.h"
36 #include "netlink-types.h"
37 #include "string-table.h"
40 /* Maximum ARP IP target defined in kernel */
41 #define BOND_MAX_ARP_TARGETS 16
59 BOND_ARP_TARGETS_MAX
= BOND_MAX_ARP_TARGETS
,
65 const NLTypeSystem
*type_system
;
66 const NLTypeSystemUnion
*type_system_union
;
74 static const NLTypeSystem rtnl_link_type_system
;
76 static const NLType empty_types
[1] = {
77 /* fake array to avoid .types==NULL, which denotes invalid type-systems */
80 static const NLTypeSystem empty_type_system
= {
85 static const NLType rtnl_link_info_data_veth_types
[] = {
86 [VETH_INFO_PEER
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
89 static const NLType rtnl_link_info_data_vxcan_types
[] = {
90 [VXCAN_INFO_PEER
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
93 static const NLType rtnl_link_info_data_ipvlan_types
[] = {
94 [IFLA_IPVLAN_MODE
] = { .type
= NETLINK_TYPE_U16
},
95 [IFLA_IPVLAN_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
98 static const NLType rtnl_macvlan_macaddr_types
[] = {
99 [IFLA_MACVLAN_MACADDR
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
102 static const NLTypeSystem rtnl_macvlan_macaddr_type_system
= {
103 .count
= ELEMENTSOF(rtnl_macvlan_macaddr_types
),
104 .types
= rtnl_macvlan_macaddr_types
,
107 static const NLType rtnl_link_info_data_macvlan_types
[] = {
108 [IFLA_MACVLAN_MODE
] = { .type
= NETLINK_TYPE_U32
},
109 [IFLA_MACVLAN_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
110 [IFLA_MACVLAN_MACADDR_MODE
] = { .type
= NETLINK_TYPE_U32
},
111 [IFLA_MACVLAN_MACADDR_DATA
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_macvlan_macaddr_type_system
},
114 static const NLType rtnl_link_info_data_bridge_types
[] = {
115 [IFLA_BR_FORWARD_DELAY
] = { .type
= NETLINK_TYPE_U32
},
116 [IFLA_BR_HELLO_TIME
] = { .type
= NETLINK_TYPE_U32
},
117 [IFLA_BR_MAX_AGE
] = { .type
= NETLINK_TYPE_U32
},
118 [IFLA_BR_AGEING_TIME
] = { .type
= NETLINK_TYPE_U32
},
119 [IFLA_BR_STP_STATE
] = { .type
= NETLINK_TYPE_U32
},
120 [IFLA_BR_PRIORITY
] = { .type
= NETLINK_TYPE_U16
},
121 [IFLA_BR_VLAN_FILTERING
] = { .type
= NETLINK_TYPE_U8
},
122 [IFLA_BR_VLAN_PROTOCOL
] = { .type
= NETLINK_TYPE_U16
},
123 [IFLA_BR_GROUP_FWD_MASK
] = { .type
= NETLINK_TYPE_U16
},
124 [IFLA_BR_ROOT_PORT
] = { .type
= NETLINK_TYPE_U16
},
125 [IFLA_BR_ROOT_PATH_COST
] = { .type
= NETLINK_TYPE_U32
},
126 [IFLA_BR_TOPOLOGY_CHANGE
] = { .type
= NETLINK_TYPE_U8
},
127 [IFLA_BR_TOPOLOGY_CHANGE_DETECTED
] = { .type
= NETLINK_TYPE_U8
},
128 [IFLA_BR_HELLO_TIMER
] = { .type
= NETLINK_TYPE_U16
},
129 [IFLA_BR_TCN_TIMER
] = { .type
= NETLINK_TYPE_U16
},
130 [IFLA_BR_TOPOLOGY_CHANGE_TIMER
] = { .type
= NETLINK_TYPE_U16
},
131 [IFLA_BR_GC_TIMER
] = { .type
= NETLINK_TYPE_U64
},
132 [IFLA_BR_GROUP_ADDR
] = { .type
= NETLINK_TYPE_U16
},
133 [IFLA_BR_FDB_FLUSH
] = { .type
= NETLINK_TYPE_U16
},
134 [IFLA_BR_MCAST_ROUTER
] = { .type
= NETLINK_TYPE_U8
},
135 [IFLA_BR_MCAST_SNOOPING
] = { .type
= NETLINK_TYPE_U8
},
136 [IFLA_BR_MCAST_QUERY_USE_IFADDR
] = { .type
= NETLINK_TYPE_U8
},
137 [IFLA_BR_MCAST_QUERIER
] = { .type
= NETLINK_TYPE_U8
},
138 [IFLA_BR_MCAST_HASH_ELASTICITY
] = { .type
= NETLINK_TYPE_U32
},
139 [IFLA_BR_MCAST_HASH_MAX
] = { .type
= NETLINK_TYPE_U16
},
140 [IFLA_BR_MCAST_LAST_MEMBER_CNT
] = { .type
= NETLINK_TYPE_U32
},
141 [IFLA_BR_MCAST_STARTUP_QUERY_CNT
] = { .type
= NETLINK_TYPE_U16
},
142 [IFLA_BR_MCAST_LAST_MEMBER_INTVL
] = { .type
= NETLINK_TYPE_U64
},
143 [IFLA_BR_MCAST_MEMBERSHIP_INTVL
] = { .type
= NETLINK_TYPE_U64
},
144 [IFLA_BR_MCAST_QUERIER_INTVL
] = { .type
= NETLINK_TYPE_U64
},
145 [IFLA_BR_MCAST_QUERY_INTVL
] = { .type
= NETLINK_TYPE_U64
},
146 [IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
] = { .type
= NETLINK_TYPE_U64
},
147 [IFLA_BR_MCAST_STARTUP_QUERY_INTVL
] = { .type
= NETLINK_TYPE_U64
},
148 [IFLA_BR_NF_CALL_IPTABLES
] = { .type
= NETLINK_TYPE_U8
},
149 [IFLA_BR_NF_CALL_IP6TABLES
] = { .type
= NETLINK_TYPE_U8
},
150 [IFLA_BR_NF_CALL_ARPTABLES
] = { .type
= NETLINK_TYPE_U8
},
151 [IFLA_BR_VLAN_DEFAULT_PVID
] = { .type
= NETLINK_TYPE_U16
},
152 [IFLA_BR_MCAST_IGMP_VERSION
] = { .type
= NETLINK_TYPE_U8
},
155 static const NLType rtnl_link_info_data_vlan_types
[] = {
156 [IFLA_VLAN_ID
] = { .type
= NETLINK_TYPE_U16
},
158 [IFLA_VLAN_FLAGS] = { .len = sizeof(struct ifla_vlan_flags) },
159 [IFLA_VLAN_EGRESS_QOS] = { .type = NETLINK_TYPE_NESTED },
160 [IFLA_VLAN_INGRESS_QOS] = { .type = NETLINK_TYPE_NESTED },
162 [IFLA_VLAN_PROTOCOL
] = { .type
= NETLINK_TYPE_U16
},
165 static const NLType rtnl_link_info_data_vxlan_types
[] = {
166 [IFLA_VXLAN_ID
] = { .type
= NETLINK_TYPE_U32
},
167 [IFLA_VXLAN_GROUP
] = { .type
= NETLINK_TYPE_IN_ADDR
},
168 [IFLA_VXLAN_LINK
] = { .type
= NETLINK_TYPE_U32
},
169 [IFLA_VXLAN_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
170 [IFLA_VXLAN_TTL
] = { .type
= NETLINK_TYPE_U8
},
171 [IFLA_VXLAN_TOS
] = { .type
= NETLINK_TYPE_U8
},
172 [IFLA_VXLAN_LEARNING
] = { .type
= NETLINK_TYPE_U8
},
173 [IFLA_VXLAN_AGEING
] = { .type
= NETLINK_TYPE_U32
},
174 [IFLA_VXLAN_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
175 [IFLA_VXLAN_PORT_RANGE
] = { .type
= NETLINK_TYPE_U32
},
176 [IFLA_VXLAN_PROXY
] = { .type
= NETLINK_TYPE_U8
},
177 [IFLA_VXLAN_RSC
] = { .type
= NETLINK_TYPE_U8
},
178 [IFLA_VXLAN_L2MISS
] = { .type
= NETLINK_TYPE_U8
},
179 [IFLA_VXLAN_L3MISS
] = { .type
= NETLINK_TYPE_U8
},
180 [IFLA_VXLAN_PORT
] = { .type
= NETLINK_TYPE_U16
},
181 [IFLA_VXLAN_GROUP6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
182 [IFLA_VXLAN_LOCAL6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
183 [IFLA_VXLAN_UDP_CSUM
] = { .type
= NETLINK_TYPE_U8
},
184 [IFLA_VXLAN_UDP_ZERO_CSUM6_TX
] = { .type
= NETLINK_TYPE_U8
},
185 [IFLA_VXLAN_UDP_ZERO_CSUM6_RX
] = { .type
= NETLINK_TYPE_U8
},
186 [IFLA_VXLAN_REMCSUM_TX
] = { .type
= NETLINK_TYPE_U8
},
187 [IFLA_VXLAN_REMCSUM_RX
] = { .type
= NETLINK_TYPE_U8
},
188 [IFLA_VXLAN_GBP
] = { .type
= NETLINK_TYPE_FLAG
},
189 [IFLA_VXLAN_REMCSUM_NOPARTIAL
] = { .type
= NETLINK_TYPE_FLAG
},
190 [IFLA_VXLAN_COLLECT_METADATA
] = { .type
= NETLINK_TYPE_U8
},
191 [IFLA_VXLAN_LABEL
] = { .type
= NETLINK_TYPE_U32
},
192 [IFLA_VXLAN_GPE
] = { .type
= NETLINK_TYPE_FLAG
},
193 [IFLA_VXLAN_TTL_INHERIT
] = { .type
= NETLINK_TYPE_FLAG
},
194 [IFLA_VXLAN_DF
] = { .type
= NETLINK_TYPE_U8
},
197 static const NLType rtnl_bond_arp_target_types
[] = {
198 [BOND_ARP_TARGETS_0
] = { .type
= NETLINK_TYPE_U32
},
199 [BOND_ARP_TARGETS_1
] = { .type
= NETLINK_TYPE_U32
},
200 [BOND_ARP_TARGETS_2
] = { .type
= NETLINK_TYPE_U32
},
201 [BOND_ARP_TARGETS_3
] = { .type
= NETLINK_TYPE_U32
},
202 [BOND_ARP_TARGETS_4
] = { .type
= NETLINK_TYPE_U32
},
203 [BOND_ARP_TARGETS_5
] = { .type
= NETLINK_TYPE_U32
},
204 [BOND_ARP_TARGETS_6
] = { .type
= NETLINK_TYPE_U32
},
205 [BOND_ARP_TARGETS_7
] = { .type
= NETLINK_TYPE_U32
},
206 [BOND_ARP_TARGETS_8
] = { .type
= NETLINK_TYPE_U32
},
207 [BOND_ARP_TARGETS_9
] = { .type
= NETLINK_TYPE_U32
},
208 [BOND_ARP_TARGETS_10
] = { .type
= NETLINK_TYPE_U32
},
209 [BOND_ARP_TARGETS_11
] = { .type
= NETLINK_TYPE_U32
},
210 [BOND_ARP_TARGETS_12
] = { .type
= NETLINK_TYPE_U32
},
211 [BOND_ARP_TARGETS_13
] = { .type
= NETLINK_TYPE_U32
},
212 [BOND_ARP_TARGETS_14
] = { .type
= NETLINK_TYPE_U32
},
213 [BOND_ARP_TARGETS_MAX
] = { .type
= NETLINK_TYPE_U32
},
216 static const NLTypeSystem rtnl_bond_arp_type_system
= {
217 .count
= ELEMENTSOF(rtnl_bond_arp_target_types
),
218 .types
= rtnl_bond_arp_target_types
,
221 static const NLType rtnl_link_info_data_bond_types
[] = {
222 [IFLA_BOND_MODE
] = { .type
= NETLINK_TYPE_U8
},
223 [IFLA_BOND_ACTIVE_SLAVE
] = { .type
= NETLINK_TYPE_U32
},
224 [IFLA_BOND_MIIMON
] = { .type
= NETLINK_TYPE_U32
},
225 [IFLA_BOND_UPDELAY
] = { .type
= NETLINK_TYPE_U32
},
226 [IFLA_BOND_DOWNDELAY
] = { .type
= NETLINK_TYPE_U32
},
227 [IFLA_BOND_USE_CARRIER
] = { .type
= NETLINK_TYPE_U8
},
228 [IFLA_BOND_ARP_INTERVAL
] = { .type
= NETLINK_TYPE_U32
},
229 [IFLA_BOND_ARP_IP_TARGET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_bond_arp_type_system
},
230 [IFLA_BOND_ARP_VALIDATE
] = { .type
= NETLINK_TYPE_U32
},
231 [IFLA_BOND_ARP_ALL_TARGETS
] = { .type
= NETLINK_TYPE_U32
},
232 [IFLA_BOND_PRIMARY
] = { .type
= NETLINK_TYPE_U32
},
233 [IFLA_BOND_PRIMARY_RESELECT
] = { .type
= NETLINK_TYPE_U8
},
234 [IFLA_BOND_FAIL_OVER_MAC
] = { .type
= NETLINK_TYPE_U8
},
235 [IFLA_BOND_XMIT_HASH_POLICY
] = { .type
= NETLINK_TYPE_U8
},
236 [IFLA_BOND_RESEND_IGMP
] = { .type
= NETLINK_TYPE_U32
},
237 [IFLA_BOND_NUM_PEER_NOTIF
] = { .type
= NETLINK_TYPE_U8
},
238 [IFLA_BOND_ALL_SLAVES_ACTIVE
] = { .type
= NETLINK_TYPE_U8
},
239 [IFLA_BOND_MIN_LINKS
] = { .type
= NETLINK_TYPE_U32
},
240 [IFLA_BOND_LP_INTERVAL
] = { .type
= NETLINK_TYPE_U32
},
241 [IFLA_BOND_PACKETS_PER_SLAVE
] = { .type
= NETLINK_TYPE_U32
},
242 [IFLA_BOND_AD_LACP_RATE
] = { .type
= NETLINK_TYPE_U8
},
243 [IFLA_BOND_AD_SELECT
] = { .type
= NETLINK_TYPE_U8
},
244 [IFLA_BOND_AD_INFO
] = { .type
= NETLINK_TYPE_NESTED
},
245 [IFLA_BOND_AD_ACTOR_SYS_PRIO
] = { .type
= NETLINK_TYPE_U16
},
246 [IFLA_BOND_AD_USER_PORT_KEY
] = { .type
= NETLINK_TYPE_U16
},
247 [IFLA_BOND_AD_ACTOR_SYSTEM
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
248 [IFLA_BOND_TLB_DYNAMIC_LB
] = { .type
= NETLINK_TYPE_U8
},
251 static const NLType rtnl_link_info_data_iptun_types
[] = {
252 [IFLA_IPTUN_LINK
] = { .type
= NETLINK_TYPE_U32
},
253 [IFLA_IPTUN_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
254 [IFLA_IPTUN_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
255 [IFLA_IPTUN_TTL
] = { .type
= NETLINK_TYPE_U8
},
256 [IFLA_IPTUN_TOS
] = { .type
= NETLINK_TYPE_U8
},
257 [IFLA_IPTUN_PMTUDISC
] = { .type
= NETLINK_TYPE_U8
},
258 [IFLA_IPTUN_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
259 [IFLA_IPTUN_PROTO
] = { .type
= NETLINK_TYPE_U8
},
260 [IFLA_IPTUN_6RD_PREFIX
] = { .type
= NETLINK_TYPE_IN_ADDR
},
261 [IFLA_IPTUN_6RD_RELAY_PREFIX
] = { .type
= NETLINK_TYPE_U32
},
262 [IFLA_IPTUN_6RD_PREFIXLEN
] = { .type
= NETLINK_TYPE_U16
},
263 [IFLA_IPTUN_6RD_RELAY_PREFIXLEN
] = { .type
= NETLINK_TYPE_U16
},
264 [IFLA_IPTUN_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
265 [IFLA_IPTUN_ENCAP_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
266 [IFLA_IPTUN_ENCAP_SPORT
] = { .type
= NETLINK_TYPE_U16
},
267 [IFLA_IPTUN_ENCAP_DPORT
] = { .type
= NETLINK_TYPE_U16
},
270 static const NLType rtnl_link_info_data_ipgre_types
[] = {
271 [IFLA_GRE_LINK
] = { .type
= NETLINK_TYPE_U32
},
272 [IFLA_GRE_IFLAGS
] = { .type
= NETLINK_TYPE_U16
},
273 [IFLA_GRE_OFLAGS
] = { .type
= NETLINK_TYPE_U16
},
274 [IFLA_GRE_IKEY
] = { .type
= NETLINK_TYPE_U32
},
275 [IFLA_GRE_OKEY
] = { .type
= NETLINK_TYPE_U32
},
276 [IFLA_GRE_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
277 [IFLA_GRE_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
278 [IFLA_GRE_TTL
] = { .type
= NETLINK_TYPE_U8
},
279 [IFLA_GRE_TOS
] = { .type
= NETLINK_TYPE_U8
},
280 [IFLA_GRE_PMTUDISC
] = { .type
= NETLINK_TYPE_U8
},
281 [IFLA_GRE_FLOWINFO
] = { .type
= NETLINK_TYPE_U32
},
282 [IFLA_GRE_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
283 [IFLA_GRE_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
284 [IFLA_GRE_ENCAP_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
285 [IFLA_GRE_ENCAP_SPORT
] = { .type
= NETLINK_TYPE_U16
},
286 [IFLA_GRE_ENCAP_DPORT
] = { .type
= NETLINK_TYPE_U16
},
287 [IFLA_GRE_ERSPAN_INDEX
] = { .type
= NETLINK_TYPE_U32
},
290 static const NLType rtnl_link_info_data_ipvti_types
[] = {
291 [IFLA_VTI_LINK
] = { .type
= NETLINK_TYPE_U32
},
292 [IFLA_VTI_IKEY
] = { .type
= NETLINK_TYPE_U32
},
293 [IFLA_VTI_OKEY
] = { .type
= NETLINK_TYPE_U32
},
294 [IFLA_VTI_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
295 [IFLA_VTI_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
298 static const NLType rtnl_link_info_data_ip6tnl_types
[] = {
299 [IFLA_IPTUN_LINK
] = { .type
= NETLINK_TYPE_U32
},
300 [IFLA_IPTUN_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
301 [IFLA_IPTUN_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
302 [IFLA_IPTUN_TTL
] = { .type
= NETLINK_TYPE_U8
},
303 [IFLA_IPTUN_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
304 [IFLA_IPTUN_PROTO
] = { .type
= NETLINK_TYPE_U8
},
305 [IFLA_IPTUN_ENCAP_LIMIT
] = { .type
= NETLINK_TYPE_U8
},
306 [IFLA_IPTUN_FLOWINFO
] = { .type
= NETLINK_TYPE_U32
},
309 static const NLType rtnl_link_info_data_vrf_types
[] = {
310 [IFLA_VRF_TABLE
] = { .type
= NETLINK_TYPE_U32
},
313 static const NLType rtnl_link_info_data_geneve_types
[] = {
314 [IFLA_GENEVE_ID
] = { .type
= NETLINK_TYPE_U32
},
315 [IFLA_GENEVE_TTL
] = { .type
= NETLINK_TYPE_U8
},
316 [IFLA_GENEVE_TOS
] = { .type
= NETLINK_TYPE_U8
},
317 [IFLA_GENEVE_PORT
] = { .type
= NETLINK_TYPE_U16
},
318 [IFLA_GENEVE_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
319 [IFLA_GENEVE_REMOTE6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
320 [IFLA_GENEVE_UDP_CSUM
] = { .type
= NETLINK_TYPE_U8
},
321 [IFLA_GENEVE_UDP_ZERO_CSUM6_TX
] = { .type
= NETLINK_TYPE_U8
},
322 [IFLA_GENEVE_UDP_ZERO_CSUM6_RX
] = { .type
= NETLINK_TYPE_U8
},
323 [IFLA_GENEVE_LABEL
] = { .type
= NETLINK_TYPE_U32
},
324 [IFLA_GENEVE_TTL_INHERIT
] = { .type
= NETLINK_TYPE_U8
},
325 [IFLA_GENEVE_DF
] = { .type
= NETLINK_TYPE_U8
},
328 static const NLType rtnl_link_info_data_can_types
[] = {
329 [IFLA_CAN_BITTIMING
] = { .size
= sizeof(struct can_bittiming
) },
330 [IFLA_CAN_RESTART_MS
] = { .type
= NETLINK_TYPE_U32
},
331 [IFLA_CAN_CTRLMODE
] = { .size
= sizeof(struct can_ctrlmode
) },
332 [IFLA_CAN_TERMINATION
] = { .type
= NETLINK_TYPE_U16
},
335 static const NLType rtnl_link_info_data_macsec_types
[] = {
336 [IFLA_MACSEC_SCI
] = { .type
= NETLINK_TYPE_U64
},
337 [IFLA_MACSEC_PORT
] = { .type
= NETLINK_TYPE_U16
},
338 [IFLA_MACSEC_ICV_LEN
] = { .type
= NETLINK_TYPE_U8
},
339 [IFLA_MACSEC_CIPHER_SUITE
] = { .type
= NETLINK_TYPE_U64
},
340 [IFLA_MACSEC_WINDOW
] = { .type
= NETLINK_TYPE_U32
},
341 [IFLA_MACSEC_ENCODING_SA
] = { .type
= NETLINK_TYPE_U8
},
342 [IFLA_MACSEC_ENCRYPT
] = { .type
= NETLINK_TYPE_U8
},
343 [IFLA_MACSEC_PROTECT
] = { .type
= NETLINK_TYPE_U8
},
344 [IFLA_MACSEC_INC_SCI
] = { .type
= NETLINK_TYPE_U8
},
345 [IFLA_MACSEC_ES
] = { .type
= NETLINK_TYPE_U8
},
346 [IFLA_MACSEC_SCB
] = { .type
= NETLINK_TYPE_U8
},
347 [IFLA_MACSEC_REPLAY_PROTECT
] = { .type
= NETLINK_TYPE_U8
},
348 [IFLA_MACSEC_VALIDATION
] = { .type
= NETLINK_TYPE_U8
},
351 static const NLType rtnl_link_info_data_xfrm_types
[] = {
352 [IFLA_XFRM_LINK
] = { .type
= NETLINK_TYPE_U32
},
353 [IFLA_XFRM_IF_ID
] = { .type
= NETLINK_TYPE_U32
}
356 static const NLType rtnl_link_info_data_bareudp_types
[] = {
357 [IFLA_BAREUDP_PORT
] = { .type
= NETLINK_TYPE_U16
},
358 [IFLA_BAREUDP_ETHERTYPE
] = { .type
= NETLINK_TYPE_U16
},
359 [IFLA_BAREUDP_SRCPORT_MIN
] = { .type
= NETLINK_TYPE_U16
},
360 [IFLA_BAREUDP_MULTIPROTO_MODE
] = { .type
= NETLINK_TYPE_FLAG
},
362 /* these strings must match the .kind entries in the kernel */
363 static const char* const nl_union_link_info_data_table
[] = {
364 [NL_UNION_LINK_INFO_DATA_BOND
] = "bond",
365 [NL_UNION_LINK_INFO_DATA_BRIDGE
] = "bridge",
366 [NL_UNION_LINK_INFO_DATA_VLAN
] = "vlan",
367 [NL_UNION_LINK_INFO_DATA_VETH
] = "veth",
368 [NL_UNION_LINK_INFO_DATA_DUMMY
] = "dummy",
369 [NL_UNION_LINK_INFO_DATA_MACVLAN
] = "macvlan",
370 [NL_UNION_LINK_INFO_DATA_MACVTAP
] = "macvtap",
371 [NL_UNION_LINK_INFO_DATA_IPVLAN
] = "ipvlan",
372 [NL_UNION_LINK_INFO_DATA_IPVTAP
] = "ipvtap",
373 [NL_UNION_LINK_INFO_DATA_VXLAN
] = "vxlan",
374 [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL
] = "ipip",
375 [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL
] = "gre",
376 [NL_UNION_LINK_INFO_DATA_ERSPAN
] = "erspan",
377 [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL
] = "gretap",
378 [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL
] = "ip6gre",
379 [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL
] = "ip6gretap",
380 [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL
] = "sit",
381 [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL
] = "vti",
382 [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL
] = "vti6",
383 [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL
] = "ip6tnl",
384 [NL_UNION_LINK_INFO_DATA_VRF
] = "vrf",
385 [NL_UNION_LINK_INFO_DATA_VCAN
] = "vcan",
386 [NL_UNION_LINK_INFO_DATA_GENEVE
] = "geneve",
387 [NL_UNION_LINK_INFO_DATA_VXCAN
] = "vxcan",
388 [NL_UNION_LINK_INFO_DATA_WIREGUARD
] = "wireguard",
389 [NL_UNION_LINK_INFO_DATA_NETDEVSIM
] = "netdevsim",
390 [NL_UNION_LINK_INFO_DATA_CAN
] = "can",
391 [NL_UNION_LINK_INFO_DATA_MACSEC
] = "macsec",
392 [NL_UNION_LINK_INFO_DATA_NLMON
] = "nlmon",
393 [NL_UNION_LINK_INFO_DATA_XFRM
] = "xfrm",
394 [NL_UNION_LINK_INFO_DATA_IFB
] = "ifb",
395 [NL_UNION_LINK_INFO_DATA_BAREUDP
] = "bareudp",
398 DEFINE_STRING_TABLE_LOOKUP(nl_union_link_info_data
, NLUnionLinkInfoData
);
400 static const NLTypeSystem rtnl_link_info_data_type_systems
[] = {
401 [NL_UNION_LINK_INFO_DATA_BOND
] = { .count
= ELEMENTSOF(rtnl_link_info_data_bond_types
),
402 .types
= rtnl_link_info_data_bond_types
},
403 [NL_UNION_LINK_INFO_DATA_BRIDGE
] = { .count
= ELEMENTSOF(rtnl_link_info_data_bridge_types
),
404 .types
= rtnl_link_info_data_bridge_types
},
405 [NL_UNION_LINK_INFO_DATA_VLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vlan_types
),
406 .types
= rtnl_link_info_data_vlan_types
},
407 [NL_UNION_LINK_INFO_DATA_VETH
] = { .count
= ELEMENTSOF(rtnl_link_info_data_veth_types
),
408 .types
= rtnl_link_info_data_veth_types
},
409 [NL_UNION_LINK_INFO_DATA_MACVLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_macvlan_types
),
410 .types
= rtnl_link_info_data_macvlan_types
},
411 [NL_UNION_LINK_INFO_DATA_MACVTAP
] = { .count
= ELEMENTSOF(rtnl_link_info_data_macvlan_types
),
412 .types
= rtnl_link_info_data_macvlan_types
},
413 [NL_UNION_LINK_INFO_DATA_IPVLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvlan_types
),
414 .types
= rtnl_link_info_data_ipvlan_types
},
415 [NL_UNION_LINK_INFO_DATA_IPVTAP
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvlan_types
),
416 .types
= rtnl_link_info_data_ipvlan_types
},
417 [NL_UNION_LINK_INFO_DATA_VXLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vxlan_types
),
418 .types
= rtnl_link_info_data_vxlan_types
},
419 [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_iptun_types
),
420 .types
= rtnl_link_info_data_iptun_types
},
421 [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
422 .types
= rtnl_link_info_data_ipgre_types
},
423 [NL_UNION_LINK_INFO_DATA_ERSPAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
424 .types
= rtnl_link_info_data_ipgre_types
},
425 [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
426 .types
= rtnl_link_info_data_ipgre_types
},
427 [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
428 .types
= rtnl_link_info_data_ipgre_types
},
429 [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
430 .types
= rtnl_link_info_data_ipgre_types
},
431 [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_iptun_types
),
432 .types
= rtnl_link_info_data_iptun_types
},
433 [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvti_types
),
434 .types
= rtnl_link_info_data_ipvti_types
},
435 [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvti_types
),
436 .types
= rtnl_link_info_data_ipvti_types
},
437 [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ip6tnl_types
),
438 .types
= rtnl_link_info_data_ip6tnl_types
},
439 [NL_UNION_LINK_INFO_DATA_VRF
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vrf_types
),
440 .types
= rtnl_link_info_data_vrf_types
},
441 [NL_UNION_LINK_INFO_DATA_GENEVE
] = { .count
= ELEMENTSOF(rtnl_link_info_data_geneve_types
),
442 .types
= rtnl_link_info_data_geneve_types
},
443 [NL_UNION_LINK_INFO_DATA_VXCAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vxcan_types
),
444 .types
= rtnl_link_info_data_vxcan_types
},
445 [NL_UNION_LINK_INFO_DATA_CAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_can_types
),
446 .types
= rtnl_link_info_data_can_types
},
447 [NL_UNION_LINK_INFO_DATA_MACSEC
] = { .count
= ELEMENTSOF(rtnl_link_info_data_macsec_types
),
448 .types
= rtnl_link_info_data_macsec_types
},
449 [NL_UNION_LINK_INFO_DATA_XFRM
] = { .count
= ELEMENTSOF(rtnl_link_info_data_xfrm_types
),
450 .types
= rtnl_link_info_data_xfrm_types
},
451 [NL_UNION_LINK_INFO_DATA_BAREUDP
] = { .count
= ELEMENTSOF(rtnl_link_info_data_bareudp_types
),
452 .types
= rtnl_link_info_data_bareudp_types
},
455 static const NLTypeSystemUnion rtnl_link_info_data_type_system_union
= {
456 .num
= _NL_UNION_LINK_INFO_DATA_MAX
,
457 .lookup
= nl_union_link_info_data_from_string
,
458 .type_systems
= rtnl_link_info_data_type_systems
,
459 .match_type
= NL_MATCH_SIBLING
,
460 .match
= IFLA_INFO_KIND
,
463 static const NLType rtnl_link_info_types
[] = {
464 [IFLA_INFO_KIND
] = { .type
= NETLINK_TYPE_STRING
},
465 [IFLA_INFO_DATA
] = { .type
= NETLINK_TYPE_UNION
, .type_system_union
= &rtnl_link_info_data_type_system_union
},
468 [IFLA_INFO_SLAVE_KIND] = { .type = NETLINK_TYPE_STRING },
469 [IFLA_INFO_SLAVE_DATA] = { .type = NETLINK_TYPE_NESTED },
473 static const NLTypeSystem rtnl_link_info_type_system
= {
474 .count
= ELEMENTSOF(rtnl_link_info_types
),
475 .types
= rtnl_link_info_types
,
478 static const struct NLType rtnl_prot_info_bridge_port_types
[] = {
479 [IFLA_BRPORT_STATE
] = { .type
= NETLINK_TYPE_U8
},
480 [IFLA_BRPORT_COST
] = { .type
= NETLINK_TYPE_U32
},
481 [IFLA_BRPORT_PRIORITY
] = { .type
= NETLINK_TYPE_U16
},
482 [IFLA_BRPORT_MODE
] = { .type
= NETLINK_TYPE_U8
},
483 [IFLA_BRPORT_GUARD
] = { .type
= NETLINK_TYPE_U8
},
484 [IFLA_BRPORT_PROTECT
] = { .type
= NETLINK_TYPE_U8
},
485 [IFLA_BRPORT_FAST_LEAVE
] = { .type
= NETLINK_TYPE_U8
},
486 [IFLA_BRPORT_LEARNING
] = { .type
= NETLINK_TYPE_U8
},
487 [IFLA_BRPORT_UNICAST_FLOOD
] = { .type
= NETLINK_TYPE_U8
},
488 [IFLA_BRPORT_PROXYARP
] = { .type
= NETLINK_TYPE_U8
},
489 [IFLA_BRPORT_LEARNING_SYNC
] = { .type
= NETLINK_TYPE_U8
},
490 [IFLA_BRPORT_PROXYARP_WIFI
] = { .type
= NETLINK_TYPE_U8
},
491 [IFLA_BRPORT_ROOT_ID
] = { .type
= NETLINK_TYPE_U8
},
492 [IFLA_BRPORT_BRIDGE_ID
] = { .type
= NETLINK_TYPE_U8
},
493 [IFLA_BRPORT_DESIGNATED_PORT
] = { .type
= NETLINK_TYPE_U16
},
494 [IFLA_BRPORT_DESIGNATED_COST
] = { .type
= NETLINK_TYPE_U16
},
495 [IFLA_BRPORT_ID
] = { .type
= NETLINK_TYPE_U16
},
496 [IFLA_BRPORT_NO
] = { .type
= NETLINK_TYPE_U16
},
497 [IFLA_BRPORT_TOPOLOGY_CHANGE_ACK
] = { .type
= NETLINK_TYPE_U8
},
498 [IFLA_BRPORT_CONFIG_PENDING
] = { .type
= NETLINK_TYPE_U8
},
499 [IFLA_BRPORT_MESSAGE_AGE_TIMER
] = { .type
= NETLINK_TYPE_U64
},
500 [IFLA_BRPORT_FORWARD_DELAY_TIMER
] = { .type
= NETLINK_TYPE_U64
},
501 [IFLA_BRPORT_HOLD_TIMER
] = { .type
= NETLINK_TYPE_U64
},
502 [IFLA_BRPORT_FLUSH
] = { .type
= NETLINK_TYPE_U8
},
503 [IFLA_BRPORT_MULTICAST_ROUTER
] = { .type
= NETLINK_TYPE_U8
},
504 [IFLA_BRPORT_PAD
] = { .type
= NETLINK_TYPE_U8
},
505 [IFLA_BRPORT_MCAST_FLOOD
] = { .type
= NETLINK_TYPE_U8
},
506 [IFLA_BRPORT_MCAST_TO_UCAST
] = { .type
= NETLINK_TYPE_U8
},
507 [IFLA_BRPORT_VLAN_TUNNEL
] = { .type
= NETLINK_TYPE_U8
},
508 [IFLA_BRPORT_BCAST_FLOOD
] = { .type
= NETLINK_TYPE_U8
},
509 [IFLA_BRPORT_GROUP_FWD_MASK
] = { .type
= NETLINK_TYPE_U16
},
510 [IFLA_BRPORT_NEIGH_SUPPRESS
] = { .type
= NETLINK_TYPE_U8
},
511 [IFLA_BRPORT_ISOLATED
] = { .type
= NETLINK_TYPE_U8
},
512 [IFLA_BRPORT_BACKUP_PORT
] = { .type
= NETLINK_TYPE_U32
},
515 static const NLTypeSystem rtnl_prot_info_type_systems
[] = {
516 [AF_BRIDGE
] = { .count
= ELEMENTSOF(rtnl_prot_info_bridge_port_types
),
517 .types
= rtnl_prot_info_bridge_port_types
},
520 static const NLTypeSystemUnion rtnl_prot_info_type_system_union
= {
522 .type_systems
= rtnl_prot_info_type_systems
,
523 .match_type
= NL_MATCH_PROTOCOL
,
526 static const struct NLType rtnl_af_spec_inet6_types
[] = {
527 [IFLA_INET6_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
532 IFLA_INET6_CACHEINFO,
533 IFLA_INET6_ICMP6STATS,
535 [IFLA_INET6_TOKEN
] = { .type
= NETLINK_TYPE_IN_ADDR
},
536 [IFLA_INET6_ADDR_GEN_MODE
] = { .type
= NETLINK_TYPE_U8
},
539 static const NLTypeSystem rtnl_af_spec_inet6_type_system
= {
540 .count
= ELEMENTSOF(rtnl_af_spec_inet6_types
),
541 .types
= rtnl_af_spec_inet6_types
,
544 static const NLType rtnl_af_spec_types
[] = {
545 [AF_INET6
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_af_spec_inet6_type_system
},
548 static const NLTypeSystem rtnl_af_spec_type_system
= {
549 .count
= ELEMENTSOF(rtnl_af_spec_types
),
550 .types
= rtnl_af_spec_types
,
553 static const NLType rtnl_prop_list_types
[] = {
554 [IFLA_ALT_IFNAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= ALTIFNAMSIZ
- 1 },
557 static const NLTypeSystem rtnl_prop_list_type_system
= {
558 .count
= ELEMENTSOF(rtnl_prop_list_types
),
559 .types
= rtnl_prop_list_types
,
562 static const NLType rtnl_vf_vlan_list_types
[] = {
563 [IFLA_VF_VLAN_INFO
] = { .size
= sizeof(struct ifla_vf_vlan_info
) },
566 static const NLTypeSystem rtnl_vf_vlan_type_system
= {
567 .count
= ELEMENTSOF(rtnl_vf_vlan_list_types
),
568 .types
= rtnl_vf_vlan_list_types
,
571 static const NLType rtnl_vf_vlan_info_types
[] = {
572 [IFLA_VF_MAC
] = { .size
= sizeof(struct ifla_vf_mac
) },
573 [IFLA_VF_VLAN
] = { .size
= sizeof(struct ifla_vf_vlan
) },
574 [IFLA_VF_VLAN_LIST
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_vf_vlan_type_system
},
575 [IFLA_VF_TX_RATE
] = { .size
= sizeof(struct ifla_vf_tx_rate
) },
576 [IFLA_VF_SPOOFCHK
] = { .size
= sizeof(struct ifla_vf_spoofchk
) },
577 [IFLA_VF_RATE
] = { .size
= sizeof(struct ifla_vf_rate
) },
578 [IFLA_VF_LINK_STATE
] = { .size
= sizeof(struct ifla_vf_link_state
) },
579 [IFLA_VF_RSS_QUERY_EN
] = { .size
= sizeof(struct ifla_vf_rss_query_en
) },
580 [IFLA_VF_TRUST
] = { .size
= sizeof(struct ifla_vf_trust
) },
581 [IFLA_VF_IB_NODE_GUID
] = { .size
= sizeof(struct ifla_vf_guid
) },
582 [IFLA_VF_IB_PORT_GUID
] = { .size
= sizeof(struct ifla_vf_guid
) },
585 static const NLTypeSystem rtnl_vf_vlan_info_type_system
= {
586 .count
= ELEMENTSOF(rtnl_vf_vlan_info_types
),
587 .types
= rtnl_vf_vlan_info_types
,
590 static const NLType rtnl_link_io_srv_types
[] = {
591 [IFLA_VF_INFO
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_vf_vlan_info_type_system
},
594 static const NLTypeSystem rtnl_io_srv_type_system
= {
595 .count
= ELEMENTSOF(rtnl_link_io_srv_types
),
596 .types
= rtnl_link_io_srv_types
,
599 static const NLType rtnl_link_types
[] = {
600 [IFLA_ADDRESS
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
601 [IFLA_BROADCAST
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
602 [IFLA_IFNAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFNAMSIZ
- 1 },
603 [IFLA_MTU
] = { .type
= NETLINK_TYPE_U32
},
604 [IFLA_LINK
] = { .type
= NETLINK_TYPE_U32
},
605 [IFLA_QDISC
] = { .type
= NETLINK_TYPE_STRING
},
606 [IFLA_STATS
] = { .size
= sizeof(struct rtnl_link_stats
) },
611 [IFLA_MASTER
] = { .type
= NETLINK_TYPE_U32
},
615 [IFLA_PROTINFO
] = { .type
= NETLINK_TYPE_UNION
, .type_system_union
= &rtnl_prot_info_type_system_union
},
616 [IFLA_TXQLEN
] = { .type
= NETLINK_TYPE_U32
},
618 [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) },
620 [IFLA_WEIGHT
] = { .type
= NETLINK_TYPE_U32
},
621 [IFLA_OPERSTATE
] = { .type
= NETLINK_TYPE_U8
},
622 [IFLA_LINKMODE
] = { .type
= NETLINK_TYPE_U8
},
623 [IFLA_LINKINFO
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_info_type_system
},
624 [IFLA_NET_NS_PID
] = { .type
= NETLINK_TYPE_U32
},
625 [IFLA_IFALIAS
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFALIASZ
- 1 },
626 [IFLA_NUM_VF
] = { .type
= NETLINK_TYPE_U32
},
627 [IFLA_VFINFO_LIST
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_io_srv_type_system
},
628 [IFLA_STATS64
] = { .size
= sizeof(struct rtnl_link_stats64
) },
630 [IFLA_VF_PORTS] = { .type = NETLINK_TYPE_NESTED },
631 [IFLA_PORT_SELF] = { .type = NETLINK_TYPE_NESTED },
633 [IFLA_AF_SPEC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_af_spec_type_system
},
639 [IFLA_GROUP
] = { .type
= NETLINK_TYPE_U32
},
640 [IFLA_NET_NS_FD
] = { .type
= NETLINK_TYPE_U32
},
641 [IFLA_EXT_MASK
] = { .type
= NETLINK_TYPE_U32
},
642 [IFLA_PROMISCUITY
] = { .type
= NETLINK_TYPE_U32
},
643 [IFLA_NUM_TX_QUEUES
] = { .type
= NETLINK_TYPE_U32
},
644 [IFLA_NUM_RX_QUEUES
] = { .type
= NETLINK_TYPE_U32
},
645 [IFLA_CARRIER
] = { .type
= NETLINK_TYPE_U8
},
647 [IFLA_PHYS_PORT_ID] = { .type = NETLINK_TYPE_BINARY, .len = MAX_PHYS_PORT_ID_LEN },
649 [IFLA_MIN_MTU
] = { .type
= NETLINK_TYPE_U32
},
650 [IFLA_MAX_MTU
] = { .type
= NETLINK_TYPE_U32
},
651 [IFLA_PROP_LIST
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_prop_list_type_system
},
652 [IFLA_ALT_IFNAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= ALTIFNAMSIZ
- 1 },
655 static const NLTypeSystem rtnl_link_type_system
= {
656 .count
= ELEMENTSOF(rtnl_link_types
),
657 .types
= rtnl_link_types
,
660 /* IFA_FLAGS was defined in kernel 3.14, but we still support older
661 * kernels where IFA_MAX is lower. */
662 static const NLType rtnl_address_types
[] = {
663 [IFA_ADDRESS
] = { .type
= NETLINK_TYPE_IN_ADDR
},
664 [IFA_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
665 [IFA_LABEL
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFNAMSIZ
- 1 },
666 [IFA_BROADCAST
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
667 [IFA_CACHEINFO
] = { .type
= NETLINK_TYPE_CACHE_INFO
, .size
= sizeof(struct ifa_cacheinfo
) },
672 [IFA_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
675 static const NLTypeSystem rtnl_address_type_system
= {
676 .count
= ELEMENTSOF(rtnl_address_types
),
677 .types
= rtnl_address_types
,
680 /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
682 static const NLType rtnl_route_metrics_types
[] = {
683 [RTAX_MTU
] = { .type
= NETLINK_TYPE_U32
},
684 [RTAX_WINDOW
] = { .type
= NETLINK_TYPE_U32
},
685 [RTAX_RTT
] = { .type
= NETLINK_TYPE_U32
},
686 [RTAX_RTTVAR
] = { .type
= NETLINK_TYPE_U32
},
687 [RTAX_SSTHRESH
] = { .type
= NETLINK_TYPE_U32
},
688 [RTAX_CWND
] = { .type
= NETLINK_TYPE_U32
},
689 [RTAX_ADVMSS
] = { .type
= NETLINK_TYPE_U32
},
690 [RTAX_REORDERING
] = { .type
= NETLINK_TYPE_U32
},
691 [RTAX_HOPLIMIT
] = { .type
= NETLINK_TYPE_U32
},
692 [RTAX_INITCWND
] = { .type
= NETLINK_TYPE_U32
},
693 [RTAX_FEATURES
] = { .type
= NETLINK_TYPE_U32
},
694 [RTAX_RTO_MIN
] = { .type
= NETLINK_TYPE_U32
},
695 [RTAX_INITRWND
] = { .type
= NETLINK_TYPE_U32
},
696 [RTAX_QUICKACK
] = { .type
= NETLINK_TYPE_U32
},
697 [RTAX_CC_ALGO
] = { .type
= NETLINK_TYPE_U32
},
698 [RTAX_FASTOPEN_NO_COOKIE
] = { .type
= NETLINK_TYPE_U32
},
701 static const NLTypeSystem rtnl_route_metrics_type_system
= {
702 .count
= ELEMENTSOF(rtnl_route_metrics_types
),
703 .types
= rtnl_route_metrics_types
,
706 static const NLType rtnl_route_types
[] = {
707 [RTA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
708 [RTA_SRC
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
709 [RTA_IIF
] = { .type
= NETLINK_TYPE_U32
},
710 [RTA_OIF
] = { .type
= NETLINK_TYPE_U32
},
711 [RTA_GATEWAY
] = { .type
= NETLINK_TYPE_IN_ADDR
},
712 [RTA_PRIORITY
] = { .type
= NETLINK_TYPE_U32
},
713 [RTA_PREFSRC
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
714 [RTA_METRICS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_metrics_type_system
},
715 [RTA_MULTIPATH
] = { .size
= sizeof(struct rtnexthop
) },
716 [RTA_FLOW
] = { .type
= NETLINK_TYPE_U32
}, /* 6? */
717 [RTA_CACHEINFO
] = { .size
= sizeof(struct rta_cacheinfo
) },
718 [RTA_TABLE
] = { .type
= NETLINK_TYPE_U32
},
719 [RTA_MARK
] = { .type
= NETLINK_TYPE_U32
},
720 [RTA_MFC_STATS
] = { .type
= NETLINK_TYPE_U64
},
721 [RTA_VIA
] = { /* See struct rtvia */ },
722 [RTA_NEWDST
] = { .type
= NETLINK_TYPE_U32
},
723 [RTA_PREF
] = { .type
= NETLINK_TYPE_U8
},
724 [RTA_EXPIRES
] = { .type
= NETLINK_TYPE_U32
},
725 [RTA_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
726 [RTA_ENCAP
] = { .type
= NETLINK_TYPE_NESTED
}, /* Multiple type systems i.e. LWTUNNEL_ENCAP_MPLS/LWTUNNEL_ENCAP_IP/LWTUNNEL_ENCAP_ILA etc... */
727 [RTA_UID
] = { .type
= NETLINK_TYPE_U32
},
728 [RTA_TTL_PROPAGATE
] = { .type
= NETLINK_TYPE_U8
},
729 [RTA_IP_PROTO
] = { .type
= NETLINK_TYPE_U8
},
730 [RTA_SPORT
] = { .type
= NETLINK_TYPE_U16
},
731 [RTA_DPORT
] = { .type
= NETLINK_TYPE_U16
},
734 static const NLTypeSystem rtnl_route_type_system
= {
735 .count
= ELEMENTSOF(rtnl_route_types
),
736 .types
= rtnl_route_types
,
739 static const NLType rtnl_neigh_types
[] = {
740 [NDA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
},
741 [NDA_LLADDR
] = { /* struct ether_addr, struct in_addr, or struct in6_addr */ },
742 [NDA_CACHEINFO
] = { .type
= NETLINK_TYPE_CACHE_INFO
, .size
= sizeof(struct nda_cacheinfo
) },
743 [NDA_PROBES
] = { .type
= NETLINK_TYPE_U32
},
744 [NDA_VLAN
] = { .type
= NETLINK_TYPE_U16
},
745 [NDA_PORT
] = { .type
= NETLINK_TYPE_U16
},
746 [NDA_VNI
] = { .type
= NETLINK_TYPE_U32
},
747 [NDA_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
750 static const NLTypeSystem rtnl_neigh_type_system
= {
751 .count
= ELEMENTSOF(rtnl_neigh_types
),
752 .types
= rtnl_neigh_types
,
755 static const NLType rtnl_addrlabel_types
[] = {
756 [IFAL_ADDRESS
] = { .type
= NETLINK_TYPE_IN_ADDR
, .size
= sizeof(struct in6_addr
) },
757 [IFAL_LABEL
] = { .type
= NETLINK_TYPE_U32
},
760 static const NLTypeSystem rtnl_addrlabel_type_system
= {
761 .count
= ELEMENTSOF(rtnl_addrlabel_types
),
762 .types
= rtnl_addrlabel_types
,
765 static const NLType rtnl_routing_policy_rule_types
[] = {
766 [FRA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
},
767 [FRA_SRC
] = { .type
= NETLINK_TYPE_IN_ADDR
},
768 [FRA_IIFNAME
] = { .type
= NETLINK_TYPE_STRING
},
769 [FRA_GOTO
] = { .type
= NETLINK_TYPE_U32
},
770 [FRA_PRIORITY
] = { .type
= NETLINK_TYPE_U32
},
771 [FRA_FWMARK
] = { .type
= NETLINK_TYPE_U32
},
772 [FRA_FLOW
] = { .type
= NETLINK_TYPE_U32
},
773 [FRA_TUN_ID
] = { .type
= NETLINK_TYPE_U64
},
774 [FRA_SUPPRESS_IFGROUP
] = { .type
= NETLINK_TYPE_U32
},
775 [FRA_SUPPRESS_PREFIXLEN
] = { .type
= NETLINK_TYPE_U32
},
776 [FRA_TABLE
] = { .type
= NETLINK_TYPE_U32
},
777 [FRA_FWMASK
] = { .type
= NETLINK_TYPE_U32
},
778 [FRA_OIFNAME
] = { .type
= NETLINK_TYPE_STRING
},
779 [FRA_PAD
] = { .type
= NETLINK_TYPE_U32
},
780 [FRA_L3MDEV
] = { .type
= NETLINK_TYPE_U8
},
781 [FRA_UID_RANGE
] = { .size
= sizeof(struct fib_rule_uid_range
) },
782 [FRA_PROTOCOL
] = { .type
= NETLINK_TYPE_U8
},
783 [FRA_IP_PROTO
] = { .type
= NETLINK_TYPE_U8
},
784 [FRA_SPORT_RANGE
] = { .size
= sizeof(struct fib_rule_port_range
) },
785 [FRA_DPORT_RANGE
] = { .size
= sizeof(struct fib_rule_port_range
) },
788 static const NLTypeSystem rtnl_routing_policy_rule_type_system
= {
789 .count
= ELEMENTSOF(rtnl_routing_policy_rule_types
),
790 .types
= rtnl_routing_policy_rule_types
,
793 static const NLType rtnl_nexthop_types
[] = {
794 [NHA_ID
] = { .type
= NETLINK_TYPE_U32
},
795 [NHA_OIF
] = { .type
= NETLINK_TYPE_U32
},
796 [NHA_GATEWAY
] = { .type
= NETLINK_TYPE_IN_ADDR
},
799 static const NLTypeSystem rtnl_nexthop_type_system
= {
800 .count
= ELEMENTSOF(rtnl_nexthop_types
),
801 .types
= rtnl_nexthop_types
,
804 static const NLType rtnl_tca_option_data_cake_types
[] = {
805 [TCA_CAKE_BASE_RATE64
] = { .type
= NETLINK_TYPE_U64
},
806 [TCA_CAKE_OVERHEAD
] = { .type
= NETLINK_TYPE_S32
},
807 [TCA_CAKE_MPU
] = { .type
= NETLINK_TYPE_U32
},
810 static const NLType rtnl_tca_option_data_codel_types
[] = {
811 [TCA_CODEL_TARGET
] = { .type
= NETLINK_TYPE_U32
},
812 [TCA_CODEL_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
813 [TCA_CODEL_INTERVAL
] = { .type
= NETLINK_TYPE_U32
},
814 [TCA_CODEL_ECN
] = { .type
= NETLINK_TYPE_U32
},
815 [TCA_CODEL_CE_THRESHOLD
] = { .type
= NETLINK_TYPE_U32
},
818 static const NLType rtnl_tca_option_data_drr_types
[] = {
819 [TCA_DRR_QUANTUM
] = { .type
= NETLINK_TYPE_U32
},
822 static const NLType rtnl_tca_option_data_ets_quanta_types
[] = {
823 [TCA_ETS_QUANTA_BAND
] = { .type
= NETLINK_TYPE_U32
, },
826 static const NLTypeSystem rtnl_tca_option_data_ets_quanta_type_system
= {
827 .count
= ELEMENTSOF(rtnl_tca_option_data_ets_quanta_types
),
828 .types
= rtnl_tca_option_data_ets_quanta_types
,
831 static const NLType rtnl_tca_option_data_ets_prio_types
[] = {
832 [TCA_ETS_PRIOMAP_BAND
] = { .type
= NETLINK_TYPE_U8
, },
835 static const NLTypeSystem rtnl_tca_option_data_ets_prio_type_system
= {
836 .count
= ELEMENTSOF(rtnl_tca_option_data_ets_prio_types
),
837 .types
= rtnl_tca_option_data_ets_prio_types
,
840 static const NLType rtnl_tca_option_data_ets_types
[] = {
841 [TCA_ETS_NBANDS
] = { .type
= NETLINK_TYPE_U8
},
842 [TCA_ETS_NSTRICT
] = { .type
= NETLINK_TYPE_U8
},
843 [TCA_ETS_QUANTA
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_option_data_ets_quanta_type_system
},
844 [TCA_ETS_PRIOMAP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_option_data_ets_prio_type_system
},
845 [TCA_ETS_QUANTA_BAND
] = { .type
= NETLINK_TYPE_U32
},
848 static const NLType rtnl_tca_option_data_fq_types
[] = {
849 [TCA_FQ_PLIMIT
] = { .type
= NETLINK_TYPE_U32
},
850 [TCA_FQ_FLOW_PLIMIT
] = { .type
= NETLINK_TYPE_U32
},
851 [TCA_FQ_QUANTUM
] = { .type
= NETLINK_TYPE_U32
},
852 [TCA_FQ_INITIAL_QUANTUM
] = { .type
= NETLINK_TYPE_U32
},
853 [TCA_FQ_RATE_ENABLE
] = { .type
= NETLINK_TYPE_U32
},
854 [TCA_FQ_FLOW_DEFAULT_RATE
] = { .type
= NETLINK_TYPE_U32
},
855 [TCA_FQ_FLOW_MAX_RATE
] = { .type
= NETLINK_TYPE_U32
},
856 [TCA_FQ_BUCKETS_LOG
] = { .type
= NETLINK_TYPE_U32
},
857 [TCA_FQ_FLOW_REFILL_DELAY
] = { .type
= NETLINK_TYPE_U32
},
858 [TCA_FQ_LOW_RATE_THRESHOLD
] = { .type
= NETLINK_TYPE_U32
},
859 [TCA_FQ_CE_THRESHOLD
] = { .type
= NETLINK_TYPE_U32
},
860 [TCA_FQ_ORPHAN_MASK
] = { .type
= NETLINK_TYPE_U32
},
863 static const NLType rtnl_tca_option_data_fq_codel_types
[] = {
864 [TCA_FQ_CODEL_TARGET
] = { .type
= NETLINK_TYPE_U32
},
865 [TCA_FQ_CODEL_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
866 [TCA_FQ_CODEL_INTERVAL
] = { .type
= NETLINK_TYPE_U32
},
867 [TCA_FQ_CODEL_ECN
] = { .type
= NETLINK_TYPE_U32
},
868 [TCA_FQ_CODEL_FLOWS
] = { .type
= NETLINK_TYPE_U32
},
869 [TCA_FQ_CODEL_QUANTUM
] = { .type
= NETLINK_TYPE_U32
},
870 [TCA_FQ_CODEL_CE_THRESHOLD
] = { .type
= NETLINK_TYPE_U32
},
871 [TCA_FQ_CODEL_DROP_BATCH_SIZE
] = { .type
= NETLINK_TYPE_U32
},
872 [TCA_FQ_CODEL_MEMORY_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
875 static const NLType rtnl_tca_option_data_fq_pie_types
[] = {
876 [TCA_FQ_PIE_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
879 static const NLType rtnl_tca_option_data_gred_types
[] = {
880 [TCA_GRED_DPS
] = { .size
= sizeof(struct tc_gred_sopt
) },
883 static const NLType rtnl_tca_option_data_hhf_types
[] = {
884 [TCA_HHF_BACKLOG_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
887 static const NLType rtnl_tca_option_data_htb_types
[] = {
888 [TCA_HTB_PARMS
] = { .size
= sizeof(struct tc_htb_opt
) },
889 [TCA_HTB_INIT
] = { .size
= sizeof(struct tc_htb_glob
) },
890 [TCA_HTB_CTAB
] = { .size
= TC_RTAB_SIZE
},
891 [TCA_HTB_RTAB
] = { .size
= TC_RTAB_SIZE
},
892 [TCA_HTB_RATE64
] = { .type
= NETLINK_TYPE_U64
},
893 [TCA_HTB_CEIL64
] = { .type
= NETLINK_TYPE_U64
},
896 static const NLType rtnl_tca_option_data_pie_types
[] = {
897 [TCA_PIE_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
900 static const NLType rtnl_tca_option_data_qfq_types
[] = {
901 [TCA_QFQ_WEIGHT
] = { .type
= NETLINK_TYPE_U32
},
902 [TCA_QFQ_LMAX
] = { .type
= NETLINK_TYPE_U32
},
905 static const NLType rtnl_tca_option_data_sfb_types
[] = {
906 [TCA_SFB_PARMS
] = { .size
= sizeof(struct tc_sfb_qopt
) },
909 static const NLType rtnl_tca_option_data_tbf_types
[] = {
910 [TCA_TBF_PARMS
] = { .size
= sizeof(struct tc_tbf_qopt
) },
911 [TCA_TBF_RTAB
] = { .size
= TC_RTAB_SIZE
},
912 [TCA_TBF_PTAB
] = { .size
= TC_RTAB_SIZE
},
913 [TCA_TBF_RATE64
] = { .type
= NETLINK_TYPE_U64
},
914 [TCA_TBF_PRATE64
] = { .type
= NETLINK_TYPE_U64
},
915 [TCA_TBF_BURST
] = { .type
= NETLINK_TYPE_U32
},
916 [TCA_TBF_PBURST
] = { .type
= NETLINK_TYPE_U32
},
919 static const char* const nl_union_tca_option_data_table
[] = {
920 [NL_UNION_TCA_OPTION_DATA_CAKE
] = "cake",
921 [NL_UNION_TCA_OPTION_DATA_CODEL
] = "codel",
922 [NL_UNION_TCA_OPTION_DATA_DRR
] = "drr",
923 [NL_UNION_TCA_OPTION_DATA_ETS
] = "ets",
924 [NL_UNION_TCA_OPTION_DATA_FQ
] = "fq",
925 [NL_UNION_TCA_OPTION_DATA_FQ_CODEL
] = "fq_codel",
926 [NL_UNION_TCA_OPTION_DATA_FQ_PIE
] = "fq_pie",
927 [NL_UNION_TCA_OPTION_DATA_GRED
] = "gred",
928 [NL_UNION_TCA_OPTION_DATA_HHF
] = "hhf",
929 [NL_UNION_TCA_OPTION_DATA_HTB
] = "htb",
930 [NL_UNION_TCA_OPTION_DATA_PIE
] = "pie",
931 [NL_UNION_TCA_OPTION_DATA_QFQ
] = "qfq",
932 [NL_UNION_TCA_OPTION_DATA_SFB
] = "sfb",
933 [NL_UNION_TCA_OPTION_DATA_TBF
] = "tbf",
936 DEFINE_STRING_TABLE_LOOKUP(nl_union_tca_option_data
, NLUnionTCAOptionData
);
938 static const NLTypeSystem rtnl_tca_option_data_type_systems
[] = {
939 [NL_UNION_TCA_OPTION_DATA_CAKE
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_cake_types
),
940 .types
= rtnl_tca_option_data_cake_types
},
941 [NL_UNION_TCA_OPTION_DATA_CODEL
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_codel_types
),
942 .types
= rtnl_tca_option_data_codel_types
},
943 [NL_UNION_TCA_OPTION_DATA_DRR
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_drr_types
),
944 .types
= rtnl_tca_option_data_drr_types
},
945 [NL_UNION_TCA_OPTION_DATA_ETS
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_ets_types
),
946 .types
= rtnl_tca_option_data_ets_types
},
947 [NL_UNION_TCA_OPTION_DATA_FQ
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_fq_types
),
948 .types
= rtnl_tca_option_data_fq_types
},
949 [NL_UNION_TCA_OPTION_DATA_FQ_CODEL
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_fq_codel_types
),
950 .types
= rtnl_tca_option_data_fq_codel_types
},
951 [NL_UNION_TCA_OPTION_DATA_FQ_PIE
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_fq_pie_types
),
952 .types
= rtnl_tca_option_data_fq_pie_types
},
953 [NL_UNION_TCA_OPTION_DATA_GRED
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_gred_types
),
954 .types
= rtnl_tca_option_data_gred_types
},
955 [NL_UNION_TCA_OPTION_DATA_HHF
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_hhf_types
),
956 .types
= rtnl_tca_option_data_hhf_types
},
957 [NL_UNION_TCA_OPTION_DATA_HTB
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_htb_types
),
958 .types
= rtnl_tca_option_data_htb_types
},
959 [NL_UNION_TCA_OPTION_DATA_PIE
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_pie_types
),
960 .types
= rtnl_tca_option_data_pie_types
},
961 [NL_UNION_TCA_OPTION_DATA_QFQ
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_qfq_types
),
962 .types
= rtnl_tca_option_data_qfq_types
},
963 [NL_UNION_TCA_OPTION_DATA_SFB
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_sfb_types
),
964 .types
= rtnl_tca_option_data_sfb_types
},
965 [NL_UNION_TCA_OPTION_DATA_TBF
] = { .count
= ELEMENTSOF(rtnl_tca_option_data_tbf_types
),
966 .types
= rtnl_tca_option_data_tbf_types
},
969 static const NLTypeSystemUnion rtnl_tca_option_data_type_system_union
= {
970 .num
= _NL_UNION_TCA_OPTION_DATA_MAX
,
971 .lookup
= nl_union_tca_option_data_from_string
,
972 .type_systems
= rtnl_tca_option_data_type_systems
,
973 .match_type
= NL_MATCH_SIBLING
,
977 static const NLType rtnl_tca_types
[] = {
978 [TCA_KIND
] = { .type
= NETLINK_TYPE_STRING
},
979 [TCA_OPTIONS
] = { .type
= NETLINK_TYPE_UNION
, .type_system_union
= &rtnl_tca_option_data_type_system_union
},
980 [TCA_INGRESS_BLOCK
] = { .type
= NETLINK_TYPE_U32
},
981 [TCA_EGRESS_BLOCK
] = { .type
= NETLINK_TYPE_U32
},
984 static const NLTypeSystem rtnl_tca_type_system
= {
985 .count
= ELEMENTSOF(rtnl_tca_types
),
986 .types
= rtnl_tca_types
,
989 static const NLType mdb_types
[] = {
990 [MDBA_SET_ENTRY
] = { .size
= sizeof(struct br_port_msg
) },
993 static const NLTypeSystem rtnl_mdb_type_system
= {
994 .count
= ELEMENTSOF(mdb_types
),
998 static const NLType error_types
[] = {
999 [NLMSGERR_ATTR_MSG
] = { .type
= NETLINK_TYPE_STRING
},
1000 [NLMSGERR_ATTR_OFFS
] = { .type
= NETLINK_TYPE_U32
},
1003 static const NLTypeSystem error_type_system
= {
1004 .count
= ELEMENTSOF(error_types
),
1005 .types
= error_types
,
1008 static const NLType rtnl_types
[] = {
1009 [NLMSG_DONE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &empty_type_system
, .size
= 0 },
1010 [NLMSG_ERROR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &error_type_system
, .size
= sizeof(struct nlmsgerr
) },
1011 [RTM_NEWLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
1012 [RTM_DELLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
1013 [RTM_GETLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
1014 [RTM_SETLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
1015 [RTM_NEWLINKPROP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
1016 [RTM_DELLINKPROP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
1017 [RTM_GETLINKPROP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
1018 [RTM_NEWADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
1019 [RTM_DELADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
1020 [RTM_GETADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
1021 [RTM_NEWROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
1022 [RTM_DELROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
1023 [RTM_GETROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
1024 [RTM_NEWNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
1025 [RTM_DELNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
1026 [RTM_GETNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
1027 [RTM_NEWADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
1028 [RTM_DELADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
1029 [RTM_GETADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
1030 [RTM_NEWRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct fib_rule_hdr
) },
1031 [RTM_DELRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct fib_rule_hdr
) },
1032 [RTM_GETRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct fib_rule_hdr
) },
1033 [RTM_NEWNEXTHOP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_nexthop_type_system
, .size
= sizeof(struct nhmsg
) },
1034 [RTM_DELNEXTHOP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_nexthop_type_system
, .size
= sizeof(struct nhmsg
) },
1035 [RTM_GETNEXTHOP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_nexthop_type_system
, .size
= sizeof(struct nhmsg
) },
1036 [RTM_NEWQDISC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_type_system
, .size
= sizeof(struct tcmsg
) },
1037 [RTM_DELQDISC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_type_system
, .size
= sizeof(struct tcmsg
) },
1038 [RTM_GETQDISC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_type_system
, .size
= sizeof(struct tcmsg
) },
1039 [RTM_NEWTCLASS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_type_system
, .size
= sizeof(struct tcmsg
) },
1040 [RTM_DELTCLASS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_type_system
, .size
= sizeof(struct tcmsg
) },
1041 [RTM_GETTCLASS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_tca_type_system
, .size
= sizeof(struct tcmsg
) },
1042 [RTM_NEWMDB
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_mdb_type_system
, .size
= sizeof(struct br_port_msg
) },
1043 [RTM_DELMDB
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_mdb_type_system
, .size
= sizeof(struct br_port_msg
) },
1044 [RTM_GETMDB
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_mdb_type_system
, .size
= sizeof(struct br_port_msg
) },
1047 const NLTypeSystem rtnl_type_system_root
= {
1048 .count
= ELEMENTSOF(rtnl_types
),
1049 .types
= rtnl_types
,
1052 static const NLType genl_wireguard_allowedip_types
[] = {
1053 [WGALLOWEDIP_A_FAMILY
] = { .type
= NETLINK_TYPE_U16
},
1054 [WGALLOWEDIP_A_IPADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1055 [WGALLOWEDIP_A_CIDR_MASK
] = { .type
= NETLINK_TYPE_U8
},
1058 static const NLTypeSystem genl_wireguard_allowedip_type_system
= {
1059 .count
= ELEMENTSOF(genl_wireguard_allowedip_types
),
1060 .types
= genl_wireguard_allowedip_types
,
1063 static const NLType genl_wireguard_peer_types
[] = {
1064 [WGPEER_A_PUBLIC_KEY
] = { .size
= WG_KEY_LEN
},
1065 [WGPEER_A_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
1066 [WGPEER_A_PRESHARED_KEY
] = { .size
= WG_KEY_LEN
},
1067 [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL
] = { .type
= NETLINK_TYPE_U16
},
1068 [WGPEER_A_ENDPOINT
] = { .type
= NETLINK_TYPE_SOCKADDR
},
1069 [WGPEER_A_ALLOWEDIPS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_wireguard_allowedip_type_system
},
1072 static const NLTypeSystem genl_wireguard_peer_type_system
= {
1073 .count
= ELEMENTSOF(genl_wireguard_peer_types
),
1074 .types
= genl_wireguard_peer_types
,
1077 static const NLType genl_wireguard_set_device_types
[] = {
1078 [WGDEVICE_A_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
1079 [WGDEVICE_A_IFNAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFNAMSIZ
-1 },
1080 [WGDEVICE_A_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
1081 [WGDEVICE_A_PRIVATE_KEY
] = { .size
= WG_KEY_LEN
},
1082 [WGDEVICE_A_LISTEN_PORT
] = { .type
= NETLINK_TYPE_U16
},
1083 [WGDEVICE_A_FWMARK
] = { .type
= NETLINK_TYPE_U32
},
1084 [WGDEVICE_A_PEERS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_wireguard_peer_type_system
},
1087 static const NLTypeSystem genl_wireguard_set_device_type_system
= {
1088 .count
= ELEMENTSOF(genl_wireguard_set_device_types
),
1089 .types
= genl_wireguard_set_device_types
,
1092 static const NLType genl_wireguard_cmds
[] = {
1093 [WG_CMD_SET_DEVICE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_wireguard_set_device_type_system
},
1096 static const NLTypeSystem genl_wireguard_type_system
= {
1097 .count
= ELEMENTSOF(genl_wireguard_cmds
),
1098 .types
= genl_wireguard_cmds
,
1101 static const NLType genl_mcast_group_types
[] = {
1102 [CTRL_ATTR_MCAST_GRP_NAME
] = { .type
= NETLINK_TYPE_STRING
},
1103 [CTRL_ATTR_MCAST_GRP_ID
] = { .type
= NETLINK_TYPE_U32
},
1106 static const NLTypeSystem genl_mcast_group_type_system
= {
1107 .count
= ELEMENTSOF(genl_mcast_group_types
),
1108 .types
= genl_mcast_group_types
,
1111 static const NLType genl_get_family_types
[] = {
1112 [CTRL_ATTR_FAMILY_NAME
] = { .type
= NETLINK_TYPE_STRING
},
1113 [CTRL_ATTR_FAMILY_ID
] = { .type
= NETLINK_TYPE_U16
},
1114 [CTRL_ATTR_MCAST_GROUPS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_mcast_group_type_system
},
1117 static const NLTypeSystem genl_get_family_type_system
= {
1118 .count
= ELEMENTSOF(genl_get_family_types
),
1119 .types
= genl_get_family_types
,
1122 static const NLType genl_ctrl_id_ctrl_cmds
[] = {
1123 [CTRL_CMD_GETFAMILY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_get_family_type_system
},
1126 static const NLTypeSystem genl_ctrl_id_ctrl_type_system
= {
1127 .count
= ELEMENTSOF(genl_ctrl_id_ctrl_cmds
),
1128 .types
= genl_ctrl_id_ctrl_cmds
,
1131 static const NLType genl_fou_types
[] = {
1132 [FOU_ATTR_PORT
] = { .type
= NETLINK_TYPE_U16
},
1133 [FOU_ATTR_AF
] = { .type
= NETLINK_TYPE_U8
},
1134 [FOU_ATTR_IPPROTO
] = { .type
= NETLINK_TYPE_U8
},
1135 [FOU_ATTR_TYPE
] = { .type
= NETLINK_TYPE_U8
},
1136 [FOU_ATTR_REMCSUM_NOPARTIAL
] = { .type
= NETLINK_TYPE_FLAG
},
1137 [FOU_ATTR_LOCAL_V4
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1138 [FOU_ATTR_PEER_V4
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1139 [FOU_ATTR_LOCAL_V6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1140 [FOU_ATTR_PEER_V6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1141 [FOU_ATTR_PEER_PORT
] = { .type
= NETLINK_TYPE_U16
},
1142 [FOU_ATTR_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
1145 static const NLTypeSystem genl_fou_type_system
= {
1146 .count
= ELEMENTSOF(genl_fou_types
),
1147 .types
= genl_fou_types
,
1150 static const NLType genl_fou_cmds
[] = {
1151 [FOU_CMD_ADD
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_fou_type_system
},
1152 [FOU_CMD_DEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_fou_type_system
},
1153 [FOU_CMD_GET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_fou_type_system
},
1156 static const NLTypeSystem genl_fou_cmds_type_system
= {
1157 .count
= ELEMENTSOF(genl_fou_cmds
),
1158 .types
= genl_fou_cmds
,
1161 static const NLType genl_l2tp_types
[] = {
1162 [L2TP_ATTR_PW_TYPE
] = { .type
= NETLINK_TYPE_U16
},
1163 [L2TP_ATTR_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
1164 [L2TP_ATTR_OFFSET
] = { .type
= NETLINK_TYPE_U16
},
1165 [L2TP_ATTR_DATA_SEQ
] = { .type
= NETLINK_TYPE_U16
},
1166 [L2TP_ATTR_L2SPEC_TYPE
] = { .type
= NETLINK_TYPE_U8
},
1167 [L2TP_ATTR_L2SPEC_LEN
] = { .type
= NETLINK_TYPE_U8
},
1168 [L2TP_ATTR_PROTO_VERSION
] = { .type
= NETLINK_TYPE_U8
},
1169 [L2TP_ATTR_IFNAME
] = { .type
= NETLINK_TYPE_STRING
},
1170 [L2TP_ATTR_CONN_ID
] = { .type
= NETLINK_TYPE_U32
},
1171 [L2TP_ATTR_PEER_CONN_ID
] = { .type
= NETLINK_TYPE_U32
},
1172 [L2TP_ATTR_SESSION_ID
] = { .type
= NETLINK_TYPE_U32
},
1173 [L2TP_ATTR_PEER_SESSION_ID
] = { .type
= NETLINK_TYPE_U32
},
1174 [L2TP_ATTR_UDP_CSUM
] = { .type
= NETLINK_TYPE_U8
},
1175 [L2TP_ATTR_VLAN_ID
] = { .type
= NETLINK_TYPE_U16
},
1176 [L2TP_ATTR_RECV_SEQ
] = { .type
= NETLINK_TYPE_U8
},
1177 [L2TP_ATTR_SEND_SEQ
] = { .type
= NETLINK_TYPE_U8
},
1178 [L2TP_ATTR_LNS_MODE
] = { .type
= NETLINK_TYPE_U8
},
1179 [L2TP_ATTR_USING_IPSEC
] = { .type
= NETLINK_TYPE_U8
},
1180 [L2TP_ATTR_FD
] = { .type
= NETLINK_TYPE_U32
},
1181 [L2TP_ATTR_IP_SADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1182 [L2TP_ATTR_IP_DADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1183 [L2TP_ATTR_UDP_SPORT
] = { .type
= NETLINK_TYPE_U16
},
1184 [L2TP_ATTR_UDP_DPORT
] = { .type
= NETLINK_TYPE_U16
},
1185 [L2TP_ATTR_IP6_SADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1186 [L2TP_ATTR_IP6_DADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
1187 [L2TP_ATTR_UDP_ZERO_CSUM6_TX
] = { .type
= NETLINK_TYPE_FLAG
},
1188 [L2TP_ATTR_UDP_ZERO_CSUM6_RX
] = { .type
= NETLINK_TYPE_FLAG
},
1191 static const NLTypeSystem genl_l2tp_type_system
= {
1192 .count
= ELEMENTSOF(genl_l2tp_types
),
1193 .types
= genl_l2tp_types
,
1196 static const NLType genl_l2tp
[] = {
1197 [L2TP_CMD_TUNNEL_CREATE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1198 [L2TP_CMD_TUNNEL_DELETE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1199 [L2TP_CMD_TUNNEL_MODIFY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1200 [L2TP_CMD_TUNNEL_GET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1201 [L2TP_CMD_SESSION_CREATE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1202 [L2TP_CMD_SESSION_DELETE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1203 [L2TP_CMD_SESSION_MODIFY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1204 [L2TP_CMD_SESSION_GET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
1207 static const NLTypeSystem genl_l2tp_tunnel_session_type_system
= {
1208 .count
= ELEMENTSOF(genl_l2tp
),
1212 static const NLType genl_rxsc_types
[] = {
1213 [MACSEC_RXSC_ATTR_SCI
] = { .type
= NETLINK_TYPE_U64
},
1216 static const NLTypeSystem genl_rxsc_config_type_system
= {
1217 .count
= ELEMENTSOF(genl_rxsc_types
),
1218 .types
= genl_rxsc_types
,
1221 static const NLType genl_macsec_rxsc_types
[] = {
1222 [MACSEC_ATTR_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
1223 [MACSEC_ATTR_RXSC_CONFIG
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_rxsc_config_type_system
},
1226 static const NLTypeSystem genl_macsec_rxsc_type_system
= {
1227 .count
= ELEMENTSOF(genl_macsec_rxsc_types
),
1228 .types
= genl_macsec_rxsc_types
,
1231 static const NLType genl_macsec_sa_config_types
[] = {
1232 [MACSEC_SA_ATTR_AN
] = { .type
= NETLINK_TYPE_U8
},
1233 [MACSEC_SA_ATTR_ACTIVE
] = { .type
= NETLINK_TYPE_U8
},
1234 [MACSEC_SA_ATTR_PN
] = { .type
= NETLINK_TYPE_U32
},
1235 [MACSEC_SA_ATTR_KEYID
] = { .size
= MACSEC_KEYID_LEN
},
1236 [MACSEC_SA_ATTR_KEY
] = { .size
= MACSEC_MAX_KEY_LEN
},
1239 static const NLTypeSystem genl_macsec_sa_config_type_system
= {
1240 .count
= ELEMENTSOF(genl_macsec_sa_config_types
),
1241 .types
= genl_macsec_sa_config_types
,
1244 static const NLType genl_macsec_rxsa_types
[] = {
1245 [MACSEC_ATTR_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
1246 [MACSEC_ATTR_SA_CONFIG
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_sa_config_type_system
},
1249 static const NLTypeSystem genl_macsec_rxsa_type_system
= {
1250 .count
= ELEMENTSOF(genl_macsec_rxsa_types
),
1251 .types
= genl_macsec_rxsa_types
,
1254 static const NLType genl_macsec_sa_types
[] = {
1255 [MACSEC_ATTR_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
1256 [MACSEC_ATTR_RXSC_CONFIG
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_rxsc_config_type_system
},
1257 [MACSEC_ATTR_SA_CONFIG
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_sa_config_type_system
},
1260 static const NLTypeSystem genl_macsec_sa_type_system
= {
1261 .count
= ELEMENTSOF(genl_macsec_sa_types
),
1262 .types
= genl_macsec_sa_types
,
1265 static const NLType genl_macsec
[] = {
1266 [MACSEC_CMD_ADD_RXSC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_rxsc_type_system
},
1267 [MACSEC_CMD_ADD_TXSA
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_rxsa_type_system
},
1268 [MACSEC_CMD_ADD_RXSA
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_sa_type_system
},
1271 static const NLTypeSystem genl_macsec_device_type_system
= {
1272 .count
= ELEMENTSOF(genl_macsec
),
1273 .types
= genl_macsec
,
1276 static const NLType genl_nl80211_types
[] = {
1277 [NL80211_ATTR_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
1278 [NL80211_ATTR_MAC
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
1279 [NL80211_ATTR_SSID
] = { .type
= NETLINK_TYPE_STRING
},
1280 [NL80211_ATTR_IFTYPE
] = { .type
= NETLINK_TYPE_U32
},
1283 static const NLTypeSystem genl_nl80211_type_system
= {
1284 .count
= ELEMENTSOF(genl_nl80211_types
),
1285 .types
= genl_nl80211_types
,
1288 static const NLType genl_nl80211_cmds
[] = {
1289 [NL80211_CMD_GET_WIPHY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1290 [NL80211_CMD_SET_WIPHY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1291 [NL80211_CMD_NEW_WIPHY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1292 [NL80211_CMD_DEL_WIPHY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1293 [NL80211_CMD_GET_INTERFACE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1294 [NL80211_CMD_SET_INTERFACE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1295 [NL80211_CMD_NEW_INTERFACE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1296 [NL80211_CMD_DEL_INTERFACE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1297 [NL80211_CMD_GET_STATION
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1298 [NL80211_CMD_SET_STATION
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1299 [NL80211_CMD_NEW_STATION
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1300 [NL80211_CMD_DEL_STATION
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
},
1303 static const NLTypeSystem genl_nl80211_cmds_type_system
= {
1304 .count
= ELEMENTSOF(genl_nl80211_cmds
),
1305 .types
= genl_nl80211_cmds
,
1308 static const NLType genl_families
[] = {
1309 [SD_GENL_ID_CTRL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_ctrl_id_ctrl_type_system
},
1310 [SD_GENL_WIREGUARD
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_wireguard_type_system
},
1311 [SD_GENL_FOU
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_fou_cmds_type_system
},
1312 [SD_GENL_L2TP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_tunnel_session_type_system
},
1313 [SD_GENL_MACSEC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_device_type_system
},
1314 [SD_GENL_NL80211
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_cmds_type_system
},
1317 static const NLType nfnl_nft_table_types
[] = {
1318 [NFTA_TABLE_NAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= NFT_TABLE_MAXNAMELEN
- 1 },
1319 [NFTA_TABLE_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
1322 static const NLTypeSystem nfnl_nft_table_type_system
= {
1323 .count
= ELEMENTSOF(nfnl_nft_table_types
),
1324 .types
= nfnl_nft_table_types
,
1327 static const NLType nfnl_nft_chain_hook_types
[] = {
1328 [NFTA_HOOK_HOOKNUM
] = { .type
= NETLINK_TYPE_U32
},
1329 [NFTA_HOOK_PRIORITY
] = { .type
= NETLINK_TYPE_U32
},
1330 [NFTA_HOOK_DEV
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFNAMSIZ
- 1 },
1333 static const NLTypeSystem nfnl_nft_chain_hook_type_system
= {
1334 .count
= ELEMENTSOF(nfnl_nft_chain_hook_types
),
1335 .types
= nfnl_nft_chain_hook_types
,
1338 static const NLType nfnl_nft_chain_types
[] = {
1339 [NFTA_CHAIN_TABLE
] = { .type
= NETLINK_TYPE_STRING
, .size
= NFT_TABLE_MAXNAMELEN
- 1 },
1340 [NFTA_CHAIN_NAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= NFT_TABLE_MAXNAMELEN
- 1 },
1341 [NFTA_CHAIN_HOOK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_chain_hook_type_system
},
1342 [NFTA_CHAIN_TYPE
] = { .type
= NETLINK_TYPE_STRING
, .size
= 16 },
1343 [NFTA_CHAIN_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
1346 static const NLTypeSystem nfnl_nft_chain_type_system
= {
1347 .count
= ELEMENTSOF(nfnl_nft_chain_types
),
1348 .types
= nfnl_nft_chain_types
,
1351 static const NLType nfnl_nft_expr_meta_types
[] = {
1352 [NFTA_META_DREG
] = { .type
= NETLINK_TYPE_U32
},
1353 [NFTA_META_KEY
] = { .type
= NETLINK_TYPE_U32
},
1354 [NFTA_META_SREG
] = { .type
= NETLINK_TYPE_U32
},
1357 static const NLType nfnl_nft_expr_payload_types
[] = {
1358 [NFTA_PAYLOAD_DREG
] = { .type
= NETLINK_TYPE_U32
},
1359 [NFTA_PAYLOAD_BASE
] = { .type
= NETLINK_TYPE_U32
},
1360 [NFTA_PAYLOAD_OFFSET
] = { .type
= NETLINK_TYPE_U32
},
1361 [NFTA_PAYLOAD_LEN
] = { .type
= NETLINK_TYPE_U32
},
1364 static const NLType nfnl_nft_expr_nat_types
[] = {
1365 [NFTA_NAT_TYPE
] = { .type
= NETLINK_TYPE_U32
},
1366 [NFTA_NAT_FAMILY
] = { .type
= NETLINK_TYPE_U32
},
1367 [NFTA_NAT_REG_ADDR_MIN
] = { .type
= NETLINK_TYPE_U32
},
1368 [NFTA_NAT_REG_ADDR_MAX
] = { .type
= NETLINK_TYPE_U32
},
1369 [NFTA_NAT_REG_PROTO_MIN
] = { .type
= NETLINK_TYPE_U32
},
1370 [NFTA_NAT_REG_PROTO_MAX
] = { .type
= NETLINK_TYPE_U32
},
1371 [NFTA_NAT_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
1374 static const NLType nfnl_nft_data_types
[] = {
1375 [NFTA_DATA_VALUE
] = { .type
= NETLINK_TYPE_BINARY
},
1378 static const NLTypeSystem nfnl_nft_data_type_system
= {
1379 .count
= ELEMENTSOF(nfnl_nft_data_types
),
1380 .types
= nfnl_nft_data_types
,
1383 static const NLType nfnl_nft_expr_bitwise_types
[] = {
1384 [NFTA_BITWISE_SREG
] = { .type
= NETLINK_TYPE_U32
},
1385 [NFTA_BITWISE_DREG
] = { .type
= NETLINK_TYPE_U32
},
1386 [NFTA_BITWISE_LEN
] = { .type
= NETLINK_TYPE_U32
},
1387 [NFTA_BITWISE_MASK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_data_type_system
},
1388 [NFTA_BITWISE_XOR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_data_type_system
},
1391 static const NLType nfnl_nft_expr_cmp_types
[] = {
1392 [NFTA_CMP_SREG
] = { .type
= NETLINK_TYPE_U32
},
1393 [NFTA_CMP_OP
] = { .type
= NETLINK_TYPE_U32
},
1394 [NFTA_CMP_DATA
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_data_type_system
},
1397 static const NLType nfnl_nft_expr_fib_types
[] = {
1398 [NFTA_FIB_DREG
] = { .type
= NETLINK_TYPE_U32
},
1399 [NFTA_FIB_RESULT
] = { .type
= NETLINK_TYPE_U32
},
1400 [NFTA_FIB_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
1403 static const NLType nfnl_nft_expr_lookup_types
[] = {
1404 [NFTA_LOOKUP_SET
] = { .type
= NETLINK_TYPE_STRING
},
1405 [NFTA_LOOKUP_SREG
] = { .type
= NETLINK_TYPE_U32
},
1406 [NFTA_LOOKUP_DREG
] = { .type
= NETLINK_TYPE_U32
},
1407 [NFTA_LOOKUP_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
1410 static const NLType nfnl_nft_expr_masq_types
[] = {
1411 [NFTA_MASQ_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
1412 [NFTA_MASQ_REG_PROTO_MIN
] = { .type
= NETLINK_TYPE_U32
},
1413 [NFTA_MASQ_REG_PROTO_MAX
] = { .type
= NETLINK_TYPE_U32
},
1416 static const NLTypeSystem nfnl_expr_data_type_systems
[] = {
1417 [NL_UNION_NFT_EXPR_DATA_BITWISE
] = { .count
= ELEMENTSOF(nfnl_nft_expr_bitwise_types
),
1418 .types
= nfnl_nft_expr_bitwise_types
},
1419 [NL_UNION_NFT_EXPR_DATA_CMP
] = { .count
= ELEMENTSOF(nfnl_nft_expr_cmp_types
),
1420 .types
= nfnl_nft_expr_cmp_types
},
1421 [NL_UNION_NFT_EXPR_DATA_FIB
] = { .count
= ELEMENTSOF(nfnl_nft_expr_fib_types
),
1422 .types
= nfnl_nft_expr_fib_types
},
1423 [NL_UNION_NFT_EXPR_DATA_LOOKUP
] = { .count
= ELEMENTSOF(nfnl_nft_expr_lookup_types
),
1424 .types
= nfnl_nft_expr_lookup_types
},
1425 [NL_UNION_NFT_EXPR_DATA_MASQ
] = { .count
= ELEMENTSOF(nfnl_nft_expr_masq_types
),
1426 .types
= nfnl_nft_expr_masq_types
},
1427 [NL_UNION_NFT_EXPR_DATA_META
] = { .count
= ELEMENTSOF(nfnl_nft_expr_meta_types
),
1428 .types
= nfnl_nft_expr_meta_types
},
1429 [NL_UNION_NFT_EXPR_DATA_NAT
] = { .count
= ELEMENTSOF(nfnl_nft_expr_nat_types
),
1430 .types
= nfnl_nft_expr_nat_types
},
1431 [NL_UNION_NFT_EXPR_DATA_PAYLOAD
] = { .count
= ELEMENTSOF(nfnl_nft_expr_payload_types
),
1432 .types
= nfnl_nft_expr_payload_types
},
1435 static const char* const nl_union_nft_expr_data_table
[] = {
1436 [NL_UNION_NFT_EXPR_DATA_BITWISE
] = "bitwise",
1437 [NL_UNION_NFT_EXPR_DATA_CMP
] = "cmp",
1438 [NL_UNION_NFT_EXPR_DATA_LOOKUP
] = "lookup",
1439 [NL_UNION_NFT_EXPR_DATA_META
] = "meta",
1440 [NL_UNION_NFT_EXPR_DATA_FIB
] = "fib",
1441 [NL_UNION_NFT_EXPR_DATA_MASQ
] = "masq",
1442 [NL_UNION_NFT_EXPR_DATA_NAT
] = "nat",
1443 [NL_UNION_NFT_EXPR_DATA_PAYLOAD
] = "payload",
1446 DEFINE_STRING_TABLE_LOOKUP(nl_union_nft_expr_data
, NLUnionNFTExprData
);
1448 static const NLTypeSystemUnion nfnl_nft_data_expr_type_system_union
= {
1449 .num
= _NL_UNION_NFT_EXPR_DATA_MAX
,
1450 .lookup
= nl_union_nft_expr_data_from_string
,
1451 .type_systems
= nfnl_expr_data_type_systems
,
1452 .match_type
= NL_MATCH_SIBLING
,
1453 .match
= NFTA_EXPR_NAME
,
1456 static const NLType nfnl_nft_rule_expr_types
[] = {
1457 [NFTA_EXPR_NAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= 16 },
1458 [NFTA_EXPR_DATA
] = { .type
= NETLINK_TYPE_UNION
,
1459 .type_system_union
= &nfnl_nft_data_expr_type_system_union
},
1462 static const NLTypeSystem nfnl_nft_rule_expr_type_system
= {
1463 .count
= ELEMENTSOF(nfnl_nft_rule_expr_types
),
1464 .types
= nfnl_nft_rule_expr_types
,
1467 static const NLType nfnl_nft_rule_types
[] = {
1468 [NFTA_RULE_TABLE
] = { .type
= NETLINK_TYPE_STRING
, .size
= NFT_TABLE_MAXNAMELEN
- 1 },
1469 [NFTA_RULE_CHAIN
] = { .type
= NETLINK_TYPE_STRING
, .size
= NFT_TABLE_MAXNAMELEN
- 1 },
1470 [NFTA_RULE_EXPRESSIONS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_rule_expr_type_system
}
1473 static const NLTypeSystem nfnl_nft_rule_type_system
= {
1474 .count
= ELEMENTSOF(nfnl_nft_rule_types
),
1475 .types
= nfnl_nft_rule_types
,
1478 static const NLType nfnl_nft_set_types
[] = {
1479 [NFTA_SET_TABLE
] = { .type
= NETLINK_TYPE_STRING
, .size
= NFT_TABLE_MAXNAMELEN
- 1 },
1480 [NFTA_SET_NAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= NFT_TABLE_MAXNAMELEN
- 1 },
1481 [NFTA_SET_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
1482 [NFTA_SET_KEY_TYPE
] = { .type
= NETLINK_TYPE_U32
},
1483 [NFTA_SET_KEY_LEN
] = { .type
= NETLINK_TYPE_U32
},
1484 [NFTA_SET_DATA_TYPE
] = { .type
= NETLINK_TYPE_U32
},
1485 [NFTA_SET_DATA_LEN
] = { .type
= NETLINK_TYPE_U32
},
1486 [NFTA_SET_POLICY
] = { .type
= NETLINK_TYPE_U32
},
1487 [NFTA_SET_ID
] = { .type
= NETLINK_TYPE_U32
},
1490 static const NLTypeSystem nfnl_nft_set_type_system
= {
1491 .count
= ELEMENTSOF(nfnl_nft_set_types
),
1492 .types
= nfnl_nft_set_types
,
1495 static const NLType nfnl_nft_setelem_types
[] = {
1496 [NFTA_SET_ELEM_KEY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_data_type_system
},
1497 [NFTA_SET_ELEM_DATA
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_data_type_system
},
1498 [NFTA_SET_ELEM_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
1501 static const NLTypeSystem nfnl_nft_setelem_type_system
= {
1502 .count
= ELEMENTSOF(nfnl_nft_setelem_types
),
1503 .types
= nfnl_nft_setelem_types
,
1506 static const NLType nfnl_nft_setelem_list_types
[] = {
1507 [NFTA_SET_ELEM_LIST_TABLE
] = { .type
= NETLINK_TYPE_STRING
, .size
= NFT_TABLE_MAXNAMELEN
- 1 },
1508 [NFTA_SET_ELEM_LIST_SET
] = { .type
= NETLINK_TYPE_STRING
, .size
= NFT_TABLE_MAXNAMELEN
- 1 },
1509 [NFTA_SET_ELEM_LIST_ELEMENTS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_setelem_type_system
},
1512 static const NLTypeSystem nfnl_nft_setelem_list_type_system
= {
1513 .count
= ELEMENTSOF(nfnl_nft_setelem_list_types
),
1514 .types
= nfnl_nft_setelem_list_types
,
1517 static const NLType nfnl_nft_msg_types
[] = {
1518 [NFT_MSG_DELTABLE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_table_type_system
, .size
= sizeof(struct nfgenmsg
) },
1519 [NFT_MSG_NEWTABLE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_table_type_system
, .size
= sizeof(struct nfgenmsg
) },
1520 [NFT_MSG_NEWCHAIN
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_chain_type_system
, .size
= sizeof(struct nfgenmsg
) },
1521 [NFT_MSG_NEWRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_rule_type_system
, .size
= sizeof(struct nfgenmsg
) },
1522 [NFT_MSG_NEWSET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_set_type_system
, .size
= sizeof(struct nfgenmsg
) },
1523 [NFT_MSG_NEWSETELEM
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_setelem_list_type_system
, .size
= sizeof(struct nfgenmsg
) },
1524 [NFT_MSG_DELSETELEM
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_setelem_list_type_system
, .size
= sizeof(struct nfgenmsg
) },
1527 static const NLTypeSystem nfnl_nft_msg_type_system
= {
1528 .count
= ELEMENTSOF(nfnl_nft_msg_types
),
1529 .types
= nfnl_nft_msg_types
,
1532 static const NLType nfnl_msg_batch_types
[] = {
1533 [NFNL_BATCH_GENID
] = { .type
= NETLINK_TYPE_U32
}
1536 static const NLTypeSystem nfnl_msg_batch_type_system
= {
1537 .count
= ELEMENTSOF(nfnl_msg_batch_types
),
1538 .types
= nfnl_msg_batch_types
,
1541 static const NLType nfnl_types
[] = {
1542 [NLMSG_DONE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &empty_type_system
, .size
= 0 },
1543 [NLMSG_ERROR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &error_type_system
, .size
= sizeof(struct nlmsgerr
) },
1544 [NFNL_MSG_BATCH_BEGIN
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_msg_batch_type_system
, .size
= sizeof(struct nfgenmsg
) },
1545 [NFNL_MSG_BATCH_END
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_msg_batch_type_system
, .size
= sizeof(struct nfgenmsg
) },
1546 [NFNL_SUBSYS_NFTABLES
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &nfnl_nft_msg_type_system
, .size
= sizeof(struct nfgenmsg
) },
1549 const NLTypeSystem nfnl_type_system_root
= {
1550 .count
= ELEMENTSOF(nfnl_types
),
1551 .types
= nfnl_types
,
1554 /* Mainly used when sending message */
1555 const NLTypeSystem genl_family_type_system_root
= {
1556 .count
= ELEMENTSOF(genl_families
),
1557 .types
= genl_families
,
1560 static const NLType genl_types
[] = {
1561 [SD_GENL_ERROR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &error_type_system
, .size
= sizeof(struct nlmsgerr
) },
1562 [SD_GENL_DONE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &empty_type_system
},
1563 [SD_GENL_ID_CTRL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_get_family_type_system
, .size
= sizeof(struct genlmsghdr
) },
1564 [SD_GENL_NL80211
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_nl80211_type_system
, .size
= sizeof(struct genlmsghdr
) },
1567 /* Mainly used when message received */
1568 const NLTypeSystem genl_type_system_root
= {
1569 .count
= ELEMENTSOF(genl_types
),
1570 .types
= genl_types
,
1573 uint16_t type_get_type(const NLType
*type
) {
1578 size_t type_get_size(const NLType
*type
) {
1583 void type_get_type_system(const NLType
*nl_type
, const NLTypeSystem
**ret
) {
1586 assert(nl_type
->type
== NETLINK_TYPE_NESTED
);
1587 assert(nl_type
->type_system
);
1589 *ret
= nl_type
->type_system
;
1592 void type_get_type_system_union(const NLType
*nl_type
, const NLTypeSystemUnion
**ret
) {
1595 assert(nl_type
->type
== NETLINK_TYPE_UNION
);
1596 assert(nl_type
->type_system_union
);
1598 *ret
= nl_type
->type_system_union
;
1601 uint16_t type_system_get_count(const NLTypeSystem
*type_system
) {
1602 assert(type_system
);
1603 return type_system
->count
;
1606 const NLTypeSystem
*type_system_get_root(int protocol
) {
1608 case NETLINK_GENERIC
:
1609 return &genl_type_system_root
;
1610 case NETLINK_NETFILTER
:
1611 return &nfnl_type_system_root
;
1612 default: /* NETLINK_ROUTE: */
1613 return &rtnl_type_system_root
;
1617 int type_system_root_get_type(sd_netlink
*nl
, const NLType
**ret
, uint16_t type
) {
1618 sd_genl_family family
;
1619 const NLType
*nl_type
;
1623 return type_system_get_type(&rtnl_type_system_root
, ret
, type
);
1625 if (nl
->protocol
!= NETLINK_GENERIC
)
1626 return type_system_get_type(type_system_get_root(nl
->protocol
), ret
, type
);
1628 r
= nlmsg_type_to_genl_family(nl
, type
, &family
);
1632 if (family
>= genl_type_system_root
.count
)
1635 nl_type
= &genl_type_system_root
.types
[family
];
1637 if (nl_type
->type
== NETLINK_TYPE_UNSPEC
)
1645 int type_system_get_type(const NLTypeSystem
*type_system
, const NLType
**ret
, uint16_t type
) {
1646 const NLType
*nl_type
;
1649 assert(type_system
);
1650 assert(type_system
->types
);
1652 if (type
>= type_system
->count
)
1655 nl_type
= &type_system
->types
[type
];
1657 if (nl_type
->type
== NETLINK_TYPE_UNSPEC
)
1665 int type_system_get_type_system(const NLTypeSystem
*type_system
, const NLTypeSystem
**ret
, uint16_t type
) {
1666 const NLType
*nl_type
;
1671 r
= type_system_get_type(type_system
, &nl_type
, type
);
1675 type_get_type_system(nl_type
, ret
);
1679 int type_system_get_type_system_union(const NLTypeSystem
*type_system
, const NLTypeSystemUnion
**ret
, uint16_t type
) {
1680 const NLType
*nl_type
;
1685 r
= type_system_get_type(type_system
, &nl_type
, type
);
1689 type_get_type_system_union(nl_type
, ret
);
1693 int type_system_union_get_type_system(const NLTypeSystemUnion
*type_system_union
, const NLTypeSystem
**ret
, const char *key
) {
1696 assert(type_system_union
);
1697 assert(type_system_union
->match_type
== NL_MATCH_SIBLING
);
1698 assert(type_system_union
->lookup
);
1699 assert(type_system_union
->type_systems
);
1703 type
= type_system_union
->lookup(key
);
1707 assert(type
< type_system_union
->num
);
1709 *ret
= &type_system_union
->type_systems
[type
];
1714 int type_system_union_protocol_get_type_system(const NLTypeSystemUnion
*type_system_union
, const NLTypeSystem
**ret
, uint16_t protocol
) {
1715 const NLTypeSystem
*type_system
;
1717 assert(type_system_union
);
1718 assert(type_system_union
->type_systems
);
1719 assert(type_system_union
->match_type
== NL_MATCH_PROTOCOL
);
1722 if (protocol
>= type_system_union
->num
)
1725 type_system
= &type_system_union
->type_systems
[protocol
];
1726 if (!type_system
->types
)