aboutsummaryrefslogtreecommitdiff
path: root/sys/linux/socket_netlink_route_sched.txt
blob: 39238f59bba594ae9195b1143f23c1f9d55f6cb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
# Copyright 2018 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

# AF_NETLINK/NETLINK_ROUTE SCHED support.

include <linux/net.h>
include <uapi/linux/if.h>
include <uapi/linux/netlink.h>
include <uapi/linux/rtnetlink.h>
include <uapi/linux/netfilter.h>
include <uapi/linux/if_packet.h>
include <uapi/linux/can.h>
include <uapi/linux/pkt_cls.h>
include <uapi/linux/pkt_sched.h>
include <uapi/linux/tc_act/tc_bpf.h>
include <uapi/linux/tc_act/tc_connmark.h>
include <uapi/linux/tc_act/tc_csum.h>
include <uapi/linux/tc_act/tc_defact.h>
include <uapi/linux/tc_act/tc_gact.h>
include <uapi/linux/tc_act/tc_ife.h>
include <uapi/linux/tc_act/tc_ipt.h>
include <uapi/linux/tc_act/tc_mirred.h>
include <uapi/linux/tc_act/tc_nat.h>
include <uapi/linux/tc_act/tc_pedit.h>
include <uapi/linux/tc_act/tc_sample.h>
include <uapi/linux/tc_act/tc_skbedit.h>
include <uapi/linux/tc_act/tc_skbmod.h>
include <uapi/linux/tc_act/tc_tunnel_key.h>
include <uapi/linux/tc_act/tc_vlan.h>
include <uapi/linux/tc_ematch/tc_em_cmp.h>
include <uapi/linux/tc_ematch/tc_em_ipt.h>
include <uapi/linux/tc_ematch/tc_em_meta.h>

sendmsg$nl_route_sched(fd sock_nl_route, msg ptr[in, msghdr_netlink[netlink_msg_route_sched]], f flags[send_flags])

netlink_msg_route_sched [
	newqdisc	netlink_msg[RTM_NEWQDISC, tcmsg[AF_UNSPEC], qdisc_policy]
	delqdisc	netlink_msg[RTM_DELQDISC, tcmsg[AF_UNSPEC], qdisc_policy]
	getqdisc	netlink_msg[RTM_GETQDISC, tcmsg[AF_UNSPEC], nlattr[TCA_DUMP_INVISIBLE, void]]
	newtclass	netlink_msg[RTM_NEWTCLASS, tcmsg[AF_UNSPEC], tclass_policy]
	deltclass	netlink_msg[RTM_DELTCLASS, tcmsg[AF_UNSPEC], tclass_policy]
	gettclass	netlink_msg[RTM_GETTCLASS, tcmsg[AF_UNSPEC], void]
	newtfilter	netlink_msg[RTM_NEWTFILTER, tcmsg[AF_UNSPEC], filter_policy]
	deltfilter	netlink_msg[RTM_DELTFILTER, tcmsg[AF_UNSPEC], filter_policy]
	gettfilter	netlink_msg[RTM_GETTFILTER, tcmsg[AF_UNSPEC], nlattr[TCA_CHAIN, int32]]
	newtaction	netlink_msg[RTM_NEWACTION, tcamsg[AF_UNSPEC], nlattr[TCA_ACT_TAB, tca_actions]]
	deltaction	netlink_msg[RTM_DELACTION, tcamsg[AF_UNSPEC], action_gd_policy]
	gettaction	netlink_msg[RTM_GETACTION, tcamsg[AF_UNSPEC], action_dump_policy]
] [varlen]

type tcmsg[FAMILY] {
	family		const[FAMILY, int8]
	ifindex		ifindex
	tcm_handle	tcm_handle
	tcm_parent	tcm_handle
	tcm_info	tcm_handle
}

tcm_handle {
	minor	flags[tcm_handle_offsets, int16]
	major	flags[tcm_handle_offsets, int16]
}

type tcamsg[FAMILY] {
	family		const[FAMILY, int8]
	tca__pad1	const[0, int8]
	tca__pad2	const[0, int16]
}

qdisc_policy [
	qdisc_kind_options	qdisc_kind_options
	TCA_RATE		nlattr[TCA_RATE, tc_estimator]
	TCA_STAB		nlattr[TCA_STAB, array[stab_policy]]
	TCA_INGRESS_BLOCK	nlattr[TCA_INGRESS_BLOCK, int32]
	TCA_EGRESS_BLOCK	nlattr[TCA_EGRESS_BLOCK, int32]
] [varlen]

tclass_policy [
	tclass_kind_options	tclass_kind_options
	TCA_RATE		nlattr[TCA_RATE, tc_estimator]
] [varlen]

filter_policy [
	filter_kind_options	filter_kind_options
	TCA_RATE		nlattr[TCA_RATE, tc_estimator]
	TCA_CHAIN		nlattr[TCA_CHAIN, int32]
] [varlen]

type tca_kind_options_t[NAME, VALUES] {
	TCA_KIND	nlattr[TCA_KIND, string[NAME]]
	TCA_OPTIONS	nlattr[TCA_OPTIONS, VALUES]
}
# ------------------------------ tc qdisc ------------------------------
qdisc_kind_options [
	q_cbq			tca_kind_options_t["cbq", array[q_cbq_options]]
	q_cbs			tca_kind_options_t["cbs", q_cbs_options]
	q_choke			tca_kind_options_t["choke", array[q_choke_options]]
	q_codel			tca_kind_options_t["codel", array[q_codel_options]]
	q_dsmark		tca_kind_options_t["dsmark", array[q_dsmark_options]]
	q_bfifo			tca_kind_options_t["bfifo", int32]
	q_pfifo			tca_kind_options_t["pfifo", int32]
	q_pfifo_head_drop	tca_kind_options_t["pfifo_head_drop", int32]
	q_fq			tca_kind_options_t["fq", array[q_fq_options]]
	q_fq_codel		tca_kind_options_t["fq_codel", array[q_fq_codel_options]]
	q_gred			tca_kind_options_t["gred", array[q_gred_options]]
	q_hfsc			tca_kind_options_t["hfsc", int16]
	q_hhf			tca_kind_options_t["hhf", array[q_hhf_options]]
	q_htb			tca_kind_options_t["htb", array[q_htb_options]]
	q_mqprio		tca_kind_options_t["mqprio", tc_mqprio_message]
	q_multiq		tca_kind_options_t["multiq", tc_multiq_qopt]
	q_netem			tca_kind_options_t["netem", tc_netem_message]
	q_pie			tca_kind_options_t["pie", array[q_pie_options]]
	q_prio			tca_kind_options_t["prio", tc_prio_qopt]
	q_red			tca_kind_options_t["red", array[q_red_options]]
	q_sfb			tca_kind_options_t["sfb", q_sfb_options]
	q_sfq			tca_kind_options_t["sfq", tc_sfq_qopt_v1]
	q_tbf			tca_kind_options_t["tbf", array[q_tbf_options]]
] [varlen]

