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/nexthop.h>
22 #include <linux/l2tp.h>
23 #include <linux/veth.h>
24 #include <linux/wireguard.h>
28 #include "netlink-types.h"
29 #include "sd-netlink.h"
30 #include "string-table.h"
33 /* Maximum ARP IP target defined in kernel */
34 #define BOND_MAX_ARP_TARGETS 16
52 BOND_ARP_TARGETS_MAX
= BOND_MAX_ARP_TARGETS
,
58 const NLTypeSystem
*type_system
;
59 const NLTypeSystemUnion
*type_system_union
;
67 static const NLTypeSystem rtnl_link_type_system
;
69 static const NLType empty_types
[1] = {
70 /* fake array to avoid .types==NULL, which denotes invalid type-systems */
73 static const NLTypeSystem empty_type_system
= {
78 static const NLType rtnl_link_info_data_veth_types
[] = {
79 [VETH_INFO_PEER
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
82 static const NLType rtnl_link_info_data_vxcan_types
[] = {
83 [VXCAN_INFO_PEER
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
86 static const NLType rtnl_link_info_data_ipvlan_types
[] = {
87 [IFLA_IPVLAN_MODE
] = { .type
= NETLINK_TYPE_U16
},
88 [IFLA_IPVLAN_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
91 static const NLType rtnl_link_info_data_macvlan_types
[] = {
92 [IFLA_MACVLAN_MODE
] = { .type
= NETLINK_TYPE_U32
},
93 [IFLA_MACVLAN_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
96 static const NLType rtnl_link_info_data_bridge_types
[] = {
97 [IFLA_BR_FORWARD_DELAY
] = { .type
= NETLINK_TYPE_U32
},
98 [IFLA_BR_HELLO_TIME
] = { .type
= NETLINK_TYPE_U32
},
99 [IFLA_BR_MAX_AGE
] = { .type
= NETLINK_TYPE_U32
},
100 [IFLA_BR_AGEING_TIME
] = { .type
= NETLINK_TYPE_U32
},
101 [IFLA_BR_STP_STATE
] = { .type
= NETLINK_TYPE_U32
},
102 [IFLA_BR_PRIORITY
] = { .type
= NETLINK_TYPE_U16
},
103 [IFLA_BR_VLAN_FILTERING
] = { .type
= NETLINK_TYPE_U8
},
104 [IFLA_BR_VLAN_PROTOCOL
] = { .type
= NETLINK_TYPE_U16
},
105 [IFLA_BR_GROUP_FWD_MASK
] = { .type
= NETLINK_TYPE_U16
},
106 [IFLA_BR_ROOT_PORT
] = { .type
= NETLINK_TYPE_U16
},
107 [IFLA_BR_ROOT_PATH_COST
] = { .type
= NETLINK_TYPE_U32
},
108 [IFLA_BR_TOPOLOGY_CHANGE
] = { .type
= NETLINK_TYPE_U8
},
109 [IFLA_BR_TOPOLOGY_CHANGE_DETECTED
] = { .type
= NETLINK_TYPE_U8
},
110 [IFLA_BR_HELLO_TIMER
] = { .type
= NETLINK_TYPE_U16
},
111 [IFLA_BR_TCN_TIMER
] = { .type
= NETLINK_TYPE_U16
},
112 [IFLA_BR_TOPOLOGY_CHANGE_TIMER
] = { .type
= NETLINK_TYPE_U16
},
113 [IFLA_BR_GC_TIMER
] = { .type
= NETLINK_TYPE_U64
},
114 [IFLA_BR_GROUP_ADDR
] = { .type
= NETLINK_TYPE_U16
},
115 [IFLA_BR_FDB_FLUSH
] = { .type
= NETLINK_TYPE_U16
},
116 [IFLA_BR_MCAST_ROUTER
] = { .type
= NETLINK_TYPE_U8
},
117 [IFLA_BR_MCAST_SNOOPING
] = { .type
= NETLINK_TYPE_U8
},
118 [IFLA_BR_MCAST_QUERY_USE_IFADDR
] = { .type
= NETLINK_TYPE_U8
},
119 [IFLA_BR_MCAST_QUERIER
] = { .type
= NETLINK_TYPE_U8
},
120 [IFLA_BR_MCAST_HASH_ELASTICITY
] = { .type
= NETLINK_TYPE_U32
},
121 [IFLA_BR_MCAST_HASH_MAX
] = { .type
= NETLINK_TYPE_U16
},
122 [IFLA_BR_MCAST_LAST_MEMBER_CNT
] = { .type
= NETLINK_TYPE_U32
},
123 [IFLA_BR_MCAST_STARTUP_QUERY_CNT
] = { .type
= NETLINK_TYPE_U16
},
124 [IFLA_BR_MCAST_LAST_MEMBER_INTVL
] = { .type
= NETLINK_TYPE_U64
},
125 [IFLA_BR_MCAST_MEMBERSHIP_INTVL
] = { .type
= NETLINK_TYPE_U64
},
126 [IFLA_BR_MCAST_QUERIER_INTVL
] = { .type
= NETLINK_TYPE_U64
},
127 [IFLA_BR_MCAST_QUERY_INTVL
] = { .type
= NETLINK_TYPE_U64
},
128 [IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
] = { .type
= NETLINK_TYPE_U64
},
129 [IFLA_BR_MCAST_STARTUP_QUERY_INTVL
] = { .type
= NETLINK_TYPE_U64
},
130 [IFLA_BR_NF_CALL_IPTABLES
] = { .type
= NETLINK_TYPE_U8
},
131 [IFLA_BR_NF_CALL_IP6TABLES
] = { .type
= NETLINK_TYPE_U8
},
132 [IFLA_BR_NF_CALL_ARPTABLES
] = { .type
= NETLINK_TYPE_U8
},
133 [IFLA_BR_VLAN_DEFAULT_PVID
] = { .type
= NETLINK_TYPE_U16
},
134 [IFLA_BR_MCAST_IGMP_VERSION
] = { .type
= NETLINK_TYPE_U8
},
137 static const NLType rtnl_link_info_data_vlan_types
[] = {
138 [IFLA_VLAN_ID
] = { .type
= NETLINK_TYPE_U16
},
140 [IFLA_VLAN_FLAGS] = { .len = sizeof(struct ifla_vlan_flags) },
141 [IFLA_VLAN_EGRESS_QOS] = { .type = NETLINK_TYPE_NESTED },
142 [IFLA_VLAN_INGRESS_QOS] = { .type = NETLINK_TYPE_NESTED },
144 [IFLA_VLAN_PROTOCOL
] = { .type
= NETLINK_TYPE_U16
},
147 static const NLType rtnl_link_info_data_vxlan_types
[] = {
148 [IFLA_VXLAN_ID
] = { .type
= NETLINK_TYPE_U32
},
149 [IFLA_VXLAN_GROUP
] = { .type
= NETLINK_TYPE_IN_ADDR
},
150 [IFLA_VXLAN_LINK
] = { .type
= NETLINK_TYPE_U32
},
151 [IFLA_VXLAN_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
152 [IFLA_VXLAN_TTL
] = { .type
= NETLINK_TYPE_U8
},
153 [IFLA_VXLAN_TOS
] = { .type
= NETLINK_TYPE_U8
},
154 [IFLA_VXLAN_LEARNING
] = { .type
= NETLINK_TYPE_U8
},
155 [IFLA_VXLAN_AGEING
] = { .type
= NETLINK_TYPE_U32
},
156 [IFLA_VXLAN_LIMIT
] = { .type
= NETLINK_TYPE_U32
},
157 [IFLA_VXLAN_PORT_RANGE
] = { .type
= NETLINK_TYPE_U32
},
158 [IFLA_VXLAN_PROXY
] = { .type
= NETLINK_TYPE_U8
},
159 [IFLA_VXLAN_RSC
] = { .type
= NETLINK_TYPE_U8
},
160 [IFLA_VXLAN_L2MISS
] = { .type
= NETLINK_TYPE_U8
},
161 [IFLA_VXLAN_L3MISS
] = { .type
= NETLINK_TYPE_U8
},
162 [IFLA_VXLAN_PORT
] = { .type
= NETLINK_TYPE_U16
},
163 [IFLA_VXLAN_GROUP6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
164 [IFLA_VXLAN_LOCAL6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
165 [IFLA_VXLAN_UDP_CSUM
] = { .type
= NETLINK_TYPE_U8
},
166 [IFLA_VXLAN_UDP_ZERO_CSUM6_TX
] = { .type
= NETLINK_TYPE_U8
},
167 [IFLA_VXLAN_UDP_ZERO_CSUM6_RX
] = { .type
= NETLINK_TYPE_U8
},
168 [IFLA_VXLAN_REMCSUM_TX
] = { .type
= NETLINK_TYPE_U8
},
169 [IFLA_VXLAN_REMCSUM_RX
] = { .type
= NETLINK_TYPE_U8
},
170 [IFLA_VXLAN_GBP
] = { .type
= NETLINK_TYPE_FLAG
},
171 [IFLA_VXLAN_REMCSUM_NOPARTIAL
] = { .type
= NETLINK_TYPE_FLAG
},
172 [IFLA_VXLAN_COLLECT_METADATA
] = { .type
= NETLINK_TYPE_U8
},
173 [IFLA_VXLAN_LABEL
] = { .type
= NETLINK_TYPE_U32
},
174 [IFLA_VXLAN_GPE
] = { .type
= NETLINK_TYPE_FLAG
},
175 [IFLA_VXLAN_TTL_INHERIT
] = { .type
= NETLINK_TYPE_FLAG
},
176 [IFLA_VXLAN_DF
] = { .type
= NETLINK_TYPE_U8
},
179 static const NLType rtnl_bond_arp_target_types
[] = {
180 [BOND_ARP_TARGETS_0
] = { .type
= NETLINK_TYPE_U32
},
181 [BOND_ARP_TARGETS_1
] = { .type
= NETLINK_TYPE_U32
},
182 [BOND_ARP_TARGETS_2
] = { .type
= NETLINK_TYPE_U32
},
183 [BOND_ARP_TARGETS_3
] = { .type
= NETLINK_TYPE_U32
},
184 [BOND_ARP_TARGETS_4
] = { .type
= NETLINK_TYPE_U32
},
185 [BOND_ARP_TARGETS_5
] = { .type
= NETLINK_TYPE_U32
},
186 [BOND_ARP_TARGETS_6
] = { .type
= NETLINK_TYPE_U32
},
187 [BOND_ARP_TARGETS_7
] = { .type
= NETLINK_TYPE_U32
},
188 [BOND_ARP_TARGETS_8
] = { .type
= NETLINK_TYPE_U32
},
189 [BOND_ARP_TARGETS_9
] = { .type
= NETLINK_TYPE_U32
},
190 [BOND_ARP_TARGETS_10
] = { .type
= NETLINK_TYPE_U32
},
191 [BOND_ARP_TARGETS_11
] = { .type
= NETLINK_TYPE_U32
},
192 [BOND_ARP_TARGETS_12
] = { .type
= NETLINK_TYPE_U32
},
193 [BOND_ARP_TARGETS_13
] = { .type
= NETLINK_TYPE_U32
},
194 [BOND_ARP_TARGETS_14
] = { .type
= NETLINK_TYPE_U32
},
195 [BOND_ARP_TARGETS_MAX
] = { .type
= NETLINK_TYPE_U32
},
198 static const NLTypeSystem rtnl_bond_arp_type_system
= {
199 .count
= ELEMENTSOF(rtnl_bond_arp_target_types
),
200 .types
= rtnl_bond_arp_target_types
,
203 static const NLType rtnl_link_info_data_bond_types
[] = {
204 [IFLA_BOND_MODE
] = { .type
= NETLINK_TYPE_U8
},
205 [IFLA_BOND_ACTIVE_SLAVE
] = { .type
= NETLINK_TYPE_U32
},
206 [IFLA_BOND_MIIMON
] = { .type
= NETLINK_TYPE_U32
},
207 [IFLA_BOND_UPDELAY
] = { .type
= NETLINK_TYPE_U32
},
208 [IFLA_BOND_DOWNDELAY
] = { .type
= NETLINK_TYPE_U32
},
209 [IFLA_BOND_USE_CARRIER
] = { .type
= NETLINK_TYPE_U8
},
210 [IFLA_BOND_ARP_INTERVAL
] = { .type
= NETLINK_TYPE_U32
},
211 [IFLA_BOND_ARP_IP_TARGET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_bond_arp_type_system
},
212 [IFLA_BOND_ARP_VALIDATE
] = { .type
= NETLINK_TYPE_U32
},
213 [IFLA_BOND_ARP_ALL_TARGETS
] = { .type
= NETLINK_TYPE_U32
},
214 [IFLA_BOND_PRIMARY
] = { .type
= NETLINK_TYPE_U32
},
215 [IFLA_BOND_PRIMARY_RESELECT
] = { .type
= NETLINK_TYPE_U8
},
216 [IFLA_BOND_FAIL_OVER_MAC
] = { .type
= NETLINK_TYPE_U8
},
217 [IFLA_BOND_XMIT_HASH_POLICY
] = { .type
= NETLINK_TYPE_U8
},
218 [IFLA_BOND_RESEND_IGMP
] = { .type
= NETLINK_TYPE_U32
},
219 [IFLA_BOND_NUM_PEER_NOTIF
] = { .type
= NETLINK_TYPE_U8
},
220 [IFLA_BOND_ALL_SLAVES_ACTIVE
] = { .type
= NETLINK_TYPE_U8
},
221 [IFLA_BOND_MIN_LINKS
] = { .type
= NETLINK_TYPE_U32
},
222 [IFLA_BOND_LP_INTERVAL
] = { .type
= NETLINK_TYPE_U32
},
223 [IFLA_BOND_PACKETS_PER_SLAVE
] = { .type
= NETLINK_TYPE_U32
},
224 [IFLA_BOND_AD_LACP_RATE
] = { .type
= NETLINK_TYPE_U8
},
225 [IFLA_BOND_AD_SELECT
] = { .type
= NETLINK_TYPE_U8
},
226 [IFLA_BOND_AD_INFO
] = { .type
= NETLINK_TYPE_NESTED
},
227 [IFLA_BOND_AD_ACTOR_SYS_PRIO
] = { .type
= NETLINK_TYPE_U16
},
228 [IFLA_BOND_AD_USER_PORT_KEY
] = { .type
= NETLINK_TYPE_U16
},
229 [IFLA_BOND_AD_ACTOR_SYSTEM
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
230 [IFLA_BOND_TLB_DYNAMIC_LB
] = { .type
= NETLINK_TYPE_U8
},
233 static const NLType rtnl_link_info_data_iptun_types
[] = {
234 [IFLA_IPTUN_LINK
] = { .type
= NETLINK_TYPE_U32
},
235 [IFLA_IPTUN_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
236 [IFLA_IPTUN_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
237 [IFLA_IPTUN_TTL
] = { .type
= NETLINK_TYPE_U8
},
238 [IFLA_IPTUN_TOS
] = { .type
= NETLINK_TYPE_U8
},
239 [IFLA_IPTUN_PMTUDISC
] = { .type
= NETLINK_TYPE_U8
},
240 [IFLA_IPTUN_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
241 [IFLA_IPTUN_PROTO
] = { .type
= NETLINK_TYPE_U8
},
242 [IFLA_IPTUN_6RD_PREFIX
] = { .type
= NETLINK_TYPE_IN_ADDR
},
243 [IFLA_IPTUN_6RD_RELAY_PREFIX
] = { .type
= NETLINK_TYPE_U32
},
244 [IFLA_IPTUN_6RD_PREFIXLEN
] = { .type
= NETLINK_TYPE_U16
},
245 [IFLA_IPTUN_6RD_RELAY_PREFIXLEN
] = { .type
= NETLINK_TYPE_U16
},
246 [IFLA_IPTUN_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
247 [IFLA_IPTUN_ENCAP_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
248 [IFLA_IPTUN_ENCAP_SPORT
] = { .type
= NETLINK_TYPE_U16
},
249 [IFLA_IPTUN_ENCAP_DPORT
] = { .type
= NETLINK_TYPE_U16
},
252 static const NLType rtnl_link_info_data_ipgre_types
[] = {
253 [IFLA_GRE_LINK
] = { .type
= NETLINK_TYPE_U32
},
254 [IFLA_GRE_IFLAGS
] = { .type
= NETLINK_TYPE_U16
},
255 [IFLA_GRE_OFLAGS
] = { .type
= NETLINK_TYPE_U16
},
256 [IFLA_GRE_IKEY
] = { .type
= NETLINK_TYPE_U32
},
257 [IFLA_GRE_OKEY
] = { .type
= NETLINK_TYPE_U32
},
258 [IFLA_GRE_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
259 [IFLA_GRE_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
260 [IFLA_GRE_TTL
] = { .type
= NETLINK_TYPE_U8
},
261 [IFLA_GRE_TOS
] = { .type
= NETLINK_TYPE_U8
},
262 [IFLA_GRE_PMTUDISC
] = { .type
= NETLINK_TYPE_U8
},
263 [IFLA_GRE_FLOWINFO
] = { .type
= NETLINK_TYPE_U32
},
264 [IFLA_GRE_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
265 [IFLA_GRE_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
266 [IFLA_GRE_ENCAP_FLAGS
] = { .type
= NETLINK_TYPE_U16
},
267 [IFLA_GRE_ENCAP_SPORT
] = { .type
= NETLINK_TYPE_U16
},
268 [IFLA_GRE_ENCAP_DPORT
] = { .type
= NETLINK_TYPE_U16
},
269 [IFLA_GRE_ERSPAN_INDEX
] = { .type
= NETLINK_TYPE_U32
},
272 static const NLType rtnl_link_info_data_ipvti_types
[] = {
273 [IFLA_VTI_LINK
] = { .type
= NETLINK_TYPE_U32
},
274 [IFLA_VTI_IKEY
] = { .type
= NETLINK_TYPE_U32
},
275 [IFLA_VTI_OKEY
] = { .type
= NETLINK_TYPE_U32
},
276 [IFLA_VTI_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
277 [IFLA_VTI_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
280 static const NLType rtnl_link_info_data_ip6tnl_types
[] = {
281 [IFLA_IPTUN_LINK
] = { .type
= NETLINK_TYPE_U32
},
282 [IFLA_IPTUN_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
283 [IFLA_IPTUN_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
284 [IFLA_IPTUN_TTL
] = { .type
= NETLINK_TYPE_U8
},
285 [IFLA_IPTUN_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
286 [IFLA_IPTUN_PROTO
] = { .type
= NETLINK_TYPE_U8
},
287 [IFLA_IPTUN_ENCAP_LIMIT
] = { .type
= NETLINK_TYPE_U8
},
288 [IFLA_IPTUN_FLOWINFO
] = { .type
= NETLINK_TYPE_U32
},
291 static const NLType rtnl_link_info_data_vrf_types
[] = {
292 [IFLA_VRF_TABLE
] = { .type
= NETLINK_TYPE_U32
},
295 static const NLType rtnl_link_info_data_geneve_types
[] = {
296 [IFLA_GENEVE_ID
] = { .type
= NETLINK_TYPE_U32
},
297 [IFLA_GENEVE_TTL
] = { .type
= NETLINK_TYPE_U8
},
298 [IFLA_GENEVE_TOS
] = { .type
= NETLINK_TYPE_U8
},
299 [IFLA_GENEVE_PORT
] = { .type
= NETLINK_TYPE_U16
},
300 [IFLA_GENEVE_REMOTE
] = { .type
= NETLINK_TYPE_IN_ADDR
},
301 [IFLA_GENEVE_REMOTE6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
302 [IFLA_GENEVE_UDP_CSUM
] = { .type
= NETLINK_TYPE_U8
},
303 [IFLA_GENEVE_UDP_ZERO_CSUM6_TX
] = { .type
= NETLINK_TYPE_U8
},
304 [IFLA_GENEVE_UDP_ZERO_CSUM6_RX
] = { .type
= NETLINK_TYPE_U8
},
305 [IFLA_GENEVE_LABEL
] = { .type
= NETLINK_TYPE_U32
},
306 [IFLA_GENEVE_TTL_INHERIT
] = { .type
= NETLINK_TYPE_U8
},
307 [IFLA_GENEVE_DF
] = { .type
= NETLINK_TYPE_U8
},
310 static const NLType rtnl_link_info_data_can_types
[] = {
311 [IFLA_CAN_BITTIMING
] = { .size
= sizeof(struct can_bittiming
) },
312 [IFLA_CAN_RESTART_MS
] = { .type
= NETLINK_TYPE_U32
},
313 [IFLA_CAN_CTRLMODE
] = { .size
= sizeof(struct can_ctrlmode
) },
316 static const NLType rtnl_link_info_data_macsec_types
[] = {
317 [IFLA_MACSEC_SCI
] = { .type
= NETLINK_TYPE_U64
},
318 [IFLA_MACSEC_PORT
] = { .type
= NETLINK_TYPE_U16
},
319 [IFLA_MACSEC_ICV_LEN
] = { .type
= NETLINK_TYPE_U8
},
320 [IFLA_MACSEC_CIPHER_SUITE
] = { .type
= NETLINK_TYPE_U64
},
321 [IFLA_MACSEC_WINDOW
] = { .type
= NETLINK_TYPE_U32
},
322 [IFLA_MACSEC_ENCODING_SA
] = { .type
= NETLINK_TYPE_U8
},
323 [IFLA_MACSEC_ENCRYPT
] = { .type
= NETLINK_TYPE_U8
},
324 [IFLA_MACSEC_PROTECT
] = { .type
= NETLINK_TYPE_U8
},
325 [IFLA_MACSEC_INC_SCI
] = { .type
= NETLINK_TYPE_U8
},
326 [IFLA_MACSEC_ES
] = { .type
= NETLINK_TYPE_U8
},
327 [IFLA_MACSEC_SCB
] = { .type
= NETLINK_TYPE_U8
},
328 [IFLA_MACSEC_REPLAY_PROTECT
] = { .type
= NETLINK_TYPE_U8
},
329 [IFLA_MACSEC_VALIDATION
] = { .type
= NETLINK_TYPE_U8
},
332 static const NLType rtnl_link_info_data_xfrm_types
[] = {
333 [IFLA_XFRM_LINK
] = { .type
= NETLINK_TYPE_U32
},
334 [IFLA_XFRM_IF_ID
] = { .type
= NETLINK_TYPE_U32
}
337 /* these strings must match the .kind entries in the kernel */
338 static const char* const nl_union_link_info_data_table
[] = {
339 [NL_UNION_LINK_INFO_DATA_BOND
] = "bond",
340 [NL_UNION_LINK_INFO_DATA_BRIDGE
] = "bridge",
341 [NL_UNION_LINK_INFO_DATA_VLAN
] = "vlan",
342 [NL_UNION_LINK_INFO_DATA_VETH
] = "veth",
343 [NL_UNION_LINK_INFO_DATA_DUMMY
] = "dummy",
344 [NL_UNION_LINK_INFO_DATA_MACVLAN
] = "macvlan",
345 [NL_UNION_LINK_INFO_DATA_MACVTAP
] = "macvtap",
346 [NL_UNION_LINK_INFO_DATA_IPVLAN
] = "ipvlan",
347 [NL_UNION_LINK_INFO_DATA_IPVTAP
] = "ipvtap",
348 [NL_UNION_LINK_INFO_DATA_VXLAN
] = "vxlan",
349 [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL
] = "ipip",
350 [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL
] = "gre",
351 [NL_UNION_LINK_INFO_DATA_ERSPAN
] = "erspan",
352 [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL
] = "gretap",
353 [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL
] = "ip6gre",
354 [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL
] = "ip6gretap",
355 [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL
] = "sit",
356 [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL
] = "vti",
357 [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL
] = "vti6",
358 [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL
] = "ip6tnl",
359 [NL_UNION_LINK_INFO_DATA_VRF
] = "vrf",
360 [NL_UNION_LINK_INFO_DATA_VCAN
] = "vcan",
361 [NL_UNION_LINK_INFO_DATA_GENEVE
] = "geneve",
362 [NL_UNION_LINK_INFO_DATA_VXCAN
] = "vxcan",
363 [NL_UNION_LINK_INFO_DATA_WIREGUARD
] = "wireguard",
364 [NL_UNION_LINK_INFO_DATA_NETDEVSIM
] = "netdevsim",
365 [NL_UNION_LINK_INFO_DATA_CAN
] = "can",
366 [NL_UNION_LINK_INFO_DATA_MACSEC
] = "macsec",
367 [NL_UNION_LINK_INFO_DATA_NLMON
] = "nlmon",
368 [NL_UNION_LINK_INFO_DATA_XFRM
] = "xfrm",
371 DEFINE_STRING_TABLE_LOOKUP(nl_union_link_info_data
, NLUnionLinkInfoData
);
373 static const NLTypeSystem rtnl_link_info_data_type_systems
[] = {
374 [NL_UNION_LINK_INFO_DATA_BOND
] = { .count
= ELEMENTSOF(rtnl_link_info_data_bond_types
),
375 .types
= rtnl_link_info_data_bond_types
},
376 [NL_UNION_LINK_INFO_DATA_BRIDGE
] = { .count
= ELEMENTSOF(rtnl_link_info_data_bridge_types
),
377 .types
= rtnl_link_info_data_bridge_types
},
378 [NL_UNION_LINK_INFO_DATA_VLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vlan_types
),
379 .types
= rtnl_link_info_data_vlan_types
},
380 [NL_UNION_LINK_INFO_DATA_VETH
] = { .count
= ELEMENTSOF(rtnl_link_info_data_veth_types
),
381 .types
= rtnl_link_info_data_veth_types
},
382 [NL_UNION_LINK_INFO_DATA_MACVLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_macvlan_types
),
383 .types
= rtnl_link_info_data_macvlan_types
},
384 [NL_UNION_LINK_INFO_DATA_MACVTAP
] = { .count
= ELEMENTSOF(rtnl_link_info_data_macvlan_types
),
385 .types
= rtnl_link_info_data_macvlan_types
},
386 [NL_UNION_LINK_INFO_DATA_IPVLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvlan_types
),
387 .types
= rtnl_link_info_data_ipvlan_types
},
388 [NL_UNION_LINK_INFO_DATA_IPVTAP
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvlan_types
),
389 .types
= rtnl_link_info_data_ipvlan_types
},
390 [NL_UNION_LINK_INFO_DATA_VXLAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vxlan_types
),
391 .types
= rtnl_link_info_data_vxlan_types
},
392 [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_iptun_types
),
393 .types
= rtnl_link_info_data_iptun_types
},
394 [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
395 .types
= rtnl_link_info_data_ipgre_types
},
396 [NL_UNION_LINK_INFO_DATA_ERSPAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
397 .types
= rtnl_link_info_data_ipgre_types
},
398 [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
399 .types
= rtnl_link_info_data_ipgre_types
},
400 [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
401 .types
= rtnl_link_info_data_ipgre_types
},
402 [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipgre_types
),
403 .types
= rtnl_link_info_data_ipgre_types
},
404 [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_iptun_types
),
405 .types
= rtnl_link_info_data_iptun_types
},
406 [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvti_types
),
407 .types
= rtnl_link_info_data_ipvti_types
},
408 [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ipvti_types
),
409 .types
= rtnl_link_info_data_ipvti_types
},
410 [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL
] = { .count
= ELEMENTSOF(rtnl_link_info_data_ip6tnl_types
),
411 .types
= rtnl_link_info_data_ip6tnl_types
},
412 [NL_UNION_LINK_INFO_DATA_VRF
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vrf_types
),
413 .types
= rtnl_link_info_data_vrf_types
},
414 [NL_UNION_LINK_INFO_DATA_GENEVE
] = { .count
= ELEMENTSOF(rtnl_link_info_data_geneve_types
),
415 .types
= rtnl_link_info_data_geneve_types
},
416 [NL_UNION_LINK_INFO_DATA_VXCAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_vxcan_types
),
417 .types
= rtnl_link_info_data_vxcan_types
},
418 [NL_UNION_LINK_INFO_DATA_CAN
] = { .count
= ELEMENTSOF(rtnl_link_info_data_can_types
),
419 .types
= rtnl_link_info_data_can_types
},
420 [NL_UNION_LINK_INFO_DATA_MACSEC
] = { .count
= ELEMENTSOF(rtnl_link_info_data_macsec_types
),
421 .types
= rtnl_link_info_data_macsec_types
},
422 [NL_UNION_LINK_INFO_DATA_XFRM
] = { .count
= ELEMENTSOF(rtnl_link_info_data_xfrm_types
),
423 .types
= rtnl_link_info_data_xfrm_types
},
426 static const NLTypeSystemUnion rtnl_link_info_data_type_system_union
= {
427 .num
= _NL_UNION_LINK_INFO_DATA_MAX
,
428 .lookup
= nl_union_link_info_data_from_string
,
429 .type_systems
= rtnl_link_info_data_type_systems
,
430 .match_type
= NL_MATCH_SIBLING
,
431 .match
= IFLA_INFO_KIND
,
434 static const NLType rtnl_link_info_types
[] = {
435 [IFLA_INFO_KIND
] = { .type
= NETLINK_TYPE_STRING
},
436 [IFLA_INFO_DATA
] = { .type
= NETLINK_TYPE_UNION
, .type_system_union
= &rtnl_link_info_data_type_system_union
},
439 [IFLA_INFO_SLAVE_KIND] = { .type = NETLINK_TYPE_STRING },
440 [IFLA_INFO_SLAVE_DATA] = { .type = NETLINK_TYPE_NESTED },
444 static const NLTypeSystem rtnl_link_info_type_system
= {
445 .count
= ELEMENTSOF(rtnl_link_info_types
),
446 .types
= rtnl_link_info_types
,
449 static const struct NLType rtnl_prot_info_bridge_port_types
[] = {
450 [IFLA_BRPORT_STATE
] = { .type
= NETLINK_TYPE_U8
},
451 [IFLA_BRPORT_COST
] = { .type
= NETLINK_TYPE_U32
},
452 [IFLA_BRPORT_PRIORITY
] = { .type
= NETLINK_TYPE_U16
},
453 [IFLA_BRPORT_MODE
] = { .type
= NETLINK_TYPE_U8
},
454 [IFLA_BRPORT_GUARD
] = { .type
= NETLINK_TYPE_U8
},
455 [IFLA_BRPORT_PROTECT
] = { .type
= NETLINK_TYPE_U8
},
456 [IFLA_BRPORT_FAST_LEAVE
] = { .type
= NETLINK_TYPE_U8
},
457 [IFLA_BRPORT_LEARNING
] = { .type
= NETLINK_TYPE_U8
},
458 [IFLA_BRPORT_UNICAST_FLOOD
] = { .type
= NETLINK_TYPE_U8
},
459 [IFLA_BRPORT_PROXYARP
] = { .type
= NETLINK_TYPE_U8
},
460 [IFLA_BRPORT_LEARNING_SYNC
] = { .type
= NETLINK_TYPE_U8
},
461 [IFLA_BRPORT_PROXYARP_WIFI
] = { .type
= NETLINK_TYPE_U8
},
462 [IFLA_BRPORT_ROOT_ID
] = { .type
= NETLINK_TYPE_U8
},
463 [IFLA_BRPORT_BRIDGE_ID
] = { .type
= NETLINK_TYPE_U8
},
464 [IFLA_BRPORT_DESIGNATED_PORT
] = { .type
= NETLINK_TYPE_U16
},
465 [IFLA_BRPORT_DESIGNATED_COST
] = { .type
= NETLINK_TYPE_U16
},
466 [IFLA_BRPORT_ID
] = { .type
= NETLINK_TYPE_U16
},
467 [IFLA_BRPORT_NO
] = { .type
= NETLINK_TYPE_U16
},
468 [IFLA_BRPORT_TOPOLOGY_CHANGE_ACK
] = { .type
= NETLINK_TYPE_U8
},
469 [IFLA_BRPORT_CONFIG_PENDING
] = { .type
= NETLINK_TYPE_U8
},
470 [IFLA_BRPORT_MESSAGE_AGE_TIMER
] = { .type
= NETLINK_TYPE_U64
},
471 [IFLA_BRPORT_FORWARD_DELAY_TIMER
] = { .type
= NETLINK_TYPE_U64
},
472 [IFLA_BRPORT_HOLD_TIMER
] = { .type
= NETLINK_TYPE_U64
},
473 [IFLA_BRPORT_FLUSH
] = { .type
= NETLINK_TYPE_U8
},
474 [IFLA_BRPORT_MULTICAST_ROUTER
] = { .type
= NETLINK_TYPE_U8
},
475 [IFLA_BRPORT_PAD
] = { .type
= NETLINK_TYPE_U8
},
476 [IFLA_BRPORT_MCAST_FLOOD
] = { .type
= NETLINK_TYPE_U8
},
477 [IFLA_BRPORT_MCAST_TO_UCAST
] = { .type
= NETLINK_TYPE_U8
},
478 [IFLA_BRPORT_VLAN_TUNNEL
] = { .type
= NETLINK_TYPE_U8
},
479 [IFLA_BRPORT_BCAST_FLOOD
] = { .type
= NETLINK_TYPE_U8
},
480 [IFLA_BRPORT_GROUP_FWD_MASK
] = { .type
= NETLINK_TYPE_U16
},
481 [IFLA_BRPORT_NEIGH_SUPPRESS
] = { .type
= NETLINK_TYPE_U8
},
482 [IFLA_BRPORT_ISOLATED
] = { .type
= NETLINK_TYPE_U8
},
483 [IFLA_BRPORT_BACKUP_PORT
] = { .type
= NETLINK_TYPE_U32
},
486 static const NLTypeSystem rtnl_prot_info_type_systems
[] = {
487 [AF_BRIDGE
] = { .count
= ELEMENTSOF(rtnl_prot_info_bridge_port_types
),
488 .types
= rtnl_prot_info_bridge_port_types
},
491 static const NLTypeSystemUnion rtnl_prot_info_type_system_union
= {
493 .type_systems
= rtnl_prot_info_type_systems
,
494 .match_type
= NL_MATCH_PROTOCOL
,
497 static const struct NLType rtnl_af_spec_inet6_types
[] = {
498 [IFLA_INET6_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
503 IFLA_INET6_CACHEINFO,
504 IFLA_INET6_ICMP6STATS,
506 [IFLA_INET6_TOKEN
] = { .type
= NETLINK_TYPE_IN_ADDR
},
507 [IFLA_INET6_ADDR_GEN_MODE
] = { .type
= NETLINK_TYPE_U8
},
510 static const NLTypeSystem rtnl_af_spec_inet6_type_system
= {
511 .count
= ELEMENTSOF(rtnl_af_spec_inet6_types
),
512 .types
= rtnl_af_spec_inet6_types
,
515 static const NLType rtnl_af_spec_types
[] = {
516 [AF_INET6
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_af_spec_inet6_type_system
},
519 static const NLTypeSystem rtnl_af_spec_type_system
= {
520 .count
= ELEMENTSOF(rtnl_af_spec_types
),
521 .types
= rtnl_af_spec_types
,
524 static const NLType rtnl_link_types
[] = {
525 [IFLA_ADDRESS
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
526 [IFLA_BROADCAST
] = { .type
= NETLINK_TYPE_ETHER_ADDR
},
527 [IFLA_IFNAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFNAMSIZ
- 1 },
528 [IFLA_MTU
] = { .type
= NETLINK_TYPE_U32
},
529 [IFLA_LINK
] = { .type
= NETLINK_TYPE_U32
},
533 [IFLA_STATS
] = { .size
= sizeof(struct rtnl_link_stats
) },
538 [IFLA_MASTER
] = { .type
= NETLINK_TYPE_U32
},
542 [IFLA_PROTINFO
] = { .type
= NETLINK_TYPE_UNION
, .type_system_union
= &rtnl_prot_info_type_system_union
},
543 [IFLA_TXQLEN
] = { .type
= NETLINK_TYPE_U32
},
545 [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) },
547 [IFLA_WEIGHT
] = { .type
= NETLINK_TYPE_U32
},
548 [IFLA_OPERSTATE
] = { .type
= NETLINK_TYPE_U8
},
549 [IFLA_LINKMODE
] = { .type
= NETLINK_TYPE_U8
},
550 [IFLA_LINKINFO
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_info_type_system
},
551 [IFLA_NET_NS_PID
] = { .type
= NETLINK_TYPE_U32
},
552 [IFLA_IFALIAS
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFALIASZ
- 1 },
555 [IFLA_VFINFO_LIST] = {. type = NETLINK_TYPE_NESTED, },
557 [IFLA_STATS64
] = { .size
= sizeof(struct rtnl_link_stats64
) },
559 [IFLA_VF_PORTS] = { .type = NETLINK_TYPE_NESTED },
560 [IFLA_PORT_SELF] = { .type = NETLINK_TYPE_NESTED },
562 [IFLA_AF_SPEC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_af_spec_type_system
},
568 [IFLA_GROUP
] = { .type
= NETLINK_TYPE_U32
},
569 [IFLA_NET_NS_FD
] = { .type
= NETLINK_TYPE_U32
},
570 [IFLA_EXT_MASK
] = { .type
= NETLINK_TYPE_U32
},
571 [IFLA_PROMISCUITY
] = { .type
= NETLINK_TYPE_U32
},
572 [IFLA_NUM_TX_QUEUES
] = { .type
= NETLINK_TYPE_U32
},
573 [IFLA_NUM_RX_QUEUES
] = { .type
= NETLINK_TYPE_U32
},
574 [IFLA_CARRIER
] = { .type
= NETLINK_TYPE_U8
},
576 [IFLA_PHYS_PORT_ID] = { .type = NETLINK_TYPE_BINARY, .len = MAX_PHYS_PORT_ID_LEN },
578 [IFLA_MIN_MTU
] = { .type
= NETLINK_TYPE_U32
},
579 [IFLA_MAX_MTU
] = { .type
= NETLINK_TYPE_U32
},
582 static const NLTypeSystem rtnl_link_type_system
= {
583 .count
= ELEMENTSOF(rtnl_link_types
),
584 .types
= rtnl_link_types
,
587 /* IFA_FLAGS was defined in kernel 3.14, but we still support older
588 * kernels where IFA_MAX is lower. */
589 static const NLType rtnl_address_types
[] = {
590 [IFA_ADDRESS
] = { .type
= NETLINK_TYPE_IN_ADDR
},
591 [IFA_LOCAL
] = { .type
= NETLINK_TYPE_IN_ADDR
},
592 [IFA_LABEL
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFNAMSIZ
- 1 },
593 [IFA_BROADCAST
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
594 [IFA_CACHEINFO
] = { .type
= NETLINK_TYPE_CACHE_INFO
, .size
= sizeof(struct ifa_cacheinfo
) },
599 [IFA_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
602 static const NLTypeSystem rtnl_address_type_system
= {
603 .count
= ELEMENTSOF(rtnl_address_types
),
604 .types
= rtnl_address_types
,
607 /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
609 static const NLType rtnl_route_metrics_types
[] = {
610 [RTAX_MTU
] = { .type
= NETLINK_TYPE_U32
},
611 [RTAX_WINDOW
] = { .type
= NETLINK_TYPE_U32
},
612 [RTAX_RTT
] = { .type
= NETLINK_TYPE_U32
},
613 [RTAX_RTTVAR
] = { .type
= NETLINK_TYPE_U32
},
614 [RTAX_SSTHRESH
] = { .type
= NETLINK_TYPE_U32
},
615 [RTAX_CWND
] = { .type
= NETLINK_TYPE_U32
},
616 [RTAX_ADVMSS
] = { .type
= NETLINK_TYPE_U32
},
617 [RTAX_REORDERING
] = { .type
= NETLINK_TYPE_U32
},
618 [RTAX_HOPLIMIT
] = { .type
= NETLINK_TYPE_U32
},
619 [RTAX_INITCWND
] = { .type
= NETLINK_TYPE_U32
},
620 [RTAX_FEATURES
] = { .type
= NETLINK_TYPE_U32
},
621 [RTAX_RTO_MIN
] = { .type
= NETLINK_TYPE_U32
},
622 [RTAX_INITRWND
] = { .type
= NETLINK_TYPE_U32
},
623 [RTAX_QUICKACK
] = { .type
= NETLINK_TYPE_U32
},
624 [RTAX_CC_ALGO
] = { .type
= NETLINK_TYPE_U32
},
625 [RTAX_FASTOPEN_NO_COOKIE
] = { .type
= NETLINK_TYPE_U32
},
628 static const NLTypeSystem rtnl_route_metrics_type_system
= {
629 .count
= ELEMENTSOF(rtnl_route_metrics_types
),
630 .types
= rtnl_route_metrics_types
,
633 static const NLType rtnl_route_types
[] = {
634 [RTA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
635 [RTA_SRC
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
636 [RTA_IIF
] = { .type
= NETLINK_TYPE_U32
},
637 [RTA_OIF
] = { .type
= NETLINK_TYPE_U32
},
638 [RTA_GATEWAY
] = { .type
= NETLINK_TYPE_IN_ADDR
},
639 [RTA_PRIORITY
] = { .type
= NETLINK_TYPE_U32
},
640 [RTA_PREFSRC
] = { .type
= NETLINK_TYPE_IN_ADDR
}, /* 6? */
641 [RTA_METRICS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_metrics_type_system
},
642 [RTA_MULTIPATH
] = { .size
= sizeof(struct rtnexthop
) },
643 [RTA_FLOW
] = { .type
= NETLINK_TYPE_U32
}, /* 6? */
644 [RTA_CACHEINFO
] = { .size
= sizeof(struct rta_cacheinfo
) },
645 [RTA_TABLE
] = { .type
= NETLINK_TYPE_U32
},
646 [RTA_MARK
] = { .type
= NETLINK_TYPE_U32
},
647 [RTA_MFC_STATS
] = { .type
= NETLINK_TYPE_U64
},
648 [RTA_VIA
] = { .type
= NETLINK_TYPE_U32
},
649 [RTA_NEWDST
] = { .type
= NETLINK_TYPE_U32
},
650 [RTA_PREF
] = { .type
= NETLINK_TYPE_U8
},
651 [RTA_EXPIRES
] = { .type
= NETLINK_TYPE_U32
},
652 [RTA_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
653 [RTA_ENCAP
] = { .type
= NETLINK_TYPE_NESTED
}, /* Multiple type systems i.e. LWTUNNEL_ENCAP_MPLS/LWTUNNEL_ENCAP_IP/LWTUNNEL_ENCAP_ILA etc... */
654 [RTA_UID
] = { .type
= NETLINK_TYPE_U32
},
655 [RTA_TTL_PROPAGATE
] = { .type
= NETLINK_TYPE_U8
},
656 [RTA_IP_PROTO
] = { .type
= NETLINK_TYPE_U8
},
657 [RTA_SPORT
] = { .type
= NETLINK_TYPE_U16
},
658 [RTA_DPORT
] = { .type
= NETLINK_TYPE_U16
},
661 static const NLTypeSystem rtnl_route_type_system
= {
662 .count
= ELEMENTSOF(rtnl_route_types
),
663 .types
= rtnl_route_types
,
666 static const NLType rtnl_neigh_types
[] = {
667 [NDA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
},
668 [NDA_LLADDR
] = { /* struct ether_addr, struct in_addr, or struct in6_addr */ },
669 [NDA_CACHEINFO
] = { .type
= NETLINK_TYPE_CACHE_INFO
, .size
= sizeof(struct nda_cacheinfo
) },
670 [NDA_PROBES
] = { .type
= NETLINK_TYPE_U32
},
671 [NDA_VLAN
] = { .type
= NETLINK_TYPE_U16
},
672 [NDA_PORT
] = { .type
= NETLINK_TYPE_U16
},
673 [NDA_VNI
] = { .type
= NETLINK_TYPE_U32
},
674 [NDA_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
677 static const NLTypeSystem rtnl_neigh_type_system
= {
678 .count
= ELEMENTSOF(rtnl_neigh_types
),
679 .types
= rtnl_neigh_types
,
682 static const NLType rtnl_addrlabel_types
[] = {
683 [IFAL_ADDRESS
] = { .type
= NETLINK_TYPE_IN_ADDR
, .size
= sizeof(struct in6_addr
) },
684 [IFAL_LABEL
] = { .type
= NETLINK_TYPE_U32
},
687 static const NLTypeSystem rtnl_addrlabel_type_system
= {
688 .count
= ELEMENTSOF(rtnl_addrlabel_types
),
689 .types
= rtnl_addrlabel_types
,
692 static const NLType rtnl_routing_policy_rule_types
[] = {
693 [FRA_DST
] = { .type
= NETLINK_TYPE_IN_ADDR
},
694 [FRA_SRC
] = { .type
= NETLINK_TYPE_IN_ADDR
},
695 [FRA_IIFNAME
] = { .type
= NETLINK_TYPE_STRING
},
696 [FRA_GOTO
] = { .type
= NETLINK_TYPE_U32
},
697 [FRA_PRIORITY
] = { .type
= NETLINK_TYPE_U32
},
698 [FRA_FWMARK
] = { .type
= NETLINK_TYPE_U32
},
699 [FRA_FLOW
] = { .type
= NETLINK_TYPE_U32
},
700 [FRA_TUN_ID
] = { .type
= NETLINK_TYPE_U64
},
701 [FRA_SUPPRESS_IFGROUP
] = { .type
= NETLINK_TYPE_U32
},
702 [FRA_SUPPRESS_PREFIXLEN
] = { .type
= NETLINK_TYPE_U32
},
703 [FRA_TABLE
] = { .type
= NETLINK_TYPE_U32
},
704 [FRA_FWMASK
] = { .type
= NETLINK_TYPE_U32
},
705 [FRA_OIFNAME
] = { .type
= NETLINK_TYPE_STRING
},
706 [FRA_PAD
] = { .type
= NETLINK_TYPE_U32
},
707 [FRA_L3MDEV
] = { .type
= NETLINK_TYPE_U8
},
708 [FRA_UID_RANGE
] = { .size
= sizeof(struct fib_rule_uid_range
) },
709 [FRA_PROTOCOL
] = { .type
= NETLINK_TYPE_U8
},
710 [FRA_IP_PROTO
] = { .type
= NETLINK_TYPE_U8
},
711 [FRA_SPORT_RANGE
] = { .size
= sizeof(struct fib_rule_port_range
) },
712 [FRA_DPORT_RANGE
] = { .size
= sizeof(struct fib_rule_port_range
) },
715 static const NLTypeSystem rtnl_routing_policy_rule_type_system
= {
716 .count
= ELEMENTSOF(rtnl_routing_policy_rule_types
),
717 .types
= rtnl_routing_policy_rule_types
,
720 static const NLType rtnl_nexthop_types
[] = {
721 [NHA_ID
] = { .type
= NETLINK_TYPE_U32
},
722 [NHA_OIF
] = { .type
= NETLINK_TYPE_U32
},
723 [NHA_GATEWAY
] = { .type
= NETLINK_TYPE_IN_ADDR
},
726 static const NLTypeSystem rtnl_nexthop_type_system
= {
727 .count
= ELEMENTSOF(rtnl_nexthop_types
),
728 .types
= rtnl_nexthop_types
,
731 static const NLType rtnl_types
[] = {
732 [NLMSG_DONE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &empty_type_system
, .size
= 0 },
733 [NLMSG_ERROR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &empty_type_system
, .size
= sizeof(struct nlmsgerr
) },
734 [RTM_NEWLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
735 [RTM_DELLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
736 [RTM_GETLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
737 [RTM_SETLINK
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_link_type_system
, .size
= sizeof(struct ifinfomsg
) },
738 [RTM_NEWADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
739 [RTM_DELADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
740 [RTM_GETADDR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_address_type_system
, .size
= sizeof(struct ifaddrmsg
) },
741 [RTM_NEWROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
742 [RTM_DELROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
743 [RTM_GETROUTE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_route_type_system
, .size
= sizeof(struct rtmsg
) },
744 [RTM_NEWNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
745 [RTM_DELNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
746 [RTM_GETNEIGH
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_neigh_type_system
, .size
= sizeof(struct ndmsg
) },
747 [RTM_NEWADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
748 [RTM_DELADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
749 [RTM_GETADDRLABEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_addrlabel_type_system
, .size
= sizeof(struct ifaddrlblmsg
) },
750 [RTM_NEWRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct rtmsg
) },
751 [RTM_DELRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct rtmsg
) },
752 [RTM_GETRULE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_routing_policy_rule_type_system
, .size
= sizeof(struct rtmsg
) },
753 [RTM_NEWNEXTHOP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_nexthop_type_system
, .size
= sizeof(struct nhmsg
) },
754 [RTM_DELNEXTHOP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_nexthop_type_system
, .size
= sizeof(struct nhmsg
) },
755 [RTM_GETNEXTHOP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &rtnl_nexthop_type_system
, .size
= sizeof(struct nhmsg
) },
758 const NLTypeSystem rtnl_type_system_root
= {
759 .count
= ELEMENTSOF(rtnl_types
),
763 static const NLType genl_wireguard_allowedip_types
[] = {
764 [WGALLOWEDIP_A_FAMILY
] = { .type
= NETLINK_TYPE_U16
},
765 [WGALLOWEDIP_A_IPADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
766 [WGALLOWEDIP_A_CIDR_MASK
] = { .type
= NETLINK_TYPE_U8
},
769 static const NLTypeSystem genl_wireguard_allowedip_type_system
= {
770 .count
= ELEMENTSOF(genl_wireguard_allowedip_types
),
771 .types
= genl_wireguard_allowedip_types
,
774 static const NLType genl_wireguard_peer_types
[] = {
775 [WGPEER_A_PUBLIC_KEY
] = { .size
= WG_KEY_LEN
},
776 [WGPEER_A_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
777 [WGPEER_A_PRESHARED_KEY
] = { .size
= WG_KEY_LEN
},
778 [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL
] = { .type
= NETLINK_TYPE_U16
},
779 [WGPEER_A_ENDPOINT
] = { .type
= NETLINK_TYPE_SOCKADDR
},
780 [WGPEER_A_ALLOWEDIPS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_wireguard_allowedip_type_system
},
783 static const NLTypeSystem genl_wireguard_peer_type_system
= {
784 .count
= ELEMENTSOF(genl_wireguard_peer_types
),
785 .types
= genl_wireguard_peer_types
,
788 static const NLType genl_wireguard_set_device_types
[] = {
789 [WGDEVICE_A_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
790 [WGDEVICE_A_IFNAME
] = { .type
= NETLINK_TYPE_STRING
, .size
= IFNAMSIZ
-1 },
791 [WGDEVICE_A_FLAGS
] = { .type
= NETLINK_TYPE_U32
},
792 [WGDEVICE_A_PRIVATE_KEY
] = { .size
= WG_KEY_LEN
},
793 [WGDEVICE_A_LISTEN_PORT
] = { .type
= NETLINK_TYPE_U16
},
794 [WGDEVICE_A_FWMARK
] = { .type
= NETLINK_TYPE_U32
},
795 [WGDEVICE_A_PEERS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_wireguard_peer_type_system
},
798 static const NLTypeSystem genl_wireguard_set_device_type_system
= {
799 .count
= ELEMENTSOF(genl_wireguard_set_device_types
),
800 .types
= genl_wireguard_set_device_types
,
803 static const NLType genl_wireguard_cmds
[] = {
804 [WG_CMD_SET_DEVICE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_wireguard_set_device_type_system
},
807 static const NLTypeSystem genl_wireguard_type_system
= {
808 .count
= ELEMENTSOF(genl_wireguard_cmds
),
809 .types
= genl_wireguard_cmds
,
812 static const NLType genl_mcast_group_types
[] = {
813 [CTRL_ATTR_MCAST_GRP_NAME
] = { .type
= NETLINK_TYPE_STRING
},
814 [CTRL_ATTR_MCAST_GRP_ID
] = { .type
= NETLINK_TYPE_U32
},
817 static const NLTypeSystem genl_mcast_group_type_system
= {
818 .count
= ELEMENTSOF(genl_mcast_group_types
),
819 .types
= genl_mcast_group_types
,
822 static const NLType genl_get_family_types
[] = {
823 [CTRL_ATTR_FAMILY_NAME
] = { .type
= NETLINK_TYPE_STRING
},
824 [CTRL_ATTR_FAMILY_ID
] = { .type
= NETLINK_TYPE_U16
},
825 [CTRL_ATTR_MCAST_GROUPS
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_mcast_group_type_system
},
828 static const NLTypeSystem genl_get_family_type_system
= {
829 .count
= ELEMENTSOF(genl_get_family_types
),
830 .types
= genl_get_family_types
,
833 static const NLType genl_ctrl_id_ctrl_cmds
[] = {
834 [CTRL_CMD_GETFAMILY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_get_family_type_system
},
837 static const NLTypeSystem genl_ctrl_id_ctrl_type_system
= {
838 .count
= ELEMENTSOF(genl_ctrl_id_ctrl_cmds
),
839 .types
= genl_ctrl_id_ctrl_cmds
,
842 static const NLType genl_fou_types
[] = {
843 [FOU_ATTR_PORT
] = { .type
= NETLINK_TYPE_U16
},
844 [FOU_ATTR_AF
] = { .type
= NETLINK_TYPE_U8
},
845 [FOU_ATTR_IPPROTO
] = { .type
= NETLINK_TYPE_U8
},
846 [FOU_ATTR_TYPE
] = { .type
= NETLINK_TYPE_U8
},
847 [FOU_ATTR_REMCSUM_NOPARTIAL
] = { .type
= NETLINK_TYPE_FLAG
},
848 [FOU_ATTR_LOCAL_V4
] = { .type
= NETLINK_TYPE_IN_ADDR
},
849 [FOU_ATTR_PEER_V4
] = { .type
= NETLINK_TYPE_IN_ADDR
},
850 [FOU_ATTR_LOCAL_V6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
851 [FOU_ATTR_PEER_V6
] = { .type
= NETLINK_TYPE_IN_ADDR
},
852 [FOU_ATTR_PEER_PORT
] = { .type
= NETLINK_TYPE_U16
},
853 [FOU_ATTR_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
856 static const NLTypeSystem genl_fou_type_system
= {
857 .count
= ELEMENTSOF(genl_fou_types
),
858 .types
= genl_fou_types
,
861 static const NLType genl_fou_cmds
[] = {
862 [FOU_CMD_ADD
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_fou_type_system
},
863 [FOU_CMD_DEL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_fou_type_system
},
864 [FOU_CMD_GET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_fou_type_system
},
867 static const NLTypeSystem genl_fou_cmds_type_system
= {
868 .count
= ELEMENTSOF(genl_fou_cmds
),
869 .types
= genl_fou_cmds
,
872 static const NLType genl_l2tp_types
[] = {
873 [L2TP_ATTR_PW_TYPE
] = { .type
= NETLINK_TYPE_U16
},
874 [L2TP_ATTR_ENCAP_TYPE
] = { .type
= NETLINK_TYPE_U16
},
875 [L2TP_ATTR_OFFSET
] = { .type
= NETLINK_TYPE_U16
},
876 [L2TP_ATTR_DATA_SEQ
] = { .type
= NETLINK_TYPE_U16
},
877 [L2TP_ATTR_L2SPEC_TYPE
] = { .type
= NETLINK_TYPE_U8
},
878 [L2TP_ATTR_L2SPEC_LEN
] = { .type
= NETLINK_TYPE_U8
},
879 [L2TP_ATTR_PROTO_VERSION
] = { .type
= NETLINK_TYPE_U8
},
880 [L2TP_ATTR_IFNAME
] = { .type
= NETLINK_TYPE_STRING
},
881 [L2TP_ATTR_CONN_ID
] = { .type
= NETLINK_TYPE_U32
},
882 [L2TP_ATTR_PEER_CONN_ID
] = { .type
= NETLINK_TYPE_U32
},
883 [L2TP_ATTR_SESSION_ID
] = { .type
= NETLINK_TYPE_U32
},
884 [L2TP_ATTR_PEER_SESSION_ID
] = { .type
= NETLINK_TYPE_U32
},
885 [L2TP_ATTR_UDP_CSUM
] = { .type
= NETLINK_TYPE_U8
},
886 [L2TP_ATTR_VLAN_ID
] = { .type
= NETLINK_TYPE_U16
},
887 [L2TP_ATTR_RECV_SEQ
] = { .type
= NETLINK_TYPE_U8
},
888 [L2TP_ATTR_SEND_SEQ
] = { .type
= NETLINK_TYPE_U8
},
889 [L2TP_ATTR_LNS_MODE
] = { .type
= NETLINK_TYPE_U8
},
890 [L2TP_ATTR_USING_IPSEC
] = { .type
= NETLINK_TYPE_U8
},
891 [L2TP_ATTR_FD
] = { .type
= NETLINK_TYPE_U32
},
892 [L2TP_ATTR_IP_SADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
893 [L2TP_ATTR_IP_DADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
894 [L2TP_ATTR_UDP_SPORT
] = { .type
= NETLINK_TYPE_U16
},
895 [L2TP_ATTR_UDP_DPORT
] = { .type
= NETLINK_TYPE_U16
},
896 [L2TP_ATTR_IP6_SADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
897 [L2TP_ATTR_IP6_DADDR
] = { .type
= NETLINK_TYPE_IN_ADDR
},
898 [L2TP_ATTR_UDP_ZERO_CSUM6_TX
] = { .type
= NETLINK_TYPE_FLAG
},
899 [L2TP_ATTR_UDP_ZERO_CSUM6_RX
] = { .type
= NETLINK_TYPE_FLAG
},
902 static const NLTypeSystem genl_l2tp_type_system
= {
903 .count
= ELEMENTSOF(genl_l2tp_types
),
904 .types
= genl_l2tp_types
,
907 static const NLType genl_l2tp
[] = {
908 [L2TP_CMD_TUNNEL_CREATE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
909 [L2TP_CMD_TUNNEL_DELETE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
910 [L2TP_CMD_TUNNEL_MODIFY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
911 [L2TP_CMD_TUNNEL_GET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
912 [L2TP_CMD_SESSION_CREATE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
913 [L2TP_CMD_SESSION_DELETE
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
914 [L2TP_CMD_SESSION_MODIFY
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
915 [L2TP_CMD_SESSION_GET
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_type_system
},
918 static const NLTypeSystem genl_l2tp_tunnel_session_type_system
= {
919 .count
= ELEMENTSOF(genl_l2tp
),
923 static const NLType genl_rxsc_types
[] = {
924 [MACSEC_RXSC_ATTR_SCI
] = { .type
= NETLINK_TYPE_U64
},
927 static const NLTypeSystem genl_rxsc_config_type_system
= {
928 .count
= ELEMENTSOF(genl_rxsc_types
),
929 .types
= genl_rxsc_types
,
932 static const NLType genl_macsec_rxsc_types
[] = {
933 [MACSEC_ATTR_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
934 [MACSEC_ATTR_RXSC_CONFIG
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_rxsc_config_type_system
},
937 static const NLTypeSystem genl_macsec_rxsc_type_system
= {
938 .count
= ELEMENTSOF(genl_macsec_rxsc_types
),
939 .types
= genl_macsec_rxsc_types
,
942 static const NLType genl_macsec_sa_config_types
[] = {
943 [MACSEC_SA_ATTR_AN
] = { .type
= NETLINK_TYPE_U8
},
944 [MACSEC_SA_ATTR_ACTIVE
] = { .type
= NETLINK_TYPE_U8
},
945 [MACSEC_SA_ATTR_PN
] = { .type
= NETLINK_TYPE_U32
},
946 [MACSEC_SA_ATTR_KEYID
] = { .size
= MACSEC_KEYID_LEN
},
947 [MACSEC_SA_ATTR_KEY
] = { .size
= MACSEC_MAX_KEY_LEN
},
950 static const NLTypeSystem genl_macsec_sa_config_type_system
= {
951 .count
= ELEMENTSOF(genl_macsec_sa_config_types
),
952 .types
= genl_macsec_sa_config_types
,
955 static const NLType genl_macsec_rxsa_types
[] = {
956 [MACSEC_ATTR_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
957 [MACSEC_ATTR_SA_CONFIG
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_sa_config_type_system
},
960 static const NLTypeSystem genl_macsec_rxsa_type_system
= {
961 .count
= ELEMENTSOF(genl_macsec_rxsa_types
),
962 .types
= genl_macsec_rxsa_types
,
965 static const NLType genl_macsec_sa_types
[] = {
966 [MACSEC_ATTR_IFINDEX
] = { .type
= NETLINK_TYPE_U32
},
967 [MACSEC_ATTR_RXSC_CONFIG
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_rxsc_config_type_system
},
968 [MACSEC_ATTR_SA_CONFIG
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_sa_config_type_system
},
971 static const NLTypeSystem genl_macsec_sa_type_system
= {
972 .count
= ELEMENTSOF(genl_macsec_sa_types
),
973 .types
= genl_macsec_sa_types
,
976 static const NLType genl_macsec
[] = {
977 [MACSEC_CMD_ADD_RXSC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_rxsc_type_system
},
978 [MACSEC_CMD_ADD_TXSA
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_rxsa_type_system
},
979 [MACSEC_CMD_ADD_RXSA
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_sa_type_system
},
982 static const NLTypeSystem genl_macsec_device_type_system
= {
983 .count
= ELEMENTSOF(genl_macsec
),
984 .types
= genl_macsec
,
987 static const NLType genl_families
[] = {
988 [SD_GENL_ID_CTRL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_ctrl_id_ctrl_type_system
},
989 [SD_GENL_WIREGUARD
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_wireguard_type_system
},
990 [SD_GENL_FOU
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_fou_cmds_type_system
},
991 [SD_GENL_L2TP
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_l2tp_tunnel_session_type_system
},
992 [SD_GENL_MACSEC
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_macsec_device_type_system
},
995 const NLTypeSystem genl_family_type_system_root
= {
996 .count
= ELEMENTSOF(genl_families
),
997 .types
= genl_families
,
1000 static const NLType genl_types
[] = {
1001 [NLMSG_ERROR
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &empty_type_system
, .size
= sizeof(struct nlmsgerr
) },
1002 [GENL_ID_CTRL
] = { .type
= NETLINK_TYPE_NESTED
, .type_system
= &genl_get_family_type_system
, .size
= sizeof(struct genlmsghdr
) },
1005 const NLTypeSystem genl_type_system_root
= {
1006 .count
= ELEMENTSOF(genl_types
),
1007 .types
= genl_types
,
1010 uint16_t type_get_type(const NLType
*type
) {
1015 size_t type_get_size(const NLType
*type
) {
1020 void type_get_type_system(const NLType
*nl_type
, const NLTypeSystem
**ret
) {
1023 assert(nl_type
->type
== NETLINK_TYPE_NESTED
);
1024 assert(nl_type
->type_system
);
1026 *ret
= nl_type
->type_system
;
1029 void type_get_type_system_union(const NLType
*nl_type
, const NLTypeSystemUnion
**ret
) {
1032 assert(nl_type
->type
== NETLINK_TYPE_UNION
);
1033 assert(nl_type
->type_system_union
);
1035 *ret
= nl_type
->type_system_union
;
1038 uint16_t type_system_get_count(const NLTypeSystem
*type_system
) {
1039 assert(type_system
);
1040 return type_system
->count
;
1043 const NLTypeSystem
*type_system_get_root(int protocol
) {
1045 case NETLINK_GENERIC
:
1046 return &genl_type_system_root
;
1047 default: /* NETLINK_ROUTE: */
1048 return &rtnl_type_system_root
;
1052 int type_system_get_type(const NLTypeSystem
*type_system
, const NLType
**ret
, uint16_t type
) {
1053 const NLType
*nl_type
;
1056 assert(type_system
);
1057 assert(type_system
->types
);
1059 if (type
>= type_system
->count
)
1062 nl_type
= &type_system
->types
[type
];
1064 if (nl_type
->type
== NETLINK_TYPE_UNSPEC
)
1072 int type_system_get_type_system(const NLTypeSystem
*type_system
, const NLTypeSystem
**ret
, uint16_t type
) {
1073 const NLType
*nl_type
;
1078 r
= type_system_get_type(type_system
, &nl_type
, type
);
1082 type_get_type_system(nl_type
, ret
);
1086 int type_system_get_type_system_union(const NLTypeSystem
*type_system
, const NLTypeSystemUnion
**ret
, uint16_t type
) {
1087 const NLType
*nl_type
;
1092 r
= type_system_get_type(type_system
, &nl_type
, type
);
1096 type_get_type_system_union(nl_type
, ret
);
1100 int type_system_union_get_type_system(const NLTypeSystemUnion
*type_system_union
, const NLTypeSystem
**ret
, const char *key
) {
1103 assert(type_system_union
);
1104 assert(type_system_union
->match_type
== NL_MATCH_SIBLING
);
1105 assert(type_system_union
->lookup
);
1106 assert(type_system_union
->type_systems
);
1110 type
= type_system_union
->lookup(key
);
1114 assert(type
< type_system_union
->num
);
1116 *ret
= &type_system_union
->type_systems
[type
];
1121 int type_system_union_protocol_get_type_system(const NLTypeSystemUnion
*type_system_union
, const NLTypeSystem
**ret
, uint16_t protocol
) {
1122 const NLTypeSystem
*type_system
;
1124 assert(type_system_union
);
1125 assert(type_system_union
->type_systems
);
1126 assert(type_system_union
->match_type
== NL_MATCH_PROTOCOL
);
1129 if (protocol
>= type_system_union
->num
)
1132 type_system
= &type_system_union
->type_systems
[protocol
];
1133 if (!type_system
->types
)