• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3  * Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch>
4  * Copyright (c) 2013 Sassano Systems LLC <joe@sassanosystems.com>
5  */
6 
7 #ifndef NETLINK_LOCAL_TYPES_H_
8 #define NETLINK_LOCAL_TYPES_H_
9 
10 #include <netlink/list.h>
11 #include <netlink/route/link.h>
12 #include <netlink/route/qdisc.h>
13 #include <netlink/route/rtnl.h>
14 #include <netlink/route/route.h>
15 #include <netlink/idiag/idiagnl.h>
16 #include <netlink/netfilter/ct.h>
17 #include <netlink-private/object-api.h>
18 #include <netlink-private/route/tc-api.h>
19 #include <netlink-private/route/link/sriov.h>
20 #include <netlink-private/route/nexthop-encap.h>
21 #include <linux/netlink.h>
22 #include <linux/rtnetlink.h>
23 #include <linux/genetlink.h>
24 #include <linux/tc_act/tc_mirred.h>
25 #include <linux/tc_act/tc_skbedit.h>
26 #include <linux/tc_act/tc_gact.h>
27 #include <linux/tc_act/tc_vlan.h>
28 #include <linux/sock_diag.h>
29 #include <linux/fib_rules.h>
30 #include <linux/if_ether.h>
31 
32 #include <netinet/in.h>
33 
34 #define NL_SOCK_PASSCRED	(1<<1)
35 #define NL_OWN_PORT		(1<<2)
36 #define NL_MSG_PEEK		(1<<3)
37 #define NL_MSG_PEEK_EXPLICIT	(1<<4)
38 #define NL_NO_AUTO_ACK		(1<<5)
39 
40 #define NL_MSG_CRED_PRESENT 1
41 
42 struct nl_cache_ops;
43 struct nl_sock;
44 struct nl_object;
45 struct nl_hash_table;
46 struct nl_vf_vlans;
47 
48 struct nl_cb
49 {
50 	nl_recvmsg_msg_cb_t	cb_set[NL_CB_TYPE_MAX+1];
51 	void *			cb_args[NL_CB_TYPE_MAX+1];
52 
53 	nl_recvmsg_err_cb_t	cb_err;
54 	void *			cb_err_arg;
55 
56 	/** May be used to replace nl_recvmsgs with your own implementation
57 	 * in all internal calls to nl_recvmsgs. */
58 	int			(*cb_recvmsgs_ow)(struct nl_sock *,
59 						  struct nl_cb *);
60 
61 	/** Overwrite internal calls to nl_recv, must return the number of
62 	 * octets read and allocate a buffer for the received data. */
63 	int			(*cb_recv_ow)(struct nl_sock *,
64 					      struct sockaddr_nl *,
65 					      unsigned char **,
66 					      struct ucred **);
67 
68 	/** Overwrites internal calls to nl_send, must send the netlink
69 	 * message. */
70 	int			(*cb_send_ow)(struct nl_sock *,
71 					      struct nl_msg *);
72 
73 	int			cb_refcnt;
74 	/** indicates the callback that is currently active */
75 	enum nl_cb_type		cb_active;
76 };
77 
78 struct nl_sock
79 {
80 	struct sockaddr_nl	s_local;
81 	struct sockaddr_nl	s_peer;
82 	int			s_fd;
83 	int			s_proto;
84 	unsigned int		s_seq_next;
85 	unsigned int		s_seq_expect;
86 	int			s_flags;
87 	struct nl_cb *		s_cb;
88 	size_t			s_bufsize;
89 };
90 
91 struct nl_cache
92 {
93 	struct nl_list_head	c_items;
94 	int			c_nitems;
95 	int                     c_iarg1;
96 	int                     c_iarg2;
97 	int			c_refcnt;
98 	unsigned int		c_flags;
99 	struct nl_hash_table *	hashtable;
100 	struct nl_cache_ops *   c_ops;
101 };
102 
103 struct nl_cache_assoc
104 {
105 	struct nl_cache *	ca_cache;
106 	change_func_t		ca_change;
107 	change_func_v2_t	ca_change_v2;
108 	void *			ca_change_data;
109 };
110 
111 struct nl_cache_mngr
112 {
113 	int			cm_protocol;
114 	int			cm_flags;
115 	int			cm_nassocs;
116 	struct nl_sock *	cm_sock;
117 	struct nl_sock *	cm_sync_sock;
118 	struct nl_cache_assoc *	cm_assocs;
119 };
120 
121 struct nl_parser_param;
122 
123 #define LOOSE_COMPARISON	1
124 #define ID_COMPARISON           2
125 
126 #define NL_OBJ_MARK		1
127 
128 struct nl_data
129 {
130 	size_t			d_size;
131 	void *			d_data;
132 };
133 
134 struct nl_addr
135 {
136 	int			a_family;
137 	unsigned int		a_maxsize;
138 	unsigned int		a_len;
139 	int			a_prefixlen;
140 	int			a_refcnt;
141 	char			a_addr[0];
142 };
143 
144 struct nl_msg
145 {
146 	int			nm_protocol;
147 	int			nm_flags;
148 	struct sockaddr_nl	nm_src;
149 	struct sockaddr_nl	nm_dst;
150 	struct ucred		nm_creds;
151 	struct nlmsghdr *	nm_nlh;
152 	size_t			nm_size;
153 	int			nm_refcnt;
154 };
155 
156 struct rtnl_link_map
157 {
158 	uint64_t lm_mem_start;
159 	uint64_t lm_mem_end;
160 	uint64_t lm_base_addr;
161 	uint16_t lm_irq;
162 	uint8_t  lm_dma;
163 	uint8_t  lm_port;
164 };
165 
166 struct rtnl_link_vf
167 {
168 	struct nl_list_head	vf_list;
169 	int			ce_refcnt;
170 	uint32_t		ce_mask;
171 	uint32_t		vf_index;
172 	uint64_t		vf_guid_node;
173 	uint64_t		vf_guid_port;
174 	uint32_t		vf_linkstate;
175 	struct nl_addr *	vf_lladdr;
176 	uint32_t		vf_max_tx_rate;
177 	uint32_t		vf_min_tx_rate;
178 	uint32_t		vf_rate;
179 	uint32_t		vf_rss_query_en;
180 	uint32_t		vf_spoofchk;
181 	uint64_t		vf_stats[RTNL_LINK_VF_STATS_MAX+1];
182 	uint32_t		vf_trust;
183 	struct nl_vf_vlans *	vf_vlans;
184 };
185 
186 #define IFQDISCSIZ	32
187 
188 struct rtnl_link
189 {
190 	NLHDR_COMMON
191 
192 	char				l_name[IFNAMSIZ];
193 	uint32_t			l_family;
194 	uint32_t			l_arptype;
195 	uint32_t			l_index;
196 	uint32_t			l_flags;
197 	uint32_t			l_change;
198 	uint32_t			l_mtu;
199 	uint32_t			l_link;
200 	int32_t                         l_link_netnsid;
201 	uint32_t			l_txqlen;
202 	uint32_t			l_weight;
203 	uint32_t			l_master;
204 	struct nl_addr *		l_addr;
205 	struct nl_addr *		l_bcast;
206 	char				l_qdisc[IFQDISCSIZ];
207 	struct rtnl_link_map		l_map;
208 	uint64_t			l_stats[RTNL_LINK_STATS_MAX+1];
209 	uint32_t			l_flag_mask;
210 	uint32_t			l_num_vf;
211 	uint8_t				l_operstate;
212 	uint8_t				l_linkmode;
213 	/* 2 byte hole */
214 	char *				l_info_kind;
215 	char *				l_info_slave_kind;
216 	struct rtnl_link_info_ops *	l_info_ops;
217 	void *				l_af_data[AF_MAX];
218 	void *				l_info;
219 	char *				l_ifalias;
220 	uint32_t			l_promiscuity;
221 	uint32_t			l_num_tx_queues;
222 	uint32_t			l_num_rx_queues;
223 	uint32_t			l_gso_max_segs;
224 	uint32_t			l_gso_max_size;
225 	uint32_t			l_group;
226 	uint8_t				l_carrier;
227 	/* 3 byte hole */
228 	uint32_t			l_carrier_changes;
229 	struct rtnl_link_af_ops *	l_af_ops;
230 	struct nl_data *		l_phys_port_id;
231 	char				l_phys_port_name[IFNAMSIZ];
232 	struct nl_data *		l_phys_switch_id;
233 	int				l_ns_fd;
234 	pid_t				l_ns_pid;
235 	struct rtnl_link_vf *		l_vf_list;
236 };
237 
238 struct rtnl_ncacheinfo
239 {
240 	uint32_t nci_confirmed;	/**< Time since neighbour validty was last confirmed */
241 	uint32_t nci_used;	/**< Time since neighbour entry was last ued */
242 	uint32_t nci_updated;	/**< Time since last update */
243 	uint32_t nci_refcnt;	/**< Reference counter */
244 };
245 
246 
247 struct rtnl_neigh
248 {
249 	NLHDR_COMMON
250 	uint32_t	n_family;
251 	uint32_t	n_ifindex;
252 	uint16_t	n_state;
253 	uint8_t		n_flags;
254 	uint8_t		n_type;
255 	struct nl_addr *n_lladdr;
256 	struct nl_addr *n_dst;
257 	uint32_t	n_probes;
258 	struct rtnl_ncacheinfo n_cacheinfo;
259 	uint32_t                n_state_mask;
260 	uint32_t                n_flag_mask;
261 	uint32_t		n_master;
262 	uint16_t	n_vlan;
263 };
264 
265 
266 struct rtnl_addr_cacheinfo
267 {
268 	/* Preferred lifetime in seconds, ticking from when the message gets constructed */
269 	uint32_t aci_prefered;
270 
271 	/* Valid lifetime in seconds, ticking from when the message gets constructed */
272 	uint32_t aci_valid;
273 
274 	/* Timestamp of creation in 1/100s since boottime, clock_gettime(CLOCK_MONOTONIC) */
275 	uint32_t aci_cstamp;
276 
277 	/* Timestamp of last update in 1/100s since boottime, clock_gettime(CLOCK_MONOTONIC) */
278 	uint32_t aci_tstamp;
279 };
280 
281 struct rtnl_addr
282 {
283 	NLHDR_COMMON
284 
285 	uint8_t		a_family;
286 	uint8_t		a_prefixlen;
287 	uint8_t		a_scope;
288 	uint32_t	a_flags;
289 	uint32_t	a_ifindex;
290 
291 	struct nl_addr *a_peer;
292 	struct nl_addr *a_local;
293 	struct nl_addr *a_bcast;
294 	struct nl_addr *a_anycast;
295 	struct nl_addr *a_multicast;
296 
297 	struct rtnl_addr_cacheinfo a_cacheinfo;
298 
299 	char a_label[IFNAMSIZ];
300 	uint32_t a_flag_mask;
301 	struct rtnl_link *a_link;
302 };
303 
304 struct rtnl_nh_encap
305 {
306 	struct nh_encap_ops *ops;
307 	void *priv;    /* private data for encap type */
308 };
309 
310 struct rtnl_nexthop
311 {
312 	uint8_t			rtnh_flags;
313 	uint8_t			rtnh_flag_mask;
314 	uint8_t			rtnh_weight;
315 	/* 1 byte spare */
316 	uint32_t		rtnh_ifindex;
317 	struct nl_addr *	rtnh_gateway;
318 	uint32_t		ce_mask; /* HACK to support attr macros */
319 	struct nl_list_head	rtnh_list;
320 	uint32_t		rtnh_realms;
321 	struct nl_addr *	rtnh_newdst;
322 	struct nl_addr *	rtnh_via;
323 	struct rtnl_nh_encap *	rtnh_encap;
324 };
325 
326 struct rtnl_route
327 {
328 	NLHDR_COMMON
329 
330 	uint8_t			rt_family;
331 	uint8_t			rt_dst_len;
332 	uint8_t			rt_src_len;
333 	uint8_t			rt_tos;
334 	uint8_t			rt_protocol;
335 	uint8_t			rt_scope;
336 	uint8_t			rt_type;
337 	uint8_t			rt_nmetrics;
338 	uint8_t			rt_ttl_propagate;
339 	uint32_t		rt_flags;
340 	struct nl_addr *	rt_dst;
341 	struct nl_addr *	rt_src;
342 	uint32_t		rt_table;
343 	uint32_t		rt_iif;
344 	uint32_t		rt_prio;
345 	uint32_t		rt_metrics[RTAX_MAX];
346 	uint32_t		rt_metrics_mask;
347 	uint32_t		rt_nr_nh;
348 	struct nl_addr *	rt_pref_src;
349 	struct nl_list_head	rt_nexthops;
350 	struct rtnl_rtcacheinfo	rt_cacheinfo;
351 	uint32_t		rt_flag_mask;
352 };
353 
354 struct rtnl_rule
355 {
356 	NLHDR_COMMON
357 	uint8_t		r_family;
358 	uint8_t		r_action;
359 	uint8_t		r_dsfield; /* ipv4 only */
360 	uint8_t		r_l3mdev;
361 	uint8_t		r_protocol; /* protocol that installed rule */
362 	uint8_t		r_ip_proto; /* IP/IPv6 protocol */
363 	uint32_t	r_table;
364 	uint32_t	r_flags;
365 	uint32_t	r_prio;
366 	uint32_t	r_mark;
367 	uint32_t	r_mask;
368 	uint32_t	r_goto;
369 	uint32_t	r_flow; /* ipv4 only */
370 	struct nl_addr *r_src;
371 	struct nl_addr *r_dst;
372 	char		r_iifname[IFNAMSIZ];
373 	char		r_oifname[IFNAMSIZ];
374 
375 	struct fib_rule_port_range	r_sport;
376 	struct fib_rule_port_range	r_dport;
377 };
378 
379 struct rtnl_neightbl_parms
380 {
381 	/**
382 	 * Interface index of the device this parameter set is assigned
383 	 * to or 0 for the default set.
384 	 */
385 	uint32_t		ntp_ifindex;
386 
387 	/**
388 	 * Number of references to this parameter set.
389 	 */
390 	uint32_t		ntp_refcnt;
391 
392 	/**
393 	 * Queue length for pending arp requests, i.e. the number of
394 	 * packets which are accepted from other layers while the
395 	 * neighbour address is still being resolved
396 	 */
397 	uint32_t		ntp_queue_len;
398 
399 	/**
400 	 * Number of requests to send to the user level ARP daemon.
401 	 * Specify 0 to disable.
402 	 */
403 	uint32_t		ntp_app_probes;
404 
405 	/**
406 	 * Maximum number of retries for unicast solicitation.
407 	 */
408 	uint32_t		ntp_ucast_probes;
409 
410 	/**
411 	 * Maximum number of retries for multicast solicitation.
412 	 */
413 	uint32_t		ntp_mcast_probes;
414 
415 	/**
416 	 * Base value in milliseconds to ompute reachable time, see RFC2461.
417 	 */
418 	uint64_t		ntp_base_reachable_time;
419 
420 	/**
421 	 * Actual reachable time (read-only)
422 	 */
423 	uint64_t		ntp_reachable_time;	/* secs */
424 
425 	/**
426 	 * The time in milliseconds between retransmitted Neighbor
427 	 * Solicitation messages.
428 	 */
429 	uint64_t		ntp_retrans_time;
430 
431 	/**
432 	 * Interval in milliseconds to check for stale neighbour
433 	 * entries.
434 	 */
435 	uint64_t		ntp_gc_stale_time;	/* secs */
436 
437 	/**
438 	 * Delay in milliseconds for the first time probe if
439 	 * the neighbour is reachable.
440 	 */
441 	uint64_t		ntp_probe_delay;	/* secs */
442 
443 	/**
444 	 * Maximum delay in milliseconds of an answer to a neighbour
445 	 * solicitation message.
446 	 */
447 	uint64_t		ntp_anycast_delay;
448 
449 	/**
450 	 * Minimum age in milliseconds before a neighbour entry
451 	 * may be replaced.
452 	 */
453 	uint64_t		ntp_locktime;
454 
455 	/**
456 	 * Delay in milliseconds before answering to an ARP request
457 	 * for which a proxy ARP entry exists.
458 	 */
459 	uint64_t		ntp_proxy_delay;
460 
461 	/**
462 	 * Queue length for the delayed proxy arp requests.
463 	 */
464 	uint32_t		ntp_proxy_qlen;
465 
466 	/**
467 	 * Mask of available parameter attributes
468 	 */
469 	uint32_t		ntp_mask;
470 };
471 
472 #define NTBLNAMSIZ	32
473 
474 /**
475  * Neighbour table
476  * @ingroup neightbl
477  */
478 struct rtnl_neightbl
479 {
480 	NLHDR_COMMON
481 
482 	char			nt_name[NTBLNAMSIZ];
483 	uint32_t		nt_family;
484 	uint32_t		nt_gc_thresh1;
485 	uint32_t		nt_gc_thresh2;
486 	uint32_t		nt_gc_thresh3;
487 	uint64_t		nt_gc_interval;
488 	struct ndt_config	nt_config;
489 	struct rtnl_neightbl_parms nt_parms;
490 	struct ndt_stats	nt_stats;
491 };
492 
493 struct rtnl_ratespec
494 {
495 	uint64_t		rs_rate64;
496 	uint16_t		rs_overhead;
497 	int16_t			rs_cell_align;
498 	uint16_t		rs_mpu;
499 	uint8_t			rs_cell_log;
500 };
501 
502 struct rtnl_tstats
503 {
504 	struct {
505 		uint64_t            bytes;
506 		uint64_t            packets;
507 	} tcs_basic;
508 
509 	struct {
510 		uint32_t            bps;
511 		uint32_t            pps;
512 	} tcs_rate_est;
513 
514 	struct {
515 		uint32_t            qlen;
516 		uint32_t            backlog;
517 		uint32_t            drops;
518 		uint32_t            requeues;
519 		uint32_t            overlimits;
520 	} tcs_queue;
521 };
522 
523 #define TCKINDSIZ	32
524 
525 #define NL_TC_GENERIC(pre)				\
526 	NLHDR_COMMON					\
527 	uint32_t		pre ##_family;		\
528 	uint32_t		pre ##_ifindex;		\
529 	uint32_t		pre ##_handle;		\
530 	uint32_t		pre ##_parent;		\
531 	uint32_t		pre ##_info;		\
532 	uint32_t		pre ##_mtu;		\
533 	uint32_t		pre ##_mpu;		\
534 	uint32_t		pre ##_overhead;	\
535 	uint32_t		pre ##_linktype;	\
536 	char			pre ##_kind[TCKINDSIZ];	\
537 	struct nl_data *	pre ##_opts;		\
538 	uint64_t		pre ##_stats[RTNL_TC_STATS_MAX+1]; \
539 	struct nl_data *	pre ##_xstats;		\
540 	struct nl_data *	pre ##_subdata;		\
541 	struct rtnl_link *	pre ##_link;		\
542 	struct rtnl_tc_ops *	pre ##_ops;		\
543 	enum rtnl_tc_type	pre ##_type;		\
544 	uint32_t		pre ##_chain
545 
546 struct rtnl_tc
547 {
548 	NL_TC_GENERIC(tc);
549 };
550 
551 struct rtnl_qdisc
552 {
553 	NL_TC_GENERIC(q);
554 };
555 
556 struct rtnl_class
557 {
558 	NL_TC_GENERIC(c);
559 };
560 
561 struct rtnl_cls
562 {
563 	NL_TC_GENERIC(c);
564 	uint16_t		c_prio;
565 	uint16_t		c_protocol;
566 };
567 
568 struct rtnl_act
569 {
570 	NL_TC_GENERIC(c);
571 	struct rtnl_act *	a_next;
572 };
573 
574 struct rtnl_mirred
575 {
576 	struct tc_mirred m_parm;
577 };
578 
579 struct rtnl_skbedit
580 {
581 	struct tc_skbedit s_parm;
582 	uint32_t	  s_flags;
583 	uint32_t	  s_mark;
584 	uint32_t	  s_prio;
585 	uint16_t	  s_queue_mapping;
586 };
587 
588 struct rtnl_gact
589 {
590 	struct tc_gact g_parm;
591 };
592 
593 struct rtnl_u32
594 {
595 	uint32_t		cu_divisor;
596 	uint32_t		cu_hash;
597 	uint32_t		cu_classid;
598 	uint32_t		cu_link;
599 	struct nl_data *	cu_pcnt;
600 	struct nl_data *	cu_selector;
601 	struct nl_data *	cu_mark;
602 	struct rtnl_act*	cu_act;
603 	struct nl_data *	cu_police;
604 	char			cu_indev[IFNAMSIZ];
605 	int			cu_mask;
606 };
607 
608 struct rtnl_mall
609 {
610 	uint32_t         m_classid;
611 	uint32_t         m_flags;
612 	struct rtnl_act *m_act;
613 	int              m_mask;
614 };
615 
616 struct rtnl_flower
617 {
618 	struct rtnl_act *cf_act;
619 	int              cf_mask;
620 	uint32_t         cf_flags;
621 	uint16_t         cf_proto;
622 	uint16_t         cf_vlan_id;
623 	uint16_t         cf_vlan_ethtype;
624 	uint8_t          cf_vlan_prio;
625 	uint8_t          cf_src_mac[ETH_ALEN];
626 	uint8_t          cf_src_mac_mask[ETH_ALEN];
627 	uint8_t          cf_dst_mac[ETH_ALEN];
628 	uint8_t          cf_dst_mac_mask[ETH_ALEN];
629 	in_addr_t        cf_ipv4_src;
630 	in_addr_t        cf_ipv4_src_mask;
631 	in_addr_t        cf_ipv4_dst;
632 	in_addr_t        cf_ipv4_dst_mask;
633 	uint8_t          cf_ip_dscp;
634 	uint8_t          cf_ip_dscp_mask;
635 };
636 
637 struct rtnl_cgroup
638 {
639 	struct rtnl_ematch_tree *cg_ematch;
640 	int			cg_mask;
641 };
642 
643 struct rtnl_fw
644 {
645 	uint32_t		cf_classid;
646 	struct nl_data *	cf_act;
647 	struct nl_data *	cf_police;
648 	char			cf_indev[IFNAMSIZ];
649 	uint32_t		cf_fwmask;
650 	int			cf_mask;
651 };
652 
653 struct rtnl_ematch
654 {
655 	uint16_t		e_id;
656 	uint16_t		e_kind;
657 	uint16_t		e_flags;
658 	uint16_t		e_index;
659 	size_t			e_datalen;
660 
661 	struct nl_list_head	e_childs;
662 	struct nl_list_head	e_list;
663 	struct rtnl_ematch_ops *e_ops;
664 
665 	void *			e_data;
666 };
667 
668 struct rtnl_ematch_tree
669 {
670 	uint16_t		et_progid;
671 	struct nl_list_head	et_list;
672 
673 };
674 
675 struct rtnl_dsmark_qdisc
676 {
677 	uint16_t	qdm_indices;
678 	uint16_t	qdm_default_index;
679 	uint32_t	qdm_set_tc_index;
680 	uint32_t	qdm_mask;
681 };
682 
683 struct rtnl_dsmark_class
684 {
685 	uint8_t		cdm_bmask;
686 	uint8_t		cdm_value;
687 	uint32_t	cdm_mask;
688 };
689 
690 struct rtnl_fifo
691 {
692 	uint32_t	qf_limit;
693 	uint32_t	qf_mask;
694 };
695 
696 struct rtnl_prio
697 {
698 	uint32_t	qp_bands;
699 	uint8_t		qp_priomap[TC_PRIO_MAX+1];
700 	uint32_t	qp_mask;
701 };
702 
703 struct rtnl_mqprio
704 {
705         uint8_t         qm_num_tc;
706         uint8_t         qm_prio_map[TC_QOPT_BITMASK + 1];
707         uint8_t         qm_hw;
708         uint16_t        qm_count[TC_QOPT_MAX_QUEUE];
709         uint16_t        qm_offset[TC_QOPT_MAX_QUEUE];
710         uint16_t        qm_mode;
711         uint16_t        qm_shaper;
712         uint64_t        qm_min_rate[TC_QOPT_MAX_QUEUE];
713         uint64_t        qm_max_rate[TC_QOPT_MAX_QUEUE];
714         uint32_t        qm_mask;
715 };
716 
717 struct rtnl_tbf
718 {
719 	uint32_t		qt_limit;
720 	struct rtnl_ratespec	qt_rate;
721 	uint32_t		qt_rate_bucket;
722 	uint32_t		qt_rate_txtime;
723 	struct rtnl_ratespec	qt_peakrate;
724 	uint32_t		qt_peakrate_bucket;
725 	uint32_t		qt_peakrate_txtime;
726 	uint32_t		qt_mask;
727 };
728 
729 struct rtnl_sfq
730 {
731 	uint32_t	qs_quantum;
732 	uint32_t	qs_perturb;
733 	uint32_t	qs_limit;
734 	uint32_t	qs_divisor;
735 	uint32_t	qs_flows;
736 	uint32_t	qs_mask;
737 };
738 
739 struct rtnl_netem_corr
740 {
741 	uint32_t	nmc_delay;
742 	uint32_t	nmc_loss;
743 	uint32_t	nmc_duplicate;
744 };
745 
746 struct rtnl_netem_reo
747 {
748 	uint32_t	nmro_probability;
749 	uint32_t	nmro_correlation;
750 };
751 
752 struct rtnl_netem_crpt
753 {
754 	uint32_t	nmcr_probability;
755 	uint32_t	nmcr_correlation;
756 };
757 
758 struct rtnl_netem_dist
759 {
760 	int16_t	*	dist_data;
761 	size_t		dist_size;
762 };
763 
764 struct rtnl_netem
765 {
766 	uint32_t		qnm_latency;
767 	uint32_t		qnm_limit;
768 	uint32_t		qnm_loss;
769 	uint32_t		qnm_gap;
770 	uint32_t		qnm_duplicate;
771 	uint32_t		qnm_jitter;
772 	uint32_t		qnm_mask;
773 	struct rtnl_netem_corr	qnm_corr;
774 	struct rtnl_netem_reo	qnm_ro;
775 	struct rtnl_netem_crpt	qnm_crpt;
776 	struct rtnl_netem_dist  qnm_dist;
777 };
778 
779 struct rtnl_htb_qdisc
780 {
781 	uint32_t		qh_rate2quantum;
782 	uint32_t		qh_defcls;
783 	uint32_t		qh_mask;
784 	uint32_t		qh_direct_pkts;
785 };
786 
787 struct rtnl_htb_class
788 {
789 	uint32_t		ch_prio;
790 	struct rtnl_ratespec	ch_rate;
791 	struct rtnl_ratespec	ch_ceil;
792 	uint32_t		ch_rbuffer;
793 	uint32_t		ch_cbuffer;
794 	uint32_t		ch_quantum;
795 	uint32_t		ch_mask;
796 	uint32_t		ch_level;
797 };
798 
799 struct rtnl_cbq
800 {
801 	struct tc_cbq_lssopt    cbq_lss;
802 	struct tc_ratespec      cbq_rate;
803 	struct tc_cbq_wrropt    cbq_wrr;
804 	struct tc_cbq_ovl       cbq_ovl;
805 	struct tc_cbq_fopt      cbq_fopt;
806 	struct tc_cbq_police    cbq_police;
807 };
808 
809 struct rtnl_red
810 {
811 	uint32_t	qr_limit;
812 	uint32_t	qr_qth_min;
813 	uint32_t	qr_qth_max;
814 	uint8_t		qr_flags;
815 	uint8_t		qr_wlog;
816 	uint8_t		qr_plog;
817 	uint8_t		qr_scell_log;
818 	uint32_t	qr_mask;
819 };
820 
821 struct rtnl_plug
822 {
823 	int             action;
824 	uint32_t        limit;
825 };
826 
827 struct rtnl_fq_codel
828 {
829 	int		fq_limit;
830 	uint32_t	fq_target;
831 	uint32_t	fq_interval;
832 	int		fq_flows;
833 	uint32_t	fq_quantum;
834 	int		fq_ecn;
835 	uint32_t	fq_mask;
836 };
837 
838 struct rtnl_hfsc_qdisc
839 {
840 	uint32_t		qh_defcls;
841 	uint32_t		qh_mask;
842 };
843 
844 struct rtnl_hfsc_class
845 {
846 	struct tc_service_curve ch_rsc;
847 	struct tc_service_curve ch_fsc;
848 	struct tc_service_curve ch_usc;
849 	uint32_t		ch_mask;
850 };
851 
852 struct flnl_request
853 {
854 	NLHDR_COMMON
855 
856 	struct nl_addr *	lr_addr;
857 	uint32_t		lr_fwmark;
858 	uint8_t			lr_tos;
859 	uint8_t			lr_scope;
860 	uint8_t			lr_table;
861 };
862 
863 
864 struct flnl_result
865 {
866 	NLHDR_COMMON
867 
868 	struct flnl_request *	fr_req;
869 	uint8_t			fr_table_id;
870 	uint8_t			fr_prefixlen;
871 	uint8_t			fr_nh_sel;
872 	uint8_t			fr_type;
873 	uint8_t			fr_scope;
874 	uint32_t		fr_error;
875 };
876 
877 #define GENL_OP_HAS_POLICY	1
878 #define GENL_OP_HAS_DOIT	2
879 #define GENL_OP_HAS_DUMPIT	4
880 
881 struct genl_family_op
882 {
883 	uint32_t		o_id;
884 	uint32_t		o_flags;
885 
886 	struct nl_list_head	o_list;
887 };
888 
889 struct genl_family_grp {
890         struct genl_family      *family;        /* private */
891         struct nl_list_head     list;           /* private */
892         char                    name[GENL_NAMSIZ];
893         u_int32_t               id;
894 };
895 
896 struct genl_family
897 {
898 	NLHDR_COMMON
899 
900 	uint16_t		gf_id;
901 	char 			gf_name[GENL_NAMSIZ];
902 	uint32_t		gf_version;
903 	uint32_t		gf_hdrsize;
904 	uint32_t		gf_maxattr;
905 
906 	struct nl_list_head	gf_ops;
907 	struct nl_list_head	gf_mc_grps;
908 };
909 
910 union nfnl_ct_proto
911 {
912 	struct {
913 		uint16_t	src;
914 		uint16_t	dst;
915 	} port;
916 	struct {
917 		uint16_t	id;
918 		uint8_t		type;
919 		uint8_t		code;
920 	} icmp;
921 };
922 
923 struct nfnl_ct_dir {
924 	struct nl_addr *	src;
925 	struct nl_addr *	dst;
926 	union nfnl_ct_proto	proto;
927 	uint64_t		packets;
928 	uint64_t		bytes;
929 };
930 
931 union nfnl_ct_protoinfo {
932 	struct {
933 		uint8_t		state;
934 	} tcp;
935 };
936 
937 struct nfnl_ct {
938 	NLHDR_COMMON
939 
940 	uint8_t			ct_family;
941 	uint8_t			ct_proto;
942 	union nfnl_ct_protoinfo	ct_protoinfo;
943 
944 	uint32_t		ct_status;
945 	uint32_t		ct_status_mask;
946 	uint32_t		ct_timeout;
947 	uint32_t		ct_mark;
948 	uint32_t		ct_use;
949 	uint32_t		ct_id;
950 	uint16_t		ct_zone;
951 
952 	struct nfnl_ct_dir	ct_orig;
953 	struct nfnl_ct_dir	ct_repl;
954 
955 	struct nfnl_ct_timestamp ct_tstamp;
956 };
957 
958 union nfnl_exp_protodata {
959 	struct {
960 		uint16_t	src;
961 		uint16_t	dst;
962 	} port;
963 	struct {
964 		uint16_t	id;
965 		uint8_t		type;
966 		uint8_t		code;
967 	} icmp;
968 };
969 
970 // Allow for different master/expect l4 protocols
971 struct nfnl_exp_proto
972 {
973 	uint8_t						l4protonum;
974 	union nfnl_exp_protodata	l4protodata;
975 };
976 
977 struct nfnl_exp_dir {
978 	struct nl_addr *		src;
979 	struct nl_addr *		dst;
980 	struct nfnl_exp_proto	proto;
981 };
982 
983 struct nfnl_exp {
984 	NLHDR_COMMON
985 
986 	uint8_t			exp_family;
987 	uint32_t		exp_timeout;
988 	uint32_t		exp_id;
989 	uint16_t		exp_zone;
990 	uint32_t		exp_class;
991 	uint32_t		exp_flags;
992 	char *			exp_helper_name;
993 	char *			exp_fn;
994 	uint8_t			exp_nat_dir;
995 
996 	struct nfnl_exp_dir		exp_expect;
997 	struct nfnl_exp_dir		exp_master;
998 	struct nfnl_exp_dir		exp_mask;
999 	struct nfnl_exp_dir		exp_nat;
1000 };
1001 
1002 struct nfnl_log {
1003 	NLHDR_COMMON
1004 
1005 	uint16_t		log_group;
1006 	uint8_t			log_copy_mode;
1007 	uint32_t		log_copy_range;
1008 	uint32_t		log_flush_timeout;
1009 	uint32_t		log_alloc_size;
1010 	uint32_t		log_queue_threshold;
1011 	uint32_t		log_flags;
1012 	uint32_t		log_flag_mask;
1013 };
1014 
1015 struct nfnl_log_msg {
1016 	NLHDR_COMMON
1017 
1018 	uint8_t			log_msg_family;
1019 	uint8_t			log_msg_hook;
1020 	uint16_t		log_msg_hwproto;
1021 	uint32_t		log_msg_mark;
1022 	struct timeval		log_msg_timestamp;
1023 	uint32_t		log_msg_indev;
1024 	uint32_t		log_msg_outdev;
1025 	uint32_t		log_msg_physindev;
1026 	uint32_t		log_msg_physoutdev;
1027 	uint8_t			log_msg_hwaddr[8];
1028 	int			log_msg_hwaddr_len;
1029 	void *			log_msg_payload;
1030 	int			log_msg_payload_len;
1031 	char *			log_msg_prefix;
1032 	uint32_t		log_msg_uid;
1033 	uint32_t		log_msg_gid;
1034 	uint32_t		log_msg_seq;
1035 	uint32_t		log_msg_seq_global;
1036 	uint16_t		log_msg_hwtype;
1037 	uint16_t		log_msg_hwlen;
1038 	void *			log_msg_hwheader;
1039 	int			log_msg_hwheader_len;
1040 	uint16_t		log_msg_vlan_tag;
1041 	uint16_t		log_msg_vlan_proto;
1042 	uint32_t		log_msg_ct_info;
1043 	struct nfnl_ct *	log_msg_ct;
1044 };
1045 
1046 struct nfnl_queue {
1047 	NLHDR_COMMON
1048 
1049 	uint16_t		queue_group;
1050 	uint32_t		queue_maxlen;
1051 	uint32_t		queue_copy_range;
1052 	uint8_t			queue_copy_mode;
1053 };
1054 
1055 struct nfnl_queue_msg {
1056 	NLHDR_COMMON
1057 
1058 	uint16_t		queue_msg_group;
1059 	uint8_t			queue_msg_family;
1060 	uint8_t			queue_msg_hook;
1061 	uint16_t		queue_msg_hwproto;
1062 	uint32_t		queue_msg_packetid;
1063 	uint32_t		queue_msg_mark;
1064 	struct timeval		queue_msg_timestamp;
1065 	uint32_t		queue_msg_indev;
1066 	uint32_t		queue_msg_outdev;
1067 	uint32_t		queue_msg_physindev;
1068 	uint32_t		queue_msg_physoutdev;
1069 	uint8_t			queue_msg_hwaddr[8];
1070 	int			queue_msg_hwaddr_len;
1071 	void *			queue_msg_payload;
1072 	int			queue_msg_payload_len;
1073 	uint32_t		queue_msg_verdict;
1074 };
1075 
1076 struct ematch_quoted {
1077 	char *	data;
1078 	size_t	len;
1079 	int	index;
1080 };
1081 
1082 struct idiagnl_meminfo {
1083 	NLHDR_COMMON
1084 
1085 	uint32_t idiag_rmem;
1086 	uint32_t idiag_wmem;
1087 	uint32_t idiag_fmem;
1088 	uint32_t idiag_tmem;
1089 };
1090 
1091 struct idiagnl_vegasinfo {
1092 	NLHDR_COMMON
1093 
1094 	uint32_t tcpv_enabled;
1095 	uint32_t tcpv_rttcnt;
1096 	uint32_t tcpv_rtt;
1097 	uint32_t tcpv_minrtt;
1098 };
1099 
1100 struct idiagnl_msg {
1101 	NLHDR_COMMON
1102 
1103 	uint8_t			    idiag_family;
1104 	uint8_t			    idiag_state;
1105 	uint8_t			    idiag_timer;
1106 	uint8_t			    idiag_retrans;
1107 	uint16_t		    idiag_sport;
1108 	uint16_t		    idiag_dport;
1109 	struct nl_addr *	    idiag_src;
1110 	struct nl_addr *	    idiag_dst;
1111 	uint32_t		    idiag_ifindex;
1112 	uint32_t		    idiag_expires;
1113 	uint32_t		    idiag_rqueue;
1114 	uint32_t		    idiag_wqueue;
1115 	uint32_t		    idiag_uid;
1116 	uint32_t		    idiag_inode;
1117 
1118 	uint8_t			    idiag_tos;
1119 	uint8_t			    idiag_tclass;
1120 	uint8_t			    idiag_shutdown;
1121 	char *			    idiag_cong;
1122 	struct idiagnl_meminfo *    idiag_meminfo;
1123 	struct idiagnl_vegasinfo *  idiag_vegasinfo;
1124 	struct tcp_info		    idiag_tcpinfo;
1125 	uint32_t		    idiag_skmeminfo[SK_MEMINFO_VARS];
1126 };
1127 
1128 struct idiagnl_req {
1129 	NLHDR_COMMON
1130 
1131 	uint8_t			idiag_family;
1132 	uint8_t			idiag_ext;
1133 	struct nl_addr *	idiag_src;
1134 	struct nl_addr *	idiag_dst;
1135 	uint32_t		idiag_ifindex;
1136 	uint32_t		idiag_states;
1137 	uint32_t		idiag_dbs;
1138 };
1139 
1140 // XFRM related definitions
1141 
1142 /* Selector, used as selector both on policy rules (SPD) and SAs. */
1143 struct xfrmnl_sel {
1144 	uint32_t        refcnt;
1145 	struct nl_addr* daddr;
1146 	struct nl_addr* saddr;
1147 	uint16_t        dport;
1148 	uint16_t        dport_mask;
1149 	uint16_t        sport;
1150 	uint16_t        sport_mask;
1151 	uint16_t        family;
1152 	uint8_t         prefixlen_d;
1153 	uint8_t         prefixlen_s;
1154 	uint8_t         proto;
1155 	int32_t         ifindex;
1156 	uint32_t        user;
1157 };
1158 
1159 /* Lifetime configuration, used for both policy rules (SPD) and SAs. */
1160 struct xfrmnl_ltime_cfg {
1161 	uint32_t        refcnt;
1162 	uint64_t        soft_byte_limit;
1163 	uint64_t        hard_byte_limit;
1164 	uint64_t        soft_packet_limit;
1165 	uint64_t        hard_packet_limit;
1166 	uint64_t        soft_add_expires_seconds;
1167 	uint64_t        hard_add_expires_seconds;
1168 	uint64_t        soft_use_expires_seconds;
1169 	uint64_t        hard_use_expires_seconds;
1170 };
1171 
1172 /* Current lifetime, used for both policy rules (SPD) and SAs. */
1173 struct xfrmnl_lifetime_cur {
1174 	uint64_t        bytes;
1175 	uint64_t        packets;
1176 	uint64_t        add_time;
1177 	uint64_t        use_time;
1178 };
1179 
1180 struct xfrmnl_replay_state {
1181 	uint32_t        oseq;
1182 	uint32_t        seq;
1183 	uint32_t        bitmap;
1184 };
1185 
1186 struct xfrmnl_replay_state_esn {
1187 	uint32_t        bmp_len;
1188 	uint32_t        oseq;
1189 	uint32_t        seq;
1190 	uint32_t        oseq_hi;
1191 	uint32_t        seq_hi;
1192 	uint32_t        replay_window;
1193 	uint32_t        bmp[0];
1194 };
1195 
1196 struct xfrmnl_mark {
1197 	uint32_t        v; /* value */
1198 	uint32_t        m; /* mask */
1199 };
1200 
1201 /* XFRM AE related definitions */
1202 
1203 struct xfrmnl_sa_id {
1204 	struct nl_addr* daddr;
1205 	uint32_t        spi;
1206 	uint16_t        family;
1207 	uint8_t         proto;
1208 };
1209 
1210 struct xfrmnl_ae {
1211 	NLHDR_COMMON
1212 
1213 	struct xfrmnl_sa_id             sa_id;
1214 	struct nl_addr*                 saddr;
1215 	uint32_t                        flags;
1216 	uint32_t                        reqid;
1217 	struct xfrmnl_mark              mark;
1218 	struct xfrmnl_lifetime_cur      lifetime_cur;
1219 	uint32_t                        replay_maxage;
1220 	uint32_t                        replay_maxdiff;
1221 	struct xfrmnl_replay_state      replay_state;
1222 	struct xfrmnl_replay_state_esn* replay_state_esn;
1223 };
1224 
1225 /* XFRM SA related definitions */
1226 
1227 struct xfrmnl_id {
1228 	struct nl_addr* daddr;
1229 	uint32_t        spi;
1230 	uint8_t         proto;
1231 };
1232 
1233 struct xfrmnl_stats {
1234 	uint32_t        replay_window;
1235 	uint32_t        replay;
1236 	uint32_t        integrity_failed;
1237 };
1238 
1239 struct xfrmnl_algo_aead {
1240 	char            alg_name[64];
1241 	uint32_t        alg_key_len;    /* in bits */
1242 	uint32_t        alg_icv_len;    /* in bits */
1243 	char            alg_key[0];
1244 };
1245 
1246 struct xfrmnl_algo_auth {
1247 	char            alg_name[64];
1248 	uint32_t        alg_key_len;    /* in bits */
1249 	uint32_t        alg_trunc_len;  /* in bits */
1250 	char            alg_key[0];
1251 };
1252 
1253 struct xfrmnl_algo {
1254 	char            alg_name[64];
1255 	uint32_t        alg_key_len;    /* in bits */
1256 	char            alg_key[0];
1257 };
1258 
1259 struct xfrmnl_encap_tmpl {
1260 	uint16_t        encap_type;
1261 	uint16_t        encap_sport;
1262 	uint16_t        encap_dport;
1263 	struct nl_addr* encap_oa;
1264 };
1265 
1266 struct xfrmnl_user_offload {
1267 	int             ifindex;
1268 	uint8_t         flags;
1269 };
1270 
1271 struct xfrmnl_sa {
1272 	NLHDR_COMMON
1273 
1274 	struct xfrmnl_sel*              sel;
1275 	struct xfrmnl_id                id;
1276 	struct nl_addr*                 saddr;
1277 	struct xfrmnl_ltime_cfg*        lft;
1278 	struct xfrmnl_lifetime_cur      curlft;
1279 	struct xfrmnl_stats             stats;
1280 	uint32_t                        seq;
1281 	uint32_t                        reqid;
1282 	uint16_t                        family;
1283 	uint8_t                         mode;        /* XFRM_MODE_xxx */
1284 	uint8_t                         replay_window;
1285 	uint8_t                         flags;
1286 	struct xfrmnl_algo_aead*        aead;
1287 	struct xfrmnl_algo_auth*        auth;
1288 	struct xfrmnl_algo*             crypt;
1289 	struct xfrmnl_algo*             comp;
1290 	struct xfrmnl_encap_tmpl*       encap;
1291 	uint32_t                        tfcpad;
1292 	struct nl_addr*                 coaddr;
1293 	struct xfrmnl_mark              mark;
1294 	struct xfrmnl_user_sec_ctx*     sec_ctx;
1295 	uint32_t                        replay_maxage;
1296 	uint32_t                        replay_maxdiff;
1297 	struct xfrmnl_replay_state      replay_state;
1298 	struct xfrmnl_replay_state_esn* replay_state_esn;
1299 	uint8_t                         hard;
1300 	struct xfrmnl_user_offload*     user_offload;
1301 };
1302 
1303 struct xfrmnl_usersa_flush {
1304 	uint8_t                         proto;
1305 };
1306 
1307 
1308 /* XFRM SP related definitions */
1309 
1310 struct xfrmnl_userpolicy_id {
1311 	struct xfrmnl_sel               sel;
1312 	uint32_t                        index;
1313 	uint8_t                         dir;
1314 };
1315 
1316 struct xfrmnl_user_sec_ctx {
1317 	uint16_t                        len;
1318 	uint16_t                        exttype;
1319 	uint8_t                         ctx_alg;
1320 	uint8_t                         ctx_doi;
1321 	uint16_t                        ctx_len;
1322 	char                            ctx[0];
1323 };
1324 
1325 struct xfrmnl_userpolicy_type {
1326 	uint8_t                         type;
1327 	uint16_t                        reserved1;
1328 	uint16_t                        reserved2;
1329 };
1330 
1331 struct xfrmnl_user_tmpl {
1332 	struct xfrmnl_id                id;
1333 	uint16_t                        family;
1334 	struct nl_addr*                 saddr;
1335 	uint32_t                        reqid;
1336 	uint8_t                         mode;
1337 	uint8_t                         share;
1338 	uint8_t                         optional;
1339 	uint32_t                        aalgos;
1340 	uint32_t                        ealgos;
1341 	uint32_t                        calgos;
1342 	struct nl_list_head             utmpl_list;
1343 };
1344 
1345 struct xfrmnl_sp {
1346 	NLHDR_COMMON
1347 
1348 	struct xfrmnl_sel*              sel;
1349 	struct xfrmnl_ltime_cfg*        lft;
1350 	struct xfrmnl_lifetime_cur      curlft;
1351 	uint32_t                        priority;
1352 	uint32_t                        index;
1353 	uint8_t                         dir;
1354 	uint8_t                         action;
1355 	uint8_t                         flags;
1356 	uint8_t                         share;
1357 	struct xfrmnl_user_sec_ctx*     sec_ctx;
1358 	struct xfrmnl_userpolicy_type   uptype;
1359 	uint32_t                        nr_user_tmpl;
1360 	struct nl_list_head             usertmpl_list;
1361 	struct xfrmnl_mark              mark;
1362 };
1363 
1364 struct rtnl_vlan
1365 {
1366 	struct tc_vlan v_parm;
1367 	uint16_t       v_vid;
1368 	uint16_t       v_proto;
1369 	uint8_t        v_prio;
1370 	uint32_t       v_flags;
1371 };
1372 
1373 struct rtnl_mdb {
1374 	NLHDR_COMMON
1375 	uint32_t ifindex;
1376 
1377 	struct nl_list_head mdb_entry_list;
1378 };
1379 
1380 struct rtnl_mdb_entry {
1381 	struct nl_list_head mdb_list;
1382 	struct nl_addr *addr;
1383 	uint32_t ifindex;
1384 	uint16_t vid;
1385 	uint16_t proto;
1386 	uint8_t state;
1387 };
1388 #endif
1389