q_cbq_options [
	TCA_CBQ_LSSOPT	nlattr[TCA_CBQ_LSSOPT, tc_cbq_lssopt]
	TCA_CBQ_WRROPT	nlattr[TCA_CBQ_WRROPT, tc_cbq_wrropt]
	TCA_CBQ_FOPT	nlattr[TCA_CBQ_FOPT, tc_cbq_fopt]
	TCA_CBQ_RATE	nlattr[TCA_CBQ_RATE, tc_ratespec]
	TCA_CBQ_RTAB	nlattr[TCA_CBQ_RTAB, array[int32, 256]]
] [varlen]

q_cbs_options [
	TCA_CBS_PARMS	nlattr[TCA_CBS_PARMS, tc_cbs_qopt]
] [varlen]

q_choke_options [
	TCA_CHOKE_PARMS	nlattr[TCA_CHOKE_PARMS, tc_red_qopt]
	TCA_CHOKE_STAB	nlattr[TCA_CHOKE_STAB, array[int8, 256]]
	TCA_CHOKE_MAX_P	nlattr[TCA_CHOKE_MAX_P, int32]
] [varlen]

q_codel_options [
	TCA_CODEL_TARGET	nlattr[TCA_CODEL_TARGET, int32]
	TCA_CODEL_LIMIT		nlattr[TCA_CODEL_LIMIT, int32]
	TCA_CODEL_INTERVAL	nlattr[TCA_CODEL_INTERVAL, int32]
	TCA_CODEL_ECN		nlattr[TCA_CODEL_ECN, int32[0:1]]
	TCA_CODEL_CE_THRESHOLD	nlattr[TCA_CODEL_CE_THRESHOLD, int32]
] [varlen]

q_dsmark_options [
	TCA_DSMARK_INDICES		nlattr[TCA_DSMARK_INDICES, flags[tca_dsmark_ind, int16]]
	TCA_DSMARK_DEFAULT_INDEX	nlattr[TCA_DSMARK_DEFAULT_INDEX, int16]
	TCA_DSMARK_SET_TC_INDEX		nlattr[TCA_DSMARK_SET_TC_INDEX, void]
] [varlen]

q_fq_options [
	TCA_FQ_PLIMIT			nlattr[TCA_FQ_PLIMIT, int32]
	TCA_FQ_FLOW_PLIMIT		nlattr[TCA_FQ_FLOW_PLIMIT, int32]
	TCA_FQ_QUANTUM			nlattr[TCA_FQ_QUANTUM, int32]
	TCA_FQ_INITIAL_QUANTUM		nlattr[TCA_FQ_INITIAL_QUANTUM, int32]
	TCA_FQ_RATE_ENABLE		nlattr[TCA_FQ_RATE_ENABLE, int32[0:1]]
	TCA_FQ_FLOW_DEFAULT_RATE	nlattr[TCA_FQ_FLOW_DEFAULT_RATE, int32]
	TCA_FQ_FLOW_MAX_RATE		nlattr[TCA_FQ_FLOW_MAX_RATE, int32]
	TCA_FQ_BUCKETS_LOG		nlattr[TCA_FQ_BUCKETS_LOG, int32[0:32]]
	TCA_FQ_FLOW_REFILL_DELAY	nlattr[TCA_FQ_FLOW_REFILL_DELAY, int32]
	TCA_FQ_ORPHAN_MASK		nlattr[TCA_FQ_ORPHAN_MASK, int32]
	TCA_FQ_LOW_RATE_THRESHOLD	nlattr[TCA_FQ_LOW_RATE_THRESHOLD, int32]
] [varlen]

q_fq_codel_options [
	TCA_FQ_CODEL_TARGET		nlattr[TCA_FQ_CODEL_TARGET, int32]
	TCA_FQ_CODEL_LIMIT		nlattr[TCA_FQ_CODEL_LIMIT, int32]
	TCA_FQ_CODEL_INTERVAL		nlattr[TCA_FQ_CODEL_INTERVAL, int32]
	TCA_FQ_CODEL_ECN		nlattr[TCA_FQ_CODEL_ECN, int32[0:1]]
	TCA_FQ_CODEL_FLOWS		nlattr[TCA_FQ_CODEL_FLOWS, int32]
	TCA_FQ_CODEL_QUANTUM		nlattr[TCA_FQ_CODEL_QUANTUM, int32]
	TCA_FQ_CODEL_CE_THRESHOLD	nlattr[TCA_FQ_CODEL_CE_THRESHOLD, int32]
	TCA_FQ_CODEL_DROP_BATCH_SIZE	nlattr[TCA_FQ_CODEL_DROP_BATCH_SIZE, int32]
	TCA_FQ_CODEL_MEMORY_LIMIT	nlattr[TCA_FQ_CODEL_MEMORY_LIMIT, int32]
] [varlen]

# TODO: we should not have TCA_GRED_PARMS and TCA_GRED_STAB when do init
q_gred_options [
	TCA_GRED_PARMS	nlattr[TCA_GRED_PARMS, tc_gred_qopt]
	TCA_GRED_STAB	nlattr[TCA_GRED_STAB, array[int8, 256]]
	TCA_GRED_DPS	nlattr[TCA_GRED_DPS, tc_gred_sopt]
	TCA_GRED_MAX_P	nlattr[TCA_GRED_MAX_P, int32]
	TCA_GRED_LIMIT	nlattr[TCA_GRED_LIMIT, int32]
] [varlen]

q_hhf_options [
	TCA_HHF_BACKLOG_LIMIT	nlattr[TCA_HHF_BACKLOG_LIMIT, int32]
	TCA_HHF_QUANTUM		nlattr[TCA_HHF_QUANTUM, int32]
	TCA_HHF_HH_FLOWS_LIMIT	nlattr[TCA_HHF_HH_FLOWS_LIMIT, int32]
	TCA_HHF_RESET_TIMEOUT	nlattr[TCA_HHF_RESET_TIMEOUT, int32]
	TCA_HHF_ADMIT_BYTES	nlattr[TCA_HHF_ADMIT_BYTES, int32]
	TCA_HHF_EVICT_TIMEOUT	nlattr[TCA_HHF_EVICT_TIMEOUT, int32]
	TCA_HHF_NON_HH_WEIGHT	nlattr[TCA_HHF_NON_HH_WEIGHT, int32]
] [varlen]

q_htb_options [
	TCA_HTB_INIT		nlattr[TCA_HTB_INIT, tc_htb_glob]
	TCA_HTB_DIRECT_QLEN	nlattr[TCA_HTB_DIRECT_QLEN, int32]
] [varlen]

tc_mqprio_message {
	qopt	tc_mqprio_qopt
	attrs	array[q_mqprio_options]
}

