]>
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 | }; | |
bfd7fb09 | 377 | |
0a827d10 | 378 | /* these strings must match the .kind entries in the kernel */ |
8ae4b6d1 | 379 | static const char* const nl_union_link_info_data_table[] = { |
d8e538ec TG |
380 | [NL_UNION_LINK_INFO_DATA_BOND] = "bond", |
381 | [NL_UNION_LINK_INFO_DATA_BRIDGE] = "bridge", | |
382 | [NL_UNION_LINK_INFO_DATA_VLAN] = "vlan", | |
383 | [NL_UNION_LINK_INFO_DATA_VETH] = "veth", | |
9e358851 | 384 | [NL_UNION_LINK_INFO_DATA_DUMMY] = "dummy", |
d8e538ec | 385 | [NL_UNION_LINK_INFO_DATA_MACVLAN] = "macvlan", |
d1312575 | 386 | [NL_UNION_LINK_INFO_DATA_MACVTAP] = "macvtap", |
c4a5ddc9 | 387 | [NL_UNION_LINK_INFO_DATA_IPVLAN] = "ipvlan", |
69c317a0 | 388 | [NL_UNION_LINK_INFO_DATA_IPVTAP] = "ipvtap", |
6ef81477 | 389 | [NL_UNION_LINK_INFO_DATA_VXLAN] = "vxlan", |
0a827d10 | 390 | [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL] = "ipip", |
8bb088c5 | 391 | [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL] = "gre", |
2266864b | 392 | [NL_UNION_LINK_INFO_DATA_ERSPAN] = "erspan", |
1af2536a | 393 | [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL] = "gretap", |
b16492f8 SS |
394 | [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL] = "ip6gre", |
395 | [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL] = "ip6gretap", | |
0a827d10 | 396 | [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL] = "sit", |
a613382b | 397 | [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL] = "vti", |
9011ce77 | 398 | [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL] = "vti6", |
855ee1a1 | 399 | [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL] = "ip6tnl", |
20897a0d | 400 | [NL_UNION_LINK_INFO_DATA_VRF] = "vrf", |
92c918b0 | 401 | [NL_UNION_LINK_INFO_DATA_VCAN] = "vcan", |
ca5e8071 | 402 | [NL_UNION_LINK_INFO_DATA_GENEVE] = "geneve", |
d6df583c | 403 | [NL_UNION_LINK_INFO_DATA_VXCAN] = "vxcan", |
e5719363 | 404 | [NL_UNION_LINK_INFO_DATA_WIREGUARD] = "wireguard", |
56e7fb50 | 405 | [NL_UNION_LINK_INFO_DATA_NETDEVSIM] = "netdevsim", |
06828bb6 | 406 | [NL_UNION_LINK_INFO_DATA_CAN] = "can", |
81962db7 | 407 | [NL_UNION_LINK_INFO_DATA_MACSEC] = "macsec", |
d61e4c5b | 408 | [NL_UNION_LINK_INFO_DATA_NLMON] = "nlmon", |
98d20a17 | 409 | [NL_UNION_LINK_INFO_DATA_XFRM] = "xfrm", |
cec1552a | 410 | [NL_UNION_LINK_INFO_DATA_IFB] = "ifb", |
af818d03 | 411 | [NL_UNION_LINK_INFO_DATA_BAREUDP] = "bareudp", |
c0267a59 | 412 | [NL_UNION_LINK_INFO_DATA_BATADV] = "batadv", |
d8e538ec TG |
413 | }; |
414 | ||
415 | DEFINE_STRING_TABLE_LOOKUP(nl_union_link_info_data, NLUnionLinkInfoData); | |
416 | ||
8ae4b6d1 | 417 | static const NLTypeSystem rtnl_link_info_data_type_systems[] = { |
92c918b0 SS |
418 | [NL_UNION_LINK_INFO_DATA_BOND] = { .count = ELEMENTSOF(rtnl_link_info_data_bond_types), |
419 | .types = rtnl_link_info_data_bond_types }, | |
420 | [NL_UNION_LINK_INFO_DATA_BRIDGE] = { .count = ELEMENTSOF(rtnl_link_info_data_bridge_types), | |
421 | .types = rtnl_link_info_data_bridge_types }, | |
422 | [NL_UNION_LINK_INFO_DATA_VLAN] = { .count = ELEMENTSOF(rtnl_link_info_data_vlan_types), | |
423 | .types = rtnl_link_info_data_vlan_types }, | |
424 | [NL_UNION_LINK_INFO_DATA_VETH] = { .count = ELEMENTSOF(rtnl_link_info_data_veth_types), | |
425 | .types = rtnl_link_info_data_veth_types }, | |
426 | [NL_UNION_LINK_INFO_DATA_MACVLAN] = { .count = ELEMENTSOF(rtnl_link_info_data_macvlan_types), | |
427 | .types = rtnl_link_info_data_macvlan_types }, | |
428 | [NL_UNION_LINK_INFO_DATA_MACVTAP] = { .count = ELEMENTSOF(rtnl_link_info_data_macvlan_types), | |
429 | .types = rtnl_link_info_data_macvlan_types }, | |
430 | [NL_UNION_LINK_INFO_DATA_IPVLAN] = { .count = ELEMENTSOF(rtnl_link_info_data_ipvlan_types), | |
431 | .types = rtnl_link_info_data_ipvlan_types }, | |
69c317a0 SS |
432 | [NL_UNION_LINK_INFO_DATA_IPVTAP] = { .count = ELEMENTSOF(rtnl_link_info_data_ipvlan_types), |
433 | .types = rtnl_link_info_data_ipvlan_types }, | |
92c918b0 SS |
434 | [NL_UNION_LINK_INFO_DATA_VXLAN] = { .count = ELEMENTSOF(rtnl_link_info_data_vxlan_types), |
435 | .types = rtnl_link_info_data_vxlan_types }, | |
436 | [NL_UNION_LINK_INFO_DATA_IPIP_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_iptun_types), | |
437 | .types = rtnl_link_info_data_iptun_types }, | |
438 | [NL_UNION_LINK_INFO_DATA_IPGRE_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_ipgre_types), | |
439 | .types = rtnl_link_info_data_ipgre_types }, | |
2266864b SS |
440 | [NL_UNION_LINK_INFO_DATA_ERSPAN] = { .count = ELEMENTSOF(rtnl_link_info_data_ipgre_types), |
441 | .types = rtnl_link_info_data_ipgre_types }, | |
c1df8dee | 442 | [NL_UNION_LINK_INFO_DATA_IPGRETAP_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_ipgre_types), |
92c918b0 SS |
443 | .types = rtnl_link_info_data_ipgre_types }, |
444 | [NL_UNION_LINK_INFO_DATA_IP6GRE_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_ipgre_types), | |
445 | .types = rtnl_link_info_data_ipgre_types }, | |
446 | [NL_UNION_LINK_INFO_DATA_IP6GRETAP_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_ipgre_types), | |
447 | .types = rtnl_link_info_data_ipgre_types }, | |
448 | [NL_UNION_LINK_INFO_DATA_SIT_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_iptun_types), | |
449 | .types = rtnl_link_info_data_iptun_types }, | |
450 | [NL_UNION_LINK_INFO_DATA_VTI_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_ipvti_types), | |
451 | .types = rtnl_link_info_data_ipvti_types }, | |
452 | [NL_UNION_LINK_INFO_DATA_VTI6_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_ipvti_types), | |
453 | .types = rtnl_link_info_data_ipvti_types }, | |
454 | [NL_UNION_LINK_INFO_DATA_IP6TNL_TUNNEL] = { .count = ELEMENTSOF(rtnl_link_info_data_ip6tnl_types), | |
455 | .types = rtnl_link_info_data_ip6tnl_types }, | |
456 | [NL_UNION_LINK_INFO_DATA_VRF] = { .count = ELEMENTSOF(rtnl_link_info_data_vrf_types), | |
457 | .types = rtnl_link_info_data_vrf_types }, | |
ca5e8071 SS |
458 | [NL_UNION_LINK_INFO_DATA_GENEVE] = { .count = ELEMENTSOF(rtnl_link_info_data_geneve_types), |
459 | .types = rtnl_link_info_data_geneve_types }, | |
d6df583c SS |
460 | [NL_UNION_LINK_INFO_DATA_VXCAN] = { .count = ELEMENTSOF(rtnl_link_info_data_vxcan_types), |
461 | .types = rtnl_link_info_data_vxcan_types }, | |
06828bb6 HP |
462 | [NL_UNION_LINK_INFO_DATA_CAN] = { .count = ELEMENTSOF(rtnl_link_info_data_can_types), |
463 | .types = rtnl_link_info_data_can_types }, | |
81962db7 SS |
464 | [NL_UNION_LINK_INFO_DATA_MACSEC] = { .count = ELEMENTSOF(rtnl_link_info_data_macsec_types), |
465 | .types = rtnl_link_info_data_macsec_types }, | |
98d20a17 | 466 | [NL_UNION_LINK_INFO_DATA_XFRM] = { .count = ELEMENTSOF(rtnl_link_info_data_xfrm_types), |
467 | .types = rtnl_link_info_data_xfrm_types }, | |
af818d03 SS |
468 | [NL_UNION_LINK_INFO_DATA_BAREUDP] = { .count = ELEMENTSOF(rtnl_link_info_data_bareudp_types), |
469 | .types = rtnl_link_info_data_bareudp_types }, | |
c0267a59 AW |
470 | [NL_UNION_LINK_INFO_DATA_BATADV] = { .count = ELEMENTSOF(rtnl_link_info_data_batadv_types), |
471 | .types = rtnl_link_info_data_batadv_types }, | |
d8e538ec TG |
472 | }; |
473 | ||
474 | static const NLTypeSystemUnion rtnl_link_info_data_type_system_union = { | |
475 | .num = _NL_UNION_LINK_INFO_DATA_MAX, | |
476 | .lookup = nl_union_link_info_data_from_string, | |
477 | .type_systems = rtnl_link_info_data_type_systems, | |
4af7b60d | 478 | .match_type = NL_MATCH_SIBLING, |
d8e538ec TG |
479 | .match = IFLA_INFO_KIND, |
480 | }; | |
481 | ||
8ae4b6d1 | 482 | static const NLType rtnl_link_info_types[] = { |
cafbc790 | 483 | [IFLA_INFO_KIND] = { .type = NETLINK_TYPE_STRING }, |
42b5f7dd | 484 | [IFLA_INFO_DATA] = { .type = NETLINK_TYPE_UNION, .type_system_union = &rtnl_link_info_data_type_system_union }, |
d8e538ec TG |
485 | /* |
486 | [IFLA_INFO_XSTATS], | |
cafbc790 DH |
487 | [IFLA_INFO_SLAVE_KIND] = { .type = NETLINK_TYPE_STRING }, |
488 | [IFLA_INFO_SLAVE_DATA] = { .type = NETLINK_TYPE_NESTED }, | |
d8e538ec TG |
489 | */ |
490 | }; | |
491 | ||
492 | static const NLTypeSystem rtnl_link_info_type_system = { | |
c1df8dee | 493 | .count = ELEMENTSOF(rtnl_link_info_types), |
d8e538ec TG |
494 | .types = rtnl_link_info_types, |
495 | }; | |
496 | ||
8ae4b6d1 | 497 | static const struct NLType rtnl_prot_info_bridge_port_types[] = { |
d3aa8b49 SS |
498 | [IFLA_BRPORT_STATE] = { .type = NETLINK_TYPE_U8 }, |
499 | [IFLA_BRPORT_COST] = { .type = NETLINK_TYPE_U32 }, | |
500 | [IFLA_BRPORT_PRIORITY] = { .type = NETLINK_TYPE_U16 }, | |
501 | [IFLA_BRPORT_MODE] = { .type = NETLINK_TYPE_U8 }, | |
502 | [IFLA_BRPORT_GUARD] = { .type = NETLINK_TYPE_U8 }, | |
503 | [IFLA_BRPORT_PROTECT] = { .type = NETLINK_TYPE_U8 }, | |
504 | [IFLA_BRPORT_FAST_LEAVE] = { .type = NETLINK_TYPE_U8 }, | |
505 | [IFLA_BRPORT_LEARNING] = { .type = NETLINK_TYPE_U8 }, | |
506 | [IFLA_BRPORT_UNICAST_FLOOD] = { .type = NETLINK_TYPE_U8 }, | |
507 | [IFLA_BRPORT_PROXYARP] = { .type = NETLINK_TYPE_U8 }, | |
508 | [IFLA_BRPORT_LEARNING_SYNC] = { .type = NETLINK_TYPE_U8 }, | |
509 | [IFLA_BRPORT_PROXYARP_WIFI] = { .type = NETLINK_TYPE_U8 }, | |
510 | [IFLA_BRPORT_ROOT_ID] = { .type = NETLINK_TYPE_U8 }, | |
511 | [IFLA_BRPORT_BRIDGE_ID] = { .type = NETLINK_TYPE_U8 }, | |
512 | [IFLA_BRPORT_DESIGNATED_PORT] = { .type = NETLINK_TYPE_U16 }, | |
513 | [IFLA_BRPORT_DESIGNATED_COST] = { .type = NETLINK_TYPE_U16 }, | |
514 | [IFLA_BRPORT_ID] = { .type = NETLINK_TYPE_U16 }, | |
515 | [IFLA_BRPORT_NO] = { .type = NETLINK_TYPE_U16 }, | |
516 | [IFLA_BRPORT_TOPOLOGY_CHANGE_ACK] = { .type = NETLINK_TYPE_U8 }, | |
517 | [IFLA_BRPORT_CONFIG_PENDING] = { .type = NETLINK_TYPE_U8 }, | |
518 | [IFLA_BRPORT_MESSAGE_AGE_TIMER] = { .type = NETLINK_TYPE_U64 }, | |
519 | [IFLA_BRPORT_FORWARD_DELAY_TIMER] = { .type = NETLINK_TYPE_U64 }, | |
520 | [IFLA_BRPORT_HOLD_TIMER] = { .type = NETLINK_TYPE_U64 }, | |
521 | [IFLA_BRPORT_FLUSH] = { .type = NETLINK_TYPE_U8 }, | |
522 | [IFLA_BRPORT_MULTICAST_ROUTER] = { .type = NETLINK_TYPE_U8 }, | |
523 | [IFLA_BRPORT_PAD] = { .type = NETLINK_TYPE_U8 }, | |
524 | [IFLA_BRPORT_MCAST_FLOOD] = { .type = NETLINK_TYPE_U8 }, | |
525 | [IFLA_BRPORT_MCAST_TO_UCAST] = { .type = NETLINK_TYPE_U8 }, | |
526 | [IFLA_BRPORT_VLAN_TUNNEL] = { .type = NETLINK_TYPE_U8 }, | |
527 | [IFLA_BRPORT_BCAST_FLOOD] = { .type = NETLINK_TYPE_U8 }, | |
528 | [IFLA_BRPORT_GROUP_FWD_MASK] = { .type = NETLINK_TYPE_U16 }, | |
529 | [IFLA_BRPORT_NEIGH_SUPPRESS] = { .type = NETLINK_TYPE_U8 }, | |
530 | [IFLA_BRPORT_ISOLATED] = { .type = NETLINK_TYPE_U8 }, | |
531 | [IFLA_BRPORT_BACKUP_PORT] = { .type = NETLINK_TYPE_U32 }, | |
d0159fdc SS |
532 | }; |
533 | ||
8ae4b6d1 | 534 | static const NLTypeSystem rtnl_prot_info_type_systems[] = { |
c1df8dee | 535 | [AF_BRIDGE] = { .count = ELEMENTSOF(rtnl_prot_info_bridge_port_types), |
4af7b60d TG |
536 | .types = rtnl_prot_info_bridge_port_types }, |
537 | }; | |
538 | ||
539 | static const NLTypeSystemUnion rtnl_prot_info_type_system_union = { | |
540 | .num = AF_MAX, | |
541 | .type_systems = rtnl_prot_info_type_systems, | |
542 | .match_type = NL_MATCH_PROTOCOL, | |
d0159fdc SS |
543 | }; |
544 | ||
8ae4b6d1 | 545 | static const struct NLType rtnl_af_spec_inet6_types[] = { |
cafbc790 | 546 | [IFLA_INET6_FLAGS] = { .type = NETLINK_TYPE_U32 }, |
c149ae08 TG |
547 | /* |
548 | IFLA_INET6_CONF, | |
549 | IFLA_INET6_STATS, | |
550 | IFLA_INET6_MCAST, | |
551 | IFLA_INET6_CACHEINFO, | |
552 | IFLA_INET6_ICMP6STATS, | |
553 | */ | |
cafbc790 DH |
554 | [IFLA_INET6_TOKEN] = { .type = NETLINK_TYPE_IN_ADDR }, |
555 | [IFLA_INET6_ADDR_GEN_MODE] = { .type = NETLINK_TYPE_U8 }, | |
c149ae08 TG |
556 | }; |
557 | ||
73cb1c14 | 558 | static const NLTypeSystem rtnl_af_spec_inet6_type_system = { |
c1df8dee | 559 | .count = ELEMENTSOF(rtnl_af_spec_inet6_types), |
73cb1c14 | 560 | .types = rtnl_af_spec_inet6_types, |
c149ae08 TG |
561 | }; |
562 | ||
bfd7fb09 | 563 | static const NLType rtnl_af_spec_unspec_types[] = { |
cafbc790 | 564 | [AF_INET6] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_af_spec_inet6_type_system }, |
73cb1c14 TG |
565 | }; |
566 | ||
bfd7fb09 YW |
567 | static const NLType rtnl_af_spec_bridge_types[] = { |
568 | [IFLA_BRIDGE_FLAGS] = { .type = NETLINK_TYPE_U16 }, | |
569 | [IFLA_BRIDGE_VLAN_INFO] = { .size = sizeof(struct bridge_vlan_info) }, | |
570 | }; | |
571 | ||
572 | static const NLTypeSystem rtnl_af_spec_type_systems[] = { | |
573 | [AF_UNSPEC] = { .count = ELEMENTSOF(rtnl_af_spec_unspec_types), | |
574 | .types = rtnl_af_spec_unspec_types }, | |
575 | [AF_BRIDGE] = { .count = ELEMENTSOF(rtnl_af_spec_bridge_types), | |
576 | .types = rtnl_af_spec_bridge_types }, | |
577 | }; | |
578 | ||
579 | static const NLTypeSystemUnion rtnl_af_spec_type_system_union = { | |
580 | .num = AF_MAX, | |
581 | .type_systems = rtnl_af_spec_type_systems, | |
582 | .match_type = NL_MATCH_PROTOCOL, | |
c149ae08 TG |
583 | }; |
584 | ||
ffeb16f5 YW |
585 | static const NLType rtnl_prop_list_types[] = { |
586 | [IFLA_ALT_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = ALTIFNAMSIZ - 1 }, | |
587 | }; | |
588 | ||
589 | static const NLTypeSystem rtnl_prop_list_type_system = { | |
590 | .count = ELEMENTSOF(rtnl_prop_list_types), | |
591 | .types = rtnl_prop_list_types, | |
592 | }; | |
593 | ||
5908ddd7 SS |
594 | static const NLType rtnl_vf_vlan_list_types[] = { |
595 | [IFLA_VF_VLAN_INFO] = { .size = sizeof(struct ifla_vf_vlan_info) }, | |
596 | }; | |
597 | ||
598 | static const NLTypeSystem rtnl_vf_vlan_type_system = { | |
599 | .count = ELEMENTSOF(rtnl_vf_vlan_list_types), | |
600 | .types = rtnl_vf_vlan_list_types, | |
601 | }; | |
602 | ||
603 | static const NLType rtnl_vf_vlan_info_types[] = { | |
604 | [IFLA_VF_MAC] = { .size = sizeof(struct ifla_vf_mac) }, | |
605 | [IFLA_VF_VLAN] = { .size = sizeof(struct ifla_vf_vlan) }, | |
606 | [IFLA_VF_VLAN_LIST] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_vf_vlan_type_system}, | |
607 | [IFLA_VF_TX_RATE] = { .size = sizeof(struct ifla_vf_tx_rate) }, | |
608 | [IFLA_VF_SPOOFCHK] = { .size = sizeof(struct ifla_vf_spoofchk) }, | |
609 | [IFLA_VF_RATE] = { .size = sizeof(struct ifla_vf_rate) }, | |
610 | [IFLA_VF_LINK_STATE] = { .size = sizeof(struct ifla_vf_link_state) }, | |
611 | [IFLA_VF_RSS_QUERY_EN] = { .size = sizeof(struct ifla_vf_rss_query_en) }, | |
612 | [IFLA_VF_TRUST] = { .size = sizeof(struct ifla_vf_trust) }, | |
613 | [IFLA_VF_IB_NODE_GUID] = { .size = sizeof(struct ifla_vf_guid) }, | |
614 | [IFLA_VF_IB_PORT_GUID] = { .size = sizeof(struct ifla_vf_guid) }, | |
615 | }; | |
616 | ||
617 | static const NLTypeSystem rtnl_vf_vlan_info_type_system = { | |
618 | .count = ELEMENTSOF(rtnl_vf_vlan_info_types), | |
619 | .types = rtnl_vf_vlan_info_types, | |
620 | }; | |
621 | ||
622 | static const NLType rtnl_link_io_srv_types[] = { | |
623 | [IFLA_VF_INFO] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_vf_vlan_info_type_system }, | |
624 | }; | |
625 | ||
626 | static const NLTypeSystem rtnl_io_srv_type_system = { | |
627 | .count = ELEMENTSOF(rtnl_link_io_srv_types), | |
628 | .types = rtnl_link_io_srv_types, | |
629 | }; | |
630 | ||
8ae4b6d1 | 631 | static const NLType rtnl_link_types[] = { |
6e74cade ZJS |
632 | [IFLA_ADDRESS] = { .type = NETLINK_TYPE_ETHER_ADDR }, |
633 | [IFLA_BROADCAST] = { .type = NETLINK_TYPE_ETHER_ADDR }, | |
634 | [IFLA_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ - 1 }, | |
cafbc790 DH |
635 | [IFLA_MTU] = { .type = NETLINK_TYPE_U32 }, |
636 | [IFLA_LINK] = { .type = NETLINK_TYPE_U32 }, | |
83949527 | 637 | [IFLA_QDISC] = { .type = NETLINK_TYPE_STRING }, |
c095e5b0 YW |
638 | [IFLA_STATS] = { .size = sizeof(struct rtnl_link_stats) }, |
639 | /* | |
d8e538ec TG |
640 | [IFLA_COST], |
641 | [IFLA_PRIORITY], | |
642 | */ | |
cafbc790 | 643 | [IFLA_MASTER] = { .type = NETLINK_TYPE_U32 }, |
d8e538ec TG |
644 | /* |
645 | [IFLA_WIRELESS], | |
d8e538ec | 646 | */ |
cafbc790 DH |
647 | [IFLA_PROTINFO] = { .type = NETLINK_TYPE_UNION, .type_system_union = &rtnl_prot_info_type_system_union }, |
648 | [IFLA_TXQLEN] = { .type = NETLINK_TYPE_U32 }, | |
d8e538ec TG |
649 | /* |
650 | [IFLA_MAP] = { .len = sizeof(struct rtnl_link_ifmap) }, | |
651 | */ | |
cafbc790 DH |
652 | [IFLA_WEIGHT] = { .type = NETLINK_TYPE_U32 }, |
653 | [IFLA_OPERSTATE] = { .type = NETLINK_TYPE_U8 }, | |
654 | [IFLA_LINKMODE] = { .type = NETLINK_TYPE_U8 }, | |
655 | [IFLA_LINKINFO] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_info_type_system }, | |
656 | [IFLA_NET_NS_PID] = { .type = NETLINK_TYPE_U32 }, | |
657 | [IFLA_IFALIAS] = { .type = NETLINK_TYPE_STRING, .size = IFALIASZ - 1 }, | |
5908ddd7 SS |
658 | [IFLA_NUM_VF] = { .type = NETLINK_TYPE_U32 }, |
659 | [IFLA_VFINFO_LIST] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_io_srv_type_system }, | |
c095e5b0 YW |
660 | [IFLA_STATS64] = { .size = sizeof(struct rtnl_link_stats64) }, |
661 | /* | |
cafbc790 DH |
662 | [IFLA_VF_PORTS] = { .type = NETLINK_TYPE_NESTED }, |
663 | [IFLA_PORT_SELF] = { .type = NETLINK_TYPE_NESTED }, | |
c149ae08 | 664 | */ |
bfd7fb09 | 665 | [IFLA_AF_SPEC] = { .type = NETLINK_TYPE_UNION, .type_system_union = &rtnl_af_spec_type_system_union }, |
c149ae08 | 666 | /* |
d8e538ec TG |
667 | [IFLA_VF_PORTS], |
668 | [IFLA_PORT_SELF], | |
d8e538ec | 669 | */ |
cafbc790 DH |
670 | [IFLA_GROUP] = { .type = NETLINK_TYPE_U32 }, |
671 | [IFLA_NET_NS_FD] = { .type = NETLINK_TYPE_U32 }, | |
672 | [IFLA_EXT_MASK] = { .type = NETLINK_TYPE_U32 }, | |
673 | [IFLA_PROMISCUITY] = { .type = NETLINK_TYPE_U32 }, | |
674 | [IFLA_NUM_TX_QUEUES] = { .type = NETLINK_TYPE_U32 }, | |
675 | [IFLA_NUM_RX_QUEUES] = { .type = NETLINK_TYPE_U32 }, | |
ba423af6 SS |
676 | [IFLA_GSO_MAX_SEGS] = { .type = NETLINK_TYPE_U32 }, |
677 | [IFLA_GSO_MAX_SIZE] = { .type = NETLINK_TYPE_U32 }, | |
cafbc790 | 678 | [IFLA_CARRIER] = { .type = NETLINK_TYPE_U8 }, |
d8e538ec | 679 | /* |
cafbc790 | 680 | [IFLA_PHYS_PORT_ID] = { .type = NETLINK_TYPE_BINARY, .len = MAX_PHYS_PORT_ID_LEN }, |
d8e538ec | 681 | */ |
ffeb16f5 YW |
682 | [IFLA_MIN_MTU] = { .type = NETLINK_TYPE_U32 }, |
683 | [IFLA_MAX_MTU] = { .type = NETLINK_TYPE_U32 }, | |
684 | [IFLA_PROP_LIST] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_prop_list_type_system }, | |
b04c5e51 | 685 | [IFLA_ALT_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = ALTIFNAMSIZ - 1 }, |
d8e538ec TG |
686 | }; |
687 | ||
688 | static const NLTypeSystem rtnl_link_type_system = { | |
c1df8dee | 689 | .count = ELEMENTSOF(rtnl_link_types), |
d8e538ec TG |
690 | .types = rtnl_link_types, |
691 | }; | |
692 | ||
de79f906 LP |
693 | /* IFA_FLAGS was defined in kernel 3.14, but we still support older |
694 | * kernels where IFA_MAX is lower. */ | |
8ae4b6d1 | 695 | static const NLType rtnl_address_types[] = { |
cafbc790 DH |
696 | [IFA_ADDRESS] = { .type = NETLINK_TYPE_IN_ADDR }, |
697 | [IFA_LOCAL] = { .type = NETLINK_TYPE_IN_ADDR }, | |
698 | [IFA_LABEL] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ - 1 }, | |
0e7bb99f YW |
699 | [IFA_BROADCAST] = { .type = NETLINK_TYPE_IN_ADDR }, |
700 | [IFA_ANYCAST] = { .type = NETLINK_TYPE_IN_ADDR }, | |
cafbc790 | 701 | [IFA_CACHEINFO] = { .type = NETLINK_TYPE_CACHE_INFO, .size = sizeof(struct ifa_cacheinfo) }, |
0e7bb99f | 702 | [IFA_MULTICAST] = { .type = NETLINK_TYPE_IN_ADDR }, |
cafbc790 | 703 | [IFA_FLAGS] = { .type = NETLINK_TYPE_U32 }, |
0e7bb99f YW |
704 | [IFA_RT_PRIORITY] = { .type = NETLINK_TYPE_U32 }, |
705 | [IFA_TARGET_NETNSID] = { .type = NETLINK_TYPE_S32 }, | |
d8e538ec TG |
706 | }; |
707 | ||
708 | static const NLTypeSystem rtnl_address_type_system = { | |
c1df8dee | 709 | .count = ELEMENTSOF(rtnl_address_types), |
d8e538ec TG |
710 | .types = rtnl_address_types, |
711 | }; | |
712 | ||
d6fceaf1 SS |
713 | /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */ |
714 | ||
715 | static const NLType rtnl_route_metrics_types[] = { | |
f4679bcb SS |
716 | [RTAX_MTU] = { .type = NETLINK_TYPE_U32 }, |
717 | [RTAX_WINDOW] = { .type = NETLINK_TYPE_U32 }, | |
718 | [RTAX_RTT] = { .type = NETLINK_TYPE_U32 }, | |
719 | [RTAX_RTTVAR] = { .type = NETLINK_TYPE_U32 }, | |
720 | [RTAX_SSTHRESH] = { .type = NETLINK_TYPE_U32 }, | |
721 | [RTAX_CWND] = { .type = NETLINK_TYPE_U32 }, | |
722 | [RTAX_ADVMSS] = { .type = NETLINK_TYPE_U32 }, | |
723 | [RTAX_REORDERING] = { .type = NETLINK_TYPE_U32 }, | |
724 | [RTAX_HOPLIMIT] = { .type = NETLINK_TYPE_U32 }, | |
725 | [RTAX_INITCWND] = { .type = NETLINK_TYPE_U32 }, | |
726 | [RTAX_FEATURES] = { .type = NETLINK_TYPE_U32 }, | |
727 | [RTAX_RTO_MIN] = { .type = NETLINK_TYPE_U32 }, | |
728 | [RTAX_INITRWND] = { .type = NETLINK_TYPE_U32 }, | |
729 | [RTAX_QUICKACK] = { .type = NETLINK_TYPE_U32 }, | |
730 | [RTAX_CC_ALGO] = { .type = NETLINK_TYPE_U32 }, | |
731 | [RTAX_FASTOPEN_NO_COOKIE] = { .type = NETLINK_TYPE_U32 }, | |
d6fceaf1 SS |
732 | }; |
733 | ||
734 | static const NLTypeSystem rtnl_route_metrics_type_system = { | |
735 | .count = ELEMENTSOF(rtnl_route_metrics_types), | |
736 | .types = rtnl_route_metrics_types, | |
737 | }; | |
738 | ||
8ae4b6d1 | 739 | static const NLType rtnl_route_types[] = { |
cafbc790 DH |
740 | [RTA_DST] = { .type = NETLINK_TYPE_IN_ADDR }, /* 6? */ |
741 | [RTA_SRC] = { .type = NETLINK_TYPE_IN_ADDR }, /* 6? */ | |
742 | [RTA_IIF] = { .type = NETLINK_TYPE_U32 }, | |
743 | [RTA_OIF] = { .type = NETLINK_TYPE_U32 }, | |
744 | [RTA_GATEWAY] = { .type = NETLINK_TYPE_IN_ADDR }, | |
745 | [RTA_PRIORITY] = { .type = NETLINK_TYPE_U32 }, | |
746 | [RTA_PREFSRC] = { .type = NETLINK_TYPE_IN_ADDR }, /* 6? */ | |
d6fceaf1 | 747 | [RTA_METRICS] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_metrics_type_system}, |
cb7e98ab | 748 | [RTA_MULTIPATH] = { .size = sizeof(struct rtnexthop) }, |
cafbc790 | 749 | [RTA_FLOW] = { .type = NETLINK_TYPE_U32 }, /* 6? */ |
cb7e98ab SS |
750 | [RTA_CACHEINFO] = { .size = sizeof(struct rta_cacheinfo) }, |
751 | [RTA_TABLE] = { .type = NETLINK_TYPE_U32 }, | |
752 | [RTA_MARK] = { .type = NETLINK_TYPE_U32 }, | |
753 | [RTA_MFC_STATS] = { .type = NETLINK_TYPE_U64 }, | |
2c59a8a6 | 754 | [RTA_VIA] = { /* See struct rtvia */ }, |
cb7e98ab | 755 | [RTA_NEWDST] = { .type = NETLINK_TYPE_U32 }, |
b69015ef | 756 | [RTA_PREF] = { .type = NETLINK_TYPE_U8 }, |
cb7e98ab SS |
757 | [RTA_ENCAP_TYPE] = { .type = NETLINK_TYPE_U16 }, |
758 | [RTA_ENCAP] = { .type = NETLINK_TYPE_NESTED }, /* Multiple type systems i.e. LWTUNNEL_ENCAP_MPLS/LWTUNNEL_ENCAP_IP/LWTUNNEL_ENCAP_ILA etc... */ | |
f5b7deb9 | 759 | [RTA_EXPIRES] = { .type = NETLINK_TYPE_U32 }, |
cb7e98ab SS |
760 | [RTA_UID] = { .type = NETLINK_TYPE_U32 }, |
761 | [RTA_TTL_PROPAGATE] = { .type = NETLINK_TYPE_U8 }, | |
762 | [RTA_IP_PROTO] = { .type = NETLINK_TYPE_U8 }, | |
763 | [RTA_SPORT] = { .type = NETLINK_TYPE_U16 }, | |
764 | [RTA_DPORT] = { .type = NETLINK_TYPE_U16 }, | |
f5b7deb9 | 765 | [RTA_NH_ID] = { .type = NETLINK_TYPE_U32 }, |
d8e538ec TG |
766 | }; |
767 | ||
768 | static const NLTypeSystem rtnl_route_type_system = { | |
c1df8dee | 769 | .count = ELEMENTSOF(rtnl_route_types), |
d8e538ec TG |
770 | .types = rtnl_route_types, |
771 | }; | |
772 | ||
8ae4b6d1 | 773 | static const NLType rtnl_neigh_types[] = { |
cafbc790 | 774 | [NDA_DST] = { .type = NETLINK_TYPE_IN_ADDR }, |
1647f241 | 775 | [NDA_LLADDR] = { /* struct ether_addr, struct in_addr, or struct in6_addr */ }, |
cafbc790 DH |
776 | [NDA_CACHEINFO] = { .type = NETLINK_TYPE_CACHE_INFO, .size = sizeof(struct nda_cacheinfo) }, |
777 | [NDA_PROBES] = { .type = NETLINK_TYPE_U32 }, | |
778 | [NDA_VLAN] = { .type = NETLINK_TYPE_U16 }, | |
779 | [NDA_PORT] = { .type = NETLINK_TYPE_U16 }, | |
780 | [NDA_VNI] = { .type = NETLINK_TYPE_U32 }, | |
781 | [NDA_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
e559b384 TG |
782 | }; |
783 | ||
784 | static const NLTypeSystem rtnl_neigh_type_system = { | |
c1df8dee | 785 | .count = ELEMENTSOF(rtnl_neigh_types), |
e559b384 TG |
786 | .types = rtnl_neigh_types, |
787 | }; | |
788 | ||
30746d60 SS |
789 | static const NLType rtnl_addrlabel_types[] = { |
790 | [IFAL_ADDRESS] = { .type = NETLINK_TYPE_IN_ADDR, .size = sizeof(struct in6_addr) }, | |
791 | [IFAL_LABEL] = { .type = NETLINK_TYPE_U32 }, | |
792 | }; | |
793 | ||
794 | static const NLTypeSystem rtnl_addrlabel_type_system = { | |
795 | .count = ELEMENTSOF(rtnl_addrlabel_types), | |
796 | .types = rtnl_addrlabel_types, | |
797 | }; | |
798 | ||
bce67bbe SS |
799 | static const NLType rtnl_routing_policy_rule_types[] = { |
800 | [FRA_DST] = { .type = NETLINK_TYPE_IN_ADDR }, | |
801 | [FRA_SRC] = { .type = NETLINK_TYPE_IN_ADDR }, | |
802 | [FRA_IIFNAME] = { .type = NETLINK_TYPE_STRING }, | |
8abd60c1 | 803 | [FRA_GOTO] = { .type = NETLINK_TYPE_U32 }, |
bce67bbe SS |
804 | [FRA_PRIORITY] = { .type = NETLINK_TYPE_U32 }, |
805 | [FRA_FWMARK] = { .type = NETLINK_TYPE_U32 }, | |
806 | [FRA_FLOW] = { .type = NETLINK_TYPE_U32 }, | |
202aa159 | 807 | [FRA_TUN_ID] = { .type = NETLINK_TYPE_U64 }, |
bce67bbe SS |
808 | [FRA_SUPPRESS_IFGROUP] = { .type = NETLINK_TYPE_U32 }, |
809 | [FRA_SUPPRESS_PREFIXLEN] = { .type = NETLINK_TYPE_U32 }, | |
810 | [FRA_TABLE] = { .type = NETLINK_TYPE_U32 }, | |
811 | [FRA_FWMASK] = { .type = NETLINK_TYPE_U32 }, | |
812 | [FRA_OIFNAME] = { .type = NETLINK_TYPE_STRING }, | |
813 | [FRA_PAD] = { .type = NETLINK_TYPE_U32 }, | |
a15ff62d | 814 | [FRA_L3MDEV] = { .type = NETLINK_TYPE_U8 }, |
bce67bbe | 815 | [FRA_UID_RANGE] = { .size = sizeof(struct fib_rule_uid_range) }, |
926062f0 SS |
816 | [FRA_PROTOCOL] = { .type = NETLINK_TYPE_U8 }, |
817 | [FRA_IP_PROTO] = { .type = NETLINK_TYPE_U8 }, | |
818 | [FRA_SPORT_RANGE] = { .size = sizeof(struct fib_rule_port_range) }, | |
819 | [FRA_DPORT_RANGE] = { .size = sizeof(struct fib_rule_port_range) }, | |
bce67bbe SS |
820 | }; |
821 | ||
822 | static const NLTypeSystem rtnl_routing_policy_rule_type_system = { | |
823 | .count = ELEMENTSOF(rtnl_routing_policy_rule_types), | |
824 | .types = rtnl_routing_policy_rule_types, | |
825 | }; | |
826 | ||
c16c7808 SS |
827 | static const NLType rtnl_nexthop_types[] = { |
828 | [NHA_ID] = { .type = NETLINK_TYPE_U32 }, | |
4684ec5e YW |
829 | [NHA_GROUP] = { /* array of struct nexthop_grp */ }, |
830 | [NHA_GROUP_TYPE] = { .type = NETLINK_TYPE_U16 }, | |
831 | [NHA_BLACKHOLE] = { .type = NETLINK_TYPE_FLAG }, | |
c16c7808 SS |
832 | [NHA_OIF] = { .type = NETLINK_TYPE_U32 }, |
833 | [NHA_GATEWAY] = { .type = NETLINK_TYPE_IN_ADDR }, | |
4684ec5e YW |
834 | [NHA_ENCAP_TYPE] = { .type = NETLINK_TYPE_U16 }, |
835 | [NHA_ENCAP] = { .type = NETLINK_TYPE_NESTED }, | |
836 | [NHA_GROUPS] = { .type = NETLINK_TYPE_FLAG }, | |
837 | [NHA_MASTER] = { .type = NETLINK_TYPE_U32 }, | |
838 | [NHA_FDB] = { .type = NETLINK_TYPE_FLAG }, | |
c16c7808 SS |
839 | }; |
840 | ||
841 | static const NLTypeSystem rtnl_nexthop_type_system = { | |
842 | .count = ELEMENTSOF(rtnl_nexthop_types), | |
843 | .types = rtnl_nexthop_types, | |
844 | }; | |
845 | ||
ad8352f4 SS |
846 | static const NLType rtnl_tca_option_data_cake_types[] = { |
847 | [TCA_CAKE_BASE_RATE64] = { .type = NETLINK_TYPE_U64 }, | |
848 | [TCA_CAKE_OVERHEAD] = { .type = NETLINK_TYPE_S32 }, | |
849 | [TCA_CAKE_MPU] = { .type = NETLINK_TYPE_U32 }, | |
850 | }; | |
851 | ||
a9a5d632 | 852 | static const NLType rtnl_tca_option_data_codel_types[] = { |
b078e528 YW |
853 | [TCA_CODEL_TARGET] = { .type = NETLINK_TYPE_U32 }, |
854 | [TCA_CODEL_LIMIT] = { .type = NETLINK_TYPE_U32 }, | |
855 | [TCA_CODEL_INTERVAL] = { .type = NETLINK_TYPE_U32 }, | |
856 | [TCA_CODEL_ECN] = { .type = NETLINK_TYPE_U32 }, | |
857 | [TCA_CODEL_CE_THRESHOLD] = { .type = NETLINK_TYPE_U32 }, | |
a9a5d632 SS |
858 | }; |
859 | ||
5c21b46e SS |
860 | static const NLType rtnl_tca_option_data_drr_types[] = { |
861 | [TCA_DRR_QUANTUM] = { .type = NETLINK_TYPE_U32 }, | |
862 | }; | |
863 | ||
4dec9218 YW |
864 | static const NLType rtnl_tca_option_data_ets_quanta_types[] = { |
865 | [TCA_ETS_QUANTA_BAND] = { .type = NETLINK_TYPE_U32, }, | |
866 | }; | |
867 | ||
868 | static const NLTypeSystem rtnl_tca_option_data_ets_quanta_type_system = { | |
869 | .count = ELEMENTSOF(rtnl_tca_option_data_ets_quanta_types), | |
870 | .types = rtnl_tca_option_data_ets_quanta_types, | |
871 | }; | |
872 | ||
873 | static const NLType rtnl_tca_option_data_ets_prio_types[] = { | |
874 | [TCA_ETS_PRIOMAP_BAND] = { .type = NETLINK_TYPE_U8, }, | |
875 | }; | |
876 | ||
877 | static const NLTypeSystem rtnl_tca_option_data_ets_prio_type_system = { | |
878 | .count = ELEMENTSOF(rtnl_tca_option_data_ets_prio_types), | |
879 | .types = rtnl_tca_option_data_ets_prio_types, | |
880 | }; | |
881 | ||
882 | static const NLType rtnl_tca_option_data_ets_types[] = { | |
883 | [TCA_ETS_NBANDS] = { .type = NETLINK_TYPE_U8 }, | |
884 | [TCA_ETS_NSTRICT] = { .type = NETLINK_TYPE_U8 }, | |
885 | [TCA_ETS_QUANTA] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_option_data_ets_quanta_type_system }, | |
886 | [TCA_ETS_PRIOMAP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_option_data_ets_prio_type_system }, | |
887 | [TCA_ETS_QUANTA_BAND] = { .type = NETLINK_TYPE_U32 }, | |
888 | }; | |
889 | ||
eb34f4b3 YW |
890 | static const NLType rtnl_tca_option_data_fq_types[] = { |
891 | [TCA_FQ_PLIMIT] = { .type = NETLINK_TYPE_U32 }, | |
892 | [TCA_FQ_FLOW_PLIMIT] = { .type = NETLINK_TYPE_U32 }, | |
893 | [TCA_FQ_QUANTUM] = { .type = NETLINK_TYPE_U32 }, | |
894 | [TCA_FQ_INITIAL_QUANTUM] = { .type = NETLINK_TYPE_U32 }, | |
895 | [TCA_FQ_RATE_ENABLE] = { .type = NETLINK_TYPE_U32 }, | |
896 | [TCA_FQ_FLOW_DEFAULT_RATE] = { .type = NETLINK_TYPE_U32 }, | |
897 | [TCA_FQ_FLOW_MAX_RATE] = { .type = NETLINK_TYPE_U32 }, | |
898 | [TCA_FQ_BUCKETS_LOG] = { .type = NETLINK_TYPE_U32 }, | |
899 | [TCA_FQ_FLOW_REFILL_DELAY] = { .type = NETLINK_TYPE_U32 }, | |
900 | [TCA_FQ_LOW_RATE_THRESHOLD] = { .type = NETLINK_TYPE_U32 }, | |
901 | [TCA_FQ_CE_THRESHOLD] = { .type = NETLINK_TYPE_U32 }, | |
e83562e5 | 902 | [TCA_FQ_ORPHAN_MASK] = { .type = NETLINK_TYPE_U32 }, |
42b5f7dd YW |
903 | }; |
904 | ||
905 | static const NLType rtnl_tca_option_data_fq_codel_types[] = { | |
906 | [TCA_FQ_CODEL_TARGET] = { .type = NETLINK_TYPE_U32 }, | |
907 | [TCA_FQ_CODEL_LIMIT] = { .type = NETLINK_TYPE_U32 }, | |
908 | [TCA_FQ_CODEL_INTERVAL] = { .type = NETLINK_TYPE_U32 }, | |
909 | [TCA_FQ_CODEL_ECN] = { .type = NETLINK_TYPE_U32 }, | |
910 | [TCA_FQ_CODEL_FLOWS] = { .type = NETLINK_TYPE_U32 }, | |
911 | [TCA_FQ_CODEL_QUANTUM] = { .type = NETLINK_TYPE_U32 }, | |
912 | [TCA_FQ_CODEL_CE_THRESHOLD] = { .type = NETLINK_TYPE_U32 }, | |
913 | [TCA_FQ_CODEL_DROP_BATCH_SIZE] = { .type = NETLINK_TYPE_U32 }, | |
914 | [TCA_FQ_CODEL_MEMORY_LIMIT] = { .type = NETLINK_TYPE_U32 }, | |
915 | }; | |
916 | ||
3428b32a SS |
917 | static const NLType rtnl_tca_option_data_fq_pie_types[] = { |
918 | [TCA_FQ_PIE_LIMIT] = { .type = NETLINK_TYPE_U32 }, | |
919 | }; | |
920 | ||
609e8340 SS |
921 | static const NLType rtnl_tca_option_data_gred_types[] = { |
922 | [TCA_GRED_DPS] = { .size = sizeof(struct tc_gred_sopt) }, | |
923 | }; | |
924 | ||
7e16f84e SS |
925 | static const NLType rtnl_tca_option_data_hhf_types[] = { |
926 | [TCA_HHF_BACKLOG_LIMIT] = { .type = NETLINK_TYPE_U32 }, | |
927 | }; | |
928 | ||
b934ac3d | 929 | static const NLType rtnl_tca_option_data_htb_types[] = { |
19f86a63 YW |
930 | [TCA_HTB_PARMS] = { .size = sizeof(struct tc_htb_opt) }, |
931 | [TCA_HTB_INIT] = { .size = sizeof(struct tc_htb_glob) }, | |
932 | [TCA_HTB_CTAB] = { .size = TC_RTAB_SIZE }, | |
933 | [TCA_HTB_RTAB] = { .size = TC_RTAB_SIZE }, | |
934 | [TCA_HTB_RATE64] = { .type = NETLINK_TYPE_U64 }, | |
935 | [TCA_HTB_CEIL64] = { .type = NETLINK_TYPE_U64 }, | |
b934ac3d YW |
936 | }; |
937 | ||
55d22831 SS |
938 | static const NLType rtnl_tca_option_data_pie_types[] = { |
939 | [TCA_PIE_LIMIT] = { .type = NETLINK_TYPE_U32 }, | |
940 | }; | |
941 | ||
c33f1e5a SS |
942 | static const NLType rtnl_tca_option_data_qfq_types[] = { |
943 | [TCA_QFQ_WEIGHT] = { .type = NETLINK_TYPE_U32 }, | |
944 | [TCA_QFQ_LMAX] = { .type = NETLINK_TYPE_U32 }, | |
945 | }; | |
946 | ||
982998b0 SS |
947 | static const NLType rtnl_tca_option_data_sfb_types[] = { |
948 | [TCA_SFB_PARMS] = { .size = sizeof(struct tc_sfb_qopt) }, | |
949 | }; | |
950 | ||
eb34f4b3 YW |
951 | static const NLType rtnl_tca_option_data_tbf_types[] = { |
952 | [TCA_TBF_PARMS] = { .size = sizeof(struct tc_tbf_qopt) }, | |
953 | [TCA_TBF_RTAB] = { .size = TC_RTAB_SIZE }, | |
954 | [TCA_TBF_PTAB] = { .size = TC_RTAB_SIZE }, | |
955 | [TCA_TBF_RATE64] = { .type = NETLINK_TYPE_U64 }, | |
956 | [TCA_TBF_PRATE64] = { .type = NETLINK_TYPE_U64 }, | |
957 | [TCA_TBF_BURST] = { .type = NETLINK_TYPE_U32 }, | |
958 | [TCA_TBF_PBURST] = { .type = NETLINK_TYPE_U32 }, | |
959 | }; | |
960 | ||
42b5f7dd | 961 | static const char* const nl_union_tca_option_data_table[] = { |
ad8352f4 | 962 | [NL_UNION_TCA_OPTION_DATA_CAKE] = "cake", |
a9a5d632 | 963 | [NL_UNION_TCA_OPTION_DATA_CODEL] = "codel", |
5c21b46e | 964 | [NL_UNION_TCA_OPTION_DATA_DRR] = "drr", |
4dec9218 | 965 | [NL_UNION_TCA_OPTION_DATA_ETS] = "ets", |
eb34f4b3 | 966 | [NL_UNION_TCA_OPTION_DATA_FQ] = "fq", |
42b5f7dd | 967 | [NL_UNION_TCA_OPTION_DATA_FQ_CODEL] = "fq_codel", |
3428b32a | 968 | [NL_UNION_TCA_OPTION_DATA_FQ_PIE] = "fq_pie", |
609e8340 | 969 | [NL_UNION_TCA_OPTION_DATA_GRED] = "gred", |
7e16f84e | 970 | [NL_UNION_TCA_OPTION_DATA_HHF] = "hhf", |
b934ac3d | 971 | [NL_UNION_TCA_OPTION_DATA_HTB] = "htb", |
55d22831 | 972 | [NL_UNION_TCA_OPTION_DATA_PIE] = "pie", |
c33f1e5a | 973 | [NL_UNION_TCA_OPTION_DATA_QFQ] = "qfq", |
982998b0 | 974 | [NL_UNION_TCA_OPTION_DATA_SFB] = "sfb", |
eb34f4b3 | 975 | [NL_UNION_TCA_OPTION_DATA_TBF] = "tbf", |
42b5f7dd YW |
976 | }; |
977 | ||
978 | DEFINE_STRING_TABLE_LOOKUP(nl_union_tca_option_data, NLUnionTCAOptionData); | |
979 | ||
980 | static const NLTypeSystem rtnl_tca_option_data_type_systems[] = { | |
ad8352f4 SS |
981 | [NL_UNION_TCA_OPTION_DATA_CAKE] = { .count = ELEMENTSOF(rtnl_tca_option_data_cake_types), |
982 | .types = rtnl_tca_option_data_cake_types }, | |
a9a5d632 SS |
983 | [NL_UNION_TCA_OPTION_DATA_CODEL] = { .count = ELEMENTSOF(rtnl_tca_option_data_codel_types), |
984 | .types = rtnl_tca_option_data_codel_types }, | |
5c21b46e SS |
985 | [NL_UNION_TCA_OPTION_DATA_DRR] = { .count = ELEMENTSOF(rtnl_tca_option_data_drr_types), |
986 | .types = rtnl_tca_option_data_drr_types }, | |
4dec9218 YW |
987 | [NL_UNION_TCA_OPTION_DATA_ETS] = { .count = ELEMENTSOF(rtnl_tca_option_data_ets_types), |
988 | .types = rtnl_tca_option_data_ets_types }, | |
eb34f4b3 YW |
989 | [NL_UNION_TCA_OPTION_DATA_FQ] = { .count = ELEMENTSOF(rtnl_tca_option_data_fq_types), |
990 | .types = rtnl_tca_option_data_fq_types }, | |
42b5f7dd YW |
991 | [NL_UNION_TCA_OPTION_DATA_FQ_CODEL] = { .count = ELEMENTSOF(rtnl_tca_option_data_fq_codel_types), |
992 | .types = rtnl_tca_option_data_fq_codel_types }, | |
3428b32a SS |
993 | [NL_UNION_TCA_OPTION_DATA_FQ_PIE] = { .count = ELEMENTSOF(rtnl_tca_option_data_fq_pie_types), |
994 | .types = rtnl_tca_option_data_fq_pie_types }, | |
609e8340 SS |
995 | [NL_UNION_TCA_OPTION_DATA_GRED] = { .count = ELEMENTSOF(rtnl_tca_option_data_gred_types), |
996 | .types = rtnl_tca_option_data_gred_types }, | |
7e16f84e SS |
997 | [NL_UNION_TCA_OPTION_DATA_HHF] = { .count = ELEMENTSOF(rtnl_tca_option_data_hhf_types), |
998 | .types = rtnl_tca_option_data_hhf_types }, | |
b934ac3d YW |
999 | [NL_UNION_TCA_OPTION_DATA_HTB] = { .count = ELEMENTSOF(rtnl_tca_option_data_htb_types), |
1000 | .types = rtnl_tca_option_data_htb_types }, | |
55d22831 SS |
1001 | [NL_UNION_TCA_OPTION_DATA_PIE] = { .count = ELEMENTSOF(rtnl_tca_option_data_pie_types), |
1002 | .types = rtnl_tca_option_data_pie_types }, | |
c33f1e5a SS |
1003 | [NL_UNION_TCA_OPTION_DATA_QFQ] = { .count = ELEMENTSOF(rtnl_tca_option_data_qfq_types), |
1004 | .types = rtnl_tca_option_data_qfq_types }, | |
982998b0 SS |
1005 | [NL_UNION_TCA_OPTION_DATA_SFB] = { .count = ELEMENTSOF(rtnl_tca_option_data_sfb_types), |
1006 | .types = rtnl_tca_option_data_sfb_types }, | |
eb34f4b3 YW |
1007 | [NL_UNION_TCA_OPTION_DATA_TBF] = { .count = ELEMENTSOF(rtnl_tca_option_data_tbf_types), |
1008 | .types = rtnl_tca_option_data_tbf_types }, | |
42b5f7dd YW |
1009 | }; |
1010 | ||
1011 | static const NLTypeSystemUnion rtnl_tca_option_data_type_system_union = { | |
1012 | .num = _NL_UNION_TCA_OPTION_DATA_MAX, | |
1013 | .lookup = nl_union_tca_option_data_from_string, | |
1014 | .type_systems = rtnl_tca_option_data_type_systems, | |
1015 | .match_type = NL_MATCH_SIBLING, | |
1016 | .match = TCA_KIND, | |
1017 | }; | |
1018 | ||
0ebb76de | 1019 | static const NLType rtnl_tca_types[] = { |
0f5bd7fe | 1020 | [TCA_KIND] = { .type = NETLINK_TYPE_STRING }, |
42b5f7dd | 1021 | [TCA_OPTIONS] = { .type = NETLINK_TYPE_UNION, .type_system_union = &rtnl_tca_option_data_type_system_union }, |
0f5bd7fe SS |
1022 | [TCA_INGRESS_BLOCK] = { .type = NETLINK_TYPE_U32 }, |
1023 | [TCA_EGRESS_BLOCK] = { .type = NETLINK_TYPE_U32 }, | |
1024 | }; | |
1025 | ||
0ebb76de YW |
1026 | static const NLTypeSystem rtnl_tca_type_system = { |
1027 | .count = ELEMENTSOF(rtnl_tca_types), | |
1028 | .types = rtnl_tca_types, | |
0f5bd7fe SS |
1029 | }; |
1030 | ||
1903c9bb DM |
1031 | static const NLType mdb_types[] = { |
1032 | [MDBA_SET_ENTRY] = { .size = sizeof(struct br_port_msg) }, | |
1033 | }; | |
1034 | ||
1035 | static const NLTypeSystem rtnl_mdb_type_system = { | |
1036 | .count = ELEMENTSOF(mdb_types), | |
1037 | .types = mdb_types, | |
1038 | }; | |
1039 | ||
e4a1e68d YW |
1040 | static const NLType error_types[] = { |
1041 | [NLMSGERR_ATTR_MSG] = { .type = NETLINK_TYPE_STRING }, | |
1042 | [NLMSGERR_ATTR_OFFS] = { .type = NETLINK_TYPE_U32 }, | |
1043 | }; | |
1044 | ||
1045 | static const NLTypeSystem error_type_system = { | |
1046 | .count = ELEMENTSOF(error_types), | |
1047 | .types = error_types, | |
1048 | }; | |
1049 | ||
8ae4b6d1 | 1050 | static const NLType rtnl_types[] = { |
30746d60 | 1051 | [NLMSG_DONE] = { .type = NETLINK_TYPE_NESTED, .type_system = &empty_type_system, .size = 0 }, |
e4a1e68d | 1052 | [NLMSG_ERROR] = { .type = NETLINK_TYPE_NESTED, .type_system = &error_type_system, .size = sizeof(struct nlmsgerr) }, |
30746d60 SS |
1053 | [RTM_NEWLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, |
1054 | [RTM_DELLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, | |
1055 | [RTM_GETLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, | |
1056 | [RTM_SETLINK] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, | |
ffeb16f5 YW |
1057 | [RTM_NEWLINKPROP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, |
1058 | [RTM_DELLINKPROP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, | |
1059 | [RTM_GETLINKPROP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_link_type_system, .size = sizeof(struct ifinfomsg) }, | |
30746d60 SS |
1060 | [RTM_NEWADDR] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) }, |
1061 | [RTM_DELADDR] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) }, | |
1062 | [RTM_GETADDR] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_address_type_system, .size = sizeof(struct ifaddrmsg) }, | |
1063 | [RTM_NEWROUTE] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_type_system, .size = sizeof(struct rtmsg) }, | |
1064 | [RTM_DELROUTE] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_type_system, .size = sizeof(struct rtmsg) }, | |
1065 | [RTM_GETROUTE] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_route_type_system, .size = sizeof(struct rtmsg) }, | |
1066 | [RTM_NEWNEIGH] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_neigh_type_system, .size = sizeof(struct ndmsg) }, | |
1067 | [RTM_DELNEIGH] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_neigh_type_system, .size = sizeof(struct ndmsg) }, | |
1068 | [RTM_GETNEIGH] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_neigh_type_system, .size = sizeof(struct ndmsg) }, | |
1069 | [RTM_NEWADDRLABEL] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_addrlabel_type_system, .size = sizeof(struct ifaddrlblmsg) }, | |
1070 | [RTM_DELADDRLABEL] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_addrlabel_type_system, .size = sizeof(struct ifaddrlblmsg) }, | |
1071 | [RTM_GETADDRLABEL] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_addrlabel_type_system, .size = sizeof(struct ifaddrlblmsg) }, | |
eca24864 YW |
1072 | [RTM_NEWRULE] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_routing_policy_rule_type_system, .size = sizeof(struct fib_rule_hdr) }, |
1073 | [RTM_DELRULE] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_routing_policy_rule_type_system, .size = sizeof(struct fib_rule_hdr) }, | |
1074 | [RTM_GETRULE] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_routing_policy_rule_type_system, .size = sizeof(struct fib_rule_hdr) }, | |
c16c7808 SS |
1075 | [RTM_NEWNEXTHOP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_nexthop_type_system, .size = sizeof(struct nhmsg) }, |
1076 | [RTM_DELNEXTHOP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_nexthop_type_system, .size = sizeof(struct nhmsg) }, | |
1077 | [RTM_GETNEXTHOP] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_nexthop_type_system, .size = sizeof(struct nhmsg) }, | |
0ebb76de YW |
1078 | [RTM_NEWQDISC] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system, .size = sizeof(struct tcmsg) }, |
1079 | [RTM_DELQDISC] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system, .size = sizeof(struct tcmsg) }, | |
1080 | [RTM_GETQDISC] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system, .size = sizeof(struct tcmsg) }, | |
1081 | [RTM_NEWTCLASS] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system, .size = sizeof(struct tcmsg) }, | |
1082 | [RTM_DELTCLASS] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system, .size = sizeof(struct tcmsg) }, | |
1083 | [RTM_GETTCLASS] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_tca_type_system, .size = sizeof(struct tcmsg) }, | |
1903c9bb DM |
1084 | [RTM_NEWMDB] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_mdb_type_system, .size = sizeof(struct br_port_msg) }, |
1085 | [RTM_DELMDB] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_mdb_type_system, .size = sizeof(struct br_port_msg) }, | |
1086 | [RTM_GETMDB] = { .type = NETLINK_TYPE_NESTED, .type_system = &rtnl_mdb_type_system, .size = sizeof(struct br_port_msg) }, | |
d8e538ec TG |
1087 | }; |
1088 | ||
05d0c2e3 | 1089 | const NLTypeSystem rtnl_type_system_root = { |
c1df8dee | 1090 | .count = ELEMENTSOF(rtnl_types), |
d8e538ec TG |
1091 | .types = rtnl_types, |
1092 | }; | |
1093 | ||
e5719363 JT |
1094 | static const NLType genl_wireguard_allowedip_types[] = { |
1095 | [WGALLOWEDIP_A_FAMILY] = { .type = NETLINK_TYPE_U16 }, | |
1096 | [WGALLOWEDIP_A_IPADDR] = { .type = NETLINK_TYPE_IN_ADDR }, | |
1097 | [WGALLOWEDIP_A_CIDR_MASK] = { .type = NETLINK_TYPE_U8 }, | |
1098 | }; | |
1099 | ||
1100 | static const NLTypeSystem genl_wireguard_allowedip_type_system = { | |
1101 | .count = ELEMENTSOF(genl_wireguard_allowedip_types), | |
1102 | .types = genl_wireguard_allowedip_types, | |
1103 | }; | |
1104 | ||
1105 | static const NLType genl_wireguard_peer_types[] = { | |
1106 | [WGPEER_A_PUBLIC_KEY] = { .size = WG_KEY_LEN }, | |
1107 | [WGPEER_A_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1108 | [WGPEER_A_PRESHARED_KEY] = { .size = WG_KEY_LEN }, | |
7d0b26a0 | 1109 | [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] = { .type = NETLINK_TYPE_U16 }, |
abd48ec8 | 1110 | [WGPEER_A_ENDPOINT] = { .type = NETLINK_TYPE_SOCKADDR }, |
e5719363 JT |
1111 | [WGPEER_A_ALLOWEDIPS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_allowedip_type_system }, |
1112 | }; | |
1113 | ||
1114 | static const NLTypeSystem genl_wireguard_peer_type_system = { | |
1115 | .count = ELEMENTSOF(genl_wireguard_peer_types), | |
1116 | .types = genl_wireguard_peer_types, | |
1117 | }; | |
1118 | ||
1119 | static const NLType genl_wireguard_set_device_types[] = { | |
1120 | [WGDEVICE_A_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
33c2ea80 | 1121 | [WGDEVICE_A_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ-1 }, |
e5719363 JT |
1122 | [WGDEVICE_A_FLAGS] = { .type = NETLINK_TYPE_U32 }, |
1123 | [WGDEVICE_A_PRIVATE_KEY] = { .size = WG_KEY_LEN }, | |
1124 | [WGDEVICE_A_LISTEN_PORT] = { .type = NETLINK_TYPE_U16 }, | |
1125 | [WGDEVICE_A_FWMARK] = { .type = NETLINK_TYPE_U32 }, | |
1126 | [WGDEVICE_A_PEERS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_peer_type_system }, | |
1127 | }; | |
1128 | ||
1129 | static const NLTypeSystem genl_wireguard_set_device_type_system = { | |
1130 | .count = ELEMENTSOF(genl_wireguard_set_device_types), | |
1131 | .types = genl_wireguard_set_device_types, | |
1132 | }; | |
1133 | ||
1134 | static const NLType genl_wireguard_cmds[] = { | |
1135 | [WG_CMD_SET_DEVICE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_set_device_type_system }, | |
1136 | }; | |
1137 | ||
1138 | static const NLTypeSystem genl_wireguard_type_system = { | |
1139 | .count = ELEMENTSOF(genl_wireguard_cmds), | |
1140 | .types = genl_wireguard_cmds, | |
1141 | }; | |
05d0c2e3 | 1142 | |
8fab2747 YW |
1143 | static const NLType genl_mcast_group_types[] = { |
1144 | [CTRL_ATTR_MCAST_GRP_NAME] = { .type = NETLINK_TYPE_STRING }, | |
1145 | [CTRL_ATTR_MCAST_GRP_ID] = { .type = NETLINK_TYPE_U32 }, | |
1146 | }; | |
1147 | ||
1148 | static const NLTypeSystem genl_mcast_group_type_system = { | |
1149 | .count = ELEMENTSOF(genl_mcast_group_types), | |
1150 | .types = genl_mcast_group_types, | |
1151 | }; | |
1152 | ||
05d0c2e3 | 1153 | static const NLType genl_get_family_types[] = { |
8fab2747 YW |
1154 | [CTRL_ATTR_FAMILY_NAME] = { .type = NETLINK_TYPE_STRING }, |
1155 | [CTRL_ATTR_FAMILY_ID] = { .type = NETLINK_TYPE_U16 }, | |
1156 | [CTRL_ATTR_MCAST_GROUPS] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_mcast_group_type_system }, | |
05d0c2e3 JT |
1157 | }; |
1158 | ||
1159 | static const NLTypeSystem genl_get_family_type_system = { | |
1160 | .count = ELEMENTSOF(genl_get_family_types), | |
1161 | .types = genl_get_family_types, | |
1162 | }; | |
1163 | ||
1164 | static const NLType genl_ctrl_id_ctrl_cmds[] = { | |
1165 | [CTRL_CMD_GETFAMILY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_get_family_type_system }, | |
1166 | }; | |
1167 | ||
1168 | static const NLTypeSystem genl_ctrl_id_ctrl_type_system = { | |
1169 | .count = ELEMENTSOF(genl_ctrl_id_ctrl_cmds), | |
1170 | .types = genl_ctrl_id_ctrl_cmds, | |
1171 | }; | |
1172 | ||
53cb501a SS |
1173 | static const NLType genl_fou_types[] = { |
1174 | [FOU_ATTR_PORT] = { .type = NETLINK_TYPE_U16 }, | |
1175 | [FOU_ATTR_AF] = { .type = NETLINK_TYPE_U8 }, | |
1176 | [FOU_ATTR_IPPROTO] = { .type = NETLINK_TYPE_U8 }, | |
1177 | [FOU_ATTR_TYPE] = { .type = NETLINK_TYPE_U8 }, | |
1178 | [FOU_ATTR_REMCSUM_NOPARTIAL] = { .type = NETLINK_TYPE_FLAG }, | |
397a74dd SS |
1179 | [FOU_ATTR_LOCAL_V4] = { .type = NETLINK_TYPE_IN_ADDR }, |
1180 | [FOU_ATTR_PEER_V4] = { .type = NETLINK_TYPE_IN_ADDR }, | |
1181 | [FOU_ATTR_LOCAL_V6] = { .type = NETLINK_TYPE_IN_ADDR }, | |
1182 | [FOU_ATTR_PEER_V6] = { .type = NETLINK_TYPE_IN_ADDR}, | |
1183 | [FOU_ATTR_PEER_PORT] = { .type = NETLINK_TYPE_U16}, | |
1184 | [FOU_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32}, | |
53cb501a SS |
1185 | }; |
1186 | ||
1187 | static const NLTypeSystem genl_fou_type_system = { | |
1188 | .count = ELEMENTSOF(genl_fou_types), | |
1189 | .types = genl_fou_types, | |
1190 | }; | |
1191 | ||
1192 | static const NLType genl_fou_cmds[] = { | |
1193 | [FOU_CMD_ADD] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_fou_type_system }, | |
1194 | [FOU_CMD_DEL] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_fou_type_system }, | |
1195 | [FOU_CMD_GET] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_fou_type_system }, | |
1196 | }; | |
1197 | ||
1198 | static const NLTypeSystem genl_fou_cmds_type_system = { | |
1199 | .count = ELEMENTSOF(genl_fou_cmds), | |
1200 | .types = genl_fou_cmds, | |
1201 | }; | |
1202 | ||
3a56e697 SS |
1203 | static const NLType genl_l2tp_types[] = { |
1204 | [L2TP_ATTR_PW_TYPE] = { .type = NETLINK_TYPE_U16 }, | |
1205 | [L2TP_ATTR_ENCAP_TYPE] = { .type = NETLINK_TYPE_U16 }, | |
1206 | [L2TP_ATTR_OFFSET] = { .type = NETLINK_TYPE_U16 }, | |
1207 | [L2TP_ATTR_DATA_SEQ] = { .type = NETLINK_TYPE_U16 }, | |
1208 | [L2TP_ATTR_L2SPEC_TYPE] = { .type = NETLINK_TYPE_U8 }, | |
1209 | [L2TP_ATTR_L2SPEC_LEN] = { .type = NETLINK_TYPE_U8 }, | |
1210 | [L2TP_ATTR_PROTO_VERSION] = { .type = NETLINK_TYPE_U8 }, | |
1211 | [L2TP_ATTR_IFNAME] = { .type = NETLINK_TYPE_STRING }, | |
1212 | [L2TP_ATTR_CONN_ID] = { .type = NETLINK_TYPE_U32 }, | |
1213 | [L2TP_ATTR_PEER_CONN_ID] = { .type = NETLINK_TYPE_U32 }, | |
1214 | [L2TP_ATTR_SESSION_ID] = { .type = NETLINK_TYPE_U32 }, | |
1215 | [L2TP_ATTR_PEER_SESSION_ID] = { .type = NETLINK_TYPE_U32 }, | |
1216 | [L2TP_ATTR_UDP_CSUM] = { .type = NETLINK_TYPE_U8 }, | |
1217 | [L2TP_ATTR_VLAN_ID] = { .type = NETLINK_TYPE_U16 }, | |
1218 | [L2TP_ATTR_RECV_SEQ] = { .type = NETLINK_TYPE_U8 }, | |
1219 | [L2TP_ATTR_SEND_SEQ] = { .type = NETLINK_TYPE_U8 }, | |
1220 | [L2TP_ATTR_LNS_MODE] = { .type = NETLINK_TYPE_U8 }, | |
1221 | [L2TP_ATTR_USING_IPSEC] = { .type = NETLINK_TYPE_U8 }, | |
1222 | [L2TP_ATTR_FD] = { .type = NETLINK_TYPE_U32 }, | |
1223 | [L2TP_ATTR_IP_SADDR] = { .type = NETLINK_TYPE_IN_ADDR }, | |
1224 | [L2TP_ATTR_IP_DADDR] = { .type = NETLINK_TYPE_IN_ADDR }, | |
1225 | [L2TP_ATTR_UDP_SPORT] = { .type = NETLINK_TYPE_U16 }, | |
1226 | [L2TP_ATTR_UDP_DPORT] = { .type = NETLINK_TYPE_U16 }, | |
1227 | [L2TP_ATTR_IP6_SADDR] = { .type = NETLINK_TYPE_IN_ADDR }, | |
1228 | [L2TP_ATTR_IP6_DADDR] = { .type = NETLINK_TYPE_IN_ADDR }, | |
1229 | [L2TP_ATTR_UDP_ZERO_CSUM6_TX] = { .type = NETLINK_TYPE_FLAG }, | |
1230 | [L2TP_ATTR_UDP_ZERO_CSUM6_RX] = { .type = NETLINK_TYPE_FLAG }, | |
1231 | }; | |
1232 | ||
1233 | static const NLTypeSystem genl_l2tp_type_system = { | |
1234 | .count = ELEMENTSOF(genl_l2tp_types), | |
1235 | .types = genl_l2tp_types, | |
1236 | }; | |
1237 | ||
1238 | static const NLType genl_l2tp[] = { | |
1239 | [L2TP_CMD_TUNNEL_CREATE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1240 | [L2TP_CMD_TUNNEL_DELETE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1241 | [L2TP_CMD_TUNNEL_MODIFY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1242 | [L2TP_CMD_TUNNEL_GET] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1243 | [L2TP_CMD_SESSION_CREATE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1244 | [L2TP_CMD_SESSION_DELETE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1245 | [L2TP_CMD_SESSION_MODIFY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1246 | [L2TP_CMD_SESSION_GET] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_type_system }, | |
1247 | }; | |
1248 | ||
1249 | static const NLTypeSystem genl_l2tp_tunnel_session_type_system = { | |
1250 | .count = ELEMENTSOF(genl_l2tp), | |
1251 | .types = genl_l2tp, | |
1252 | }; | |
1253 | ||
81962db7 SS |
1254 | static const NLType genl_rxsc_types[] = { |
1255 | [MACSEC_RXSC_ATTR_SCI] = { .type = NETLINK_TYPE_U64 }, | |
1256 | }; | |
1257 | ||
1258 | static const NLTypeSystem genl_rxsc_config_type_system = { | |
1259 | .count = ELEMENTSOF(genl_rxsc_types), | |
1260 | .types = genl_rxsc_types, | |
1261 | }; | |
1262 | ||
1263 | static const NLType genl_macsec_rxsc_types[] = { | |
1264 | [MACSEC_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
1265 | [MACSEC_ATTR_RXSC_CONFIG] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_rxsc_config_type_system }, | |
1266 | }; | |
1267 | ||
1268 | static const NLTypeSystem genl_macsec_rxsc_type_system = { | |
1269 | .count = ELEMENTSOF(genl_macsec_rxsc_types), | |
1270 | .types = genl_macsec_rxsc_types, | |
1271 | }; | |
1272 | ||
1273 | static const NLType genl_macsec_sa_config_types[] = { | |
1274 | [MACSEC_SA_ATTR_AN] = { .type = NETLINK_TYPE_U8 }, | |
1275 | [MACSEC_SA_ATTR_ACTIVE] = { .type = NETLINK_TYPE_U8 }, | |
1276 | [MACSEC_SA_ATTR_PN] = { .type = NETLINK_TYPE_U32 }, | |
1277 | [MACSEC_SA_ATTR_KEYID] = { .size = MACSEC_KEYID_LEN }, | |
1278 | [MACSEC_SA_ATTR_KEY] = { .size = MACSEC_MAX_KEY_LEN }, | |
1279 | }; | |
1280 | ||
1281 | static const NLTypeSystem genl_macsec_sa_config_type_system = { | |
1282 | .count = ELEMENTSOF(genl_macsec_sa_config_types), | |
1283 | .types = genl_macsec_sa_config_types, | |
1284 | }; | |
1285 | ||
1286 | static const NLType genl_macsec_rxsa_types[] = { | |
1287 | [MACSEC_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
1288 | [MACSEC_ATTR_SA_CONFIG] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_sa_config_type_system }, | |
1289 | }; | |
1290 | ||
1291 | static const NLTypeSystem genl_macsec_rxsa_type_system = { | |
1292 | .count = ELEMENTSOF(genl_macsec_rxsa_types), | |
1293 | .types = genl_macsec_rxsa_types, | |
1294 | }; | |
1295 | ||
1296 | static const NLType genl_macsec_sa_types[] = { | |
1297 | [MACSEC_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
1298 | [MACSEC_ATTR_RXSC_CONFIG] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_rxsc_config_type_system }, | |
1299 | [MACSEC_ATTR_SA_CONFIG] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_sa_config_type_system }, | |
1300 | }; | |
1301 | ||
1302 | static const NLTypeSystem genl_macsec_sa_type_system = { | |
1303 | .count = ELEMENTSOF(genl_macsec_sa_types), | |
1304 | .types = genl_macsec_sa_types, | |
1305 | }; | |
1306 | ||
1307 | static const NLType genl_macsec[] = { | |
1308 | [MACSEC_CMD_ADD_RXSC] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_rxsc_type_system }, | |
1309 | [MACSEC_CMD_ADD_TXSA] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_rxsa_type_system}, | |
1310 | [MACSEC_CMD_ADD_RXSA] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_sa_type_system }, | |
1311 | }; | |
1312 | ||
1313 | static const NLTypeSystem genl_macsec_device_type_system = { | |
1314 | .count = ELEMENTSOF(genl_macsec), | |
1315 | .types = genl_macsec, | |
1316 | }; | |
1317 | ||
a1d736e2 YW |
1318 | static const NLType genl_nl80211_types[] = { |
1319 | [NL80211_ATTR_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
1320 | [NL80211_ATTR_MAC] = { .type = NETLINK_TYPE_ETHER_ADDR }, | |
1321 | [NL80211_ATTR_SSID] = { .type = NETLINK_TYPE_STRING }, | |
78404d22 | 1322 | [NL80211_ATTR_IFTYPE] = { .type = NETLINK_TYPE_U32 }, |
a1d736e2 YW |
1323 | }; |
1324 | ||
1325 | static const NLTypeSystem genl_nl80211_type_system = { | |
1326 | .count = ELEMENTSOF(genl_nl80211_types), | |
1327 | .types = genl_nl80211_types, | |
1328 | }; | |
1329 | ||
1330 | static const NLType genl_nl80211_cmds[] = { | |
1331 | [NL80211_CMD_GET_WIPHY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1332 | [NL80211_CMD_SET_WIPHY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1333 | [NL80211_CMD_NEW_WIPHY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1334 | [NL80211_CMD_DEL_WIPHY] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1335 | [NL80211_CMD_GET_INTERFACE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1336 | [NL80211_CMD_SET_INTERFACE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1337 | [NL80211_CMD_NEW_INTERFACE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1338 | [NL80211_CMD_DEL_INTERFACE] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1339 | [NL80211_CMD_GET_STATION] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1340 | [NL80211_CMD_SET_STATION] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1341 | [NL80211_CMD_NEW_STATION] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1342 | [NL80211_CMD_DEL_STATION] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system }, | |
1343 | }; | |
1344 | ||
1345 | static const NLTypeSystem genl_nl80211_cmds_type_system = { | |
1346 | .count = ELEMENTSOF(genl_nl80211_cmds), | |
1347 | .types = genl_nl80211_cmds, | |
1348 | }; | |
1349 | ||
c0267a59 AW |
1350 | static const NLType genl_batadv_types[] = { |
1351 | [BATADV_ATTR_VERSION] = { .type = NETLINK_TYPE_STRING }, | |
1352 | [BATADV_ATTR_ALGO_NAME] = { .type = NETLINK_TYPE_STRING }, | |
1353 | [BATADV_ATTR_MESH_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
1354 | [BATADV_ATTR_MESH_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ }, | |
1355 | [BATADV_ATTR_MESH_ADDRESS] = { .size = ETH_ALEN }, | |
1356 | [BATADV_ATTR_HARD_IFINDEX] = { .type = NETLINK_TYPE_U32 }, | |
1357 | [BATADV_ATTR_HARD_IFNAME] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ }, | |
1358 | [BATADV_ATTR_HARD_ADDRESS] = { .size = ETH_ALEN }, | |
1359 | [BATADV_ATTR_ORIG_ADDRESS] = { .size = ETH_ALEN }, | |
1360 | [BATADV_ATTR_TPMETER_RESULT] = { .type = NETLINK_TYPE_U8 }, | |
1361 | [BATADV_ATTR_TPMETER_TEST_TIME] = { .type = NETLINK_TYPE_U32 }, | |
1362 | [BATADV_ATTR_TPMETER_BYTES] = { .type = NETLINK_TYPE_U64 }, | |
1363 | [BATADV_ATTR_TPMETER_COOKIE] = { .type = NETLINK_TYPE_U32 }, | |
1364 | [BATADV_ATTR_PAD] = { .type = NETLINK_TYPE_UNSPEC }, | |
1365 | [BATADV_ATTR_ACTIVE] = { .type = NETLINK_TYPE_FLAG }, | |
1366 | [BATADV_ATTR_TT_ADDRESS] = { .size = ETH_ALEN }, | |
1367 | [BATADV_ATTR_TT_TTVN] = { .type = NETLINK_TYPE_U8 }, | |
1368 | [BATADV_ATTR_TT_LAST_TTVN] = { .type = NETLINK_TYPE_U8 }, | |
1369 | [BATADV_ATTR_TT_CRC32] = { .type = NETLINK_TYPE_U32 }, | |
1370 | [BATADV_ATTR_TT_VID] = { .type = NETLINK_TYPE_U16 }, | |
1371 | [BATADV_ATTR_TT_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1372 | [BATADV_ATTR_FLAG_BEST] = { .type = NETLINK_TYPE_FLAG }, | |
1373 | [BATADV_ATTR_LAST_SEEN_MSECS] = { .type = NETLINK_TYPE_U32 }, | |
1374 | [BATADV_ATTR_NEIGH_ADDRESS] = { .size = ETH_ALEN }, | |
1375 | [BATADV_ATTR_TQ] = { .type = NETLINK_TYPE_U8 }, | |
1376 | [BATADV_ATTR_THROUGHPUT] = { .type = NETLINK_TYPE_U32 }, | |
1377 | [BATADV_ATTR_BANDWIDTH_UP] = { .type = NETLINK_TYPE_U32 }, | |
1378 | [BATADV_ATTR_BANDWIDTH_DOWN] = { .type = NETLINK_TYPE_U32 }, | |
1379 | [BATADV_ATTR_ROUTER] = { .size = ETH_ALEN }, | |
1380 | [BATADV_ATTR_BLA_OWN] = { .type = NETLINK_TYPE_FLAG }, | |
1381 | [BATADV_ATTR_BLA_ADDRESS] = { .size = ETH_ALEN }, | |
1382 | [BATADV_ATTR_BLA_VID] = { .type = NETLINK_TYPE_U16 }, | |
1383 | [BATADV_ATTR_BLA_BACKBONE] = { .size = ETH_ALEN }, | |
1384 | [BATADV_ATTR_BLA_CRC] = { .type = NETLINK_TYPE_U16 }, | |
1385 | [BATADV_ATTR_DAT_CACHE_IP4ADDRESS] = { .type = NETLINK_TYPE_U32 }, | |
1386 | [BATADV_ATTR_DAT_CACHE_HWADDRESS] = { .size = ETH_ALEN }, | |
1387 | [BATADV_ATTR_DAT_CACHE_VID] = { .type = NETLINK_TYPE_U16 }, | |
1388 | [BATADV_ATTR_MCAST_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1389 | [BATADV_ATTR_MCAST_FLAGS_PRIV] = { .type = NETLINK_TYPE_U32 }, | |
1390 | [BATADV_ATTR_VLANID] = { .type = NETLINK_TYPE_U16 }, | |
1391 | [BATADV_ATTR_AGGREGATED_OGMS_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1392 | [BATADV_ATTR_AP_ISOLATION_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1393 | [BATADV_ATTR_ISOLATION_MARK] = { .type = NETLINK_TYPE_U32 }, | |
1394 | [BATADV_ATTR_ISOLATION_MASK] = { .type = NETLINK_TYPE_U32 }, | |
1395 | [BATADV_ATTR_BONDING_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1396 | [BATADV_ATTR_BRIDGE_LOOP_AVOIDANCE_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1397 | [BATADV_ATTR_DISTRIBUTED_ARP_TABLE_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1398 | [BATADV_ATTR_FRAGMENTATION_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1399 | [BATADV_ATTR_GW_BANDWIDTH_DOWN] = { .type = NETLINK_TYPE_U32 }, | |
1400 | [BATADV_ATTR_GW_BANDWIDTH_UP] = { .type = NETLINK_TYPE_U32 }, | |
1401 | [BATADV_ATTR_GW_MODE] = { .type = NETLINK_TYPE_U8 }, | |
1402 | [BATADV_ATTR_GW_SEL_CLASS] = { .type = NETLINK_TYPE_U32 }, | |
1403 | [BATADV_ATTR_HOP_PENALTY] = { .type = NETLINK_TYPE_U8 }, | |
1404 | [BATADV_ATTR_LOG_LEVEL] = { .type = NETLINK_TYPE_U32 }, | |
1405 | [BATADV_ATTR_MULTICAST_FORCEFLOOD_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1406 | [BATADV_ATTR_MULTICAST_FANOUT] = { .type = NETLINK_TYPE_U32 }, | |
1407 | [BATADV_ATTR_NETWORK_CODING_ENABLED] = { .type = NETLINK_TYPE_U8 }, | |
1408 | [BATADV_ATTR_ORIG_INTERVAL] = { .type = NETLINK_TYPE_U32 }, | |
1409 | [BATADV_ATTR_ELP_INTERVAL] = { .type = NETLINK_TYPE_U32 }, | |
1410 | [BATADV_ATTR_THROUGHPUT_OVERRIDE] = { .type = NETLINK_TYPE_U32 }, | |
1411 | }; | |
1412 | ||
1413 | static const NLTypeSystem genl_batadv_type_system = { | |
1414 | .count = ELEMENTSOF(genl_batadv_types), | |
1415 | .types = genl_batadv_types, | |
1416 | }; | |
1417 | ||
1418 | static const NLType genl_batadv_cmds[] = { | |
1419 | [BATADV_CMD_SET_MESH] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_batadv_type_system }, | |
1420 | }; | |
1421 | ||
1422 | static const NLTypeSystem genl_batadv_cmds_type_system = { | |
1423 | .count = ELEMENTSOF(genl_batadv_cmds), | |
1424 | .types = genl_batadv_cmds, | |
1425 | }; | |
1426 | ||
05d0c2e3 | 1427 | static const NLType genl_families[] = { |
53cb501a | 1428 | [SD_GENL_ID_CTRL] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_ctrl_id_ctrl_type_system }, |
e5719363 | 1429 | [SD_GENL_WIREGUARD] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_wireguard_type_system }, |
2be081ff | 1430 | [SD_GENL_FOU] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_fou_cmds_type_system }, |
3a56e697 | 1431 | [SD_GENL_L2TP] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_l2tp_tunnel_session_type_system }, |
81962db7 | 1432 | [SD_GENL_MACSEC] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_macsec_device_type_system }, |
a1d736e2 | 1433 | [SD_GENL_NL80211] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_cmds_type_system }, |
c0267a59 | 1434 | [SD_GENL_BATADV] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_batadv_cmds_type_system }, |
05d0c2e3 JT |
1435 | }; |
1436 | ||
6f00fd9b FW |
1437 | static const NLType nfnl_nft_table_types[] = { |
1438 | [NFTA_TABLE_NAME] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1439 | [NFTA_TABLE_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1440 | }; | |
1441 | ||
1442 | static const NLTypeSystem nfnl_nft_table_type_system = { | |
1443 | .count = ELEMENTSOF(nfnl_nft_table_types), | |
1444 | .types = nfnl_nft_table_types, | |
1445 | }; | |
1446 | ||
1447 | static const NLType nfnl_nft_chain_hook_types[] = { | |
1448 | [NFTA_HOOK_HOOKNUM] = { .type = NETLINK_TYPE_U32 }, | |
1449 | [NFTA_HOOK_PRIORITY] = { .type = NETLINK_TYPE_U32 }, | |
1450 | [NFTA_HOOK_DEV] = { .type = NETLINK_TYPE_STRING, .size = IFNAMSIZ - 1 }, | |
1451 | }; | |
1452 | ||
1453 | static const NLTypeSystem nfnl_nft_chain_hook_type_system = { | |
1454 | .count = ELEMENTSOF(nfnl_nft_chain_hook_types), | |
1455 | .types = nfnl_nft_chain_hook_types, | |
1456 | }; | |
1457 | ||
1458 | static const NLType nfnl_nft_chain_types[] = { | |
1459 | [NFTA_CHAIN_TABLE] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1460 | [NFTA_CHAIN_NAME] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1461 | [NFTA_CHAIN_HOOK] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_chain_hook_type_system }, | |
1462 | [NFTA_CHAIN_TYPE] = { .type = NETLINK_TYPE_STRING, .size = 16 }, | |
1463 | [NFTA_CHAIN_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1464 | }; | |
1465 | ||
1466 | static const NLTypeSystem nfnl_nft_chain_type_system = { | |
1467 | .count = ELEMENTSOF(nfnl_nft_chain_types), | |
1468 | .types = nfnl_nft_chain_types, | |
1469 | }; | |
1470 | ||
1471 | static const NLType nfnl_nft_expr_meta_types[] = { | |
1472 | [NFTA_META_DREG] = { .type = NETLINK_TYPE_U32 }, | |
1473 | [NFTA_META_KEY] = { .type = NETLINK_TYPE_U32 }, | |
1474 | [NFTA_META_SREG] = { .type = NETLINK_TYPE_U32 }, | |
1475 | }; | |
1476 | ||
1477 | static const NLType nfnl_nft_expr_payload_types[] = { | |
1478 | [NFTA_PAYLOAD_DREG] = { .type = NETLINK_TYPE_U32 }, | |
1479 | [NFTA_PAYLOAD_BASE] = { .type = NETLINK_TYPE_U32 }, | |
1480 | [NFTA_PAYLOAD_OFFSET] = { .type = NETLINK_TYPE_U32 }, | |
1481 | [NFTA_PAYLOAD_LEN] = { .type = NETLINK_TYPE_U32 }, | |
1482 | }; | |
1483 | ||
1484 | static const NLType nfnl_nft_expr_nat_types[] = { | |
1485 | [NFTA_NAT_TYPE] = { .type = NETLINK_TYPE_U32 }, | |
1486 | [NFTA_NAT_FAMILY] = { .type = NETLINK_TYPE_U32 }, | |
1487 | [NFTA_NAT_REG_ADDR_MIN] = { .type = NETLINK_TYPE_U32 }, | |
1488 | [NFTA_NAT_REG_ADDR_MAX] = { .type = NETLINK_TYPE_U32 }, | |
1489 | [NFTA_NAT_REG_PROTO_MIN] = { .type = NETLINK_TYPE_U32 }, | |
1490 | [NFTA_NAT_REG_PROTO_MAX] = { .type = NETLINK_TYPE_U32 }, | |
1491 | [NFTA_NAT_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1492 | }; | |
1493 | ||
1494 | static const NLType nfnl_nft_data_types[] = { | |
1495 | [NFTA_DATA_VALUE] = { .type = NETLINK_TYPE_BINARY }, | |
1496 | }; | |
1497 | ||
1498 | static const NLTypeSystem nfnl_nft_data_type_system = { | |
1499 | .count = ELEMENTSOF(nfnl_nft_data_types), | |
1500 | .types = nfnl_nft_data_types, | |
1501 | }; | |
1502 | ||
1503 | static const NLType nfnl_nft_expr_bitwise_types[] = { | |
1504 | [NFTA_BITWISE_SREG] = { .type = NETLINK_TYPE_U32 }, | |
1505 | [NFTA_BITWISE_DREG] = { .type = NETLINK_TYPE_U32 }, | |
1506 | [NFTA_BITWISE_LEN] = { .type = NETLINK_TYPE_U32 }, | |
1507 | [NFTA_BITWISE_MASK] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system }, | |
1508 | [NFTA_BITWISE_XOR] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system }, | |
1509 | }; | |
1510 | ||
1511 | static const NLType nfnl_nft_expr_cmp_types[] = { | |
1512 | [NFTA_CMP_SREG] = { .type = NETLINK_TYPE_U32 }, | |
1513 | [NFTA_CMP_OP] = { .type = NETLINK_TYPE_U32 }, | |
1514 | [NFTA_CMP_DATA] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system }, | |
1515 | }; | |
1516 | ||
1517 | static const NLType nfnl_nft_expr_fib_types[] = { | |
1518 | [NFTA_FIB_DREG] = { .type = NETLINK_TYPE_U32 }, | |
1519 | [NFTA_FIB_RESULT] = { .type = NETLINK_TYPE_U32 }, | |
1520 | [NFTA_FIB_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1521 | }; | |
1522 | ||
1523 | static const NLType nfnl_nft_expr_lookup_types[] = { | |
1524 | [NFTA_LOOKUP_SET] = { .type = NETLINK_TYPE_STRING }, | |
1525 | [NFTA_LOOKUP_SREG] = { .type = NETLINK_TYPE_U32 }, | |
1526 | [NFTA_LOOKUP_DREG] = { .type = NETLINK_TYPE_U32 }, | |
1527 | [NFTA_LOOKUP_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1528 | }; | |
1529 | ||
1530 | static const NLType nfnl_nft_expr_masq_types[] = { | |
1531 | [NFTA_MASQ_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1532 | [NFTA_MASQ_REG_PROTO_MIN] = { .type = NETLINK_TYPE_U32 }, | |
1533 | [NFTA_MASQ_REG_PROTO_MAX] = { .type = NETLINK_TYPE_U32 }, | |
1534 | }; | |
1535 | ||
1536 | static const NLTypeSystem nfnl_expr_data_type_systems[] = { | |
1537 | [NL_UNION_NFT_EXPR_DATA_BITWISE] = { .count = ELEMENTSOF(nfnl_nft_expr_bitwise_types), | |
1538 | .types = nfnl_nft_expr_bitwise_types }, | |
1539 | [NL_UNION_NFT_EXPR_DATA_CMP] = { .count = ELEMENTSOF(nfnl_nft_expr_cmp_types), | |
1540 | .types = nfnl_nft_expr_cmp_types }, | |
1541 | [NL_UNION_NFT_EXPR_DATA_FIB] = { .count = ELEMENTSOF(nfnl_nft_expr_fib_types), | |
1542 | .types = nfnl_nft_expr_fib_types }, | |
1543 | [NL_UNION_NFT_EXPR_DATA_LOOKUP] = { .count = ELEMENTSOF(nfnl_nft_expr_lookup_types), | |
1544 | .types = nfnl_nft_expr_lookup_types }, | |
1545 | [NL_UNION_NFT_EXPR_DATA_MASQ] = { .count = ELEMENTSOF(nfnl_nft_expr_masq_types), | |
1546 | .types = nfnl_nft_expr_masq_types }, | |
1547 | [NL_UNION_NFT_EXPR_DATA_META] = { .count = ELEMENTSOF(nfnl_nft_expr_meta_types), | |
1548 | .types = nfnl_nft_expr_meta_types }, | |
1549 | [NL_UNION_NFT_EXPR_DATA_NAT] = { .count = ELEMENTSOF(nfnl_nft_expr_nat_types), | |
1550 | .types = nfnl_nft_expr_nat_types }, | |
1551 | [NL_UNION_NFT_EXPR_DATA_PAYLOAD] = { .count = ELEMENTSOF(nfnl_nft_expr_payload_types), | |
1552 | .types = nfnl_nft_expr_payload_types }, | |
1553 | }; | |
1554 | ||
1555 | static const char* const nl_union_nft_expr_data_table[] = { | |
1556 | [NL_UNION_NFT_EXPR_DATA_BITWISE] = "bitwise", | |
1557 | [NL_UNION_NFT_EXPR_DATA_CMP] = "cmp", | |
1558 | [NL_UNION_NFT_EXPR_DATA_LOOKUP] = "lookup", | |
1559 | [NL_UNION_NFT_EXPR_DATA_META] = "meta", | |
1560 | [NL_UNION_NFT_EXPR_DATA_FIB] = "fib", | |
1561 | [NL_UNION_NFT_EXPR_DATA_MASQ] = "masq", | |
1562 | [NL_UNION_NFT_EXPR_DATA_NAT] = "nat", | |
1563 | [NL_UNION_NFT_EXPR_DATA_PAYLOAD] = "payload", | |
1564 | }; | |
1565 | ||
1566 | DEFINE_STRING_TABLE_LOOKUP(nl_union_nft_expr_data, NLUnionNFTExprData); | |
1567 | ||
1568 | static const NLTypeSystemUnion nfnl_nft_data_expr_type_system_union = { | |
1569 | .num = _NL_UNION_NFT_EXPR_DATA_MAX, | |
1570 | .lookup = nl_union_nft_expr_data_from_string, | |
1571 | .type_systems = nfnl_expr_data_type_systems, | |
1572 | .match_type = NL_MATCH_SIBLING, | |
1573 | .match = NFTA_EXPR_NAME, | |
1574 | }; | |
1575 | ||
1576 | static const NLType nfnl_nft_rule_expr_types[] = { | |
1577 | [NFTA_EXPR_NAME] = { .type = NETLINK_TYPE_STRING, .size = 16 }, | |
1578 | [NFTA_EXPR_DATA] = { .type = NETLINK_TYPE_UNION, | |
1579 | .type_system_union = &nfnl_nft_data_expr_type_system_union }, | |
1580 | }; | |
1581 | ||
1582 | static const NLTypeSystem nfnl_nft_rule_expr_type_system = { | |
1583 | .count = ELEMENTSOF(nfnl_nft_rule_expr_types), | |
1584 | .types = nfnl_nft_rule_expr_types, | |
1585 | }; | |
1586 | ||
1587 | static const NLType nfnl_nft_rule_types[] = { | |
1588 | [NFTA_RULE_TABLE] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1589 | [NFTA_RULE_CHAIN] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
faa0d69c | 1590 | [NFTA_RULE_EXPRESSIONS] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_rule_expr_type_system } |
6f00fd9b FW |
1591 | }; |
1592 | ||
1593 | static const NLTypeSystem nfnl_nft_rule_type_system = { | |
1594 | .count = ELEMENTSOF(nfnl_nft_rule_types), | |
1595 | .types = nfnl_nft_rule_types, | |
1596 | }; | |
1597 | ||
1598 | static const NLType nfnl_nft_set_types[] = { | |
1599 | [NFTA_SET_TABLE] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1600 | [NFTA_SET_NAME] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1601 | [NFTA_SET_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1602 | [NFTA_SET_KEY_TYPE] = { .type = NETLINK_TYPE_U32 }, | |
1603 | [NFTA_SET_KEY_LEN] = { .type = NETLINK_TYPE_U32 }, | |
1604 | [NFTA_SET_DATA_TYPE] = { .type = NETLINK_TYPE_U32 }, | |
1605 | [NFTA_SET_DATA_LEN] = { .type = NETLINK_TYPE_U32 }, | |
1606 | [NFTA_SET_POLICY] = { .type = NETLINK_TYPE_U32 }, | |
1607 | [NFTA_SET_ID] = { .type = NETLINK_TYPE_U32 }, | |
1608 | }; | |
1609 | ||
1610 | static const NLTypeSystem nfnl_nft_set_type_system = { | |
1611 | .count = ELEMENTSOF(nfnl_nft_set_types), | |
1612 | .types = nfnl_nft_set_types, | |
1613 | }; | |
1614 | ||
1615 | static const NLType nfnl_nft_setelem_types[] = { | |
1616 | [NFTA_SET_ELEM_KEY] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system }, | |
1617 | [NFTA_SET_ELEM_DATA] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_data_type_system }, | |
1618 | [NFTA_SET_ELEM_FLAGS] = { .type = NETLINK_TYPE_U32 }, | |
1619 | }; | |
1620 | ||
1621 | static const NLTypeSystem nfnl_nft_setelem_type_system = { | |
1622 | .count = ELEMENTSOF(nfnl_nft_setelem_types), | |
1623 | .types = nfnl_nft_setelem_types, | |
1624 | }; | |
1625 | ||
1626 | static const NLType nfnl_nft_setelem_list_types[] = { | |
1627 | [NFTA_SET_ELEM_LIST_TABLE] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1628 | [NFTA_SET_ELEM_LIST_SET] = { .type = NETLINK_TYPE_STRING, .size = NFT_TABLE_MAXNAMELEN - 1 }, | |
1629 | [NFTA_SET_ELEM_LIST_ELEMENTS] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_setelem_type_system }, | |
1630 | }; | |
1631 | ||
1632 | static const NLTypeSystem nfnl_nft_setelem_list_type_system = { | |
1633 | .count = ELEMENTSOF(nfnl_nft_setelem_list_types), | |
1634 | .types = nfnl_nft_setelem_list_types, | |
1635 | }; | |
1636 | ||
1637 | static const NLType nfnl_nft_msg_types [] = { | |
1638 | [NFT_MSG_DELTABLE] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_table_type_system, .size = sizeof(struct nfgenmsg) }, | |
1639 | [NFT_MSG_NEWTABLE] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_table_type_system, .size = sizeof(struct nfgenmsg) }, | |
1640 | [NFT_MSG_NEWCHAIN] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_chain_type_system, .size = sizeof(struct nfgenmsg) }, | |
1641 | [NFT_MSG_NEWRULE] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_rule_type_system, .size = sizeof(struct nfgenmsg) }, | |
1642 | [NFT_MSG_NEWSET] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_set_type_system, .size = sizeof(struct nfgenmsg) }, | |
1643 | [NFT_MSG_NEWSETELEM] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_setelem_list_type_system, .size = sizeof(struct nfgenmsg) }, | |
1644 | [NFT_MSG_DELSETELEM] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_setelem_list_type_system, .size = sizeof(struct nfgenmsg) }, | |
1645 | }; | |
1646 | ||
1647 | static const NLTypeSystem nfnl_nft_msg_type_system = { | |
1648 | .count = ELEMENTSOF(nfnl_nft_msg_types), | |
1649 | .types = nfnl_nft_msg_types, | |
1650 | }; | |
1651 | ||
1652 | static const NLType nfnl_msg_batch_types [] = { | |
1653 | [NFNL_BATCH_GENID] = { .type = NETLINK_TYPE_U32 } | |
1654 | }; | |
1655 | ||
1656 | static const NLTypeSystem nfnl_msg_batch_type_system = { | |
1657 | .count = ELEMENTSOF(nfnl_msg_batch_types), | |
1658 | .types = nfnl_msg_batch_types, | |
1659 | }; | |
1660 | ||
1661 | static const NLType nfnl_types[] = { | |
1662 | [NLMSG_DONE] = { .type = NETLINK_TYPE_NESTED, .type_system = &empty_type_system, .size = 0 }, | |
1663 | [NLMSG_ERROR] = { .type = NETLINK_TYPE_NESTED, .type_system = &error_type_system, .size = sizeof(struct nlmsgerr) }, | |
1664 | [NFNL_MSG_BATCH_BEGIN] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_msg_batch_type_system, .size = sizeof(struct nfgenmsg) }, | |
1665 | [NFNL_MSG_BATCH_END] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_msg_batch_type_system, .size = sizeof(struct nfgenmsg) }, | |
1666 | [NFNL_SUBSYS_NFTABLES] = { .type = NETLINK_TYPE_NESTED, .type_system = &nfnl_nft_msg_type_system, .size = sizeof(struct nfgenmsg) }, | |
1667 | }; | |
1668 | ||
1669 | const NLTypeSystem nfnl_type_system_root = { | |
1670 | .count = ELEMENTSOF(nfnl_types), | |
1671 | .types = nfnl_types, | |
1672 | }; | |
1673 | ||
4e8f0ef9 | 1674 | /* Mainly used when sending message */ |
05d0c2e3 JT |
1675 | const NLTypeSystem genl_family_type_system_root = { |
1676 | .count = ELEMENTSOF(genl_families), | |
1677 | .types = genl_families, | |
1678 | }; | |
1679 | ||
1680 | static const NLType genl_types[] = { | |
e4a1e68d | 1681 | [SD_GENL_ERROR] = { .type = NETLINK_TYPE_NESTED, .type_system = &error_type_system, .size = sizeof(struct nlmsgerr) }, |
2be081ff | 1682 | [SD_GENL_DONE] = { .type = NETLINK_TYPE_NESTED, .type_system = &empty_type_system }, |
4e8f0ef9 | 1683 | [SD_GENL_ID_CTRL] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_get_family_type_system, .size = sizeof(struct genlmsghdr) }, |
a1d736e2 | 1684 | [SD_GENL_NL80211] = { .type = NETLINK_TYPE_NESTED, .type_system = &genl_nl80211_type_system, .size = sizeof(struct genlmsghdr) }, |
05d0c2e3 JT |
1685 | }; |
1686 | ||
4e8f0ef9 | 1687 | /* Mainly used when message received */ |
05d0c2e3 JT |
1688 | const NLTypeSystem genl_type_system_root = { |
1689 | .count = ELEMENTSOF(genl_types), | |
1690 | .types = genl_types, | |
1691 | }; | |
1692 | ||
817d1cd8 DH |
1693 | uint16_t type_get_type(const NLType *type) { |
1694 | assert(type); | |
1695 | return type->type; | |
1696 | } | |
1697 | ||
1698 | size_t type_get_size(const NLType *type) { | |
1699 | assert(type); | |
1700 | return type->size; | |
1701 | } | |
1702 | ||
49eb0a68 | 1703 | const NLTypeSystem *type_get_type_system(const NLType *nl_type) { |
c658008f | 1704 | assert(nl_type); |
c658008f DH |
1705 | assert(nl_type->type == NETLINK_TYPE_NESTED); |
1706 | assert(nl_type->type_system); | |
49eb0a68 | 1707 | return nl_type->type_system; |
c658008f DH |
1708 | } |
1709 | ||
49eb0a68 | 1710 | const NLTypeSystemUnion *type_get_type_system_union(const NLType *nl_type) { |
c658008f | 1711 | assert(nl_type); |
c658008f DH |
1712 | assert(nl_type->type == NETLINK_TYPE_UNION); |
1713 | assert(nl_type->type_system_union); | |
49eb0a68 | 1714 | return nl_type->type_system_union; |
c658008f DH |
1715 | } |
1716 | ||
c1df8dee | 1717 | uint16_t type_system_get_count(const NLTypeSystem *type_system) { |
435bbb02 | 1718 | assert(type_system); |
c1df8dee | 1719 | return type_system->count; |
435bbb02 DH |
1720 | } |
1721 | ||
05d0c2e3 JT |
1722 | const NLTypeSystem *type_system_get_root(int protocol) { |
1723 | switch (protocol) { | |
1724 | case NETLINK_GENERIC: | |
1725 | return &genl_type_system_root; | |
6f00fd9b FW |
1726 | case NETLINK_NETFILTER: |
1727 | return &nfnl_type_system_root; | |
05d0c2e3 JT |
1728 | default: /* NETLINK_ROUTE: */ |
1729 | return &rtnl_type_system_root; | |
1730 | } | |
1731 | } | |
1732 | ||
4e8f0ef9 | 1733 | int type_system_root_get_type(sd_netlink *nl, const NLType **ret, uint16_t type) { |
2324fd3a | 1734 | sd_genl_family_t family; |
4e8f0ef9 YW |
1735 | const NLType *nl_type; |
1736 | int r; | |
1737 | ||
6f00fd9b | 1738 | if (!nl) |
4e8f0ef9 YW |
1739 | return type_system_get_type(&rtnl_type_system_root, ret, type); |
1740 | ||
6f00fd9b FW |
1741 | if (nl->protocol != NETLINK_GENERIC) |
1742 | return type_system_get_type(type_system_get_root(nl->protocol), ret, type); | |
1743 | ||
4e8f0ef9 YW |
1744 | r = nlmsg_type_to_genl_family(nl, type, &family); |
1745 | if (r < 0) | |
1746 | return r; | |
1747 | ||
1748 | if (family >= genl_type_system_root.count) | |
1749 | return -EOPNOTSUPP; | |
1750 | ||
1751 | nl_type = &genl_type_system_root.types[family]; | |
1752 | ||
1753 | if (nl_type->type == NETLINK_TYPE_UNSPEC) | |
1754 | return -EOPNOTSUPP; | |
1755 | ||
1756 | *ret = nl_type; | |
1757 | ||
1758 | return 0; | |
1759 | } | |
1760 | ||
d8e538ec TG |
1761 | int type_system_get_type(const NLTypeSystem *type_system, const NLType **ret, uint16_t type) { |
1762 | const NLType *nl_type; | |
1763 | ||
1764 | assert(ret); | |
846a6b3d | 1765 | assert(type_system); |
d8e538ec TG |
1766 | assert(type_system->types); |
1767 | ||
c1df8dee | 1768 | if (type >= type_system->count) |
15411c0c | 1769 | return -EOPNOTSUPP; |
d8e538ec TG |
1770 | |
1771 | nl_type = &type_system->types[type]; | |
1772 | ||
cafbc790 | 1773 | if (nl_type->type == NETLINK_TYPE_UNSPEC) |
15411c0c | 1774 | return -EOPNOTSUPP; |
d8e538ec TG |
1775 | |
1776 | *ret = nl_type; | |
d8e538ec TG |
1777 | return 0; |
1778 | } | |
1779 | ||
1780 | int type_system_get_type_system(const NLTypeSystem *type_system, const NLTypeSystem **ret, uint16_t type) { | |
1781 | const NLType *nl_type; | |
1782 | int r; | |
1783 | ||
1784 | assert(ret); | |
1785 | ||
1786 | r = type_system_get_type(type_system, &nl_type, type); | |
1787 | if (r < 0) | |
1788 | return r; | |
1789 | ||
49eb0a68 | 1790 | *ret = type_get_type_system(nl_type); |
d8e538ec TG |
1791 | return 0; |
1792 | } | |
1793 | ||
1794 | int type_system_get_type_system_union(const NLTypeSystem *type_system, const NLTypeSystemUnion **ret, uint16_t type) { | |
1795 | const NLType *nl_type; | |
1796 | int r; | |
1797 | ||
1798 | assert(ret); | |
1799 | ||
1800 | r = type_system_get_type(type_system, &nl_type, type); | |
1801 | if (r < 0) | |
1802 | return r; | |
1803 | ||
49eb0a68 | 1804 | *ret = type_get_type_system_union(nl_type); |
d8e538ec TG |
1805 | return 0; |
1806 | } | |
1807 | ||
ea073c8f | 1808 | int type_system_union_get_type_system_by_string(const NLTypeSystemUnion *type_system_union, const NLTypeSystem **ret, const char *key) { |
d8e538ec TG |
1809 | int type; |
1810 | ||
1811 | assert(type_system_union); | |
f8a6ca1b | 1812 | assert(type_system_union->match_type == NL_MATCH_SIBLING); |
d8e538ec TG |
1813 | assert(type_system_union->lookup); |
1814 | assert(type_system_union->type_systems); | |
1815 | assert(ret); | |
1816 | assert(key); | |
1817 | ||
1818 | type = type_system_union->lookup(key); | |
1819 | if (type < 0) | |
15411c0c | 1820 | return -EOPNOTSUPP; |
d8e538ec TG |
1821 | |
1822 | assert(type < type_system_union->num); | |
1823 | ||
1824 | *ret = &type_system_union->type_systems[type]; | |
d8e538ec TG |
1825 | return 0; |
1826 | } | |
4af7b60d | 1827 | |
ea073c8f | 1828 | int type_system_union_get_type_system_by_protocol(const NLTypeSystemUnion *type_system_union, const NLTypeSystem **ret, uint16_t protocol) { |
4af7b60d TG |
1829 | const NLTypeSystem *type_system; |
1830 | ||
1831 | assert(type_system_union); | |
1832 | assert(type_system_union->type_systems); | |
f8a6ca1b | 1833 | assert(type_system_union->match_type == NL_MATCH_PROTOCOL); |
4af7b60d | 1834 | assert(ret); |
4af7b60d TG |
1835 | |
1836 | if (protocol >= type_system_union->num) | |
15411c0c | 1837 | return -EOPNOTSUPP; |
4af7b60d TG |
1838 | |
1839 | type_system = &type_system_union->type_systems[protocol]; | |
e7de105c | 1840 | if (!type_system->types) |
15411c0c | 1841 | return -EOPNOTSUPP; |
4af7b60d TG |
1842 | |
1843 | *ret = type_system; | |
4af7b60d TG |
1844 | return 0; |
1845 | } |