]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
d8e538ec | 2 | |
5a2dadf1 | 3 | #include <netinet/in.h> |
d8e538ec TG |
4 | #include <stdint.h> |
5 | #include <sys/socket.h> | |
01234e1f | 6 | #include <linux/can/vxcan.h> |
d8e538ec TG |
7 | #include <linux/netlink.h> |
8 | #include <linux/rtnetlink.h> | |
5a2dadf1 LP |
9 | #include <linux/genetlink.h> |
10 | #include <linux/ip.h> | |
11 | #include <linux/if.h> | |
c0267a59 | 12 | #include <linux/batman_adv.h> |
92c918b0 | 13 | #include <linux/can/netlink.h> |
bce67bbe | 14 | #include <linux/fib_rules.h> |
01234e1f | 15 | #include <linux/fou.h> |
d8e538ec | 16 | #include <linux/if_addr.h> |
30746d60 | 17 | #include <linux/if_addrlabel.h> |
bce67bbe | 18 | #include <linux/if_bridge.h> |
c4a5ddc9 | 19 | #include <linux/if_link.h> |
81962db7 | 20 | #include <linux/if_macsec.h> |
0a827d10 | 21 | #include <linux/if_tunnel.h> |
3a56e697 | 22 | #include <linux/l2tp.h> |
6f00fd9b FW |
23 | #include <linux/netfilter/nf_tables.h> |
24 | #include <linux/netfilter/nfnetlink.h> | |
0f5bd7fe | 25 | #include <linux/nexthop.h> |
a1d736e2 | 26 | #include <linux/nl80211.h> |
0f5bd7fe | 27 | #include <linux/pkt_sched.h> |
5a2dadf1 | 28 | #include <linux/veth.h> |
01234e1f | 29 | #include <linux/wireguard.h> |
d6df583c | 30 | |
4e8f0ef9 YW |
31 | #include "sd-netlink.h" |
32 | ||
33 | #include "generic-netlink.h" | |
34 | #include "hashmap.h" | |
d8e538ec | 35 | #include "macro.h" |
4e8f0ef9 | 36 | #include "netlink-internal.h" |
8b43440b LP |
37 | #include "netlink-types.h" |
38 | #include "string-table.h" | |
39 | #include "util.h" | |
d8e538ec | 40 | |
dd906398 DH |
41 | /* Maximum ARP IP target defined in kernel */ |
42 | #define BOND_MAX_ARP_TARGETS 16 | |
43 | ||
44 | typedef enum { | |
45 | BOND_ARP_TARGETS_0, | |
46 | BOND_ARP_TARGETS_1, | |
47 | BOND_ARP_TARGETS_2, | |
48 | BOND_ARP_TARGETS_3, | |
49 | BOND_ARP_TARGETS_4, | |
50 | BOND_ARP_TARGETS_5, | |
51 | BOND_ARP_TARGETS_6, | |
52 | BOND_ARP_TARGETS_7, | |
53 | BOND_ARP_TARGETS_8, | |
54 | BOND_ARP_TARGETS_9, | |
55 | BOND_ARP_TARGETS_10, | |
56 | BOND_ARP_TARGETS_11, | |
57 | BOND_ARP_TARGETS_12, | |
58 | BOND_ARP_TARGETS_13, | |
59 | BOND_ARP_TARGETS_14, | |
60 | BOND_ARP_TARGETS_MAX = BOND_MAX_ARP_TARGETS, | |
61 | } BondArpTargets; | |
62 | ||
817d1cd8 DH |
63 | struct NLType { |
64 | uint16_t type; | |
65 | size_t size; | |
66 | const NLTypeSystem *type_system; | |
67 | const NLTypeSystemUnion *type_system_union; | |
68 | }; | |
69 | ||
435bbb02 | 70 | struct NLTypeSystem { |
c1df8dee | 71 | uint16_t count; |
435bbb02 DH |
72 | const NLType *types; |
73 | }; | |
74 | ||
d8e538ec TG |
75 | static const NLTypeSystem rtnl_link_type_system; |
76 | ||
979e7eb9 DH |
77 | static const NLType empty_types[1] = { |
78 | /* fake array to avoid .types==NULL, which denotes invalid type-systems */ | |
79 | }; | |
80 | ||
81 | static const NLTypeSystem empty_type_system = { | |
82 | .count = 0, | |
83 | .types = empty_types, | |
84 | }; | |
85 | ||
c0267a59 AW |
86 | static const NLType rtnl_link_info_data_batadv_types[] = { |
87 | [IFLA_BATADV_ALGO_NAME] = { .type = NETLINK_TYPE_STRING, .size = 20 }, | |
88 | }; | |
89 | ||
8ae4b6d1 | 90 | static const NLType rtnl_link_info_data_veth_types[] = { |
cafbc790 | 91 | [VETH_INFO_PEER] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, |
d8e538ec TG |
92 | }; |
93 | ||
d6df583c SS |
94 | static const NLType rtnl_link_info_data_vxcan_types[] = { |
95 | [VXCAN_INFO_PEER] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, | |
96 | }; | |
97 | ||
8ae4b6d1 | 98 | static const NLType rtnl_link_info_data_ipvlan_types[] = { |
cafbc790 | 99 | [IFLA_IPVLAN_MODE] = { .type = NETLINK_TYPE_U16 }, |
d384826f | 100 | [IFLA_IPVLAN_FLAGS] = { .type = NETLINK_TYPE_U16 }, |
c4a5ddc9 | 101 | }; |
d8e538ec | 102 | |
0d0de133 AŠ |
103 | static const NLType rtnl_macvlan_macaddr_types[] = { |
104 | [IFLA_MACVLAN_MACADDR] = { .type = NETLINK_TYPE_ETHER_ADDR }, | |
105 | }; | |
106 | ||
107 | static const NLTypeSystem rtnl_macvlan_macaddr_type_system = { | |
108 | .count = ELEMENTSOF(rtnl_macvlan_macaddr_types), | |
109 | .types = rtnl_macvlan_macaddr_types, | |
110 | }; | |
111 | ||
8ae4b6d1 | 112 | static const NLType rtnl_link_info_data_macvlan_types[] = { |
7e27a745 SS |
113 | [IFLA_MACVLAN_MODE] = { .type = NETLINK_TYPE_U32 }, |
114 | [IFLA_MACVLAN_FLAGS] = { .type = NETLINK_TYPE_U16 }, | |
115 | [IFLA_MACVLAN_MACADDR_MODE] = { .type = NETLINK_TYPE_U32 }, | |
116 | [IFLA_MACVLAN_MACADDR_DATA] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_macvlan_macaddr_type_system }, | |
117 | [IFLA_MACVLAN_MACADDR_COUNT] = { .type = NETLINK_TYPE_U32 }, | |
118 | [IFLA_MACVLAN_BC_QUEUE_LEN] = { .type = NETLINK_TYPE_U32 }, | |
119 | [IFLA_MACVLAN_BC_QUEUE_LEN_USED] = { .type = NETLINK_TYPE_REJECT }, | |
d8e538ec TG |
120 | }; |
121 | ||
8ae4b6d1 | 122 | static const NLType rtnl_link_info_data_bridge_types[] = { |
3fef7a3f SS |
123 | [IFLA_BR_FORWARD_DELAY] = { .type = NETLINK_TYPE_U32 }, |
124 | [IFLA_BR_HELLO_TIME] = { .type = NETLINK_TYPE_U32 }, | |
125 | [IFLA_BR_MAX_AGE] = { .type = NETLINK_TYPE_U32 }, | |
126 | [IFLA_BR_AGEING_TIME] = { .type = NETLINK_TYPE_U32 }, | |
127 | [IFLA_BR_STP_STATE] = { .type = NETLINK_TYPE_U32 }, | |
128 | [IFLA_BR_PRIORITY] = { .type = NETLINK_TYPE_U16 }, | |
129 | [IFLA_BR_VLAN_FILTERING] = { .type = NETLINK_TYPE_U8 }, | |
130 | [IFLA_BR_VLAN_PROTOCOL] = { .type = NETLINK_TYPE_U16 }, | |
131 | [IFLA_BR_GROUP_FWD_MASK] = { .type = NETLINK_TYPE_U16 }, | |
132 | [IFLA_BR_ROOT_PORT] = { .type = NETLINK_TYPE_U16 }, | |
133 | [IFLA_BR_ROOT_PATH_COST] = { .type = NETLINK_TYPE_U32 }, | |
134 | [IFLA_BR_TOPOLOGY_CHANGE] = { .type = NETLINK_TYPE_U8 }, | |
135 | [IFLA_BR_TOPOLOGY_CHANGE_DETECTED] = { .type = NETLINK_TYPE_U8 }, | |
136 | [IFLA_BR_HELLO_TIMER] = { .type = NETLINK_TYPE_U16 }, | |
137 | [IFLA_BR_TCN_TIMER] = { .type = NETLINK_TYPE_U16 }, | |
138 | [IFLA_BR_TOPOLOGY_CHANGE_TIMER] = { .type = NETLINK_TYPE_U16 }, | |
139 | [IFLA_BR_GC_TIMER] = { .type = NETLINK_TYPE_U64 }, | |
140 | [IFLA_BR_GROUP_ADDR] = { .type = NETLINK_TYPE_U16 }, | |
141 | [IFLA_BR_FDB_FLUSH] = { .type = NETLINK_TYPE_U16 }, | |
142 | [IFLA_BR_MCAST_ROUTER] = { .type = NETLINK_TYPE_U8 }, | |
143 | [IFLA_BR_MCAST_SNOOPING] = { .type = NETLINK_TYPE_U8 }, | |
144 | [IFLA_BR_MCAST_QUERY_USE_IFADDR] = { .type = NETLINK_TYPE_U8 }, | |
145 | [IFLA_BR_MCAST_QUERIER] = { .type = NETLINK_TYPE_U8 }, | |
146 | [IFLA_BR_MCAST_HASH_ELASTICITY] = { .type = NETLINK_TYPE_U32 }, | |
147 | [IFLA_BR_MCAST_HASH_MAX] = { .type = NETLINK_TYPE_U16 }, | |
148 | [IFLA_BR_MCAST_LAST_MEMBER_CNT] = { .type = NETLINK_TYPE_U32 }, | |
149 | [IFLA_BR_MCAST_STARTUP_QUERY_CNT] = { .type = NETLINK_TYPE_U16 }, | |
150 | [IFLA_BR_MCAST_LAST_MEMBER_INTVL] = { .type = NETLINK_TYPE_U64 }, | |
151 | [IFLA_BR_MCAST_MEMBERSHIP_INTVL] = { .type = NETLINK_TYPE_U64 }, | |
152 | [IFLA_BR_MCAST_QUERIER_INTVL] = { .type = NETLINK_TYPE_U64 }, | |
153 | [IFLA_BR_MCAST_QUERY_INTVL] = { .type = NETLINK_TYPE_U64 }, | |
154 | [IFLA_BR_MCAST_QUERY_RESPONSE_INTVL] = { .type = NETLINK_TYPE_U64 }, | |
155 | [IFLA_BR_MCAST_STARTUP_QUERY_INTVL] = { .type = NETLINK_TYPE_U64 }, | |
156 | [IFLA_BR_NF_CALL_IPTABLES] = { .type = NETLINK_TYPE_U8 }, | |
157 | [IFLA_BR_NF_CALL_IP6TABLES] = { .type = NETLINK_TYPE_U8 }, | |
158 | [IFLA_BR_NF_CALL_ARPTABLES] = { .type = NETLINK_TYPE_U8 }, | |
159 | [IFLA_BR_VLAN_DEFAULT_PVID] = { .type = NETLINK_TYPE_U16 }, | |
037dbb80 | 160 | [IFLA_BR_MCAST_IGMP_VERSION] = { .type = NETLINK_TYPE_U8 }, |
ced671e1 SS |
161 | }; |
162 | ||
810f2914 SS |
163 | static const NLType rtnl_vlan_qos_map_types[] = { |
164 | [IFLA_VLAN_QOS_MAPPING] = { .size = sizeof(struct ifla_vlan_qos_mapping) }, | |
165 | }; | |
166 | ||
167 | static const NLTypeSystem rtnl_vlan_qos_map_type_system = { | |
168 | .count = ELEMENTSOF(rtnl_vlan_qos_map_types), | |
169 | .types = rtnl_vlan_qos_map_types, | |
170 | }; | |
171 | ||
8ae4b6d1 | 172 | static const NLType rtnl_link_info_data_vlan_types[] = { |
cafbc790 | 173 | [IFLA_VLAN_ID] = { .type = NETLINK_TYPE_U16 }, |
810f2914 SS |
174 | [IFLA_VLAN_FLAGS] = { .size = sizeof(struct ifla_vlan_flags) }, |
175 | [IFLA_VLAN_EGRESS_QOS] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_vlan_qos_map_type_system }, | |
176 | [IFLA_VLAN_INGRESS_QOS] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_vlan_qos_map_type_system }, | |
cafbc790 | 177 | [IFLA_VLAN_PROTOCOL] = { .type = NETLINK_TYPE_U16 }, |
d8e538ec TG |
178 | }; |
179 | ||
8ae4b6d1 | 180 | static const NLType rtnl_link_info_data_vxlan_types[] = { |
452c9569 SS |
181 | [IFLA_VXLAN_ID] = { .type = NETLINK_TYPE_U32 }, |
182 | [IFLA_VXLAN_GROUP] = { .type = NETLINK_TYPE_IN_ADDR }, | |
183 | [IFLA_VXLAN_LINK] = { .type = NETLINK_TYPE_U32 }, | |
5564545b | 184 | [IFLA_VXLAN_LOCAL] = { .type = NETLINK_TYPE_IN_ADDR }, |
452c9569 SS |
185 | [IFLA_VXLAN_TTL] = { .type = NETLINK_TYPE_U8 }, |
186 | [IFLA_VXLAN_TOS] = { .type = NETLINK_TYPE_U8 }, | |
187 | [IFLA_VXLAN_LEARNING] = { .type = NETLINK_TYPE_U8 }, | |
188 | [IFLA_VXLAN_AGEING] = { .type = NETLINK_TYPE_U32 }, | |
189 | [IFLA_VXLAN_LIMIT] = { .type = NETLINK_TYPE_U32 }, | |
190 | [IFLA_VXLAN_PORT_RANGE] = { .type = NETLINK_TYPE_U32}, | |
191 | [IFLA_VXLAN_PROXY] = { .type = NETLINK_TYPE_U8 }, | |
192 | [IFLA_VXLAN_RSC] = { .type = NETLINK_TYPE_U8 }, | |
193 | [IFLA_VXLAN_L2MISS] = { .type = NETLINK_TYPE_U8 }, | |
194 | [IFLA_VXLAN_L3MISS] = { .type = NETLINK_TYPE_U8 }, | |
195 | [IFLA_VXLAN_PORT] = { .type = NETLINK_TYPE_U16 }, | |
196 | [IFLA_VXLAN_GROUP6] = { .type = NETLINK_TYPE_IN_ADDR }, | |
197 | [IFLA_VXLAN_LOCAL6] = { .type = NETLINK_TYPE_IN_ADDR }, | |
198 | [IFLA_VXLAN_UDP_CSUM] = { .type = NETLINK_TYPE_U8 }, | |
199 | [IFLA_VXLAN_UDP_ZERO_CSUM6_TX] = { .type = NETLINK_TYPE_U8 }, | |
200 | [IFLA_VXLAN_UDP_ZERO_CSUM6_RX] = { .type = NETLINK_TYPE_U8 }, | |
201 | [IFLA_VXLAN_REMCSUM_TX] = { .type = NETLINK_TYPE_U8 }, | |
202 | [IFLA_VXLAN_REMCSUM_RX] = { .type = NETLINK_TYPE_U8 }, | |
203 | [IFLA_VXLAN_GBP] = { .type = NETLINK_TYPE_FLAG }, | |
204 | [IFLA_VXLAN_REMCSUM_NOPARTIAL] = { .type = NETLINK_TYPE_FLAG }, | |
6d21646a SS |
205 | [IFLA_VXLAN_COLLECT_METADATA] = { .type = NETLINK_TYPE_U8 }, |
206 | [IFLA_VXLAN_LABEL] = { .type = NETLINK_TYPE_U32 }, | |
207 | [IFLA_VXLAN_GPE] = { .type = NETLINK_TYPE_FLAG }, | |
2a36d400 SS |
208 | [IFLA_VXLAN_TTL_INHERIT] = { .type = NETLINK_TYPE_FLAG }, |
209 | [IFLA_VXLAN_DF] = { .type = NETLINK_TYPE_U8 }, | |
6ef81477 SS |
210 | }; |
211 | ||
8ae4b6d1 | 212 | static const NLType rtnl_bond_arp_target_types[] = { |
cafbc790 DH |
213 | [BOND_ARP_TARGETS_0] = { .type = NETLINK_TYPE_U32 }, |
214 | [BOND_ARP_TARGETS_1] = { .type = NETLINK_TYPE_U32 }, | |
215 | [BOND_ARP_TARGETS_2] = { .type = NETLINK_TYPE_U32 }, | |
216 | [BOND_ARP_TARGETS_3] = { .type = NETLINK_TYPE_U32 }, | |
217 | [BOND_ARP_TARGETS_4] = { .type = NETLINK_TYPE_U32 }, | |
218 | [BOND_ARP_TARGETS_5] = { .type = NETLINK_TYPE_U32 }, | |
219 | [BOND_ARP_TARGETS_6] = { .type = NETLINK_TYPE_U32 }, | |
220 | [BOND_ARP_TARGETS_7] = { .type = NETLINK_TYPE_U32 }, | |
221 | [BOND_ARP_TARGETS_8] = { .type = NETLINK_TYPE_U32 }, | |
222 | [BOND_ARP_TARGETS_9] = { .type = NETLINK_TYPE_U32 }, | |
223 | [BOND_ARP_TARGETS_10] = { .type = NETLINK_TYPE_U32 }, | |
224 | [BOND_ARP_TARGETS_11] = { .type = NETLINK_TYPE_U32 }, | |
225 | [BOND_ARP_TARGETS_12] = { .type = NETLINK_TYPE_U32 }, | |
226 | [BOND_ARP_TARGETS_13] = { .type = NETLINK_TYPE_U32 }, | |
227 | [BOND_ARP_TARGETS_14] = { .type = NETLINK_TYPE_U32 }, | |
228 | [BOND_ARP_TARGETS_MAX] = { .type = NETLINK_TYPE_U32 }, | |
81bd37a8 SS |
229 | }; |
230 | ||
231 | static const NLTypeSystem rtnl_bond_arp_type_system = { | |
c1df8dee | 232 | .count = ELEMENTSOF(rtnl_bond_arp_target_types), |
81bd37a8 SS |
233 | .types = rtnl_bond_arp_target_types, |
234 | }; | |
235 | ||
8ae4b6d1 | 236 | static const NLType rtnl_link_info_data_bond_types[] = { |
cafbc790 DH |
237 | [IFLA_BOND_MODE] = { .type = NETLINK_TYPE_U8 }, |
238 | [IFLA_BOND_ACTIVE_SLAVE] = { .type = NETLINK_TYPE_U32 }, | |
239 | [IFLA_BOND_MIIMON] = { .type = NETLINK_TYPE_U32 }, | |
240 | [IFLA_BOND_UPDELAY] = { .type = NETLINK_TYPE_U32 }, | |
241 | [IFLA_BOND_DOWNDELAY] = { .type = NETLINK_TYPE_U32 }, | |
242 | [IFLA_BOND_USE_CARRIER] = { .type = NETLINK_TYPE_U8 }, | |
243 | [IFLA_BOND_ARP_INTERVAL] = { .type = NETLINK_TYPE_U32 }, | |
244 | [IFLA_BOND_ARP_IP_TARGET] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_bond_arp_type_system }, | |
245 | [IFLA_BOND_ARP_VALIDATE] = { .type = NETLINK_TYPE_U32 }, | |
246 | [IFLA_BOND_ARP_ALL_TARGETS] = { .type = NETLINK_TYPE_U32 }, | |
247 | [IFLA_BOND_PRIMARY] = { .type = NETLINK_TYPE_U32 }, | |
248 | [IFLA_BOND_PRIMARY_RESELECT] = { .type = NETLINK_TYPE_U8 }, | |
249 | [IFLA_BOND_FAIL_OVER_MAC] = { .type = NETLINK_TYPE_U8 }, | |
250 | [IFLA_BOND_XMIT_HASH_POLICY] = { .type = NETLINK_TYPE_U8 }, | |
251 | [IFLA_BOND_RESEND_IGMP] = { .type = NETLINK_TYPE_U32 }, | |
252 | [IFLA_BOND_NUM_PEER_NOTIF] = { .type = NETLINK_TYPE_U8 }, | |
253 | [IFLA_BOND_ALL_SLAVES_ACTIVE] = { .type = NETLINK_TYPE_U8 }, | |
254 | [IFLA_BOND_MIN_LINKS] = { .type = NETLINK_TYPE_U32 }, | |
255 | [IFLA_BOND_LP_INTERVAL] = { .type = NETLINK_TYPE_U32 }, | |
256 | [IFLA_BOND_PACKETS_PER_SLAVE] = { .type = NETLINK_TYPE_U32 }, | |
257 | [IFLA_BOND_AD_LACP_RATE] = { .type = NETLINK_TYPE_U8 }, | |
258 | [IFLA_BOND_AD_SELECT] = { .type = NETLINK_TYPE_U8 }, | |
259 | [IFLA_BOND_AD_INFO] = { .type = NETLINK_TYPE_NESTED }, | |
99f68ef0 TJ |
260 | [IFLA_BOND_AD_ACTOR_SYS_PRIO] = { .type = NETLINK_TYPE_U16 }, |
261 | [IFLA_BOND_AD_USER_PORT_KEY] = { .type = NETLINK_TYPE_U16 }, | |
262 | [IFLA_BOND_AD_ACTOR_SYSTEM] = { .type = NETLINK_TYPE_ETHER_ADDR }, | |
fde60a42 | 263 | [IFLA_BOND_TLB_DYNAMIC_LB] = { .type = NETLINK_TYPE_U8 }, |
d8e538ec TG |
264 | }; |
265 | ||
8ae4b6d1 | 266 | static const NLType rtnl_link_info_data_iptun_types[] = { |
cafbc790 DH |
267 | [IFLA_IPTUN_LINK] = { .type = NETLINK_TYPE_U32 }, |
268 | [IFLA_IPTUN_LOCAL] = { .type = NETLINK_TYPE_IN_ADDR }, | |
269 | [IFLA_IPTUN_REMOTE] = { .type = NETLINK_TYPE_IN_ADDR }, | |
270 | [IFLA_IPTUN_TTL] = { .type = NETLINK_TYPE_U8 }, | |
271 | [IFLA_IPTUN_TOS] = { .type = NETLINK_TYPE_U8 }, | |
272 | [IFLA_IPTUN_PMTUDISC] = { .type = NETLINK_TYPE_U8 }, | |
273 | [IFLA_IPTUN_FLAGS] = { .type = NETLINK_TYPE_U16 }, | |
274 | [IFLA_IPTUN_PROTO] = { .type = NETLINK_TYPE_U8 }, | |
275 | [IFLA_IPTUN_6RD_PREFIX] = { .type = NETLINK_TYPE_IN_ADDR }, | |
276 | [IFLA_IPTUN_6RD_RELAY_PREFIX] = { .type = NETLINK_TYPE_U32 }, | |
277 | [IFLA_IPTUN_6RD_PREFIXLEN] = { .type = NETLINK_TYPE_U16 }, | |
278 | [IFLA_IPTUN_6RD_RELAY_PREFIXLEN] = { .type = NETLINK_TYPE_U16 }, | |
6e74cade ZJS |
279 | [IFLA_IPTUN_ENCAP_TYPE] = { .type = NETLINK_TYPE_U16 }, |
280 | [IFLA_IPTUN_ENCAP_FLAGS] = { .type = NETLINK_TYPE_U16 }, | |
281 | [IFLA_IPTUN_ENCAP_SPORT] = { .type = NETLINK_TYPE_U16 }, | |
282 | [IFLA_IPTUN_ENCAP_DPORT] = { .type = NETLINK_TYPE_U16 }, | |
0a827d10 SS |
283 | }; |
284 | ||
8ae4b6d1 | 285 | static const NLType rtnl_link_info_data_ipgre_types[] = { |
8aee0f1f SS |
286 | [IFLA_GRE_LINK] = { .type = NETLINK_TYPE_U32 }, |
287 | [IFLA_GRE_IFLAGS] = { .type = NETLINK_TYPE_U16 }, | |
288 | [IFLA_GRE_OFLAGS] = { .type = NETLINK_TYPE_U16 }, | |
289 | [IFLA_GRE_IKEY] = { .type = NETLINK_TYPE_U32 }, | |
290 | [IFLA_GRE_OKEY] = { .type = NETLINK_TYPE_U32 }, | |
291 | [IFLA_GRE_LOCAL] = { .type = NETLINK_TYPE_IN_ADDR }, | |
292 | [IFLA_GRE_REMOTE] = { .type = NETLINK_TYPE_IN_ADDR }, | |
293 | [IFLA_GRE_TTL] = { .type = NETLINK_TYPE_U8 }, | |
294 | [IFLA_GRE_TOS] = { .type = NETLINK_TYPE_U8 }, | |
295 | [IFLA_GRE_PMTUDISC] = { .type = NETLINK_TYPE_U8 }, | |
296 | [IFLA_GRE_FLOWINFO] = { .type = NETLINK_TYPE_U32 }, | |
297 | [IFLA_GRE_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
298 | [IFLA_GRE_ENCAP_TYPE] = { .type = NETLINK_TYPE_U16 }, | |
299 | [IFLA_GRE_ENCAP_FLAGS] = { .type = NETLINK_TYPE_U16 }, | |
300 | [IFLA_GRE_ENCAP_SPORT] = { .type = NETLINK_TYPE_U16 }, | |
301 | [IFLA_GRE_ENCAP_DPORT] = { .type = NETLINK_TYPE_U16 }, | |
2266864b | 302 | [IFLA_GRE_ERSPAN_INDEX] = { .type = NETLINK_TYPE_U32 }, |
8bb088c5 SS |
303 | }; |
304 | ||
8ae4b6d1 | 305 | static const NLType rtnl_link_info_data_ipvti_types[] = { |
cafbc790 DH |
306 | [IFLA_VTI_LINK] = { .type = NETLINK_TYPE_U32 }, |
307 | [IFLA_VTI_IKEY] = { .type = NETLINK_TYPE_U32 }, | |
308 | [IFLA_VTI_OKEY] = { .type = NETLINK_TYPE_U32 }, | |
6e74cade ZJS |
309 | [IFLA_VTI_LOCAL] = { .type = NETLINK_TYPE_IN_ADDR }, |
310 | [IFLA_VTI_REMOTE] = { .type = NETLINK_TYPE_IN_ADDR }, | |
a613382b SS |
311 | }; |
312 | ||
8ae4b6d1 | 313 | static const NLType rtnl_link_info_data_ip6tnl_types[] = { |
cafbc790 DH |
314 | [IFLA_IPTUN_LINK] = { .type = NETLINK_TYPE_U32 }, |
315 | [IFLA_IPTUN_LOCAL] = { .type = NETLINK_TYPE_IN_ADDR }, | |
316 | [IFLA_IPTUN_REMOTE] = { .type = NETLINK_TYPE_IN_ADDR }, | |
317 | [IFLA_IPTUN_TTL] = { .type = NETLINK_TYPE_U8 }, | |
318 | [IFLA_IPTUN_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
319 | [IFLA_IPTUN_PROTO] = { .type = NETLINK_TYPE_U8 }, | |
320 | [IFLA_IPTUN_ENCAP_LIMIT] = { .type = NETLINK_TYPE_U8 }, | |
6e74cade | 321 | [IFLA_IPTUN_FLOWINFO] = { .type = NETLINK_TYPE_U32 }, |
855ee1a1 SS |
322 | }; |
323 | ||
20897a0d AR |
324 | static const NLType rtnl_link_info_data_vrf_types[] = { |
325 | [IFLA_VRF_TABLE] = { .type = NETLINK_TYPE_U32 }, | |
326 | }; | |
327 | ||
ca5e8071 SS |
328 | static const NLType rtnl_link_info_data_geneve_types[] = { |
329 | [IFLA_GENEVE_ID] = { .type = NETLINK_TYPE_U32 }, | |
330 | [IFLA_GENEVE_TTL] = { .type = NETLINK_TYPE_U8 }, | |
331 | [IFLA_GENEVE_TOS] = { .type = NETLINK_TYPE_U8 }, | |
332 | [IFLA_GENEVE_PORT] = { .type = NETLINK_TYPE_U16 }, | |
333 | [IFLA_GENEVE_REMOTE] = { .type = NETLINK_TYPE_IN_ADDR }, | |
334 | [IFLA_GENEVE_REMOTE6] = { .type = NETLINK_TYPE_IN_ADDR }, | |
335 | [IFLA_GENEVE_UDP_CSUM] = { .type = NETLINK_TYPE_U8 }, | |
336 | [IFLA_GENEVE_UDP_ZERO_CSUM6_TX] = { .type = NETLINK_TYPE_U8 }, | |
337 | [IFLA_GENEVE_UDP_ZERO_CSUM6_RX] = { .type = NETLINK_TYPE_U8 }, | |
338 | [IFLA_GENEVE_LABEL] = { .type = NETLINK_TYPE_U32 }, | |
469fd848 SS |
339 | [IFLA_GENEVE_TTL_INHERIT] = { .type = NETLINK_TYPE_U8 }, |
340 | [IFLA_GENEVE_DF] = { .type = NETLINK_TYPE_U8 }, | |
ca5e8071 SS |
341 | }; |
342 | ||
06828bb6 HP |
343 | static const NLType rtnl_link_info_data_can_types[] = { |
344 | [IFLA_CAN_BITTIMING] = { .size = sizeof(struct can_bittiming) }, | |
345 | [IFLA_CAN_RESTART_MS] = { .type = NETLINK_TYPE_U32 }, | |
c423be28 | 346 | [IFLA_CAN_CTRLMODE] = { .size = sizeof(struct can_ctrlmode) }, |
52aa38f1 | 347 | [IFLA_CAN_TERMINATION] = { .type = NETLINK_TYPE_U16 }, |
06828bb6 HP |
348 | }; |
349 | ||
81962db7 SS |
350 | static const NLType rtnl_link_info_data_macsec_types[] = { |
351 | [IFLA_MACSEC_SCI] = { .type = NETLINK_TYPE_U64 }, | |
352 | [IFLA_MACSEC_PORT] = { .type = NETLINK_TYPE_U16 }, | |
353 | [IFLA_MACSEC_ICV_LEN] = { .type = NETLINK_TYPE_U8 }, | |
354 | [IFLA_MACSEC_CIPHER_SUITE] = { .type = NETLINK_TYPE_U64 }, | |
355 | [IFLA_MACSEC_WINDOW] = { .type = NETLINK_TYPE_U32 }, | |
356 | [IFLA_MACSEC_ENCODING_SA] = { .type = NETLINK_TYPE_U8 }, | |
357 | [IFLA_MACSEC_ENCRYPT] = { .type = NETLINK_TYPE_U8 }, | |
358 | [IFLA_MACSEC_PROTECT] = { .type = NETLINK_TYPE_U8 }, | |
359 | [IFLA_MACSEC_INC_SCI] = { .type = NETLINK_TYPE_U8 }, | |
360 | [IFLA_MACSEC_ES] = { .type = NETLINK_TYPE_U8 }, | |
361 | [IFLA_MACSEC_SCB] = { .type = NETLINK_TYPE_U8 }, | |
362 | [IFLA_MACSEC_REPLAY_PROTECT] = { .type = NETLINK_TYPE_U8 }, | |
363 | [IFLA_MACSEC_VALIDATION] = { .type = NETLINK_TYPE_U8 }, | |
364 | }; | |
365 | ||
98d20a17 | 366 | static const NLType rtnl_link_info_data_xfrm_types[] = { |
367 | [IFLA_XFRM_LINK] = { .type = NETLINK_TYPE_U32 }, | |
368 | [IFLA_XFRM_IF_ID] = { .type = NETLINK_TYPE_U32 } | |
369 | }; | |
370 | ||
af818d03 SS |
371 | static const NLType rtnl_link_info_data_bareudp_types[] = { |
372 | [IFLA_BAREUDP_PORT] = { .type = NETLINK_TYPE_U16 }, | |
373 | [IFLA_BAREUDP_ETHERTYPE] = { .type = NETLINK_TYPE_U16 }, | |
374 | [IFLA_BAREUDP_SRCPORT_MIN] = { .type = NETLINK_TYPE_U16 }, | |
375 | [IFLA_BAREUDP_MULTIPROTO_MODE] = { .type = NETLINK_TYPE_FLAG }, | |
376 | }; | |
0a827d10 | 377 | /* these strings must match the .kind entries in the kernel */ |
8ae4b6d1 | 378 | static const char* const nl_union_link_info_data_table[] = { |
d8e538ec TG |
379 | [NL_UNION_LINK_INFO_DATA_BOND] = "bond", |
380 | [NL_UNION_LINK_INFO_DATA_BRIDGE] = "bridge", | |
381 | [NL_UNION_LINK_INFO_DATA_VLAN] = "vlan", | |
382 | [NL_UNION_LINK_INFO_DATA_VETH] = "veth", | |
9e358851 | 383 | [NL_UNION_LINK_INFO_DATA_DUMMY] = "dummy", |
d8e538ec | 384 | [NL_UNION_LINK_INFO_DATA_MACVLAN] = "macvlan", |
d1312575 | 385 | [NL_UNION_LINK_INFO_DATA_MACVTAP] = "macvtap", |
c4a5ddc9 | 386 | [NL_UNION_LINK_INFO_DATA_IPVLAN] = "ipvlan", |
69c317a0 | 387 | [NL_UNION_LINK_INFO_DATA_IPVTAP] = "ipvtap", |
6ef81477 | 388 | [NL_UNION_LINK_INFO_DATA_VXLAN] = "vxlan", |
0a827d10 | 389 | [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL] = "ipip", |
8bb088c5 | 390 | [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL] = "gre", |
2266864b | 391 | [NL_UNION_LINK_INFO_DATA_ERSPAN] = "erspan", |
1af2536a | 392 | [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL] = "gretap", |
b16492f8 SS |
393 | [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL] = "ip6gre", |
394 | [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL] = "ip6gretap", | |
0a827d10 | 395 | [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL] = "sit", |
a613382b | 396 | [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL] = "vti", |
9011ce77 | 397 | [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL] = "vti6", |
855ee1a1 | 398 | [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL] = "ip6tnl", |
20897a0d | 399 | [NL_UNION_LINK_INFO_DATA_VRF] = "vrf", |
92c918b0 | 400 | [NL_UNION_LINK_INFO_DATA_VCAN] = "vcan", |
ca5e8071 | 401 | [NL_UNION_LINK_INFO_DATA_GENEVE] = "geneve", |
d6df583c | 402 | [NL_UNION_LINK_INFO_DATA_VXCAN] = "vxcan", |
e5719363 | 403 | [NL_UNION_LINK_INFO_DATA_WIREGUARD] = "wireguard", |
56e7fb50 | 404 | [NL_UNION_LINK_INFO_DATA_NETDEVSIM] = "netdevsim", |
06828bb6 | 405 | [NL_UNION_LINK_INFO_DATA_CAN] = "can", |
81962db7 | 406 | [NL_UNION_LINK_INFO_DATA_MACSEC] = "macsec", |
d61e4c5b | 407 | [NL_UNION_LINK_INFO_DATA_NLMON] = "nlmon", |
98d20a17 | 408 | [NL_UNION_LINK_INFO_DATA_XFRM] = "xfrm", |
cec1552a | 409 | [NL_UNION_LINK_INFO_DATA_IFB] = "ifb", |
af818d03 | 410 | [NL_UNION_LINK_INFO_DATA_BAREUDP] = "bareudp", |
c0267a59 | 411 | [NL_UNION_LINK_INFO_DATA_BATADV] = "batadv", |
d8e538ec TG |
412 | }; |
413 | ||
414 | DEFINE_STRING_TABLE_LOOKUP(nl_union_link_info_data, NLUnionLinkInfoData); | |
415 | ||
8ae4b6d1 | 416 | static const NLTypeSystem rtnl_link_info_data_type_systems[] = { |
92c918b0 SS |
417 | [NL_UNION_LINK_INFO_DATA_BOND] = { .count = ELEMENTSOF(rtnl_link_info_data_bond_types), |
418 | .types = rtnl_link_info_data_bond_types }, | |
419 | [NL_UNION_LINK_INFO_DATA_BRIDGE] = { .count = ELEMENTSOF(rtnl_link_info_data_bridge_types), | |
420 | .types = rtnl_link_info_data_bridge_types }, | |
421 | [NL_UNION_LINK_INFO_DATA_VLAN] = { .count = ELEMENTSOF(rtnl_link_info_data_vlan_types), | |
422 | .types = rtnl_link_info_data_vlan_types }, | |
423 | [NL_UNION_LINK_INFO_DATA_VETH] = { .count = ELEMENTSOF(rtnl_link_info_data_veth_types), | |
424 | .types = rtnl_link_info_data_veth_types }, | |
425 | [NL_UNION_LINK_INFO_DATA_MACVLAN] = { .count = ELEMENTSOF(rtnl_link_info_data_macvlan_types), | |
426 | .types = rtnl_link_info_data_macvlan_types }, | |
427 | [NL_UNION_LINK_INFO_DATA_MACVTAP] = { .count = ELEMENTSOF(rtnl_link_info_data_macvlan_types), | |
428 | .types = rtnl_link_info_data_macvlan_types }, | |
429 | [NL_UNION_LINK_INFO_DATA_IPVLAN] = { .count = ELEMENTSOF(rtnl_link_info_data_ipvlan_types), | |
430 | .types = rtnl_link_info_data_ipvlan_types }, | |
69c317a0 SS |
431 | [NL_UNION_LINK_INFO_DATA_IPVTAP] = { .count = ELEMENTSOF(rtnl_link_info_data_ipvlan_types), |
432 | .types = rtnl_link_info_data_ipvlan_types }, | |
92c918b0 SS |
433 | [NL_UNION_LINK_INFO_DATA_VXLAN] = { .count = ELEMENTSOF(rtnl_link_info_data_vxlan_types), |
434 | .types = rtnl_link_info_data_vxlan_types }, | |
435 | [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_iptun_types), | |
436 | .types = rtnl_link_info_data_iptun_types }, | |
437 | [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_ipgre_types), | |
438 | .types = rtnl_link_info_data_ipgre_types }, | |
2266864b SS |
439 | [NL_UNION_LINK_INFO_DATA_ERSPAN] = { .count = ELEMENTSOF(rtnl_link_info_data_ipgre_types), |
440 | .types = rtnl_link_info_data_ipgre_types }, | |
c1df8dee | 441 | [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_ipgre_types), |
92c918b0 SS |
442 | .types = rtnl_link_info_data_ipgre_types }, |
443 | [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_ipgre_types), | |
444 | .types = rtnl_link_info_data_ipgre_types }, | |
445 | [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_ipgre_types), | |
446 | .types = rtnl_link_info_data_ipgre_types }, | |
447 | [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_iptun_types), | |
448 | .types = rtnl_link_info_data_iptun_types }, | |
449 | [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_ipvti_types), | |
450 | .types = rtnl_link_info_data_ipvti_types }, | |
451 | [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_ipvti_types), | |
452 | .types = rtnl_link_info_data_ipvti_types }, | |
453 | [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_ip6tnl_types), | |
454 | .types = rtnl_link_info_data_ip6tnl_types }, | |
455 | [NL_UNION_LINK_INFO_DATA_VRF] = { .count = ELEMENTSOF(rtnl_link_info_data_vrf_types), | |
456 | .types = rtnl_link_info_data_vrf_types }, | |
ca5e8071 SS |
457 | [NL_UNION_LINK_INFO_DATA_GENEVE] = { .count = ELEMENTSOF(rtnl_link_info_data_geneve_types), |
458 | .types = rtnl_link_info_data_geneve_types }, | |
d6df583c SS |
459 | [NL_UNION_LINK_INFO_DATA_VXCAN] = { .count = ELEMENTSOF(rtnl_link_info_data_vxcan_types), |
460 | .types = rtnl_link_info_data_vxcan_types }, | |
06828bb6 HP |
461 | [NL_UNION_LINK_INFO_DATA_CAN] = { .count = ELEMENTSOF(rtnl_link_info_data_can_types), |
462 | .types = rtnl_link_info_data_can_types }, | |
81962db7 SS |
463 | [NL_UNION_LINK_INFO_DATA_MACSEC] = { .count = ELEMENTSOF(rtnl_link_info_data_macsec_types), |
464 | .types = rtnl_link_info_data_macsec_types }, | |
98d20a17 | 465 | [NL_UNION_LINK_INFO_DATA_XFRM] = { .count = ELEMENTSOF(rtnl_link_info_data_xfrm_types), |
466 | .types = rtnl_link_info_data_xfrm_types }, | |
af818d03 SS |
467 | [NL_UNION_LINK_INFO_DATA_BAREUDP] = { .count = ELEMENTSOF(rtnl_link_info_data_bareudp_types), |
468 | .types = rtnl_link_info_data_bareudp_types }, | |
c0267a59 AW |
469 | [NL_UNION_LINK_INFO_DATA_BATADV] = { .count = ELEMENTSOF(rtnl_link_info_data_batadv_types), |
470 | .types = rtnl_link_info_data_batadv_types }, | |
d8e538ec TG |
471 | }; |
472 | ||
473 | static const NLTypeSystemUnion rtnl_link_info_data_type_system_union = { | |
474 | .num = _NL_UNION_LINK_INFO_DATA_MAX, | |
475 | .lookup = nl_union_link_info_data_from_string, | |
476 | .type_systems = rtnl_link_info_data_type_systems, | |
4af7b60d | 477 | .match_type = NL_MATCH_SIBLING, |
d8e538ec TG |
478 | .match = IFLA_INFO_KIND, |
479 | }; | |
480 | ||
8ae4b6d1 | 481 | static const NLType rtnl_link_info_types[] = { |
cafbc790 | 482 | [IFLA_INFO_KIND] = { .type = NETLINK_TYPE_STRING }, |
42b5f7dd | 483 | [IFLA_INFO_DATA] = { .type = NETLINK_TYPE_UNION, .type_system_union = &rtnl_link_info_data_type_system_union }, |
d8e538ec TG |
484 | /* |
485 | [IFLA_INFO_XSTATS], | |
cafbc790 DH |
486 | [IFLA_INFO_SLAVE_KIND] = { .type = NETLINK_TYPE_STRING }, |
487 | [IFLA_INFO_SLAVE_DATA] = { .type = NETLINK_TYPE_NESTED }, | |
d8e538ec TG |
488 | */ |
489 | }; | |
490 | ||
491 | static const NLTypeSystem rtnl_link_info_type_system = { | |
c1df8dee | 492 | .count = ELEMENTSOF(rtnl_link_info_types), |
d8e538ec TG |
493 | .types = rtnl_link_info_types, |
494 | }; | |
495 | ||
8ae4b6d1 | 496 | static const struct NLType rtnl_prot_info_bridge_port_types[] = { |
d3aa8b49 SS |
497 | [IFLA_BRPORT_STATE] = { .type = NETLINK_TYPE_U8 }, |
498 | [IFLA_BRPORT_COST] = { .type = NETLINK_TYPE_U32 }, | |
499 | [IFLA_BRPORT_PRIORITY] = { .type = NETLINK_TYPE_U16 }, | |
500 | [IFLA_BRPORT_MODE] = { .type = NETLINK_TYPE_U8 }, | |
501 | [IFLA_BRPORT_GUARD] = { .type = NETLINK_TYPE_U8 }, | |
502 | [IFLA_BRPORT_PROTECT] = { .type = NETLINK_TYPE_U8 }, | |
503 | [IFLA_BRPORT_FAST_LEAVE] = { .type = NETLINK_TYPE_U8 }, | |
504 | [IFLA_BRPORT_LEARNING] = { .type = NETLINK_TYPE_U8 }, | |
505 | [IFLA_BRPORT_UNICAST_FLOOD] = { .type = NETLINK_TYPE_U8 }, | |
506 | [IFLA_BRPORT_PROXYARP] = { .type = NETLINK_TYPE_U8 }, | |
507 | [IFLA_BRPORT_LEARNING_SYNC] = { .type = NETLINK_TYPE_U8 }, | |
508 | [IFLA_BRPORT_PROXYARP_WIFI] = { .type = NETLINK_TYPE_U8 }, | |
509 | [IFLA_BRPORT_ROOT_ID] = { .type = NETLINK_TYPE_U8 }, | |
510 | [IFLA_BRPORT_BRIDGE_ID] = { .type = NETLINK_TYPE_U8 }, | |
511 | [IFLA_BRPORT_DESIGNATED_PORT] = { .type = NETLINK_TYPE_U16 }, | |
512 | [IFLA_BRPORT_DESIGNATED_COST] = { .type = NETLINK_TYPE_U16 }, | |
513 | [IFLA_BRPORT_ID] = { .type = NETLINK_TYPE_U16 }, | |
514 | [IFLA_BRPORT_NO] = { .type = NETLINK_TYPE_U16 }, | |
515 | [IFLA_BRPORT_TOPOLOGY_CHANGE_ACK] = { .type = NETLINK_TYPE_U8 }, | |
516 | [IFLA_BRPORT_CONFIG_PENDING] = { .type = NETLINK_TYPE_U8 }, | |
517 | [IFLA_BRPORT_MESSAGE_AGE_TIMER] = { .type = NETLINK_TYPE_U64 }, | |
518 | [IFLA_BRPORT_FORWARD_DELAY_TIMER] = { .type = NETLINK_TYPE_U64 }, | |
519 | [IFLA_BRPORT_HOLD_TIMER] = { .type = NETLINK_TYPE_U64 }, | |
520 | [IFLA_BRPORT_FLUSH] = { .type = NETLINK_TYPE_U8 }, | |
521 | [IFLA_BRPORT_MULTICAST_ROUTER] = { .type = NETLINK_TYPE_U8 }, | |
522 | [IFLA_BRPORT_PAD] = { .type = NETLINK_TYPE_U8 }, | |
523 | [IFLA_BRPORT_MCAST_FLOOD] = { .type = NETLINK_TYPE_U8 }, | |
524 | [IFLA_BRPORT_MCAST_TO_UCAST] = { .type = NETLINK_TYPE_U8 }, | |
525 | [IFLA_BRPORT_VLAN_TUNNEL] = { .type = NETLINK_TYPE_U8 }, | |
526 | [IFLA_BRPORT_BCAST_FLOOD] = { .type = NETLINK_TYPE_U8 }, | |
527 | [IFLA_BRPORT_GROUP_FWD_MASK] = { .type = NETLINK_TYPE_U16 }, | |
528 | [IFLA_BRPORT_NEIGH_SUPPRESS] = { .type = NETLINK_TYPE_U8 }, | |
529 | [IFLA_BRPORT_ISOLATED] = { .type = NETLINK_TYPE_U8 }, | |
530 | [IFLA_BRPORT_BACKUP_PORT] = { .type = NETLINK_TYPE_U32 }, | |
d0159fdc SS |
531 | }; |
532 | ||
8ae4b6d1 | 533 | static const NLTypeSystem rtnl_prot_info_type_systems[] = { |
c1df8dee | 534 | [AF_BRIDGE] = { .count = ELEMENTSOF(rtnl_prot_info_bridge_port_types), |
4af7b60d TG |
535 | .types = rtnl_prot_info_bridge_port_types }, |
536 | }; | |
537 | ||
538 | static const NLTypeSystemUnion rtnl_prot_info_type_system_union = { | |
539 | .num = AF_MAX, | |
540 | .type_systems = rtnl_prot_info_type_systems, | |
541 | .match_type = NL_MATCH_PROTOCOL, | |
d0159fdc SS |
542 | }; |
543 | ||
8ae4b6d1 | 544 | static const struct NLType rtnl_af_spec_inet6_types[] = { |
cafbc790 | 545 | [IFLA_INET6_FLAGS] = { .type = NETLINK_TYPE_U32 }, |
c149ae08 TG |
546 | /* |
547 | IFLA_INET6_CONF, | |
548 | IFLA_INET6_STATS, | |
549 | IFLA_INET6_MCAST, | |
550 | IFLA_INET6_CACHEINFO, | |
551 | IFLA_INET6_ICMP6STATS, | |
552 | */ | |
cafbc790 DH |
553 | [IFLA_INET6_TOKEN] = { .type = NETLINK_TYPE_IN_ADDR }, |
554 | [IFLA_INET6_ADDR_GEN_MODE] = { .type = NETLINK_TYPE_U8 }, | |
c149ae08 TG |
555 | }; |
556 | ||
73cb1c14 | 557 | static const NLTypeSystem rtnl_af_spec_inet6_type_system = { |
c1df8dee | 558 | .count = ELEMENTSOF(rtnl_af_spec_inet6_types), |
73cb1c14 | 559 | .types = rtnl_af_spec_inet6_types, |
c149ae08 TG |
560 | }; |
561 | ||
8ae4b6d1 | 562 | static const NLType rtnl_af_spec_types[] = { |
cafbc790 | 563 | [AF_INET6] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_af_spec_inet6_type_system }, |
73cb1c14 TG |
564 | }; |
565 | ||
566 | static const NLTypeSystem rtnl_af_spec_type_system = { | |
c1df8dee | 567 | .count = ELEMENTSOF(rtnl_af_spec_types), |
73cb1c14 | 568 | .types = rtnl_af_spec_types, |
c149ae08 TG |
569 | }; |
570 | ||
ffeb16f5 YW |
571 | static const NLType rtnl_prop_list_types[] = { |
572 | [IFLA_ALT_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = ALTIFNAMSIZ - 1 }, | |
573 | }; | |
574 | ||
575 | static const NLTypeSystem rtnl_prop_list_type_system = { | |
576 | .count = ELEMENTSOF(rtnl_prop_list_types), | |
577 | .types = rtnl_prop_list_types, | |
578 | }; | |
579 | ||
5908ddd7 SS |
580 | static const NLType rtnl_vf_vlan_list_types[] = { |
581 | [IFLA_VF_VLAN_INFO] = { .size = sizeof(struct ifla_vf_vlan_info) }, | |
582 | }; | |
583 | ||
584 | static const NLTypeSystem rtnl_vf_vlan_type_system = { | |
585 | .count = ELEMENTSOF(rtnl_vf_vlan_list_types), | |
586 | .types = rtnl_vf_vlan_list_types, | |
587 | }; | |
588 | ||
589 | static const NLType rtnl_vf_vlan_info_types[] = { | |
590 | [IFLA_VF_MAC] = { .size = sizeof(struct ifla_vf_mac) }, | |
591 | [IFLA_VF_VLAN] = { .size = sizeof(struct ifla_vf_vlan) }, | |
592 | [IFLA_VF_VLAN_LIST] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_vf_vlan_type_system}, | |
593 | [IFLA_VF_TX_RATE] = { .size = sizeof(struct ifla_vf_tx_rate) }, | |
594 | [IFLA_VF_SPOOFCHK] = { .size = sizeof(struct ifla_vf_spoofchk) }, | |
595 | [IFLA_VF_RATE] = { .size = sizeof(struct ifla_vf_rate) }, | |
596 | [IFLA_VF_LINK_STATE] = { .size = sizeof(struct ifla_vf_link_state) }, | |
597 | [IFLA_VF_RSS_QUERY_EN] = { .size = sizeof(struct ifla_vf_rss_query_en) }, | |
598 | [IFLA_VF_TRUST] = { .size = sizeof(struct ifla_vf_trust) }, | |
599 | [IFLA_VF_IB_NODE_GUID] = { .size = sizeof(struct ifla_vf_guid) }, | |
600 | [IFLA_VF_IB_PORT_GUID] = { .size = sizeof(struct ifla_vf_guid) }, | |
601 | }; | |
602 | ||
603 | static const NLTypeSystem rtnl_vf_vlan_info_type_system = { | |
604 | .count = ELEMENTSOF(rtnl_vf_vlan_info_types), | |
605 | .types = rtnl_vf_vlan_info_types, | |
606 | }; | |
607 | ||
608 | static const NLType rtnl_link_io_srv_types[] = { | |
609 | [IFLA_VF_INFO] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_vf_vlan_info_type_system }, | |
610 | }; | |
611 | ||
612 | static const NLTypeSystem rtnl_io_srv_type_system = { | |
613 | .count = ELEMENTSOF(rtnl_link_io_srv_types), | |
614 | .types = rtnl_link_io_srv_types, | |
615 | }; | |
616 | ||
8ae4b6d1 | 617 | static const NLType rtnl_link_types[] = { |
6e74cade ZJS |
618 | [IFLA_ADDRESS] = { .type = NETLINK_TYPE_ETHER_ADDR }, |
619 | [IFLA_BROADCAST] = { .type = NETLINK_TYPE_ETHER_ADDR }, | |
620 | [IFLA_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ - 1 }, | |
cafbc790 DH |
621 | [IFLA_MTU] = { .type = NETLINK_TYPE_U32 }, |
622 | [IFLA_LINK] = { .type = NETLINK_TYPE_U32 }, | |
83949527 | 623 | [IFLA_QDISC] = { .type = NETLINK_TYPE_STRING }, |
c095e5b0 YW |
624 | [IFLA_STATS] = { .size = sizeof(struct rtnl_link_stats) }, |
625 | /* | |
d8e538ec TG |
626 | [IFLA_COST], |
627 | [IFLA_PRIORITY], | |
628 | */ | |
cafbc790 | 629 | [IFLA_MASTER] = { .type = NETLINK_TYPE_U32 }, |
d8e538ec TG |
630 | /* |
631 | [IFLA_WIRELESS], | |
d8e538ec | 632 | */ |
cafbc790 DH |
633 | [IFLA_PROTINFO] = { .type = NETLINK_TYPE_UNION, .type_system_union = &rtnl_prot_info_type_system_union }, |
634 | [IFLA_TXQLEN] = { .type = NETLINK_TYPE_U32 }, | |
d8e538ec TG |
635 | /* |
636 | [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) }, | |
637 | */ | |
cafbc790 DH |
638 | [IFLA_WEIGHT] = { .type = NETLINK_TYPE_U32 }, |
639 | [IFLA_OPERSTATE] = { .type = NETLINK_TYPE_U8 }, | |
640 | [IFLA_LINKMODE] = { .type = NETLINK_TYPE_U8 }, | |
641 | [IFLA_LINKINFO] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_info_type_system }, | |
642 | [IFLA_NET_NS_PID] = { .type = NETLINK_TYPE_U32 }, | |
643 | [IFLA_IFALIAS] = { .type = NETLINK_TYPE_STRING, .size = IFALIASZ - 1 }, | |
5908ddd7 SS |
644 | [IFLA_NUM_VF] = { .type = NETLINK_TYPE_U32 }, |
645 | [IFLA_VFINFO_LIST] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_io_srv_type_system }, | |
c095e5b0 YW |
646 | [IFLA_STATS64] = { .size = sizeof(struct rtnl_link_stats64) }, |
647 | /* | |
cafbc790 DH |
648 | [IFLA_VF_PORTS] = { .type = NETLINK_TYPE_NESTED }, |
649 | [IFLA_PORT_SELF] = { .type = NETLINK_TYPE_NESTED }, | |
c149ae08 | 650 | */ |
cafbc790 | 651 | [IFLA_AF_SPEC] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_af_spec_type_system }, |
c149ae08 | 652 | /* |
d8e538ec TG |
653 | [IFLA_VF_PORTS], |
654 | [IFLA_PORT_SELF], | |
655 | [IFLA_AF_SPEC], | |
656 | */ | |
cafbc790 DH |
657 | [IFLA_GROUP] = { .type = NETLINK_TYPE_U32 }, |
658 | [IFLA_NET_NS_FD] = { .type = NETLINK_TYPE_U32 }, | |
659 | [IFLA_EXT_MASK] = { .type = NETLINK_TYPE_U32 }, | |
660 | [IFLA_PROMISCUITY] = { .type = NETLINK_TYPE_U32 }, | |
661 | [IFLA_NUM_TX_QUEUES] = { .type = NETLINK_TYPE_U32 }, | |
662 | [IFLA_NUM_RX_QUEUES] = { .type = NETLINK_TYPE_U32 }, | |
ba423af6 SS |
663 | [IFLA_GSO_MAX_SEGS] = { .type = NETLINK_TYPE_U32 }, |
664 | [IFLA_GSO_MAX_SIZE] = { .type = NETLINK_TYPE_U32 }, | |
cafbc790 | 665 | [IFLA_CARRIER] = { .type = NETLINK_TYPE_U8 }, |
d8e538ec | 666 | /* |
cafbc790 | 667 | [IFLA_PHYS_PORT_ID] = { .type = NETLINK_TYPE_BINARY, .len = MAX_PHYS_PORT_ID_LEN }, |
d8e538ec | 668 | */ |
ffeb16f5 YW |
669 | [IFLA_MIN_MTU] = { .type = NETLINK_TYPE_U32 }, |
670 | [IFLA_MAX_MTU] = { .type = NETLINK_TYPE_U32 }, | |
671 | [IFLA_PROP_LIST] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_prop_list_type_system }, | |
b04c5e51 | 672 | [IFLA_ALT_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = ALTIFNAMSIZ - 1 }, |
d8e538ec TG |
673 | }; |
674 | ||
675 | static const NLTypeSystem rtnl_link_type_system = { | |
c1df8dee | 676 | .count = ELEMENTSOF(rtnl_link_types), |
d8e538ec TG |
677 | .types = rtnl_link_types, |
678 | }; | |
679 | ||
de79f906 LP |
680 | /* IFA_FLAGS was defined in kernel 3.14, but we still support older |
681 | * kernels where IFA_MAX is lower. */ | |
8ae4b6d1 | 682 | static const NLType rtnl_address_types[] = { |
cafbc790 DH |
683 | [IFA_ADDRESS] = { .type = NETLINK_TYPE_IN_ADDR }, |
684 | [IFA_LOCAL] = { .type = NETLINK_TYPE_IN_ADDR }, | |
685 | [IFA_LABEL] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ - 1 }, | |
686 | [IFA_BROADCAST] = { .type = NETLINK_TYPE_IN_ADDR }, /* 6? */ | |
687 | [IFA_CACHEINFO] = { .type = NETLINK_TYPE_CACHE_INFO, .size = sizeof(struct ifa_cacheinfo) }, | |
d8e538ec TG |
688 | /* |
689 | [IFA_ANYCAST], | |
d8e538ec TG |
690 | [IFA_MULTICAST], |
691 | */ | |
cafbc790 | 692 | [IFA_FLAGS] = { .type = NETLINK_TYPE_U32 }, |
d8e538ec TG |
693 | }; |
694 | ||
695 | static const NLTypeSystem rtnl_address_type_system = { | |
c1df8dee | 696 | .count = ELEMENTSOF(rtnl_address_types), |
d8e538ec TG |
697 | .types = rtnl_address_types, |
698 | }; | |
699 | ||
d6fceaf1 SS |
700 | /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */ |
701 | ||
702 | static const NLType rtnl_route_metrics_types[] = { | |
f4679bcb SS |
703 | [RTAX_MTU] = { .type = NETLINK_TYPE_U32 }, |
704 | [RTAX_WINDOW] = { .type = NETLINK_TYPE_U32 }, | |
705 | [RTAX_RTT] = { .type = NETLINK_TYPE_U32 }, | |
706 | [RTAX_RTTVAR] = { .type = NETLINK_TYPE_U32 }, | |
707 | [RTAX_SSTHRESH] = { .type = NETLINK_TYPE_U32 }, | |
708 | [RTAX_CWND] = { .type = NETLINK_TYPE_U32 }, | |
709 | [RTAX_ADVMSS] = { .type = NETLINK_TYPE_U32 }, | |
710 | [RTAX_REORDERING] = { .type = NETLINK_TYPE_U32 }, | |
711 | [RTAX_HOPLIMIT] = { .type = NETLINK_TYPE_U32 }, | |
712 | [RTAX_INITCWND] = { .type = NETLINK_TYPE_U32 }, | |
713 | [RTAX_FEATURES] = { .type = NETLINK_TYPE_U32 }, | |
714 | [RTAX_RTO_MIN] = { .type = NETLINK_TYPE_U32 }, | |
715 | [RTAX_INITRWND] = { .type = NETLINK_TYPE_U32 }, | |
716 | [RTAX_QUICKACK] = { .type = NETLINK_TYPE_U32 }, | |
717 | [RTAX_CC_ALGO] = { .type = NETLINK_TYPE_U32 }, | |
718 | [RTAX_FASTOPEN_NO_COOKIE] = { .type = NETLINK_TYPE_U32 }, | |
d6fceaf1 SS |
719 | }; |
720 | ||
721 | static const NLTypeSystem rtnl_route_metrics_type_system = { | |
722 | .count = ELEMENTSOF(rtnl_route_metrics_types), | |
723 | .types = rtnl_route_metrics_types, | |
724 | }; | |
725 | ||
8ae4b6d1 | 726 | static const NLType rtnl_route_types[] = { |
cafbc790 DH |
727 | [RTA_DST] = { .type = NETLINK_TYPE_IN_ADDR }, /* 6? */ |
728 | [RTA_SRC] = { .type = NETLINK_TYPE_IN_ADDR }, /* 6? */ | |
729 | [RTA_IIF] = { .type = NETLINK_TYPE_U32 }, | |
730 | [RTA_OIF] = { .type = NETLINK_TYPE_U32 }, | |
731 | [RTA_GATEWAY] = { .type = NETLINK_TYPE_IN_ADDR }, | |
732 | [RTA_PRIORITY] = { .type = NETLINK_TYPE_U32 }, | |
733 | [RTA_PREFSRC] = { .type = NETLINK_TYPE_IN_ADDR }, /* 6? */ | |
d6fceaf1 | 734 | [RTA_METRICS] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_metrics_type_system}, |
cb7e98ab | 735 | [RTA_MULTIPATH] = { .size = sizeof(struct rtnexthop) }, |
cafbc790 | 736 | [RTA_FLOW] = { .type = NETLINK_TYPE_U32 }, /* 6? */ |
cb7e98ab SS |
737 | [RTA_CACHEINFO] = { .size = sizeof(struct rta_cacheinfo) }, |
738 | [RTA_TABLE] = { .type = NETLINK_TYPE_U32 }, | |
739 | [RTA_MARK] = { .type = NETLINK_TYPE_U32 }, | |
740 | [RTA_MFC_STATS] = { .type = NETLINK_TYPE_U64 }, | |
2c59a8a6 | 741 | [RTA_VIA] = { /* See struct rtvia */ }, |
cb7e98ab | 742 | [RTA_NEWDST] = { .type = NETLINK_TYPE_U32 }, |
b69015ef | 743 | [RTA_PREF] = { .type = NETLINK_TYPE_U8 }, |
cb7e98ab SS |
744 | [RTA_ENCAP_TYPE] = { .type = NETLINK_TYPE_U16 }, |
745 | [RTA_ENCAP] = { .type = NETLINK_TYPE_NESTED }, /* Multiple type systems i.e. LWTUNNEL_ENCAP_MPLS/LWTUNNEL_ENCAP_IP/LWTUNNEL_ENCAP_ILA etc... */ | |
f5b7deb9 | 746 | [RTA_EXPIRES] = { .type = NETLINK_TYPE_U32 }, |
cb7e98ab SS |
747 | [RTA_UID] = { .type = NETLINK_TYPE_U32 }, |
748 | [RTA_TTL_PROPAGATE] = { .type = NETLINK_TYPE_U8 }, | |
749 | [RTA_IP_PROTO] = { .type = NETLINK_TYPE_U8 }, | |
750 | [RTA_SPORT] = { .type = NETLINK_TYPE_U16 }, | |
751 | [RTA_DPORT] = { .type = NETLINK_TYPE_U16 }, | |
f5b7deb9 | 752 | [RTA_NH_ID] = { .type = NETLINK_TYPE_U32 }, |
d8e538ec TG |
753 | }; |
754 | ||
755 | static const NLTypeSystem rtnl_route_type_system = { | |
c1df8dee | 756 | .count = ELEMENTSOF(rtnl_route_types), |
d8e538ec TG |
757 | .types = rtnl_route_types, |
758 | }; | |
759 | ||
8ae4b6d1 | 760 | static const NLType rtnl_neigh_types[] = { |
cafbc790 | 761 | [NDA_DST] = { .type = NETLINK_TYPE_IN_ADDR }, |
1647f241 | 762 | [NDA_LLADDR] = { /* struct ether_addr, struct in_addr, or struct in6_addr */ }, |
cafbc790 DH |
763 | [NDA_CACHEINFO] = { .type = NETLINK_TYPE_CACHE_INFO, .size = sizeof(struct nda_cacheinfo) }, |
764 | [NDA_PROBES] = { .type = NETLINK_TYPE_U32 }, | |
765 | [NDA_VLAN] = { .type = NETLINK_TYPE_U16 }, | |
766 | [NDA_PORT] = { .type = NETLINK_TYPE_U16 }, | |
767 | [NDA_VNI] = { .type = NETLINK_TYPE_U32 }, | |
768 | [NDA_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
e559b384 TG |
769 | }; |
770 | ||
771 | static const NLTypeSystem rtnl_neigh_type_system = { | |
c1df8dee | 772 | .count = ELEMENTSOF(rtnl_neigh_types), |
e559b384 TG |
773 | .types = rtnl_neigh_types, |
774 | }; | |
775 | ||
30746d60 SS |
776 | static const NLType rtnl_addrlabel_types[] = { |
777 | [IFAL_ADDRESS] = { .type = NETLINK_TYPE_IN_ADDR, .size = sizeof(struct in6_addr) }, | |
778 | [IFAL_LABEL] = { .type = NETLINK_TYPE_U32 }, | |
779 | }; | |
780 | ||
781 | static const NLTypeSystem rtnl_addrlabel_type_system = { | |
782 | .count = ELEMENTSOF(rtnl_addrlabel_types), | |
783 | .types = rtnl_addrlabel_types, | |
784 | }; | |
785 | ||
bce67bbe SS |
786 | static const NLType rtnl_routing_policy_rule_types[] = { |
787 | [FRA_DST] = { .type = NETLINK_TYPE_IN_ADDR }, | |
788 | [FRA_SRC] = { .type = NETLINK_TYPE_IN_ADDR }, | |
789 | [FRA_IIFNAME] = { .type = NETLINK_TYPE_STRING }, | |
8abd60c1 | 790 | [FRA_GOTO] = { .type = NETLINK_TYPE_U32 }, |
bce67bbe SS |
791 | [FRA_PRIORITY] = { .type = NETLINK_TYPE_U32 }, |
792 | [FRA_FWMARK] = { .type = NETLINK_TYPE_U32 }, | |
793 | [FRA_FLOW] = { .type = NETLINK_TYPE_U32 }, | |
202aa159 | 794 | [FRA_TUN_ID] = { .type = NETLINK_TYPE_U64 }, |
bce67bbe SS |
795 | [FRA_SUPPRESS_IFGROUP] = { .type = NETLINK_TYPE_U32 }, |
796 | [FRA_SUPPRESS_PREFIXLEN] = { .type = NETLINK_TYPE_U32 }, | |
797 | [FRA_TABLE] = { .type = NETLINK_TYPE_U32 }, | |
798 | [FRA_FWMASK] = { .type = NETLINK_TYPE_U32 }, | |
799 | [FRA_OIFNAME] = { .type = NETLINK_TYPE_STRING }, | |
800 | [FRA_PAD] = { .type = NETLINK_TYPE_U32 }, | |
a15ff62d | 801 | [FRA_L3MDEV] = { .type = NETLINK_TYPE_U8 }, |
bce67bbe | 802 | [FRA_UID_RANGE] = { .size = sizeof(struct fib_rule_uid_range) }, |
926062f0 SS |
803 | [FRA_PROTOCOL] = { .type = NETLINK_TYPE_U8 }, |
804 | [FRA_IP_PROTO] = { .type = NETLINK_TYPE_U8 }, | |
805 | [FRA_SPORT_RANGE] = { .size = sizeof(struct fib_rule_port_range) }, | |
806 | [FRA_DPORT_RANGE] = { .size = sizeof(struct fib_rule_port_range) }, | |
bce67bbe SS |
807 | }; |
808 | ||
809 | static const NLTypeSystem rtnl_routing_policy_rule_type_system = { | |
810 | .count = ELEMENTSOF(rtnl_routing_policy_rule_types), | |
811 | .types = rtnl_routing_policy_rule_types, | |
812 | }; | |
813 | ||
c16c7808 SS |
814 | static const NLType rtnl_nexthop_types[] = { |
815 | [NHA_ID] = { .type = NETLINK_TYPE_U32 }, | |
4684ec5e YW |
816 | [NHA_GROUP] = { /* array of struct nexthop_grp */ }, |
817 | [NHA_GROUP_TYPE] = { .type = NETLINK_TYPE_U16 }, | |
818 | [NHA_BLACKHOLE] = { .type = NETLINK_TYPE_FLAG }, | |
c16c7808 SS |
819 | [NHA_OIF] = { .type = NETLINK_TYPE_U32 }, |
820 | [NHA_GATEWAY] = { .type = NETLINK_TYPE_IN_ADDR }, | |
4684ec5e YW |
821 | [NHA_ENCAP_TYPE] = { .type = NETLINK_TYPE_U16 }, |
822 | [NHA_ENCAP] = { .type = NETLINK_TYPE_NESTED }, | |
823 | [NHA_GROUPS] = { .type = NETLINK_TYPE_FLAG }, | |
824 | [NHA_MASTER] = { .type = NETLINK_TYPE_U32 }, | |
825 | [NHA_FDB] = { .type = NETLINK_TYPE_FLAG }, | |
c16c7808 SS |
826 | }; |
827 | ||
828 | static const NLTypeSystem rtnl_nexthop_type_system = { | |
829 | .count = ELEMENTSOF(rtnl_nexthop_types), | |
830 | .types = rtnl_nexthop_types, | |
831 | }; | |
832 | ||
ad8352f4 SS |
833 | static const NLType rtnl_tca_option_data_cake_types[] = { |
834 | [TCA_CAKE_BASE_RATE64] = { .type = NETLINK_TYPE_U64 }, | |
835 | [TCA_CAKE_OVERHEAD] = { .type = NETLINK_TYPE_S32 }, | |
836 | [TCA_CAKE_MPU] = { .type = NETLINK_TYPE_U32 }, | |
837 | }; | |
838 | ||
a9a5d632 | 839 | static const NLType rtnl_tca_option_data_codel_types[] = { |
b078e528 YW |
840 | [TCA_CODEL_TARGET] = { .type = NETLINK_TYPE_U32 }, |
841 | [TCA_CODEL_LIMIT] = { .type = NETLINK_TYPE_U32 }, | |
842 | [TCA_CODEL_INTERVAL] = { .type = NETLINK_TYPE_U32 }, | |
843 | [TCA_CODEL_ECN] = { .type = NETLINK_TYPE_U32 }, | |
844 | [TCA_CODEL_CE_THRESHOLD] = { .type = NETLINK_TYPE_U32 }, | |
a9a5d632 SS |
845 | }; |
846 | ||
5c21b46e SS |
847 | static const NLType rtnl_tca_option_data_drr_types[] = { |
848 | [TCA_DRR_QUANTUM] = { .type = NETLINK_TYPE_U32 }, | |
849 | }; | |
850 | ||
4dec9218 YW |
851 | static const NLType rtnl_tca_option_data_ets_quanta_types[] = { |
852 | [TCA_ETS_QUANTA_BAND] = { .type = NETLINK_TYPE_U32, }, | |
853 | }; | |
854 | ||
855 | static const NLTypeSystem rtnl_tca_option_data_ets_quanta_type_system = { | |
856 | .count = ELEMENTSOF(rtnl_tca_option_data_ets_quanta_types), | |
857 | .types = rtnl_tca_option_data_ets_quanta_types, | |
858 | }; | |
859 | ||
860 | static const NLType rtnl_tca_option_data_ets_prio_types[] = { | |
861 | [TCA_ETS_PRIOMAP_BAND] = { .type = NETLINK_TYPE_U8, }, | |
862 | }; | |
863 | ||
864 | static const NLTypeSystem rtnl_tca_option_data_ets_prio_type_system = { | |
865 | .count = ELEMENTSOF(rtnl_tca_option_data_ets_prio_types), | |
866 | .types = rtnl_tca_option_data_ets_prio_types, | |
867 | }; | |
868 | ||
869 | static const NLType rtnl_tca_option_data_ets_types[] = { | |
870 | [TCA_ETS_NBANDS] = { .type = NETLINK_TYPE_U8 }, | |
871 | [TCA_ETS_NSTRICT] = { .type = NETLINK_TYPE_U8 }, | |
872 | [TCA_ETS_QUANTA] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_option_data_ets_quanta_type_system }, | |
873 | [TCA_ETS_PRIOMAP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_option_data_ets_prio_type_system }, | |
874 | [TCA_ETS_QUANTA_BAND] = { .type = NETLINK_TYPE_U32 }, | |
875 | }; | |
876 | ||
eb34f4b3 YW |
877 | static const NLType rtnl_tca_option_data_fq_types[] = { |
878 | [TCA_FQ_PLIMIT] = { .type = NETLINK_TYPE_U32 }, | |
879 | [TCA_FQ_FLOW_PLIMIT] = { .type = NETLINK_TYPE_U32 }, | |
880 | [TCA_FQ_QUANTUM] = { .type = NETLINK_TYPE_U32 }, | |
881 | [TCA_FQ_INITIAL_QUANTUM] = { .type = NETLINK_TYPE_U32 }, | |
882 | [TCA_FQ_RATE_ENABLE] = { .type = NETLINK_TYPE_U32 }, | |
883 | [TCA_FQ_FLOW_DEFAULT_RATE] = { .type = NETLINK_TYPE_U32 }, | |
884 | [TCA_FQ_FLOW_MAX_RATE] = { .type = NETLINK_TYPE_U32 }, | |
885 | [TCA_FQ_BUCKETS_LOG] = { .type = NETLINK_TYPE_U32 }, | |
886 | [TCA_FQ_FLOW_REFILL_DELAY] = { .type = NETLINK_TYPE_U32 }, | |
887 | [TCA_FQ_LOW_RATE_THRESHOLD] = { .type = NETLINK_TYPE_U32 }, | |
888 | [TCA_FQ_CE_THRESHOLD] = { .type = NETLINK_TYPE_U32 }, | |
e83562e5 | 889 | [TCA_FQ_ORPHAN_MASK] = { .type = NETLINK_TYPE_U32 }, |
42b5f7dd YW |
890 | }; |
891 | ||
892 | static const NLType rtnl_tca_option_data_fq_codel_types[] = { | |
893 | [TCA_FQ_CODEL_TARGET] = { .type = NETLINK_TYPE_U32 }, | |
894 | [TCA_FQ_CODEL_LIMIT] = { .type = NETLINK_TYPE_U32 }, | |
895 | [TCA_FQ_CODEL_INTERVAL] = { .type = NETLINK_TYPE_U32 }, | |
896 | [TCA_FQ_CODEL_ECN] = { .type = NETLINK_TYPE_U32 }, | |
897 | [TCA_FQ_CODEL_FLOWS] = { .type = NETLINK_TYPE_U32 }, | |
898 | [TCA_FQ_CODEL_QUANTUM] = { .type = NETLINK_TYPE_U32 }, | |
899 | [TCA_FQ_CODEL_CE_THRESHOLD] = { .type = NETLINK_TYPE_U32 }, | |
900 | [TCA_FQ_CODEL_DROP_BATCH_SIZE] = { .type = NETLINK_TYPE_U32 }, | |
901 | [TCA_FQ_CODEL_MEMORY_LIMIT] = { .type = NETLINK_TYPE_U32 }, | |
902 | }; | |
903 | ||
3428b32a SS |
904 | static const NLType rtnl_tca_option_data_fq_pie_types[] = { |
905 | [TCA_FQ_PIE_LIMIT] = { .type = NETLINK_TYPE_U32 }, | |
906 | }; | |
907 | ||
609e8340 SS |
908 | static const NLType rtnl_tca_option_data_gred_types[] = { |
909 | [TCA_GRED_DPS] = { .size = sizeof(struct tc_gred_sopt) }, | |
910 | }; | |
911 | ||
7e16f84e SS |
912 | static const NLType rtnl_tca_option_data_hhf_types[] = { |
913 | [TCA_HHF_BACKLOG_LIMIT] = { .type = NETLINK_TYPE_U32 }, | |
914 | }; | |
915 | ||
b934ac3d | 916 | static const NLType rtnl_tca_option_data_htb_types[] = { |
19f86a63 YW |
917 | [TCA_HTB_PARMS] = { .size = sizeof(struct tc_htb_opt) }, |
918 | [TCA_HTB_INIT] = { .size = sizeof(struct tc_htb_glob) }, | |
919 | [TCA_HTB_CTAB] = { .size = TC_RTAB_SIZE }, | |
920 | [TCA_HTB_RTAB] = { .size = TC_RTAB_SIZE }, | |
921 | [TCA_HTB_RATE64] = { .type = NETLINK_TYPE_U64 }, | |
922 | [TCA_HTB_CEIL64] = { .type = NETLINK_TYPE_U64 }, | |
b934ac3d YW |
923 | }; |
924 | ||
55d22831 SS |
925 | static const NLType rtnl_tca_option_data_pie_types[] = { |
926 | [TCA_PIE_LIMIT] = { .type = NETLINK_TYPE_U32 }, | |
927 | }; | |
928 | ||
c33f1e5a SS |
929 | static const NLType rtnl_tca_option_data_qfq_types[] = { |
930 | [TCA_QFQ_WEIGHT] = { .type = NETLINK_TYPE_U32 }, | |
931 | [TCA_QFQ_LMAX] = { .type = NETLINK_TYPE_U32 }, | |
932 | }; | |
933 | ||
982998b0 SS |
934 | static const NLType rtnl_tca_option_data_sfb_types[] = { |
935 | [TCA_SFB_PARMS] = { .size = sizeof(struct tc_sfb_qopt) }, | |
936 | }; | |
937 | ||
eb34f4b3 YW |
938 | static const NLType rtnl_tca_option_data_tbf_types[] = { |
939 | [TCA_TBF_PARMS] = { .size = sizeof(struct tc_tbf_qopt) }, | |
940 | [TCA_TBF_RTAB] = { .size = TC_RTAB_SIZE }, | |
941 | [TCA_TBF_PTAB] = { .size = TC_RTAB_SIZE }, | |
942 | [TCA_TBF_RATE64] = { .type = NETLINK_TYPE_U64 }, | |
943 | [TCA_TBF_PRATE64] = { .type = NETLINK_TYPE_U64 }, | |
944 | [TCA_TBF_BURST] = { .type = NETLINK_TYPE_U32 }, | |
945 | [TCA_TBF_PBURST] = { .type = NETLINK_TYPE_U32 }, | |
946 | }; | |
947 | ||
42b5f7dd | 948 | static const char* const nl_union_tca_option_data_table[] = { |
ad8352f4 | 949 | [NL_UNION_TCA_OPTION_DATA_CAKE] = "cake", |
a9a5d632 | 950 | [NL_UNION_TCA_OPTION_DATA_CODEL] = "codel", |
5c21b46e | 951 | [NL_UNION_TCA_OPTION_DATA_DRR] = "drr", |
4dec9218 | 952 | [NL_UNION_TCA_OPTION_DATA_ETS] = "ets", |
eb34f4b3 | 953 | [NL_UNION_TCA_OPTION_DATA_FQ] = "fq", |
42b5f7dd | 954 | [NL_UNION_TCA_OPTION_DATA_FQ_CODEL] = "fq_codel", |
3428b32a | 955 | [NL_UNION_TCA_OPTION_DATA_FQ_PIE] = "fq_pie", |
609e8340 | 956 | [NL_UNION_TCA_OPTION_DATA_GRED] = "gred", |
7e16f84e | 957 | [NL_UNION_TCA_OPTION_DATA_HHF] = "hhf", |
b934ac3d | 958 | [NL_UNION_TCA_OPTION_DATA_HTB] = "htb", |
55d22831 | 959 | [NL_UNION_TCA_OPTION_DATA_PIE] = "pie", |
c33f1e5a | 960 | [NL_UNION_TCA_OPTION_DATA_QFQ] = "qfq", |
982998b0 | 961 | [NL_UNION_TCA_OPTION_DATA_SFB] = "sfb", |
eb34f4b3 | 962 | [NL_UNION_TCA_OPTION_DATA_TBF] = "tbf", |
42b5f7dd YW |
963 | }; |
964 | ||
965 | DEFINE_STRING_TABLE_LOOKUP(nl_union_tca_option_data, NLUnionTCAOptionData); | |
966 | ||
967 | static const NLTypeSystem rtnl_tca_option_data_type_systems[] = { | |
ad8352f4 SS |
968 | [NL_UNION_TCA_OPTION_DATA_CAKE] = { .count = ELEMENTSOF(rtnl_tca_option_data_cake_types), |
969 | .types = rtnl_tca_option_data_cake_types }, | |
a9a5d632 SS |
970 | [NL_UNION_TCA_OPTION_DATA_CODEL] = { .count = ELEMENTSOF(rtnl_tca_option_data_codel_types), |
971 | .types = rtnl_tca_option_data_codel_types }, | |
5c21b46e SS |
972 | [NL_UNION_TCA_OPTION_DATA_DRR] = { .count = ELEMENTSOF(rtnl_tca_option_data_drr_types), |
973 | .types = rtnl_tca_option_data_drr_types }, | |
4dec9218 YW |
974 | [NL_UNION_TCA_OPTION_DATA_ETS] = { .count = ELEMENTSOF(rtnl_tca_option_data_ets_types), |
975 | .types = rtnl_tca_option_data_ets_types }, | |
eb34f4b3 YW |
976 | [NL_UNION_TCA_OPTION_DATA_FQ] = { .count = ELEMENTSOF(rtnl_tca_option_data_fq_types), |
977 | .types = rtnl_tca_option_data_fq_types }, | |
42b5f7dd YW |
978 | [NL_UNION_TCA_OPTION_DATA_FQ_CODEL] = { .count = ELEMENTSOF(rtnl_tca_option_data_fq_codel_types), |
979 | .types = rtnl_tca_option_data_fq_codel_types }, | |
3428b32a SS |
980 | [NL_UNION_TCA_OPTION_DATA_FQ_PIE] = { .count = ELEMENTSOF(rtnl_tca_option_data_fq_pie_types), |
981 | .types = rtnl_tca_option_data_fq_pie_types }, | |
609e8340 SS |
982 | [NL_UNION_TCA_OPTION_DATA_GRED] = { .count = ELEMENTSOF(rtnl_tca_option_data_gred_types), |
983 | .types = rtnl_tca_option_data_gred_types }, | |
7e16f84e SS |
984 | [NL_UNION_TCA_OPTION_DATA_HHF] = { .count = ELEMENTSOF(rtnl_tca_option_data_hhf_types), |
985 | .types = rtnl_tca_option_data_hhf_types }, | |
b934ac3d YW |
986 | [NL_UNION_TCA_OPTION_DATA_HTB] = { .count = ELEMENTSOF(rtnl_tca_option_data_htb_types), |
987 | .types = rtnl_tca_option_data_htb_types }, | |
55d22831 SS |
988 | [NL_UNION_TCA_OPTION_DATA_PIE] = { .count = ELEMENTSOF(rtnl_tca_option_data_pie_types), |
989 | .types = rtnl_tca_option_data_pie_types }, | |
c33f1e5a SS |
990 | [NL_UNION_TCA_OPTION_DATA_QFQ] = { .count = ELEMENTSOF(rtnl_tca_option_data_qfq_types), |
991 | .types = rtnl_tca_option_data_qfq_types }, | |
982998b0 SS |
992 | [NL_UNION_TCA_OPTION_DATA_SFB] = { .count = ELEMENTSOF(rtnl_tca_option_data_sfb_types), |
993 | .types = rtnl_tca_option_data_sfb_types }, | |
eb34f4b3 YW |
994 | [NL_UNION_TCA_OPTION_DATA_TBF] = { .count = ELEMENTSOF(rtnl_tca_option_data_tbf_types), |
995 | .types = rtnl_tca_option_data_tbf_types }, | |
42b5f7dd YW |
996 | }; |
997 | ||
998 | static const NLTypeSystemUnion rtnl_tca_option_data_type_system_union = { | |
999 | .num = _NL_UNION_TCA_OPTION_DATA_MAX, | |
1000 | .lookup = nl_union_tca_option_data_from_string, | |
1001 | .type_systems = rtnl_tca_option_data_type_systems, | |
1002 | .match_type = NL_MATCH_SIBLING, | |
1003 | .match = TCA_KIND, | |
1004 | }; | |
1005 | ||
0ebb76de | 1006 | static const NLType rtnl_tca_types[] = { |
0f5bd7fe | 1007 | [TCA_KIND] = { .type = NETLINK_TYPE_STRING }, |
42b5f7dd | 1008 | [TCA_OPTIONS] = { .type = NETLINK_TYPE_UNION, .type_system_union = &rtnl_tca_option_data_type_system_union }, |
0f5bd7fe SS |
1009 | [TCA_INGRESS_BLOCK] = { .type = NETLINK_TYPE_U32 }, |
1010 | [TCA_EGRESS_BLOCK] = { .type = NETLINK_TYPE_U32 }, | |
1011 | }; | |
1012 | ||
0ebb76de YW |
1013 | static const NLTypeSystem rtnl_tca_type_system = { |
1014 | .count = ELEMENTSOF(rtnl_tca_types), | |
1015 | .types = rtnl_tca_types, | |
0f5bd7fe SS |
1016 | }; |
1017 | ||
1903c9bb DM |
1018 | static const NLType mdb_types[] = { |
1019 | [MDBA_SET_ENTRY] = { .size = sizeof(struct br_port_msg) }, | |
1020 | }; | |
1021 | ||
1022 | static const NLTypeSystem rtnl_mdb_type_system = { | |
1023 | .count = ELEMENTSOF(mdb_types), | |
1024 | .types = mdb_types, | |
1025 | }; | |
1026 | ||
e4a1e68d YW |
1027 | static const NLType error_types[] = { |
1028 | [NLMSGERR_ATTR_MSG] = { .type = NETLINK_TYPE_STRING }, | |
1029 | [NLMSGERR_ATTR_OFFS] = { .type = NETLINK_TYPE_U32 }, | |
1030 | }; | |
1031 | ||
1032 | static const NLTypeSystem error_type_system = { | |
1033 | .count = ELEMENTSOF(error_types), | |
1034 | .types = error_types, | |
1035 | }; | |
1036 | ||
8ae4b6d1 | 1037 | static const NLType rtnl_types[] = { |
30746d60 | 1038 | [NLMSG_DONE] = { .type = NETLINK_TYPE_NESTED, .type_system = &empty_type_system, .size = 0 }, |
e4a1e68d | 1039 | [NLMSG_ERROR] = { .type = NETLINK_TYPE_NESTED, .type_system = &error_type_system, .size = sizeof(struct nlmsgerr) }, |
30746d60 SS |
1040 | [RTM_NEWLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, |
1041 | [RTM_DELLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, | |
1042 | [RTM_GETLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, | |
1043 | [RTM_SETLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, | |
ffeb16f5 YW |
1044 | [RTM_NEWLINKPROP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, |
1045 | [RTM_DELLINKPROP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, | |
1046 | [RTM_GETLINKPROP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, | |
30746d60 SS |
1047 | [RTM_NEWADDR] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) }, |
1048 | [RTM_DELADDR] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) }, | |
1049 | [RTM_GETADDR] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) }, | |
1050 | [RTM_NEWROUTE] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_type_system, .size = sizeof(struct rtmsg) }, | |
1051 | [RTM_DELROUTE] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_type_system, .size = sizeof(struct rtmsg) }, | |
1052 | [RTM_GETROUTE] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_type_system, .size = sizeof(struct rtmsg) }, | |
1053 | [RTM_NEWNEIGH] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_neigh_type_system, .size = sizeof(struct ndmsg) }, | |
1054 | [RTM_DELNEIGH] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_neigh_type_system, .size = sizeof(struct ndmsg) }, | |
1055 | [RTM_GETNEIGH] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_neigh_type_system, .size = sizeof(struct ndmsg) }, | |
1056 | [RTM_NEWADDRLABEL] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_addrlabel_type_system, .size = sizeof(struct ifaddrlblmsg) }, | |
1057 | [RTM_DELADDRLABEL] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_addrlabel_type_system, .size = sizeof(struct ifaddrlblmsg) }, | |
1058 | [RTM_GETADDRLABEL] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_addrlabel_type_system, .size = sizeof(struct ifaddrlblmsg) }, | |
eca24864 YW |
1059 | [RTM_NEWRULE] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_routing_policy_rule_type_system, .size = sizeof(struct fib_rule_hdr) }, |
1060 | [RTM_DELRULE] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_routing_policy_rule_type_system, .size = sizeof(struct fib_rule_hdr) }, | |
1061 | [RTM_GETRULE] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_routing_policy_rule_type_system, .size = sizeof(struct fib_rule_hdr) }, | |
c16c7808 SS |
1062 | [RTM_NEWNEXTHOP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_nexthop_type_system, .size = sizeof(struct nhmsg) }, |
1063 | [RTM_DELNEXTHOP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_nexthop_type_system, .size = sizeof(struct nhmsg) }, | |
1064 | [RTM_GETNEXTHOP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_nexthop_type_system, .size = sizeof(struct nhmsg) }, | |
0ebb76de YW |
1065 | [RTM_NEWQDISC] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system, .size = sizeof(struct tcmsg) }, |
1066 | [RTM_DELQDISC] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system, .size = sizeof(struct tcmsg) }, | |
1067 | [RTM_GETQDISC] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system, .size = sizeof(struct tcmsg) }, | |
1068 | [RTM_NEWTCLASS] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system, .size = sizeof(struct tcmsg) }, | |
1069 | [RTM_DELTCLASS] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system, .size = sizeof(struct tcmsg) }, | |
1070 | [RTM_GETTCLASS] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system, .size = sizeof(struct tcmsg) }, | |
1903c9bb DM |
1071 | [RTM_NEWMDB] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_mdb_type_system, .size = sizeof(struct br_port_msg) }, |
1072 | [RTM_DELMDB] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_mdb_type_system, .size = sizeof(struct br_port_msg) }, | |
1073 | [RTM_GETMDB] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_mdb_type_system, .size = sizeof(struct br_port_msg) }, | |
d8e538ec TG |
1074 | }; |
1075 | ||
05d0c2e3 | 1076 | const NLTypeSystem rtnl_type_system_root = { |
c1df8dee | 1077 | .count = ELEMENTSOF(rtnl_types), |
d8e538ec TG |
1078 | .types = rtnl_types, |
1079 | }; | |
1080 | ||
e5719363 JT |
1081 | static const NLType genl_wireguard_allowedip_types[] = { |
1082 | [WGALLOWEDIP_A_FAMILY] = { .type = NETLINK_TYPE_U16 }, | |
1083 | [WGALLOWEDIP_A_IPADDR] = { .type = NETLINK_TYPE_IN_ADDR }, | |
1084 | [WGALLOWEDIP_A_CIDR_MASK] = { .type = NETLINK_TYPE_U8 }, | |
1085 | }; | |
1086 | ||
1087 | static const NLTypeSystem genl_wireguard_allowedip_type_system = { | |
1088 | .count = ELEMENTSOF(genl_wireguard_allowedip_types), | |
1089 | .types = genl_wireguard_allowedip_types, | |
1090 | }; | |
1091 | ||
1092 | static const NLType genl_wireguard_peer_types[] = { | |
1093 | [WGPEER_A_PUBLIC_KEY] = { .size = WG_KEY_LEN }, | |
1094 | [WGPEER_A_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1095 | [WGPEER_A_PRESHARED_KEY] = { .size = WG_KEY_LEN }, | |
7d0b26a0 | 1096 | [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] = { .type = NETLINK_TYPE_U16 }, |
abd48ec8 | 1097 | [WGPEER_A_ENDPOINT] = { .type = NETLINK_TYPE_SOCKADDR }, |
e5719363 JT |
1098 | [WGPEER_A_ALLOWEDIPS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_allowedip_type_system }, |
1099 | }; | |
1100 | ||
1101 | static const NLTypeSystem genl_wireguard_peer_type_system = { | |
1102 | .count = ELEMENTSOF(genl_wireguard_peer_types), | |
1103 | .types = genl_wireguard_peer_types, | |
1104 | }; | |
1105 | ||
1106 | static const NLType genl_wireguard_set_device_types[] = { | |
1107 | [WGDEVICE_A_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
33c2ea80 | 1108 | [WGDEVICE_A_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ-1 }, |
e5719363 JT |
1109 | [WGDEVICE_A_FLAGS] = { .type = NETLINK_TYPE_U32 }, |
1110 | [WGDEVICE_A_PRIVATE_KEY] = { .size = WG_KEY_LEN }, | |
1111 | [WGDEVICE_A_LISTEN_PORT] = { .type = NETLINK_TYPE_U16 }, | |
1112 | [WGDEVICE_A_FWMARK] = { .type = NETLINK_TYPE_U32 }, | |
1113 | [WGDEVICE_A_PEERS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_peer_type_system }, | |
1114 | }; | |
1115 | ||
1116 | static const NLTypeSystem genl_wireguard_set_device_type_system = { | |
1117 | .count = ELEMENTSOF(genl_wireguard_set_device_types), | |
1118 | .types = genl_wireguard_set_device_types, | |
1119 | }; | |
1120 | ||
1121 | static const NLType genl_wireguard_cmds[] = { | |
1122 | [WG_CMD_SET_DEVICE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_set_device_type_system }, | |
1123 | }; | |
1124 | ||
1125 | static const NLTypeSystem genl_wireguard_type_system = { | |
1126 | .count = ELEMENTSOF(genl_wireguard_cmds), | |
1127 | .types = genl_wireguard_cmds, | |
1128 | }; | |
05d0c2e3 | 1129 | |
8fab2747 YW |
1130 | static const NLType genl_mcast_group_types[] = { |
1131 | [CTRL_ATTR_MCAST_GRP_NAME] = { .type = NETLINK_TYPE_STRING }, | |
1132 | [CTRL_ATTR_MCAST_GRP_ID] = { .type = NETLINK_TYPE_U32 }, | |
1133 | }; | |
1134 | ||
1135 | static const NLTypeSystem genl_mcast_group_type_system = { | |
1136 | .count = ELEMENTSOF(genl_mcast_group_types), | |
1137 | .types = genl_mcast_group_types, | |
1138 | }; | |
1139 | ||
05d0c2e3 | 1140 | static const NLType genl_get_family_types[] = { |
8fab2747 YW |
1141 | [CTRL_ATTR_FAMILY_NAME] = { .type = NETLINK_TYPE_STRING }, |
1142 | [CTRL_ATTR_FAMILY_ID] = { .type = NETLINK_TYPE_U16 }, | |
1143 | [CTRL_ATTR_MCAST_GROUPS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_mcast_group_type_system }, | |
05d0c2e3 JT |
1144 | }; |
1145 | ||
1146 | static const NLTypeSystem genl_get_family_type_system = { | |
1147 | .count = ELEMENTSOF(genl_get_family_types), | |
1148 | .types = genl_get_family_types, | |
1149 | }; | |
1150 | ||
1151 | static const NLType genl_ctrl_id_ctrl_cmds[] = { | |
1152 | [CTRL_CMD_GETFAMILY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_get_family_type_system }, | |
1153 | }; | |
1154 | ||
1155 | static const NLTypeSystem genl_ctrl_id_ctrl_type_system = { | |
1156 | .count = ELEMENTSOF(genl_ctrl_id_ctrl_cmds), | |
1157 | .types = genl_ctrl_id_ctrl_cmds, | |
1158 | }; | |
1159 | ||
53cb501a SS |
1160 | static const NLType genl_fou_types[] = { |
1161 | [FOU_ATTR_PORT] = { .type = NETLINK_TYPE_U16 }, | |
1162 | [FOU_ATTR_AF] = { .type = NETLINK_TYPE_U8 }, | |
1163 | [FOU_ATTR_IPPROTO] = { .type = NETLINK_TYPE_U8 }, | |
1164 | [FOU_ATTR_TYPE] = { .type = NETLINK_TYPE_U8 }, | |
1165 | [FOU_ATTR_REMCSUM_NOPARTIAL] = { .type = NETLINK_TYPE_FLAG }, | |
397a74dd SS |
1166 | [FOU_ATTR_LOCAL_V4] = { .type = NETLINK_TYPE_IN_ADDR }, |
1167 | [FOU_ATTR_PEER_V4] = { .type = NETLINK_TYPE_IN_ADDR }, | |
1168 | [FOU_ATTR_LOCAL_V6] = { .type = NETLINK_TYPE_IN_ADDR }, | |
1169 | [FOU_ATTR_PEER_V6] = { .type = NETLINK_TYPE_IN_ADDR}, | |
1170 | [FOU_ATTR_PEER_PORT] = { .type = NETLINK_TYPE_U16}, | |
1171 | [FOU_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32}, | |
53cb501a SS |
1172 | }; |
1173 | ||
1174 | static const NLTypeSystem genl_fou_type_system = { | |
1175 | .count = ELEMENTSOF(genl_fou_types), | |
1176 | .types = genl_fou_types, | |
1177 | }; | |
1178 | ||
1179 | static const NLType genl_fou_cmds[] = { | |
1180 | [FOU_CMD_ADD] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_fou_type_system }, | |
1181 | [FOU_CMD_DEL] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_fou_type_system }, | |
1182 | [FOU_CMD_GET] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_fou_type_system }, | |
1183 | }; | |
1184 | ||
1185 | static const NLTypeSystem genl_fou_cmds_type_system = { | |
1186 | .count = ELEMENTSOF(genl_fou_cmds), | |
1187 | .types = genl_fou_cmds, | |
1188 | }; | |
1189 | ||
3a56e697 SS |
1190 | static const NLType genl_l2tp_types[] = { |
1191 | [L2TP_ATTR_PW_TYPE] = { .type = NETLINK_TYPE_U16 }, | |
1192 | [L2TP_ATTR_ENCAP_TYPE] = { .type = NETLINK_TYPE_U16 }, | |
1193 | [L2TP_ATTR_OFFSET] = { .type = NETLINK_TYPE_U16 }, | |
1194 | [L2TP_ATTR_DATA_SEQ] = { .type = NETLINK_TYPE_U16 }, | |
1195 | [L2TP_ATTR_L2SPEC_TYPE] = { .type = NETLINK_TYPE_U8 }, | |
1196 | [L2TP_ATTR_L2SPEC_LEN] = { .type = NETLINK_TYPE_U8 }, | |
1197 | [L2TP_ATTR_PROTO_VERSION] = { .type = NETLINK_TYPE_U8 }, | |
1198 | [L2TP_ATTR_IFNAME] = { .type = NETLINK_TYPE_STRING }, | |
1199 | [L2TP_ATTR_CONN_ID] = { .type = NETLINK_TYPE_U32 }, | |
1200 | [L2TP_ATTR_PEER_CONN_ID] = { .type = NETLINK_TYPE_U32 }, | |
1201 | [L2TP_ATTR_SESSION_ID] = { .type = NETLINK_TYPE_U32 }, | |
1202 | [L2TP_ATTR_PEER_SESSION_ID] = { .type = NETLINK_TYPE_U32 }, | |
1203 | [L2TP_ATTR_UDP_CSUM] = { .type = NETLINK_TYPE_U8 }, | |
1204 | [L2TP_ATTR_VLAN_ID] = { .type = NETLINK_TYPE_U16 }, | |
1205 | [L2TP_ATTR_RECV_SEQ] = { .type = NETLINK_TYPE_U8 }, | |
1206 | [L2TP_ATTR_SEND_SEQ] = { .type = NETLINK_TYPE_U8 }, | |
1207 | [L2TP_ATTR_LNS_MODE] = { .type = NETLINK_TYPE_U8 }, | |
1208 | [L2TP_ATTR_USING_IPSEC] = { .type = NETLINK_TYPE_U8 }, | |
1209 | [L2TP_ATTR_FD] = { .type = NETLINK_TYPE_U32 }, | |
1210 | [L2TP_ATTR_IP_SADDR] = { .type = NETLINK_TYPE_IN_ADDR }, | |
1211 | [L2TP_ATTR_IP_DADDR] = { .type = NETLINK_TYPE_IN_ADDR }, | |
1212 | [L2TP_ATTR_UDP_SPORT] = { .type = NETLINK_TYPE_U16 }, | |
1213 | [L2TP_ATTR_UDP_DPORT] = { .type = NETLINK_TYPE_U16 }, | |
1214 | [L2TP_ATTR_IP6_SADDR] = { .type = NETLINK_TYPE_IN_ADDR }, | |
1215 | [L2TP_ATTR_IP6_DADDR] = { .type = NETLINK_TYPE_IN_ADDR }, | |
1216 | [L2TP_ATTR_UDP_ZERO_CSUM6_TX] = { .type = NETLINK_TYPE_FLAG }, | |
1217 | [L2TP_ATTR_UDP_ZERO_CSUM6_RX] = { .type = NETLINK_TYPE_FLAG }, | |
1218 | }; | |
1219 | ||
1220 | static const NLTypeSystem genl_l2tp_type_system = { | |
1221 | .count = ELEMENTSOF(genl_l2tp_types), | |
1222 | .types = genl_l2tp_types, | |
1223 | }; | |
1224 | ||
1225 | static const NLType genl_l2tp[] = { | |
1226 | [L2TP_CMD_TUNNEL_CREATE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1227 | [L2TP_CMD_TUNNEL_DELETE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1228 | [L2TP_CMD_TUNNEL_MODIFY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1229 | [L2TP_CMD_TUNNEL_GET] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1230 | [L2TP_CMD_SESSION_CREATE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1231 | [L2TP_CMD_SESSION_DELETE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1232 | [L2TP_CMD_SESSION_MODIFY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1233 | [L2TP_CMD_SESSION_GET] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1234 | }; | |
1235 | ||
1236 | static const NLTypeSystem genl_l2tp_tunnel_session_type_system = { | |
1237 | .count = ELEMENTSOF(genl_l2tp), | |
1238 | .types = genl_l2tp, | |
1239 | }; | |
1240 | ||
81962db7 SS |
1241 | static const NLType genl_rxsc_types[] = { |
1242 | [MACSEC_RXSC_ATTR_SCI] = { .type = NETLINK_TYPE_U64 }, | |
1243 | }; | |
1244 | ||
1245 | static const NLTypeSystem genl_rxsc_config_type_system = { | |
1246 | .count = ELEMENTSOF(genl_rxsc_types), | |
1247 | .types = genl_rxsc_types, | |
1248 | }; | |
1249 | ||
1250 | static const NLType genl_macsec_rxsc_types[] = { | |
1251 | [MACSEC_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
1252 | [MACSEC_ATTR_RXSC_CONFIG] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_rxsc_config_type_system }, | |
1253 | }; | |
1254 | ||
1255 | static const NLTypeSystem genl_macsec_rxsc_type_system = { | |
1256 | .count = ELEMENTSOF(genl_macsec_rxsc_types), | |
1257 | .types = genl_macsec_rxsc_types, | |
1258 | }; | |
1259 | ||
1260 | static const NLType genl_macsec_sa_config_types[] = { | |
1261 | [MACSEC_SA_ATTR_AN] = { .type = NETLINK_TYPE_U8 }, | |
1262 | [MACSEC_SA_ATTR_ACTIVE] = { .type = NETLINK_TYPE_U8 }, | |
1263 | [MACSEC_SA_ATTR_PN] = { .type = NETLINK_TYPE_U32 }, | |
1264 | [MACSEC_SA_ATTR_KEYID] = { .size = MACSEC_KEYID_LEN }, | |
1265 | [MACSEC_SA_ATTR_KEY] = { .size = MACSEC_MAX_KEY_LEN }, | |
1266 | }; | |
1267 | ||
1268 | static const NLTypeSystem genl_macsec_sa_config_type_system = { | |
1269 | .count = ELEMENTSOF(genl_macsec_sa_config_types), | |
1270 | .types = genl_macsec_sa_config_types, | |
1271 | }; | |
1272 | ||
1273 | static const NLType genl_macsec_rxsa_types[] = { | |
1274 | [MACSEC_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
1275 | [MACSEC_ATTR_SA_CONFIG] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_sa_config_type_system }, | |
1276 | }; | |
1277 | ||
1278 | static const NLTypeSystem genl_macsec_rxsa_type_system = { | |
1279 | .count = ELEMENTSOF(genl_macsec_rxsa_types), | |
1280 | .types = genl_macsec_rxsa_types, | |
1281 | }; | |
1282 | ||
1283 | static const NLType genl_macsec_sa_types[] = { | |
1284 | [MACSEC_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
1285 | [MACSEC_ATTR_RXSC_CONFIG] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_rxsc_config_type_system }, | |
1286 | [MACSEC_ATTR_SA_CONFIG] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_sa_config_type_system }, | |
1287 | }; | |
1288 | ||
1289 | static const NLTypeSystem genl_macsec_sa_type_system = { | |
1290 | .count = ELEMENTSOF(genl_macsec_sa_types), | |
1291 | .types = genl_macsec_sa_types, | |
1292 | }; | |
1293 | ||
1294 | static const NLType genl_macsec[] = { | |
1295 | [MACSEC_CMD_ADD_RXSC] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_rxsc_type_system }, | |
1296 | [MACSEC_CMD_ADD_TXSA] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_rxsa_type_system}, | |
1297 | [MACSEC_CMD_ADD_RXSA] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_sa_type_system }, | |
1298 | }; | |
1299 | ||
1300 | static const NLTypeSystem genl_macsec_device_type_system = { | |
1301 | .count = ELEMENTSOF(genl_macsec), | |
1302 | .types = genl_macsec, | |
1303 | }; | |
1304 | ||
a1d736e2 YW |
1305 | static const NLType genl_nl80211_types[] = { |
1306 | [NL80211_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
1307 | [NL80211_ATTR_MAC] = { .type = NETLINK_TYPE_ETHER_ADDR }, | |
1308 | [NL80211_ATTR_SSID] = { .type = NETLINK_TYPE_STRING }, | |
78404d22 | 1309 | [NL80211_ATTR_IFTYPE] = { .type = NETLINK_TYPE_U32 }, |
a1d736e2 YW |
1310 | }; |
1311 | ||
1312 | static const NLTypeSystem genl_nl80211_type_system = { | |
1313 | .count = ELEMENTSOF(genl_nl80211_types), | |
1314 | .types = genl_nl80211_types, | |
1315 | }; | |
1316 | ||
1317 | static const NLType genl_nl80211_cmds[] = { | |
1318 | [NL80211_CMD_GET_WIPHY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1319 | [NL80211_CMD_SET_WIPHY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1320 | [NL80211_CMD_NEW_WIPHY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1321 | [NL80211_CMD_DEL_WIPHY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1322 | [NL80211_CMD_GET_INTERFACE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1323 | [NL80211_CMD_SET_INTERFACE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1324 | [NL80211_CMD_NEW_INTERFACE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1325 | [NL80211_CMD_DEL_INTERFACE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1326 | [NL80211_CMD_GET_STATION] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1327 | [NL80211_CMD_SET_STATION] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1328 | [NL80211_CMD_NEW_STATION] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1329 | [NL80211_CMD_DEL_STATION] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1330 | }; | |
1331 | ||
1332 | static const NLTypeSystem genl_nl80211_cmds_type_system = { | |
1333 | .count = ELEMENTSOF(genl_nl80211_cmds), | |
1334 | .types = genl_nl80211_cmds, | |
1335 | }; | |
1336 | ||
c0267a59 AW |
1337 | static const NLType genl_batadv_types[] = { |
1338 | [BATADV_ATTR_VERSION] = { .type = NETLINK_TYPE_STRING }, | |
1339 | [BATADV_ATTR_ALGO_NAME] = { .type = NETLINK_TYPE_STRING }, | |
1340 | [BATADV_ATTR_MESH_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
1341 | [BATADV_ATTR_MESH_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ }, | |
1342 | [BATADV_ATTR_MESH_ADDRESS] = { .size = ETH_ALEN }, | |
1343 | [BATADV_ATTR_HARD_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
1344 | [BATADV_ATTR_HARD_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ }, | |
1345 | [BATADV_ATTR_HARD_ADDRESS] = { .size = ETH_ALEN }, | |
1346 | [BATADV_ATTR_ORIG_ADDRESS] = { .size = ETH_ALEN }, | |
1347 | [BATADV_ATTR_TPMETER_RESULT] = { .type = NETLINK_TYPE_U8 }, | |
1348 | [BATADV_ATTR_TPMETER_TEST_TIME] = { .type = NETLINK_TYPE_U32 }, | |
1349 | [BATADV_ATTR_TPMETER_BYTES] = { .type = NETLINK_TYPE_U64 }, | |
1350 | [BATADV_ATTR_TPMETER_COOKIE] = { .type = NETLINK_TYPE_U32 }, | |
1351 | [BATADV_ATTR_PAD] = { .type = NETLINK_TYPE_UNSPEC }, | |
1352 | [BATADV_ATTR_ACTIVE] = { .type = NETLINK_TYPE_FLAG }, | |
1353 | [BATADV_ATTR_TT_ADDRESS] = { .size = ETH_ALEN }, | |
1354 | [BATADV_ATTR_TT_TTVN] = { .type = NETLINK_TYPE_U8 }, | |
1355 | [BATADV_ATTR_TT_LAST_TTVN] = { .type = NETLINK_TYPE_U8 }, | |
1356 | [BATADV_ATTR_TT_CRC32] = { .type = NETLINK_TYPE_U32 }, | |
1357 | [BATADV_ATTR_TT_VID] = { .type = NETLINK_TYPE_U16 }, | |
1358 | [BATADV_ATTR_TT_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1359 | [BATADV_ATTR_FLAG_BEST] = { .type = NETLINK_TYPE_FLAG }, | |
1360 | [BATADV_ATTR_LAST_SEEN_MSECS] = { .type = NETLINK_TYPE_U32 }, | |
1361 | [BATADV_ATTR_NEIGH_ADDRESS] = { .size = ETH_ALEN }, | |
1362 | [BATADV_ATTR_TQ] = { .type = NETLINK_TYPE_U8 }, | |
1363 | [BATADV_ATTR_THROUGHPUT] = { .type = NETLINK_TYPE_U32 }, | |
1364 | [BATADV_ATTR_BANDWIDTH_UP] = { .type = NETLINK_TYPE_U32 }, | |
1365 | [BATADV_ATTR_BANDWIDTH_DOWN] = { .type = NETLINK_TYPE_U32 }, | |
1366 | [BATADV_ATTR_ROUTER] = { .size = ETH_ALEN }, | |
1367 | [BATADV_ATTR_BLA_OWN] = { .type = NETLINK_TYPE_FLAG }, | |
1368 | [BATADV_ATTR_BLA_ADDRESS] = { .size = ETH_ALEN }, | |
1369 | [BATADV_ATTR_BLA_VID] = { .type = NETLINK_TYPE_U16 }, | |
1370 | [BATADV_ATTR_BLA_BACKBONE] = { .size = ETH_ALEN }, | |
1371 | [BATADV_ATTR_BLA_CRC] = { .type = NETLINK_TYPE_U16 }, | |
1372 | [BATADV_ATTR_DAT_CACHE_IP4ADDRESS] = { .type = NETLINK_TYPE_U32 }, | |
1373 | [BATADV_ATTR_DAT_CACHE_HWADDRESS] = { .size = ETH_ALEN }, | |
1374 | [BATADV_ATTR_DAT_CACHE_VID] = { .type = NETLINK_TYPE_U16 }, | |
1375 | [BATADV_ATTR_MCAST_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1376 | [BATADV_ATTR_MCAST_FLAGS_PRIV] = { .type = NETLINK_TYPE_U32 }, | |
1377 | [BATADV_ATTR_VLANID] = { .type = NETLINK_TYPE_U16 }, | |
1378 | [BATADV_ATTR_AGGREGATED_OGMS_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1379 | [BATADV_ATTR_AP_ISOLATION_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1380 | [BATADV_ATTR_ISOLATION_MARK] = { .type = NETLINK_TYPE_U32 }, | |
1381 | [BATADV_ATTR_ISOLATION_MASK] = { .type = NETLINK_TYPE_U32 }, | |
1382 | [BATADV_ATTR_BONDING_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1383 | [BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1384 | [BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1385 | [BATADV_ATTR_FRAGMENTATION_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1386 | [BATADV_ATTR_GW_BANDWIDTH_DOWN] = { .type = NETLINK_TYPE_U32 }, | |
1387 | [BATADV_ATTR_GW_BANDWIDTH_UP] = { .type = NETLINK_TYPE_U32 }, | |
1388 | [BATADV_ATTR_GW_MODE] = { .type = NETLINK_TYPE_U8 }, | |
1389 | [BATADV_ATTR_GW_SEL_CLASS] = { .type = NETLINK_TYPE_U32 }, | |
1390 | [BATADV_ATTR_HOP_PENALTY] = { .type = NETLINK_TYPE_U8 }, | |
1391 | [BATADV_ATTR_LOG_LEVEL] = { .type = NETLINK_TYPE_U32 }, | |
1392 | [BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1393 | [BATADV_ATTR_MULTICAST_FANOUT] = { .type = NETLINK_TYPE_U32 }, | |
1394 | [BATADV_ATTR_NETWORK_CODING_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1395 | [BATADV_ATTR_ORIG_INTERVAL] = { .type = NETLINK_TYPE_U32 }, | |
1396 | [BATADV_ATTR_ELP_INTERVAL] = { .type = NETLINK_TYPE_U32 }, | |
1397 | [BATADV_ATTR_THROUGHPUT_OVERRIDE] = { .type = NETLINK_TYPE_U32 }, | |
1398 | }; | |
1399 | ||
1400 | static const NLTypeSystem genl_batadv_type_system = { | |
1401 | .count = ELEMENTSOF(genl_batadv_types), | |
1402 | .types = genl_batadv_types, | |
1403 | }; | |
1404 | ||
1405 | static const NLType genl_batadv_cmds[] = { | |
1406 | [BATADV_CMD_SET_MESH] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_batadv_type_system }, | |
1407 | }; | |
1408 | ||
1409 | static const NLTypeSystem genl_batadv_cmds_type_system = { | |
1410 | .count = ELEMENTSOF(genl_batadv_cmds), | |
1411 | .types = genl_batadv_cmds, | |
1412 | }; | |
1413 | ||
05d0c2e3 | 1414 | static const NLType genl_families[] = { |
53cb501a | 1415 | [SD_GENL_ID_CTRL] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_ctrl_id_ctrl_type_system }, |
e5719363 | 1416 | [SD_GENL_WIREGUARD] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_type_system }, |
2be081ff | 1417 | [SD_GENL_FOU] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_fou_cmds_type_system }, |
3a56e697 | 1418 | [SD_GENL_L2TP] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_tunnel_session_type_system }, |
81962db7 | 1419 | [SD_GENL_MACSEC] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_device_type_system }, |
a1d736e2 | 1420 | [SD_GENL_NL80211] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_cmds_type_system }, |
c0267a59 | 1421 | [SD_GENL_BATADV] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_batadv_cmds_type_system }, |
05d0c2e3 JT |
1422 | }; |
1423 | ||
6f00fd9b FW |
1424 | static const NLType nfnl_nft_table_types[] = { |
1425 | [NFTA_TABLE_NAME] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1426 | [NFTA_TABLE_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1427 | }; | |
1428 | ||
1429 | static const NLTypeSystem nfnl_nft_table_type_system = { | |
1430 | .count = ELEMENTSOF(nfnl_nft_table_types), | |
1431 | .types = nfnl_nft_table_types, | |
1432 | }; | |
1433 | ||
1434 | static const NLType nfnl_nft_chain_hook_types[] = { | |
1435 | [NFTA_HOOK_HOOKNUM] = { .type = NETLINK_TYPE_U32 }, | |
1436 | [NFTA_HOOK_PRIORITY] = { .type = NETLINK_TYPE_U32 }, | |
1437 | [NFTA_HOOK_DEV] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ - 1 }, | |
1438 | }; | |
1439 | ||
1440 | static const NLTypeSystem nfnl_nft_chain_hook_type_system = { | |
1441 | .count = ELEMENTSOF(nfnl_nft_chain_hook_types), | |
1442 | .types = nfnl_nft_chain_hook_types, | |
1443 | }; | |
1444 | ||
1445 | static const NLType nfnl_nft_chain_types[] = { | |
1446 | [NFTA_CHAIN_TABLE] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1447 | [NFTA_CHAIN_NAME] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1448 | [NFTA_CHAIN_HOOK] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_chain_hook_type_system }, | |
1449 | [NFTA_CHAIN_TYPE] = { .type = NETLINK_TYPE_STRING, .size = 16 }, | |
1450 | [NFTA_CHAIN_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1451 | }; | |
1452 | ||
1453 | static const NLTypeSystem nfnl_nft_chain_type_system = { | |
1454 | .count = ELEMENTSOF(nfnl_nft_chain_types), | |
1455 | .types = nfnl_nft_chain_types, | |
1456 | }; | |
1457 | ||
1458 | static const NLType nfnl_nft_expr_meta_types[] = { | |
1459 | [NFTA_META_DREG] = { .type = NETLINK_TYPE_U32 }, | |
1460 | [NFTA_META_KEY] = { .type = NETLINK_TYPE_U32 }, | |
1461 | [NFTA_META_SREG] = { .type = NETLINK_TYPE_U32 }, | |
1462 | }; | |
1463 | ||
1464 | static const NLType nfnl_nft_expr_payload_types[] = { | |
1465 | [NFTA_PAYLOAD_DREG] = { .type = NETLINK_TYPE_U32 }, | |
1466 | [NFTA_PAYLOAD_BASE] = { .type = NETLINK_TYPE_U32 }, | |
1467 | [NFTA_PAYLOAD_OFFSET] = { .type = NETLINK_TYPE_U32 }, | |
1468 | [NFTA_PAYLOAD_LEN] = { .type = NETLINK_TYPE_U32 }, | |
1469 | }; | |
1470 | ||
1471 | static const NLType nfnl_nft_expr_nat_types[] = { | |
1472 | [NFTA_NAT_TYPE] = { .type = NETLINK_TYPE_U32 }, | |
1473 | [NFTA_NAT_FAMILY] = { .type = NETLINK_TYPE_U32 }, | |
1474 | [NFTA_NAT_REG_ADDR_MIN] = { .type = NETLINK_TYPE_U32 }, | |
1475 | [NFTA_NAT_REG_ADDR_MAX] = { .type = NETLINK_TYPE_U32 }, | |
1476 | [NFTA_NAT_REG_PROTO_MIN] = { .type = NETLINK_TYPE_U32 }, | |
1477 | [NFTA_NAT_REG_PROTO_MAX] = { .type = NETLINK_TYPE_U32 }, | |
1478 | [NFTA_NAT_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1479 | }; | |
1480 | ||
1481 | static const NLType nfnl_nft_data_types[] = { | |
1482 | [NFTA_DATA_VALUE] = { .type = NETLINK_TYPE_BINARY }, | |
1483 | }; | |
1484 | ||
1485 | static const NLTypeSystem nfnl_nft_data_type_system = { | |
1486 | .count = ELEMENTSOF(nfnl_nft_data_types), | |
1487 | .types = nfnl_nft_data_types, | |
1488 | }; | |
1489 | ||
1490 | static const NLType nfnl_nft_expr_bitwise_types[] = { | |
1491 | [NFTA_BITWISE_SREG] = { .type = NETLINK_TYPE_U32 }, | |
1492 | [NFTA_BITWISE_DREG] = { .type = NETLINK_TYPE_U32 }, | |
1493 | [NFTA_BITWISE_LEN] = { .type = NETLINK_TYPE_U32 }, | |
1494 | [NFTA_BITWISE_MASK] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system }, | |
1495 | [NFTA_BITWISE_XOR] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system }, | |
1496 | }; | |
1497 | ||
1498 | static const NLType nfnl_nft_expr_cmp_types[] = { | |
1499 | [NFTA_CMP_SREG] = { .type = NETLINK_TYPE_U32 }, | |
1500 | [NFTA_CMP_OP] = { .type = NETLINK_TYPE_U32 }, | |
1501 | [NFTA_CMP_DATA] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system }, | |
1502 | }; | |
1503 | ||
1504 | static const NLType nfnl_nft_expr_fib_types[] = { | |
1505 | [NFTA_FIB_DREG] = { .type = NETLINK_TYPE_U32 }, | |
1506 | [NFTA_FIB_RESULT] = { .type = NETLINK_TYPE_U32 }, | |
1507 | [NFTA_FIB_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1508 | }; | |
1509 | ||
1510 | static const NLType nfnl_nft_expr_lookup_types[] = { | |
1511 | [NFTA_LOOKUP_SET] = { .type = NETLINK_TYPE_STRING }, | |
1512 | [NFTA_LOOKUP_SREG] = { .type = NETLINK_TYPE_U32 }, | |
1513 | [NFTA_LOOKUP_DREG] = { .type = NETLINK_TYPE_U32 }, | |
1514 | [NFTA_LOOKUP_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1515 | }; | |
1516 | ||
1517 | static const NLType nfnl_nft_expr_masq_types[] = { | |
1518 | [NFTA_MASQ_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1519 | [NFTA_MASQ_REG_PROTO_MIN] = { .type = NETLINK_TYPE_U32 }, | |
1520 | [NFTA_MASQ_REG_PROTO_MAX] = { .type = NETLINK_TYPE_U32 }, | |
1521 | }; | |
1522 | ||
1523 | static const NLTypeSystem nfnl_expr_data_type_systems[] = { | |
1524 | [NL_UNION_NFT_EXPR_DATA_BITWISE] = { .count = ELEMENTSOF(nfnl_nft_expr_bitwise_types), | |
1525 | .types = nfnl_nft_expr_bitwise_types }, | |
1526 | [NL_UNION_NFT_EXPR_DATA_CMP] = { .count = ELEMENTSOF(nfnl_nft_expr_cmp_types), | |
1527 | .types = nfnl_nft_expr_cmp_types }, | |
1528 | [NL_UNION_NFT_EXPR_DATA_FIB] = { .count = ELEMENTSOF(nfnl_nft_expr_fib_types), | |
1529 | .types = nfnl_nft_expr_fib_types }, | |
1530 | [NL_UNION_NFT_EXPR_DATA_LOOKUP] = { .count = ELEMENTSOF(nfnl_nft_expr_lookup_types), | |
1531 | .types = nfnl_nft_expr_lookup_types }, | |
1532 | [NL_UNION_NFT_EXPR_DATA_MASQ] = { .count = ELEMENTSOF(nfnl_nft_expr_masq_types), | |
1533 | .types = nfnl_nft_expr_masq_types }, | |
1534 | [NL_UNION_NFT_EXPR_DATA_META] = { .count = ELEMENTSOF(nfnl_nft_expr_meta_types), | |
1535 | .types = nfnl_nft_expr_meta_types }, | |
1536 | [NL_UNION_NFT_EXPR_DATA_NAT] = { .count = ELEMENTSOF(nfnl_nft_expr_nat_types), | |
1537 | .types = nfnl_nft_expr_nat_types }, | |
1538 | [NL_UNION_NFT_EXPR_DATA_PAYLOAD] = { .count = ELEMENTSOF(nfnl_nft_expr_payload_types), | |
1539 | .types = nfnl_nft_expr_payload_types }, | |
1540 | }; | |
1541 | ||
1542 | static const char* const nl_union_nft_expr_data_table[] = { | |
1543 | [NL_UNION_NFT_EXPR_DATA_BITWISE] = "bitwise", | |
1544 | [NL_UNION_NFT_EXPR_DATA_CMP] = "cmp", | |
1545 | [NL_UNION_NFT_EXPR_DATA_LOOKUP] = "lookup", | |
1546 | [NL_UNION_NFT_EXPR_DATA_META] = "meta", | |
1547 | [NL_UNION_NFT_EXPR_DATA_FIB] = "fib", | |
1548 | [NL_UNION_NFT_EXPR_DATA_MASQ] = "masq", | |
1549 | [NL_UNION_NFT_EXPR_DATA_NAT] = "nat", | |
1550 | [NL_UNION_NFT_EXPR_DATA_PAYLOAD] = "payload", | |
1551 | }; | |
1552 | ||
1553 | DEFINE_STRING_TABLE_LOOKUP(nl_union_nft_expr_data, NLUnionNFTExprData); | |
1554 | ||
1555 | static const NLTypeSystemUnion nfnl_nft_data_expr_type_system_union = { | |
1556 | .num = _NL_UNION_NFT_EXPR_DATA_MAX, | |
1557 | .lookup = nl_union_nft_expr_data_from_string, | |
1558 | .type_systems = nfnl_expr_data_type_systems, | |
1559 | .match_type = NL_MATCH_SIBLING, | |
1560 | .match = NFTA_EXPR_NAME, | |
1561 | }; | |
1562 | ||
1563 | static const NLType nfnl_nft_rule_expr_types[] = { | |
1564 | [NFTA_EXPR_NAME] = { .type = NETLINK_TYPE_STRING, .size = 16 }, | |
1565 | [NFTA_EXPR_DATA] = { .type = NETLINK_TYPE_UNION, | |
1566 | .type_system_union = &nfnl_nft_data_expr_type_system_union }, | |
1567 | }; | |
1568 | ||
1569 | static const NLTypeSystem nfnl_nft_rule_expr_type_system = { | |
1570 | .count = ELEMENTSOF(nfnl_nft_rule_expr_types), | |
1571 | .types = nfnl_nft_rule_expr_types, | |
1572 | }; | |
1573 | ||
1574 | static const NLType nfnl_nft_rule_types[] = { | |
1575 | [NFTA_RULE_TABLE] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1576 | [NFTA_RULE_CHAIN] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
faa0d69c | 1577 | [NFTA_RULE_EXPRESSIONS] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_rule_expr_type_system } |
6f00fd9b FW |
1578 | }; |
1579 | ||
1580 | static const NLTypeSystem nfnl_nft_rule_type_system = { | |
1581 | .count = ELEMENTSOF(nfnl_nft_rule_types), | |
1582 | .types = nfnl_nft_rule_types, | |
1583 | }; | |
1584 | ||
1585 | static const NLType nfnl_nft_set_types[] = { | |
1586 | [NFTA_SET_TABLE] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1587 | [NFTA_SET_NAME] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1588 | [NFTA_SET_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1589 | [NFTA_SET_KEY_TYPE] = { .type = NETLINK_TYPE_U32 }, | |
1590 | [NFTA_SET_KEY_LEN] = { .type = NETLINK_TYPE_U32 }, | |
1591 | [NFTA_SET_DATA_TYPE] = { .type = NETLINK_TYPE_U32 }, | |
1592 | [NFTA_SET_DATA_LEN] = { .type = NETLINK_TYPE_U32 }, | |
1593 | [NFTA_SET_POLICY] = { .type = NETLINK_TYPE_U32 }, | |
1594 | [NFTA_SET_ID] = { .type = NETLINK_TYPE_U32 }, | |
1595 | }; | |
1596 | ||
1597 | static const NLTypeSystem nfnl_nft_set_type_system = { | |
1598 | .count = ELEMENTSOF(nfnl_nft_set_types), | |
1599 | .types = nfnl_nft_set_types, | |
1600 | }; | |
1601 | ||
1602 | static const NLType nfnl_nft_setelem_types[] = { | |
1603 | [NFTA_SET_ELEM_KEY] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system }, | |
1604 | [NFTA_SET_ELEM_DATA] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system }, | |
1605 | [NFTA_SET_ELEM_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1606 | }; | |
1607 | ||
1608 | static const NLTypeSystem nfnl_nft_setelem_type_system = { | |
1609 | .count = ELEMENTSOF(nfnl_nft_setelem_types), | |
1610 | .types = nfnl_nft_setelem_types, | |
1611 | }; | |
1612 | ||
1613 | static const NLType nfnl_nft_setelem_list_types[] = { | |
1614 | [NFTA_SET_ELEM_LIST_TABLE] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1615 | [NFTA_SET_ELEM_LIST_SET] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1616 | [NFTA_SET_ELEM_LIST_ELEMENTS] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_setelem_type_system }, | |
1617 | }; | |
1618 | ||
1619 | static const NLTypeSystem nfnl_nft_setelem_list_type_system = { | |
1620 | .count = ELEMENTSOF(nfnl_nft_setelem_list_types), | |
1621 | .types = nfnl_nft_setelem_list_types, | |
1622 | }; | |
1623 | ||
1624 | static const NLType nfnl_nft_msg_types [] = { | |
1625 | [NFT_MSG_DELTABLE] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_table_type_system, .size = sizeof(struct nfgenmsg) }, | |
1626 | [NFT_MSG_NEWTABLE] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_table_type_system, .size = sizeof(struct nfgenmsg) }, | |
1627 | [NFT_MSG_NEWCHAIN] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_chain_type_system, .size = sizeof(struct nfgenmsg) }, | |
1628 | [NFT_MSG_NEWRULE] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_rule_type_system, .size = sizeof(struct nfgenmsg) }, | |
1629 | [NFT_MSG_NEWSET] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_set_type_system, .size = sizeof(struct nfgenmsg) }, | |
1630 | [NFT_MSG_NEWSETELEM] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_setelem_list_type_system, .size = sizeof(struct nfgenmsg) }, | |
1631 | [NFT_MSG_DELSETELEM] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_setelem_list_type_system, .size = sizeof(struct nfgenmsg) }, | |
1632 | }; | |
1633 | ||
1634 | static const NLTypeSystem nfnl_nft_msg_type_system = { | |
1635 | .count = ELEMENTSOF(nfnl_nft_msg_types), | |
1636 | .types = nfnl_nft_msg_types, | |
1637 | }; | |
1638 | ||
1639 | static const NLType nfnl_msg_batch_types [] = { | |
1640 | [NFNL_BATCH_GENID] = { .type = NETLINK_TYPE_U32 } | |
1641 | }; | |
1642 | ||
1643 | static const NLTypeSystem nfnl_msg_batch_type_system = { | |
1644 | .count = ELEMENTSOF(nfnl_msg_batch_types), | |
1645 | .types = nfnl_msg_batch_types, | |
1646 | }; | |
1647 | ||
1648 | static const NLType nfnl_types[] = { | |
1649 | [NLMSG_DONE] = { .type = NETLINK_TYPE_NESTED, .type_system = &empty_type_system, .size = 0 }, | |
1650 | [NLMSG_ERROR] = { .type = NETLINK_TYPE_NESTED, .type_system = &error_type_system, .size = sizeof(struct nlmsgerr) }, | |
1651 | [NFNL_MSG_BATCH_BEGIN] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_msg_batch_type_system, .size = sizeof(struct nfgenmsg) }, | |
1652 | [NFNL_MSG_BATCH_END] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_msg_batch_type_system, .size = sizeof(struct nfgenmsg) }, | |
1653 | [NFNL_SUBSYS_NFTABLES] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_msg_type_system, .size = sizeof(struct nfgenmsg) }, | |
1654 | }; | |
1655 | ||
1656 | const NLTypeSystem nfnl_type_system_root = { | |
1657 | .count = ELEMENTSOF(nfnl_types), | |
1658 | .types = nfnl_types, | |
1659 | }; | |
1660 | ||
4e8f0ef9 | 1661 | /* Mainly used when sending message */ |
05d0c2e3 JT |
1662 | const NLTypeSystem genl_family_type_system_root = { |
1663 | .count = ELEMENTSOF(genl_families), | |
1664 | .types = genl_families, | |
1665 | }; | |
1666 | ||
1667 | static const NLType genl_types[] = { | |
e4a1e68d | 1668 | [SD_GENL_ERROR] = { .type = NETLINK_TYPE_NESTED, .type_system = &error_type_system, .size = sizeof(struct nlmsgerr) }, |
2be081ff | 1669 | [SD_GENL_DONE] = { .type = NETLINK_TYPE_NESTED, .type_system = &empty_type_system }, |
4e8f0ef9 | 1670 | [SD_GENL_ID_CTRL] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_get_family_type_system, .size = sizeof(struct genlmsghdr) }, |
a1d736e2 | 1671 | [SD_GENL_NL80211] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system, .size = sizeof(struct genlmsghdr) }, |
05d0c2e3 JT |
1672 | }; |
1673 | ||
4e8f0ef9 | 1674 | /* Mainly used when message received */ |
05d0c2e3 JT |
1675 | const NLTypeSystem genl_type_system_root = { |
1676 | .count = ELEMENTSOF(genl_types), | |
1677 | .types = genl_types, | |
1678 | }; | |
1679 | ||
817d1cd8 DH |
1680 | uint16_t type_get_type(const NLType *type) { |
1681 | assert(type); | |
1682 | return type->type; | |
1683 | } | |
1684 | ||
1685 | size_t type_get_size(const NLType *type) { | |
1686 | assert(type); | |
1687 | return type->size; | |
1688 | } | |
1689 | ||
c658008f DH |
1690 | void type_get_type_system(const NLType *nl_type, const NLTypeSystem **ret) { |
1691 | assert(nl_type); | |
1692 | assert(ret); | |
1693 | assert(nl_type->type == NETLINK_TYPE_NESTED); | |
1694 | assert(nl_type->type_system); | |
1695 | ||
1696 | *ret = nl_type->type_system; | |
1697 | } | |
1698 | ||
1699 | void type_get_type_system_union(const NLType *nl_type, const NLTypeSystemUnion **ret) { | |
1700 | assert(nl_type); | |
1701 | assert(ret); | |
1702 | assert(nl_type->type == NETLINK_TYPE_UNION); | |
1703 | assert(nl_type->type_system_union); | |
1704 | ||
1705 | *ret = nl_type->type_system_union; | |
1706 | } | |
1707 | ||
c1df8dee | 1708 | uint16_t type_system_get_count(const NLTypeSystem *type_system) { |
435bbb02 | 1709 | assert(type_system); |
c1df8dee | 1710 | return type_system->count; |
435bbb02 DH |
1711 | } |
1712 | ||
05d0c2e3 JT |
1713 | const NLTypeSystem *type_system_get_root(int protocol) { |
1714 | switch (protocol) { | |
1715 | case NETLINK_GENERIC: | |
1716 | return &genl_type_system_root; | |
6f00fd9b FW |
1717 | case NETLINK_NETFILTER: |
1718 | return &nfnl_type_system_root; | |
05d0c2e3 JT |
1719 | default: /* NETLINK_ROUTE: */ |
1720 | return &rtnl_type_system_root; | |
1721 | } | |
1722 | } | |
1723 | ||
4e8f0ef9 | 1724 | int type_system_root_get_type(sd_netlink *nl, const NLType **ret, uint16_t type) { |
2324fd3a | 1725 | sd_genl_family_t family; |
4e8f0ef9 YW |
1726 | const NLType *nl_type; |
1727 | int r; | |
1728 | ||
6f00fd9b | 1729 | if (!nl) |
4e8f0ef9 YW |
1730 | return type_system_get_type(&rtnl_type_system_root, ret, type); |
1731 | ||
6f00fd9b FW |
1732 | if (nl->protocol != NETLINK_GENERIC) |
1733 | return type_system_get_type(type_system_get_root(nl->protocol), ret, type); | |
1734 | ||
4e8f0ef9 YW |
1735 | r = nlmsg_type_to_genl_family(nl, type, &family); |
1736 | if (r < 0) | |
1737 | return r; | |
1738 | ||
1739 | if (family >= genl_type_system_root.count) | |
1740 | return -EOPNOTSUPP; | |
1741 | ||
1742 | nl_type = &genl_type_system_root.types[family]; | |
1743 | ||
1744 | if (nl_type->type == NETLINK_TYPE_UNSPEC) | |
1745 | return -EOPNOTSUPP; | |
1746 | ||
1747 | *ret = nl_type; | |
1748 | ||
1749 | return 0; | |
1750 | } | |
1751 | ||
d8e538ec TG |
1752 | int type_system_get_type(const NLTypeSystem *type_system, const NLType **ret, uint16_t type) { |
1753 | const NLType *nl_type; | |
1754 | ||
1755 | assert(ret); | |
846a6b3d | 1756 | assert(type_system); |
d8e538ec TG |
1757 | assert(type_system->types); |
1758 | ||
c1df8dee | 1759 | if (type >= type_system->count) |
15411c0c | 1760 | return -EOPNOTSUPP; |
d8e538ec TG |
1761 | |
1762 | nl_type = &type_system->types[type]; | |
1763 | ||
cafbc790 | 1764 | if (nl_type->type == NETLINK_TYPE_UNSPEC) |
15411c0c | 1765 | return -EOPNOTSUPP; |
d8e538ec TG |
1766 | |
1767 | *ret = nl_type; | |
1768 | ||
1769 | return 0; | |
1770 | } | |
1771 | ||
1772 | int type_system_get_type_system(const NLTypeSystem *type_system, const NLTypeSystem **ret, uint16_t type) { | |
1773 | const NLType *nl_type; | |
1774 | int r; | |
1775 | ||
1776 | assert(ret); | |
1777 | ||
1778 | r = type_system_get_type(type_system, &nl_type, type); | |
1779 | if (r < 0) | |
1780 | return r; | |
1781 | ||
c658008f | 1782 | type_get_type_system(nl_type, ret); |
d8e538ec TG |
1783 | return 0; |
1784 | } | |
1785 | ||
1786 | int type_system_get_type_system_union(const NLTypeSystem *type_system, const NLTypeSystemUnion **ret, uint16_t type) { | |
1787 | const NLType *nl_type; | |
1788 | int r; | |
1789 | ||
1790 | assert(ret); | |
1791 | ||
1792 | r = type_system_get_type(type_system, &nl_type, type); | |
1793 | if (r < 0) | |
1794 | return r; | |
1795 | ||
c658008f | 1796 | type_get_type_system_union(nl_type, ret); |
d8e538ec TG |
1797 | return 0; |
1798 | } | |
1799 | ||
1800 | int type_system_union_get_type_system(const NLTypeSystemUnion *type_system_union, const NLTypeSystem **ret, const char *key) { | |
1801 | int type; | |
1802 | ||
1803 | assert(type_system_union); | |
f8a6ca1b | 1804 | assert(type_system_union->match_type == NL_MATCH_SIBLING); |
d8e538ec TG |
1805 | assert(type_system_union->lookup); |
1806 | assert(type_system_union->type_systems); | |
1807 | assert(ret); | |
1808 | assert(key); | |
1809 | ||
1810 | type = type_system_union->lookup(key); | |
1811 | if (type < 0) | |
15411c0c | 1812 | return -EOPNOTSUPP; |
d8e538ec TG |
1813 | |
1814 | assert(type < type_system_union->num); | |
1815 | ||
1816 | *ret = &type_system_union->type_systems[type]; | |
1817 | ||
1818 | return 0; | |
1819 | } | |
4af7b60d TG |
1820 | |
1821 | int type_system_union_protocol_get_type_system(const NLTypeSystemUnion *type_system_union, const NLTypeSystem **ret, uint16_t protocol) { | |
1822 | const NLTypeSystem *type_system; | |
1823 | ||
1824 | assert(type_system_union); | |
1825 | assert(type_system_union->type_systems); | |
f8a6ca1b | 1826 | assert(type_system_union->match_type == NL_MATCH_PROTOCOL); |
4af7b60d | 1827 | assert(ret); |
4af7b60d TG |
1828 | |
1829 | if (protocol >= type_system_union->num) | |
15411c0c | 1830 | return -EOPNOTSUPP; |
4af7b60d TG |
1831 | |
1832 | type_system = &type_system_union->type_systems[protocol]; | |
e7de105c | 1833 | if (!type_system->types) |
15411c0c | 1834 | return -EOPNOTSUPP; |
4af7b60d TG |
1835 | |
1836 | *ret = type_system; | |
1837 | ||
1838 | return 0; | |
1839 | } |