q_mqprio_options [
	TCA_MQPRIO_MODE		nlattr[TCA_MQPRIO_MODE, flags[tc_mqprio_modes, int32]]
	TCA_MQPRIO_SHAPER	nlattr[TCA_MQPRIO_SHAPER, flags[tc_mqprio_shapers, int32]]
	TCA_MQPRIO_MIN_RATE64	nlattr[TCA_MQPRIO_MIN_RATE64, array[nlattr[TCA_MQPRIO_MIN_RATE64, int64], 0:16]]
	TCA_MQPRIO_MAX_RATE64	nlattr[TCA_MQPRIO_MAX_RATE64, array[nlattr[TCA_MQPRIO_MAX_RATE64, int64], 0:16]]
] [varlen]

tc_netem_message {
	qopt	tc_netem_qopt
	attrs	array[q_netem_options]
}

q_netem_options [
	TCA_NETEM_CORR		nlattr[TCA_NETEM_CORR, tc_netem_corr]
	TCA_NETEM_DELAY_DIST	nlattr[TCA_NETEM_DELAY_DIST, array[int8, 0:100]]
	TCA_NETEM_REORDER	nlattr[TCA_NETEM_REORDER, tc_netem_reorder]
	TCA_NETEM_CORRUPT	nlattr[TCA_NETEM_CORRUPT, tc_netem_corrupt]
	TCA_NETEM_LOSS		nlattr[TCA_NETEM_LOSS, array[netem_loss_policy]]
	TCA_NETEM_RATE		nlattr[TCA_NETEM_RATE, tc_netem_rate]
	TCA_NETEM_ECN		nlattr[TCA_NETEM_ECN, int32[0:1]]
	TCA_NETEM_RATE64	nlattr[TCA_NETEM_RATE64, int64[0x100000000:0xffffffffffffffff]]
	TCA_NETEM_LATENCY64	nlattr[TCA_NETEM_LATENCY64, int64]
	TCA_NETEM_JITTER64	nlattr[TCA_NETEM_JITTER64, int64]
	TCA_NETEM_SLOT		nlattr[TCA_NETEM_SLOT, tc_netem_slot]
] [varlen]

netem_loss_policy [
	NETEM_LOSS_GI	nlattr[NETEM_LOSS_GI, tc_netem_gimodel]
	NETEM_LOSS_GE	nlattr[NETEM_LOSS_GE, tc_netem_gemodel]
] [varlen]

q_pie_options [
	TCA_PIE_TARGET		nlattr[TCA_PIE_TARGET, int32]
	TCA_PIE_LIMIT		nlattr[TCA_PIE_LIMIT, int32]
	TCA_PIE_TUPDATE		nlattr[TCA_PIE_TUPDATE, int32]
	TCA_PIE_ALPHA		nlattr[TCA_PIE_ALPHA, int32[0:32]]
	TCA_PIE_BETA		nlattr[TCA_PIE_BETA, int32[0:32]]
	TCA_PIE_ECN		nlattr[TCA_PIE_ECN, int32[0:1]]
	TCA_PIE_BYTEMODE	nlattr[TCA_PIE_BYTEMODE, int32[0:1]]
] [varlen]

q_red_options [
	TCA_RED_PARMS	nlattr[TCA_RED_PARMS, tc_red_qopt]
	TCA_RED_STAB	nlattr[TCA_RED_STAB, array[int8, 256]]
	TCA_RED_MAX_P	nlattr[TCA_RED_MAX_P, int32]
] [varlen]

q_sfb_options [
	TCA_SFB_PARMS	nlattr[TCA_SFB_PARMS, tc_sfb_qopt]
] [varlen]

q_tbf_options [
	TCA_TBF_PARMS	nlattr[TCA_TBF_PARMS, tc_tbf_qopt]
	TCA_TBF_RTAB	nlattr[TCA_TBF_RTAB, array[int32, 256]]
	TCA_TBF_PTAB	nlattr[TCA_TBF_PTAB, array[int32, 256]]
	TCA_TBF_RATE64	nlattr[TCA_TBF_RATE64, int64[0x100000000:0xffffffffffffffff]]
	TCA_TBF_PRATE64	nlattr[TCA_TBF_PRATE64, int64[0x100000000:0xffffffffffffffff]]
	TCA_TBF_BURST	nlattr[TCA_TBF_BURST, int32]
	TCA_TBF_PBURST	nlattr[TCA_TBF_PBURST, int32[0:9000]]
] [varlen]

tc_cbq_lssopt {
	change		int8[0:64]
	flags		int8[0:3]
	ewma_log	int8[0:32]
	level		int8
	maxidle		int32
	minidle		int32
	offtime		int32
	avpkt		int32
}

tc_cbq_wrropt {
	flags		int8
	priority	int8[0:TC_CBQ_MAXPRIO]
	cpriority	int8
	__reserved	int8
	allot		int32
	weight		int32
}

tc_cbq_fopt {
	split		tcm_handle
	defmap		int32
	defchange	int32
}

tc_cbs_qopt {
	offload		int8
	_pad		array[const[0, int8], 3]
	hicredit	int32
	locredit	int32
	idleslope	int32
	sendslope	int32
}

# NEED: limit >= qth_max >= qth_min
tc_red_qopt {
	limit		int32
	qth_min		int32
	qth_max		int32
	Wlog		int8[0:32]
	Plog		int8[0:32]
	Scell_log	int8[0:32]
	flag		int8[0:8]
}

tc_gred_sopt {
	DPs	int32[0:16]
	def_DP	int32[0:16]
	grio	int8[0:1]
	flags	int8[0:8]
	pad1	const[0, int16]
}

tc_gred_qopt {
	limit		int32
	qth_min		int32
	qth_max		int32
	DP		int32[0:16]
	backlog		int32
	qave		int32
	forced		int32
	early		int32
	other		int32
	pdrop		int32
	Wlog		int8[0:32]
	Plog		int8[0:32]
	Scell_log	int8[0:32]
	prio		int8
	packets		int32
	bytesin		int32
}

tc_htb_glob {
	version		const[3, int32]
	rate2quantum	int32
	defcls		int32
	debug		const[0, int32]
	direct_pkts	const[0, int32]
}

tc_mqprio_qopt {
	num_tc		int8
	prio_tc_map	array[int8, 16]
	hw		int8
	count		array[int16, TC_QOPT_MAX_QUEUE]
	offset		array[int16, TC_QOPT_MAX_QUEUE]
}

tc_multiq_qopt {
	bands		int16
	max_bands	int16
}

tc_netem_qopt {
	latency		int32
	limit		int32
	loss		int32
	gap		int32
	duplicate	int32
	jitter		int32
}

tc_netem_corr {
	delay_corr	int32
	loss_corr	int32
	dup_corr	int32
}

tc_netem_reorder {
	probability	int32
	correlation	int32
}

tc_netem_corrupt {
	probability	int32
	correlation	int32
}

tc_netem_rate {
	rate		int32
	packet_overhead	int32
	cell_size	int32
	cell_overhead	int32
}

tc_netem_slot {
	min_delay	int64
	max_delay	int64
	max_packets	int32
	max_bytes	int32
}

tc_netem_gimodel {
	p13	int32
	p31	int32
	p32	int32
	p14	int32
	p23	int32
}

tc_netem_gemodel {
	p	int32
	r	int32
	h	int32
	k1	int32
}

tc_prio_qopt {
	bands	int32
	priomap	array[int8, 16]
}

tc_sfb_qopt {
	rehash_interval	int32
	warmup_time	int32
	max		int32
	bin_size	int32
	increment	int32
	decrement	int32
	limit		int32
	penalty_rate	int32
	penalty_burst	int32
}

tc_sfq_qopt_v1 {
	v0		tc_sfq_qopt
	depth		int32
	headdrop	int32[0:1]
	limit		int32
	qth_min		int32
	qth_max		int32
	Wlog		int8[0:32]
	Plog		int8[0:32]
	Scell_log	int8[0:32]
	flag		int8[0:8]
	stats		tc_sfqred_stats
}

tc_sfq_qopt {
	quantum		int32
	perturb_period	int32
	limit		int32
	divisor		int32
	flows		int32
}

tc_sfqred_stats {
	prob_drop		int32
	forced_drop		int32
	prob_mark		int32
	forced_mark		int32
	prob_mark_head		int32
	forced_mark_head	int32
}

tc_tbf_qopt [
	rate		tc_ratespec
	peakrate	tc_ratespec
	limit		int32
	buffer		int32
	mtu		int32[0:9000]
]

# ------------------------------ tc class ------------------------------
tclass_kind_options [
	c_atm		tca_kind_options_t["atm", array[c_atm_options]]
	c_cbq		tca_kind_options_t["cbq", array[c_cbq_options]]
	c_drr		tca_kind_options_t["drr", c_drr_options]
	c_dsmark	tca_kind_options_t["dsmark", c_dsmark_options]
	c_hfsc		tca_kind_options_t["hfsc", array[c_hfsc_options]]
	c_htb		tca_kind_options_t["htb", array[c_htb_options]]
	c_qfq		tca_kind_options_t["qfq", array[c_qfq_options]]
] [varlen]

c_atm_options [
	TCA_ATM_FD	nlattr[TCA_ATM_FD, sock]
	TCA_ATM_HDR	nlattr[TCA_ATM_HDR, array[int8, 0:64]]
	TCA_ATM_EXCESS	nlattr[TCA_ATM_EXCESS, tcm_handle]
] [varlen]

type c_cbq_options q_cbq_options

c_drr_options [
	TCA_DRR_QUANTUM	nlattr[TCA_DRR_QUANTUM, int32]
] [varlen]

c_dsmark_options [
	TCA_DSMARK_MASK		nlattr[TCA_DSMARK_MASK, int8]
	TCA_DSMARK_VALUE	nlattr[TCA_DSMARK_VALUE, int8]
] [varlen]

c_hfsc_options [
	TCA_HFSC_RSC	nlattr[TCA_HFSC_RSC, tc_service_curve]
	TCA_HFSC_FSC	nlattr[TCA_HFSC_FSC, tc_service_curve]
	TCA_HFSC_USC	nlattr[TCA_HFSC_USC, tc_service_curve]
] [varlen]

c_htb_options [
	TCA_HTB_PARMS	nlattr[TCA_HTB_PARMS, tc_htb_opt]
	TCA_HTB_CTAB	nlattr[TCA_HTB_CTAB, array[int32, 256]]
	TCA_HTB_RTAB	nlattr[TCA_HTB_RTAB, array[int32, 256]]
	TCA_HTB_RATE64	nlattr[TCA_HTB_RATE64, int64]
	TCA_HTB_CEIL64	nlattr[TCA_HTB_CEIL64, int64]
] [varlen]

c_qfq_options [
	TCA_QFQ_WEIGHT	nlattr[TCA_QFQ_WEIGHT, int32]
	TCA_QFQ_LMAX	nlattr[TCA_QFQ_LMAX, int32]
] [varlen]

tc_service_curve {
	m1	int32
	d	int32
	m2	int32
}

tc_htb_opt {
	rate	tc_ratespec
	ceil	tc_ratespec
	buffer	int32
	cbuffer	int32
	quantum	int32
	level	int32
	prio	int32
}

# ------------------------------ tc filter ------------------------------
filter_kind_options [
	f_basic		tca_kind_options_t["basic", array[f_basic_options]]
	f_bpf		tca_kind_options_t["bpf", array[f_bpf_options]]
	f_cgroup	tca_kind_options_t["cgroup", array[f_cgroup_options]]
	f_flow		tca_kind_options_t["flow", array[f_flow_options]]
	f_fw		tca_kind_options_t["fw", array[f_fw_options]]
	f_matchall	tca_kind_options_t["matchall", array[f_matchall_options]]
	f_route		tca_kind_options_t["route", array[f_route_options]]
	f_rsvp		tca_kind_options_t["rsvp", array[f_rfvp_options]]
	f_rsvp6		tca_kind_options_t["rsvp6", array[f_rfvp6_options]]
	f_tcindex	tca_kind_options_t["tcindex", array[f_tcindex_options]]
	f_u32		tca_kind_options_t["u32", array[f_u32_options]]
] [varlen]

f_basic_options [
	TCA_BASIC_CLASSID	nlattr[TCA_BASIC_CLASSID, tcm_handle]
	TCA_BASIC_EMATCHES	nlattr[TCA_BASIC_EMATCHES, array[tca_ematches]]
	TCA_BASIC_ACT		nlattr[TCA_BASIC_ACT, tca_actions]
	TCA_BASIC_POLICE	nlattr[TCA_BASIC_POLICE, tca_polices]
] [varlen]

f_bpf_options [
	TCA_BPF_ACT		nlattr[TCA_BPF_ACT, tca_actions]
	TCA_BPF_POLICE		nlattr[TCA_BPF_POLICE, tca_polices]
	TCA_BPF_CLASSID		nlattr[TCA_BPF_CLASSID, tcm_handle]
	TCA_BPF_OPS		tca_bpf_ops
	TCA_BPF_FD		nlattr[TCA_BPF_FD, fd_bpf_prog]
	TCA_BPF_NAME		nlattr[TCA_BPF_NAME, string[filename]]
	TCA_BPF_FLAGS		nlattr[TCA_BPF_FLAGS, int32[0:1]]
	TCA_BPF_FLAGS_GEN	nlattr[TCA_BPF_FLAGS_GEN, int32[0:8]]
] [varlen]

tca_bpf_ops {
	TCA_BPF_OPS_LEN	nlattr[TCA_BPF_OPS_LEN, len[tca_bpf_ops:TCA_BPF_OPS:payload, int16]]
	TCA_BPF_OPS	nlattr[TCA_BPF_OPS, array[sock_filter]]
} [packed]

f_cgroup_options [
	TCA_CGROUP_ACT		nlattr[TCA_CGROUP_ACT, tca_actions]
	TCA_CGROUP_POLICE	nlattr[TCA_CGROUP_POLICE, tca_polices]
	TCA_CGROUP_EMATCHES	nlattr[TCA_CGROUP_EMATCHES, array[tca_ematches]]
] [varlen]

f_flow_options [
	TCA_FLOW_KEYS		nlattr[TCA_FLOW_KEYS, int32[0:0x1ffff]]
	TCA_FLOW_MODE		nlattr[TCA_FLOW_MODE, flags[tc_flow_modes, int32]]
	TCA_FLOW_BASECLASS	nlattr[TCA_FLOW_BASECLASS, tcm_handle]
	TCA_FLOW_RSHIFT		nlattr[TCA_FLOW_RSHIFT, int32]
	TCA_FLOW_ADDEND		nlattr[TCA_FLOW_ADDEND, int32]
	TCA_FLOW_MASK		nlattr[TCA_FLOW_MASK, int32]
	TCA_FLOW_XOR		nlattr[TCA_FLOW_XOR, int32]
	TCA_FLOW_DIVISOR	nlattr[TCA_FLOW_DIVISOR, int32]
	TCA_FLOW_ACT		nlattr[TCA_FLOW_ACT, tca_actions]
	TCA_FLOW_POLICE		nlattr[TCA_FLOW_POLICE, tca_polices]
	TCA_FLOW_EMATCHES	nlattr[TCA_FLOW_EMATCHES, array[tca_ematches]]
	TCA_FLOW_PERTURB	nlattr[TCA_FLOW_PERTURB, int32]
] [varlen]

f_fw_options [
	TCA_FW_CLASSID	nlattr[TCA_FW_CLASSID, tcm_handle]
	TCA_FW_POLICE	nlattr[TCA_FW_POLICE, tca_polices]
	TCA_FW_INDEV	nlattr[TCA_FW_INDEV, devname]
	TCA_FW_ACT	nlattr[TCA_FW_ACT, tca_actions]
	TCA_FW_MASK	nlattr[TCA_FW_MASK, int32]
] [varlen]

f_matchall_options [
	TCA_MATCHALL_CLASSID	nlattr[TCA_MATCHALL_CLASSID, tcm_handle]
	TCA_MATCHALL_ACT	nlattr[TCA_MATCHALL_ACT, tca_actions]
	TCA_MATCHALL_FLAGS	nlattr[TCA_MATCHALL_FLAGS, int32[0:8]]
] [varlen]

f_route_options [
	TCA_ROUTE4_CLASSID	nlattr[TCA_ROUTE4_CLASSID, tcm_handle]
	TCA_ROUTE4_TO		nlattr[TCA_ROUTE4_TO, int32[0:256]]
	TCA_ROUTE4_FROM		nlattr[TCA_ROUTE4_FROM, int32[0:256]]
	TCA_ROUTE4_IIF		nlattr[TCA_ROUTE4_IIF, devname]
	TCA_ROUTE4_POLICE	nlattr[TCA_ROUTE4_POLICE, tca_polices]
	TCA_ROUTE4_ACT		nlattr[TCA_ROUTE4_ACT, tca_actions]
] [varlen]

f_rfvp_options [
	TCA_RSVP_CLASSID	nlattr[TCA_RSVP_CLASSID, tcm_handle]
	TCA_RSVP_DST		nlattr[TCA_RSVP_DST, ipv4_addr]
	TCA_RSVP_SRC		nlattr[TCA_RSVP_SRC, ipv4_addr]
	TCA_RSVP_PINFO		nlattr[TCA_RSVP_PINFO, tc_rsvp_pinfo]
	TCA_RSVP_POLICE		nlattr[TCA_RSVP_POLICE, tca_polices]
	TCA_RSVP_ACT		nlattr[TCA_RSVP_ACT, tca_actions]
] [varlen]

f_rfvp6_options [
	TCA_RSVP_CLASSID	nlattr[TCA_RSVP_CLASSID, tcm_handle]
	TCA_RSVP_DST		nlattr[TCA_RSVP_DST, ipv6_addr]
	TCA_RSVP_SRC		nlattr[TCA_RSVP_SRC, ipv6_addr]
	TCA_RSVP_PINFO		nlattr[TCA_RSVP_PINFO, tc_rsvp_pinfo]
	TCA_RSVP_POLICE		nlattr[TCA_RSVP_POLICE, tca_polices]
	TCA_RSVP_ACT		nlattr[TCA_RSVP_ACT, tca_actions]
] [varlen]

f_tcindex_options [
	TCA_TCINDEX_HASH		nlattr[TCA_TCINDEX_HASH, int32[0:0x10000]]
	TCA_TCINDEX_MASK		nlattr[TCA_TCINDEX_MASK, int16]
	TCA_TCINDEX_SHIFT		nlattr[TCA_TCINDEX_SHIFT, int32]
	TCA_TCINDEX_FALL_THROUGH	nlattr[TCA_TCINDEX_FALL_THROUGH, int32[0:1]]
	TCA_TCINDEX_CLASSID		nlattr[TCA_TCINDEX_CLASSID, tcm_handle]
	TCA_TCINDEX_POLICE		nlattr[TCA_TCINDEX_POLICE, tca_polices]
	TCA_TCINDEX_ACT			nlattr[TCA_TCINDEX_ACT, tca_actions]
] [varlen]

f_u32_options [
	TCA_U32_CLASSID	nlattr[TCA_U32_CLASSID, tcm_handle]
	TCA_U32_HASH	nlattr[TCA_U32_HASH, int32]
	TCA_U32_LINK	nlattr[TCA_U32_LINK, int32]
	TCA_U32_DIVISOR	nlattr[TCA_U32_DIVISOR, int32[0:0x100]]
	TCA_U32_SEL	nlattr[TCA_U32_SEL, tc_u32_sel]
	TCA_U32_POLICE	nlattr[TCA_U32_POLICE, tca_polices]
	TCA_U32_ACT	nlattr[TCA_U32_ACT, tca_actions]
	TCA_U32_INDEV	nlattr[TCA_U32_INDEV, devname]
	TCA_U32_MARK	nlattr[TCA_U32_MARK, tc_u32_mark]
	TCA_U32_FLAGS	nlattr[TCA_U32_FLAGS, int32[0:8]]
] [varlen]

tc_rsvp_gpi {
	key	int32
	mask	int32
	offset	int32
}

tc_rsvp_pinfo {
	dpi		tc_rsvp_gpi
	spi		tc_rsvp_gpi
	protocol	flags[ipv4_types, int8]
	tunnelid	int8
	tunnelhdr	int8
	pad		const[0, int8]
}

tc_u32_sel {
	flags		int8[0:16]
	offshift	int8
	nkeys		int8
	offmast		int16be
	off		int16
	offoff		int16
	hoff		int16
	hmast		int32be
	keys		array[tc_u32_key, 0:128]
}

# NEED: (mark.val & mark.mask) should equal to mark.val
tc_u32_mark {
	val	int32
	mask	int32
	success	const[0, int32]
}

# ------------------------------ tc action ------------------------------
tca_actions [
	m_bpf		nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["bpf", array[m_bpf_options]]]
	m_connmark	nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["connmark", m_connmark_options]]
	m_csum		nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["csum", m_csum_options]]
	m_gact		nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["gact", array[m_gact_options]]]
	m_ife		nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["ife", array[m_ife_options]]]
	m_ipt		nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["ipt", array[m_ipt_options]]]
	m_mirred	nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["mirred", m_mirred_options]]
	m_nat		nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["nat", m_nat_options]]
	m_pedit		nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["pedit", array[m_pedit_options]]]
	m_police	nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["police", array[m_police_options]]]
	m_sample	nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["sample", array[m_sample_options]]]
	m_simple	nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["simple", array[m_simple_options]]]
	m_skbedit	nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["skbedit", array[m_skbedit_options]]]
	m_skbmod	nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["skbmod", array[m_skbmod_options]]]
	m_tunnel_key	nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["tunnel_key", array[m_tunnel_key_options]]]
	m_vlan		nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_t["vlan", array[m_vlan_options]]]
] [varlen]

type tca_actions_t[NAME, VALUES] {
	TCA_ACT_KIND	nlattr[TCA_ACT_KIND, string[NAME]]
	TCA_ACT_OPTIONS	nlattr[TCA_ACT_OPTIONS, VALUES]
	TCA_ACT_COOKIE	nlattr[TCA_ACT_COOKIE, array[int8]]
} [packed, align_4]

m_bpf_options [
	TCA_ACT_BPF_PARMS	nlattr[TCA_ACT_BPF_PARMS, tc_act_bpf]
	TCA_ACT_BPF_OPS_LEN	nlattr[TCA_ACT_BPF_OPS_LEN, int16[0:10]]
	TCA_ACT_BPF_OPS		nlattr[TCA_ACT_BPF_OPS, array[sock_filter]]
	TCA_ACT_BPF_FD		nlattr[TCA_ACT_BPF_FD, fd]
	TCA_ACT_BPF_NAME	nlattr[TCA_ACT_BPF_NAME, string[filename]]
] [varlen]

m_connmark_options [
	TCA_CONNMARK_PARMS	nlattr[TCA_CONNMARK_PARMS, tc_connmark]
] [varlen]

m_csum_options [
	TCA_CSUM_PARMS	nlattr[TCA_CSUM_PARMS, tc_csum]
] [varlen]

m_gact_options [
	TCA_GACT_PARMS	nlattr[TCA_GACT_PARMS, tc_gen]
	TCA_GACT_PROB	nlattr[TCA_GACT_PROB, tc_gact_p]
] [varlen]

m_ife_options [
	TCA_IFE_PARMS	nlattr[TCA_IFE_PARMS, tc_ife]
	TCA_IFE_DMAC	nlattr[TCA_IFE_DMAC, mac_addr]
	TCA_IFE_SMAC	nlattr[TCA_IFE_SMAC, mac_addr]
	TCA_IFE_TYPE	nlattr[TCA_IFE_TYPE, int16]
	TCA_IFE_METALST	nlattr[TCA_IFE_METALST, array[tca_ife_meta_policy]]
] [varlen]

tca_ife_meta_policy [
	IFE_META_SKBMARK	nlattr[IFE_META_SKBMARK, optional[int32]]
	IFE_META_PRIO		nlattr[IFE_META_PRIO, optional[int32]]
	IFE_META_TCINDEX	nlattr[IFE_META_TCINDEX, optional[int16]]
] [varlen]

# TODO: add TCA_IPT_TARG support
m_ipt_options [
	TCA_IPT_TABLE	nlattr[TCA_IPT_TABLE, string[ipt_tables, IFNAMSIZ]]
	TCA_IPT_HOOK	nlattr[TCA_IPT_HOOK, flags[nf_inet_hooks, int32]]
	TCA_IPT_INDEX	nlattr[TCA_IPT_INDEX, int32]
] [varlen]

m_mirred_options [
	TCA_MIRRED_PARMS	nlattr[TCA_MIRRED_PARMS, tc_mirred]
] [varlen]

m_nat_options [
	TCA_NAT_PARMS	nlattr[TCA_NAT_PARMS, tc_nat]
] [varlen]

m_pedit_options [
	TCA_PEDIT_PARMS		nlattr[TCA_PEDIT_PARMS, m_pedit_sel]
	TCA_PEDIT_PARMS_EX	nlattr[TCA_PEDIT_PARMS_EX, m_pedit_sel]
	TCA_PEDIT_KEYS_EX	nlattr[TCA_PEDIT_KEYS_EX, array[tca_pedit_keys_ex_policy]]
] [varlen]

tca_pedit_keys_ex_policy [
	TCA_PEDIT_KEY_EX	nlattr[TCA_PEDIT_KEY_EX, array[tca_pedit_key_ex_policy]]
] [varlen]

tca_pedit_key_ex_policy [
	TCA_PEDIT_KEY_EX_HTYPE	nlattr[TCA_PEDIT_KEY_EX_HTYPE, flags[pedit_header_type, int16]]
	TCA_PEDIT_KEY_EX_CMD	nlattr[TCA_PEDIT_KEY_EX_CMD, flags[pedit_cmd, int16]]
] [varlen]

m_police_options [
	TCA_POLICE_TBF		nlattr[TCA_POLICE_TBF, tc_police]
	TCA_POLICE_RATE		nlattr[TCA_POLICE_RATE, array[int32, 256]]
	TCA_POLICE_PEAKRATE	nlattr[TCA_POLICE_PEAKRATE, array[int32, 256]]
	TCA_POLICE_AVRATE	nlattr[TCA_POLICE_AVRATE, int32]
	TCA_POLICE_RESULT	nlattr[TCA_POLICE_RESULT, int32]
] [varlen]

m_sample_options [
	TCA_SAMPLE_PARMS		nlattr[TCA_SAMPLE_PARMS, tc_gen]
	TCA_SAMPLE_RATE			nlattr[TCA_SAMPLE_RATE, int32]
	TCA_SAMPLE_TRUNC_SIZE		nlattr[TCA_SAMPLE_TRUNC_SIZE, int32]
	TCA_SAMPLE_PSAMPLE_GROUP	nlattr[TCA_SAMPLE_PSAMPLE_GROUP, int32]
] [varlen]

m_simple_options [
	TCA_DEF_PARMS	nlattr[TCA_DEF_PARMS, tc_gen]
	TCA_DEF_DATA	nlattr[TCA_DEF_DATA, string]
] [varlen]

m_skbedit_options [
	TCA_SKBEDIT_PARMS		nlattr[TCA_SKBEDIT_PARMS, tc_gen]
	TCA_SKBEDIT_QUEUE_MAPPING	nlattr[TCA_SKBEDIT_QUEUE_MAPPING, int16]
	TCA_SKBEDIT_PRIORITY		nlattr[TCA_SKBEDIT_PRIORITY, tcm_handle]
	TCA_SKBEDIT_MARK		nlattr[TCA_SKBEDIT_MARK, int32]
	TCA_SKBEDIT_PTYPE		nlattr[TCA_SKBEDIT_PTYPE, flags[packet_types, int16]]
] [varlen]

m_skbmod_options [
	TCA_SKBMOD_PARMS	nlattr[TCA_SKBMOD_PARMS, tc_skbmod]
	TCA_SKBMOD_DMAC		nlattr[TCA_SKBMOD_DMAC, mac_addr]
	TCA_SKBMOD_SMAC		nlattr[TCA_SKBMOD_SMAC, mac_addr]
	TCA_SKBMOD_ETYPE	nlattr[TCA_SKBMOD_ETYPE, int16]
] [varlen]

m_tunnel_key_options [
	TCA_TUNNEL_KEY_PARMS		nlattr[TCA_TUNNEL_KEY_PARMS, tc_tunnel_key]
	TCA_TUNNEL_KEY_ENC_IPV4_SRC	nlattr[TCA_TUNNEL_KEY_ENC_IPV4_SRC, ipv4_addr]
	TCA_TUNNEL_KEY_ENC_IPV4_DST	nlattr[TCA_TUNNEL_KEY_ENC_IPV4_DST, ipv4_addr]
	TCA_TUNNEL_KEY_ENC_IPV6_SRC	nlattr[TCA_TUNNEL_KEY_ENC_IPV6_SRC, ipv6_addr]
	TCA_TUNNEL_KEY_ENC_IPV6_DST	nlattr[TCA_TUNNEL_KEY_ENC_IPV6_DST, ipv6_addr]
	TCA_TUNNEL_KEY_ENC_KEY_ID	nlattr[TCA_TUNNEL_KEY_ENC_KEY_ID, int32]
	TCA_TUNNEL_KEY_ENC_DST_PORT	nlattr[TCA_TUNNEL_KEY_ENC_DST_PORT, sock_port]
	TCA_TUNNEL_KEY_NO_CSUM		nlattr[TCA_TUNNEL_KEY_NO_CSUM, int8[0:1]]
] [varlen]

m_vlan_options [
	TCA_VLAN_PARMS			nlattr[TCA_VLAN_PARMS, tc_vlan]
	TCA_VLAN_PUSH_VLAN_ID		nlattr[TCA_VLAN_PUSH_VLAN_ID, int16[0:0xfff]]
	TCA_VLAN_PUSH_VLAN_PROTOCOL	nlattr[TCA_VLAN_PUSH_VLAN_PROTOCOL, flags[vlan_proto, int16be]]
	TCA_VLAN_PUSH_VLAN_PRIORITY	nlattr[TCA_VLAN_PUSH_VLAN_PRIORITY, int8[0:7]]
] [varlen]

action_gd_policy [
	TCA_ACT_TAB	nlattr[TCA_ACT_TAB, array[nlattr_t[int32[0:TCA_ACT_MAX_PRIO], tca_actions_kind_index]]]
] [varlen]

tca_actions_kind_index [
	TCA_ACT_KIND	nlattr[TCA_ACT_KIND, string[tca_actions_kinds]]
	TCA_ACT_INDEX	nlattr[TCA_ACT_INDEX, int32]
] [varlen]

action_dump_flags [
	TCA_ROOT_FLAGS		nlattr[TCA_ROOT_FLAGS, nla_bitfield32]
	TCA_ROOT_TIME_DELTA	nlattr[TCA_ROOT_TIME_DELTA, int32]
] [varlen]

action_dump_policy [
	action_gd		action_gd_policy
	action_dump_flags	action_dump_flags
] [varlen]

tc_gen {
	index	int32
	capab	int32
	action	flags[tc_actions, int32]
	refcnt	int32
	bindcnt	int32
}

type tc_act_bpf tc_gen

tc_connmark {
	tc_gen	tc_gen
	zone	int16
}

nla_bitfield32 {
	value		int32[0:1]
	selector	int32[0:1]
}

tc_csum {
	tc_gen		tc_gen
	update_flags	int32[0:128]
}

tc_gact_p {
	ptype	flags[tc_pgact_flags, int16]
	pval	int16[0:10000]
	paction	flags[tc_actions, int32]
}

tc_ife {
	tc_gen	tc_gen
	flags	int16[0:1]
}

tc_mirred {
	tc_gen	tc_gen
	eaction	flags[tc_mirred_eactions, int32]
	ifindex	ifindex
}

tc_nat {
	tc_gen		tc_gen
	old_addr	ipv4_addr
	new_addr	ipv4_addr
	mask		ipv4_addr_mask
	flags		int32[0:1]
}

m_pedit_sel {
	sel		tc_pedit_sel
	keys		array[tc_pedit_key, 128]
	keys_ex		array[m_pedit_key_ex, 128]
	extended	bool8
} [packed, align_4]

tc_pedit_sel {
	tc_gen	tc_gen
	nkeys	int8
	flags	int8
	keys	array[tc_pedit_key]
}

tc_pedit_key {
	mask	int32
	val	int32
	off	int32
	at	int32
	offmask	int32
	shift	int32
}

m_pedit_key_ex {
	htype	flags[pedit_header_type, int16]
	cmd	flags[pedit_cmd, int16]
}

tc_skbmod {
	tc_gen	tc_gen
	flags	int64[0:16]
}

tc_tunnel_key {
	tc_gen		tc_gen
	t_action	int32[1:2]
}

tc_vlan {
	tc_gen		tc_gen
	v_action	int32[1:3]
}

# ------------------------------ tc police ------------------------------
tca_polices [
	TCA_POLICE_TBF		nlattr[TCA_POLICE_TBF, tc_police]
	TCA_POLICE_RATE		nlattr[TCA_POLICE_RATE, array[int32, 256]]
	TCA_POLICE_PEAKRATE	nlattr[TCA_POLICE_PEAKRATE, array[int32, 256]]
	TCA_POLICE_AVRATE	nlattr[TCA_POLICE_AVRATE, int32]
	TCA_POLICE_RESULT	nlattr[TCA_POLICE_RESULT, int32]
] [varlen]

tc_police {
	index		int32
	action		flags[tc_actions, int32]
	limit		int32
	burst		int32
	mtu		int32
	rate		tc_ratespec
	peakrate	tc_ratespec
	refcnt		int32
	bindcnt		int32
	capab		int32
}

tc_ratespec {
	cell_log	int8
	linklayer	flags[linklayer, int8]
	overhead	int16
	cell_align	int16
	mpu		int16
	rate		int32
}

# ------------------------------ tc ematch ------------------------------
tca_ematches [
	TCA_EMATCH_TREE_HDR	nlattr[TCA_EMATCH_TREE_HDR, tcf_ematch_tree_hdr]
	TCA_EMATCH_TREE_LIST	nlattr[TCA_EMATCH_TREE_LIST, tca_ematch_tree_list]
] [varlen]

tcf_ematch_tree_hdr {
	nmatches	int16
	progid		const[TCF_EM_PROG_TC, int16]
}

tca_ematch_tree_list [
	TCF_EM_CONTAINER	nlattr_t[int32, tcf_ematch_hdr[TCF_EM_CONTAINER, array[int8]]]
	TCF_EM_CMP		nlattr_t[int32, tcf_ematch_hdr[TCF_EM_CMP, tcf_em_cmp]]
	TCF_EM_NBYTE		nlattr_t[int32, tcf_ematch_hdr[TCF_EM_NBYTE, tcf_em_nbyte]]
	TCF_EM_U32		nlattr_t[int32, tcf_ematch_hdr[TCF_EM_U32, tc_u32_key]]
	TCF_EM_META		nlattr_t[int32, tcf_ematch_hdr[TCF_EM_META, array[tcf_em_meta_policy]]]
	TCF_EM_CANID		nlattr_t[int32, tcf_ematch_hdr[TCF_EM_CANID, can_filter]]
	TCF_EM_IPSET		nlattr_t[int32, tcf_ematch_hdr[TCF_EM_IPSET, xt_set_info]]
	TCF_EM_IPT		nlattr_t[int32, tcf_ematch_hdr[TCF_EM_IPT, array[tcf_em_ipt_policy]]]
] [varlen]

type tcf_ematch_hdr[KIND, PAYLOAD] {
	matchid	int16
	kind	const[KIND, int16]
	flags	int16
	pad	const[0, int16]
	payload	PAYLOAD
} [align_4]

tcf_em_cmp {
	val	int32
	mask	int32
	off	int16
	align	flags[tcf_em_aligns, int8:4]
	flags	int8:4
	layer	flags[tcf_layers, int8:4]
	opnd	flags[tcf_em_opnds, int8:4]
}

tcf_em_nbyte {
	off	int32
	len	bytesize[payload, int16:12]
	layer	flags[tcf_layers, int8:4]
	payload	array[int8, 0:10]
} [align_4]

tc_u32_key {
	mask	int32be
	val	int32be
	off	int32
	offmask	int32
}

tcf_em_meta_policy [
	TCA_EM_META_HDR		nlattr[TCA_EM_META_HDR, tcf_meta_hdr]
	TCA_EM_META_LVALUE	nlattr[TCA_EM_META_LVALUE, array[tcf_em_meta_int_var]]
	TCA_EM_META_RVALUE	nlattr[TCA_EM_META_RVALUE, array[tcf_em_meta_int_var]]
] [varlen]

tcf_meta_hdr {
	left	tcf_meta_val
	right	tcf_meta_val
}

tcf_meta_val {
# TODO: kind value should be TCF_META_TYPE_VAR << 12 or TCF_META_TYPE_INT << 12
	kind	int16
	shift	int8
	op	flags[tcf_em_opnds, int8]
}

tcf_em_meta_int_var [
	TCF_META_TYPE_INT	int32[0:10]
	TCF_META_TYPE_VAR	array[int8, 0:10]
] [varlen]

can_filter {
	can_id		int32
	can_mask	int32
}

tcf_em_ipt_policy [
	TCA_EM_IPT_HOOK			nlattr[TCA_EM_IPT_HOOK, flags[nf_inet_hooks, int32]]
	TCA_EM_IPT_MATCH_NAME		nlattr[TCA_EM_IPT_MATCH_NAME, string["policy"]]
	TCA_EM_IPT_MATCH_REVISION	nlattr[TCA_EM_IPT_MATCH_REVISION, int8]
	TCA_EM_IPT_NFPROTO		nlattr[TCA_EM_IPT_NFPROTO, flags[nfproto, int8]]
	TCA_EM_IPT_MATCH_DATA		nlattr[TCA_EM_IPT_MATCH_DATA, array[int8]]
] [varlen]

# ------------------------------ tc others ------------------------------
tc_estimator {
	interval	int8
	ewma_log	int8
}

stab_policy {
	TCA_STAB_BASE	nlattr[TCA_STAB_BASE, tc_sizespec]
	TCA_STAB_DATA	nlattr[TCA_STAB_DATA, array[int16]]
} [packed]

tc_sizespec {
	cell_log	int8
	size_log	int8
	cell_align	int16
	overhead	int32
	linklayer	flags[linklayer, int32]
	mpu		int32
	mtu		int32
	tsize		len[stab_policy:TCA_STAB_DATA:payload, int32]
}

tcm_handle_offsets = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 0xffe0, 0xfff1, 0xfff2, 0xfff3, 0xffff
tcf_em_aligns = TCF_EM_ALIGN_U8, TCF_EM_ALIGN_U16, TCF_EM_ALIGN_U32
tcf_layers = TCF_LAYER_LINK, TCF_LAYER_NETWORK, TCF_LAYER_TRANSPORT
tcf_em_opnds = TCF_EM_OPND_EQ, TCF_EM_OPND_GT, TCF_EM_OPND_LT
nf_inet_hooks = NF_INET_PRE_ROUTING, NF_INET_LOCAL_IN, NF_INET_FORWARD, NF_INET_LOCAL_OUT, NF_INET_POST_ROUTING
linklayer = TC_LINKLAYER_UNAWARE, TC_LINKLAYER_ETHERNET, TC_LINKLAYER_ATM
tc_actions = TC_ACT_UNSPEC, TC_ACT_OK, TC_ACT_RECLASSIFY, TC_ACT_SHOT, TC_ACT_PIPE, TC_ACT_STOLEN, TC_ACT_QUEUED, TC_ACT_REPEAT, TC_ACT_REDIRECT, TC_ACT_TRAP, TC_ACT_JUMP, TC_ACT_GOTO_CHAIN
tca_actions_kinds = "bpf", "connmark", "csum", "gact", "ife", "ipt", "mirred", "nat", "pedit", "police", "sample", "skbedit", "skbmod", "tunnel_key", "vlan", "xt"
tc_flow_modes = FLOW_MODE_MAP, FLOW_MODE_HASH
tca_dsmark_ind = 1, 2, 4, 8, 16, 32
tc_mqprio_modes = TC_MQPRIO_MODE_DCB, TC_MQPRIO_MODE_CHANNEL
tc_mqprio_shapers = TC_MQPRIO_SHAPER_DCB, TC_MQPRIO_SHAPER_BW_RATE
tc_pgact_flags = PGACT_NONE, PGACT_NETRAND, PGACT_DETERM
tc_mirred_eactions = TCA_EGRESS_REDIR, TCA_EGRESS_MIRROR, TCA_INGRESS_REDIR, TCA_INGRESS_MIRROR
pedit_header_type = TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK, TCA_PEDIT_KEY_EX_HDR_TYPE_ETH, TCA_PEDIT_KEY_EX_HDR_TYPE_IP4, TCA_PEDIT_KEY_EX_HDR_TYPE_IP6, TCA_PEDIT_KEY_EX_HDR_TYPE_TCP, TCA_PEDIT_KEY_EX_HDR_TYPE_UDP
pedit_cmd = TCA_PEDIT_KEY_EX_CMD_SET, TCA_PEDIT_KEY_EX_CMD_ADD
packet_types = PACKET_HOST, PACKET_BROADCAST, PACKET_MULTICAST, PACKET_OTHERHOST, PACKET_OUTGOING, PACKET_LOOPBACK, PACKET_USER, PACKET_KERNEL
vlan_proto = ETH_P_8021Q, ETH_P_8021AD