diff --git a/home/nipa/nipa_out/963794/ynl/new-code/tc-user.c b/home/nipa/nipa_out/963794/ynl/new-code/tc-user.c new file mode 100644 index 000000000000..6a04aa4df36c --- /dev/null +++ b/home/nipa/nipa_out/963794/ynl/new-code/tc-user.c @@ -0,0 +1,10848 @@ +// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/tc.yaml */ +/* YNL-GEN user source */ + +#include +#include +#include "tc-user.h" +#include "ynl.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* Enums */ +static const char * const tc_op_strmap[] = { + [36] = "getqdisc", + [40] = "gettclass", + [44] = "gettfilter", + [100] = "getchain", +}; + +const char *tc_op_str(int op) +{ + if (op < 0 || op >= (int)YNL_ARRAY_SIZE(tc_op_strmap)) + return NULL; + return tc_op_strmap[op]; +} + +static const char * const tc_cls_flags_strmap[] = { + [0] = "skip-hw", + [1] = "skip-sw", + [2] = "in-hw", + [3] = "not-in-nw", + [4] = "verbose", +}; + +const char *tc_cls_flags_str(int value) +{ + value = ffs(value) - 1; + if (value < 0 || value >= (int)YNL_ARRAY_SIZE(tc_cls_flags_strmap)) + return NULL; + return tc_cls_flags_strmap[value]; +} + +static const char * const tc_flower_key_ctrl_flags_strmap[] = { + [0] = "frag", + [1] = "firstfrag", + [2] = "tuncsum", + [3] = "tundf", + [4] = "tunoam", + [5] = "tuncrit", +}; + +const char *tc_flower_key_ctrl_flags_str(int value) +{ + value = ffs(value) - 1; + if (value < 0 || value >= (int)YNL_ARRAY_SIZE(tc_flower_key_ctrl_flags_strmap)) + return NULL; + return tc_flower_key_ctrl_flags_strmap[value]; +} + +/* Policies */ +extern const struct ynl_policy_nest tc_ets_attrs_nest; + +const struct ynl_policy_attr tc_tca_stab_attrs_policy[TCA_STAB_MAX + 1] = { + [TCA_STAB_BASE] = { .name = "base", .type = YNL_PT_BINARY,}, + [TCA_STAB_DATA] = { .name = "data", .type = YNL_PT_BINARY,}, +}; + +const struct ynl_policy_nest tc_tca_stab_attrs_nest = { + .max_attr = TCA_STAB_MAX, + .table = tc_tca_stab_attrs_policy, +}; + +const struct ynl_policy_attr tc_cake_attrs_policy[TCA_CAKE_MAX + 1] = { + [TCA_CAKE_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_CAKE_BASE_RATE64] = { .name = "base-rate64", .type = YNL_PT_U64, }, + [TCA_CAKE_DIFFSERV_MODE] = { .name = "diffserv-mode", .type = YNL_PT_U32, }, + [TCA_CAKE_ATM] = { .name = "atm", .type = YNL_PT_U32, }, + [TCA_CAKE_FLOW_MODE] = { .name = "flow-mode", .type = YNL_PT_U32, }, + [TCA_CAKE_OVERHEAD] = { .name = "overhead", .type = YNL_PT_U32, }, + [TCA_CAKE_RTT] = { .name = "rtt", .type = YNL_PT_U32, }, + [TCA_CAKE_TARGET] = { .name = "target", .type = YNL_PT_U32, }, + [TCA_CAKE_AUTORATE] = { .name = "autorate", .type = YNL_PT_U32, }, + [TCA_CAKE_MEMORY] = { .name = "memory", .type = YNL_PT_U32, }, + [TCA_CAKE_NAT] = { .name = "nat", .type = YNL_PT_U32, }, + [TCA_CAKE_RAW] = { .name = "raw", .type = YNL_PT_U32, }, + [TCA_CAKE_WASH] = { .name = "wash", .type = YNL_PT_U32, }, + [TCA_CAKE_MPU] = { .name = "mpu", .type = YNL_PT_U32, }, + [TCA_CAKE_INGRESS] = { .name = "ingress", .type = YNL_PT_U32, }, + [TCA_CAKE_ACK_FILTER] = { .name = "ack-filter", .type = YNL_PT_U32, }, + [TCA_CAKE_SPLIT_GSO] = { .name = "split-gso", .type = YNL_PT_U32, }, + [TCA_CAKE_FWMARK] = { .name = "fwmark", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_cake_attrs_nest = { + .max_attr = TCA_CAKE_MAX, + .table = tc_cake_attrs_policy, +}; + +const struct ynl_policy_attr tc_cbs_attrs_policy[TCA_CBS_MAX + 1] = { + [TCA_CBS_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, +}; + +const struct ynl_policy_nest tc_cbs_attrs_nest = { + .max_attr = TCA_CBS_MAX, + .table = tc_cbs_attrs_policy, +}; + +const struct ynl_policy_attr tc_choke_attrs_policy[TCA_CHOKE_MAX + 1] = { + [TCA_CHOKE_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_CHOKE_STAB] = { .name = "stab", .type = YNL_PT_BINARY,}, + [TCA_CHOKE_MAX_P] = { .name = "max-p", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_choke_attrs_nest = { + .max_attr = TCA_CHOKE_MAX, + .table = tc_choke_attrs_policy, +}; + +const struct ynl_policy_attr tc_codel_attrs_policy[TCA_CODEL_MAX + 1] = { + [TCA_CODEL_TARGET] = { .name = "target", .type = YNL_PT_U32, }, + [TCA_CODEL_LIMIT] = { .name = "limit", .type = YNL_PT_U32, }, + [TCA_CODEL_INTERVAL] = { .name = "interval", .type = YNL_PT_U32, }, + [TCA_CODEL_ECN] = { .name = "ecn", .type = YNL_PT_U32, }, + [TCA_CODEL_CE_THRESHOLD] = { .name = "ce-threshold", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_codel_attrs_nest = { + .max_attr = TCA_CODEL_MAX, + .table = tc_codel_attrs_policy, +}; + +const struct ynl_policy_attr tc_drr_attrs_policy[TCA_DRR_MAX + 1] = { + [TCA_DRR_QUANTUM] = { .name = "quantum", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_drr_attrs_nest = { + .max_attr = TCA_DRR_MAX, + .table = tc_drr_attrs_policy, +}; + +const struct ynl_policy_attr tc_etf_attrs_policy[TCA_ETF_MAX + 1] = { + [TCA_ETF_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, +}; + +const struct ynl_policy_nest tc_etf_attrs_nest = { + .max_attr = TCA_ETF_MAX, + .table = tc_etf_attrs_policy, +}; + +const struct ynl_policy_attr tc_fq_attrs_policy[TCA_FQ_MAX + 1] = { + [TCA_FQ_PLIMIT] = { .name = "plimit", .type = YNL_PT_U32, }, + [TCA_FQ_FLOW_PLIMIT] = { .name = "flow-plimit", .type = YNL_PT_U32, }, + [TCA_FQ_QUANTUM] = { .name = "quantum", .type = YNL_PT_U32, }, + [TCA_FQ_INITIAL_QUANTUM] = { .name = "initial-quantum", .type = YNL_PT_U32, }, + [TCA_FQ_RATE_ENABLE] = { .name = "rate-enable", .type = YNL_PT_U32, }, + [TCA_FQ_FLOW_DEFAULT_RATE] = { .name = "flow-default-rate", .type = YNL_PT_U32, }, + [TCA_FQ_FLOW_MAX_RATE] = { .name = "flow-max-rate", .type = YNL_PT_U32, }, + [TCA_FQ_BUCKETS_LOG] = { .name = "buckets-log", .type = YNL_PT_U32, }, + [TCA_FQ_FLOW_REFILL_DELAY] = { .name = "flow-refill-delay", .type = YNL_PT_U32, }, + [TCA_FQ_ORPHAN_MASK] = { .name = "orphan-mask", .type = YNL_PT_U32, }, + [TCA_FQ_LOW_RATE_THRESHOLD] = { .name = "low-rate-threshold", .type = YNL_PT_U32, }, + [TCA_FQ_CE_THRESHOLD] = { .name = "ce-threshold", .type = YNL_PT_U32, }, + [TCA_FQ_TIMER_SLACK] = { .name = "timer-slack", .type = YNL_PT_U32, }, + [TCA_FQ_HORIZON] = { .name = "horizon", .type = YNL_PT_U32, }, + [TCA_FQ_HORIZON_DROP] = { .name = "horizon-drop", .type = YNL_PT_U8, }, + [TCA_FQ_PRIOMAP] = { .name = "priomap", .type = YNL_PT_BINARY,}, + [TCA_FQ_WEIGHTS] = { .name = "weights", .type = YNL_PT_BINARY,}, +}; + +const struct ynl_policy_nest tc_fq_attrs_nest = { + .max_attr = TCA_FQ_MAX, + .table = tc_fq_attrs_policy, +}; + +const struct ynl_policy_attr tc_fq_codel_attrs_policy[TCA_FQ_CODEL_MAX + 1] = { + [TCA_FQ_CODEL_TARGET] = { .name = "target", .type = YNL_PT_U32, }, + [TCA_FQ_CODEL_LIMIT] = { .name = "limit", .type = YNL_PT_U32, }, + [TCA_FQ_CODEL_INTERVAL] = { .name = "interval", .type = YNL_PT_U32, }, + [TCA_FQ_CODEL_ECN] = { .name = "ecn", .type = YNL_PT_U32, }, + [TCA_FQ_CODEL_FLOWS] = { .name = "flows", .type = YNL_PT_U32, }, + [TCA_FQ_CODEL_QUANTUM] = { .name = "quantum", .type = YNL_PT_U32, }, + [TCA_FQ_CODEL_CE_THRESHOLD] = { .name = "ce-threshold", .type = YNL_PT_U32, }, + [TCA_FQ_CODEL_DROP_BATCH_SIZE] = { .name = "drop-batch-size", .type = YNL_PT_U32, }, + [TCA_FQ_CODEL_MEMORY_LIMIT] = { .name = "memory-limit", .type = YNL_PT_U32, }, + [TCA_FQ_CODEL_CE_THRESHOLD_SELECTOR] = { .name = "ce-threshold-selector", .type = YNL_PT_U8, }, + [TCA_FQ_CODEL_CE_THRESHOLD_MASK] = { .name = "ce-threshold-mask", .type = YNL_PT_U8, }, +}; + +const struct ynl_policy_nest tc_fq_codel_attrs_nest = { + .max_attr = TCA_FQ_CODEL_MAX, + .table = tc_fq_codel_attrs_policy, +}; + +const struct ynl_policy_attr tc_fq_pie_attrs_policy[TCA_FQ_PIE_MAX + 1] = { + [TCA_FQ_PIE_LIMIT] = { .name = "limit", .type = YNL_PT_U32, }, + [TCA_FQ_PIE_FLOWS] = { .name = "flows", .type = YNL_PT_U32, }, + [TCA_FQ_PIE_TARGET] = { .name = "target", .type = YNL_PT_U32, }, + [TCA_FQ_PIE_TUPDATE] = { .name = "tupdate", .type = YNL_PT_U32, }, + [TCA_FQ_PIE_ALPHA] = { .name = "alpha", .type = YNL_PT_U32, }, + [TCA_FQ_PIE_BETA] = { .name = "beta", .type = YNL_PT_U32, }, + [TCA_FQ_PIE_QUANTUM] = { .name = "quantum", .type = YNL_PT_U32, }, + [TCA_FQ_PIE_MEMORY_LIMIT] = { .name = "memory-limit", .type = YNL_PT_U32, }, + [TCA_FQ_PIE_ECN_PROB] = { .name = "ecn-prob", .type = YNL_PT_U32, }, + [TCA_FQ_PIE_ECN] = { .name = "ecn", .type = YNL_PT_U32, }, + [TCA_FQ_PIE_BYTEMODE] = { .name = "bytemode", .type = YNL_PT_U32, }, + [TCA_FQ_PIE_DQ_RATE_ESTIMATOR] = { .name = "dq-rate-estimator", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_fq_pie_attrs_nest = { + .max_attr = TCA_FQ_PIE_MAX, + .table = tc_fq_pie_attrs_policy, +}; + +const struct ynl_policy_attr tc_hhf_attrs_policy[TCA_HHF_MAX + 1] = { + [TCA_HHF_BACKLOG_LIMIT] = { .name = "backlog-limit", .type = YNL_PT_U32, }, + [TCA_HHF_QUANTUM] = { .name = "quantum", .type = YNL_PT_U32, }, + [TCA_HHF_HH_FLOWS_LIMIT] = { .name = "hh-flows-limit", .type = YNL_PT_U32, }, + [TCA_HHF_RESET_TIMEOUT] = { .name = "reset-timeout", .type = YNL_PT_U32, }, + [TCA_HHF_ADMIT_BYTES] = { .name = "admit-bytes", .type = YNL_PT_U32, }, + [TCA_HHF_EVICT_TIMEOUT] = { .name = "evict-timeout", .type = YNL_PT_U32, }, + [TCA_HHF_NON_HH_WEIGHT] = { .name = "non-hh-weight", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_hhf_attrs_nest = { + .max_attr = TCA_HHF_MAX, + .table = tc_hhf_attrs_policy, +}; + +const struct ynl_policy_attr tc_htb_attrs_policy[TCA_HTB_MAX + 1] = { + [TCA_HTB_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_HTB_INIT] = { .name = "init", .type = YNL_PT_BINARY,}, + [TCA_HTB_CTAB] = { .name = "ctab", .type = YNL_PT_BINARY,}, + [TCA_HTB_RTAB] = { .name = "rtab", .type = YNL_PT_BINARY,}, + [TCA_HTB_DIRECT_QLEN] = { .name = "direct-qlen", .type = YNL_PT_U32, }, + [TCA_HTB_RATE64] = { .name = "rate64", .type = YNL_PT_U64, }, + [TCA_HTB_CEIL64] = { .name = "ceil64", .type = YNL_PT_U64, }, + [TCA_HTB_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_HTB_OFFLOAD] = { .name = "offload", .type = YNL_PT_FLAG, }, +}; + +const struct ynl_policy_nest tc_htb_attrs_nest = { + .max_attr = TCA_HTB_MAX, + .table = tc_htb_attrs_policy, +}; + +const struct ynl_policy_attr tc_pie_attrs_policy[TCA_PIE_MAX + 1] = { + [TCA_PIE_TARGET] = { .name = "target", .type = YNL_PT_U32, }, + [TCA_PIE_LIMIT] = { .name = "limit", .type = YNL_PT_U32, }, + [TCA_PIE_TUPDATE] = { .name = "tupdate", .type = YNL_PT_U32, }, + [TCA_PIE_ALPHA] = { .name = "alpha", .type = YNL_PT_U32, }, + [TCA_PIE_BETA] = { .name = "beta", .type = YNL_PT_U32, }, + [TCA_PIE_ECN] = { .name = "ecn", .type = YNL_PT_U32, }, + [TCA_PIE_BYTEMODE] = { .name = "bytemode", .type = YNL_PT_U32, }, + [TCA_PIE_DQ_RATE_ESTIMATOR] = { .name = "dq-rate-estimator", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_pie_attrs_nest = { + .max_attr = TCA_PIE_MAX, + .table = tc_pie_attrs_policy, +}; + +const struct ynl_policy_attr tc_qfq_attrs_policy[TCA_QFQ_MAX + 1] = { + [TCA_QFQ_WEIGHT] = { .name = "weight", .type = YNL_PT_U32, }, + [TCA_QFQ_LMAX] = { .name = "lmax", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_qfq_attrs_nest = { + .max_attr = TCA_QFQ_MAX, + .table = tc_qfq_attrs_policy, +}; + +const struct ynl_policy_attr tc_red_attrs_policy[TCA_RED_MAX + 1] = { + [TCA_RED_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_RED_STAB] = { .name = "stab", .type = YNL_PT_BINARY,}, + [TCA_RED_MAX_P] = { .name = "max-p", .type = YNL_PT_U32, }, + [TCA_RED_FLAGS] = { .name = "flags", .type = YNL_PT_BITFIELD32, }, + [TCA_RED_EARLY_DROP_BLOCK] = { .name = "early-drop-block", .type = YNL_PT_U32, }, + [TCA_RED_MARK_BLOCK] = { .name = "mark-block", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_red_attrs_nest = { + .max_attr = TCA_RED_MAX, + .table = tc_red_attrs_policy, +}; + +const struct ynl_policy_attr tc_tbf_attrs_policy[TCA_TBF_MAX + 1] = { + [TCA_TBF_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_TBF_RTAB] = { .name = "rtab", .type = YNL_PT_BINARY,}, + [TCA_TBF_PTAB] = { .name = "ptab", .type = YNL_PT_BINARY,}, + [TCA_TBF_RATE64] = { .name = "rate64", .type = YNL_PT_U64, }, + [TCA_TBF_PRATE64] = { .name = "prate64", .type = YNL_PT_U64, }, + [TCA_TBF_BURST] = { .name = "burst", .type = YNL_PT_U32, }, + [TCA_TBF_PBURST] = { .name = "pburst", .type = YNL_PT_U32, }, + [TCA_TBF_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, +}; + +const struct ynl_policy_nest tc_tbf_attrs_nest = { + .max_attr = TCA_TBF_MAX, + .table = tc_tbf_attrs_policy, +}; + +const struct ynl_policy_attr tc_ematch_attrs_policy[TCA_EMATCH_TREE_MAX + 1] = { + [TCA_EMATCH_TREE_HDR] = { .name = "tree-hdr", .type = YNL_PT_BINARY,}, + [TCA_EMATCH_TREE_LIST] = { .name = "tree-list", .type = YNL_PT_BINARY,}, +}; + +const struct ynl_policy_nest tc_ematch_attrs_nest = { + .max_attr = TCA_EMATCH_TREE_MAX, + .table = tc_ematch_attrs_policy, +}; + +const struct ynl_policy_attr tc_police_attrs_policy[TCA_POLICE_MAX + 1] = { + [TCA_POLICE_TBF] = { .name = "tbf", .type = YNL_PT_BINARY,}, + [TCA_POLICE_RATE] = { .name = "rate", .type = YNL_PT_BINARY,}, + [TCA_POLICE_PEAKRATE] = { .name = "peakrate", .type = YNL_PT_BINARY,}, + [TCA_POLICE_AVRATE] = { .name = "avrate", .type = YNL_PT_U32, }, + [TCA_POLICE_RESULT] = { .name = "result", .type = YNL_PT_U32, }, + [TCA_POLICE_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_POLICE_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_POLICE_RATE64] = { .name = "rate64", .type = YNL_PT_U64, }, + [TCA_POLICE_PEAKRATE64] = { .name = "peakrate64", .type = YNL_PT_U64, }, + [TCA_POLICE_PKTRATE64] = { .name = "pktrate64", .type = YNL_PT_U64, }, + [TCA_POLICE_PKTBURST64] = { .name = "pktburst64", .type = YNL_PT_U64, }, +}; + +const struct ynl_policy_nest tc_police_attrs_nest = { + .max_attr = TCA_POLICE_MAX, + .table = tc_police_attrs_policy, +}; + +const struct ynl_policy_attr tc_flower_key_mpls_opt_attrs_policy[TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX + 1] = { + [TCA_FLOWER_KEY_MPLS_OPT_LSE_DEPTH] = { .name = "lse-depth", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_MPLS_OPT_LSE_TTL] = { .name = "lse-ttl", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_MPLS_OPT_LSE_BOS] = { .name = "lse-bos", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_MPLS_OPT_LSE_TC] = { .name = "lse-tc", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_MPLS_OPT_LSE_LABEL] = { .name = "lse-label", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_flower_key_mpls_opt_attrs_nest = { + .max_attr = TCA_FLOWER_KEY_MPLS_OPT_LSE_MAX, + .table = tc_flower_key_mpls_opt_attrs_policy, +}; + +const struct ynl_policy_attr tc_flower_key_cfm_attrs_policy[TCA_FLOWER_KEY_CFM_MAX + 1] = { + [TCA_FLOWER_KEY_CFM_MD_LEVEL] = { .name = "md-level", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_CFM_OPCODE] = { .name = "opcode", .type = YNL_PT_U8, }, +}; + +const struct ynl_policy_nest tc_flower_key_cfm_attrs_nest = { + .max_attr = TCA_FLOWER_KEY_CFM_MAX, + .table = tc_flower_key_cfm_attrs_policy, +}; + +const struct ynl_policy_attr tc_netem_loss_attrs_policy[NETEM_LOSS_MAX + 1] = { + [NETEM_LOSS_GI] = { .name = "gi", .type = YNL_PT_BINARY,}, + [NETEM_LOSS_GE] = { .name = "ge", .type = YNL_PT_BINARY,}, +}; + +const struct ynl_policy_nest tc_netem_loss_attrs_nest = { + .max_attr = NETEM_LOSS_MAX, + .table = tc_netem_loss_attrs_policy, +}; + +const struct ynl_policy_attr tc_taprio_sched_entry_policy[TCA_TAPRIO_SCHED_ENTRY_MAX + 1] = { + [TCA_TAPRIO_SCHED_ENTRY_INDEX] = { .name = "index", .type = YNL_PT_U32, }, + [TCA_TAPRIO_SCHED_ENTRY_CMD] = { .name = "cmd", .type = YNL_PT_U8, }, + [TCA_TAPRIO_SCHED_ENTRY_GATE_MASK] = { .name = "gate-mask", .type = YNL_PT_U32, }, + [TCA_TAPRIO_SCHED_ENTRY_INTERVAL] = { .name = "interval", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_taprio_sched_entry_nest = { + .max_attr = TCA_TAPRIO_SCHED_ENTRY_MAX, + .table = tc_taprio_sched_entry_policy, +}; + +const struct ynl_policy_attr tc_taprio_tc_entry_attrs_policy[TCA_TAPRIO_TC_ENTRY_MAX + 1] = { + [TCA_TAPRIO_TC_ENTRY_INDEX] = { .name = "index", .type = YNL_PT_U32, }, + [TCA_TAPRIO_TC_ENTRY_MAX_SDU] = { .name = "max-sdu", .type = YNL_PT_U32, }, + [TCA_TAPRIO_TC_ENTRY_FP] = { .name = "fp", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_taprio_tc_entry_attrs_nest = { + .max_attr = TCA_TAPRIO_TC_ENTRY_MAX, + .table = tc_taprio_tc_entry_attrs_policy, +}; + +const struct ynl_policy_attr tc_cake_tin_stats_attrs_policy[TCA_CAKE_TIN_STATS_MAX + 1] = { + [TCA_CAKE_TIN_STATS_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_CAKE_TIN_STATS_SENT_PACKETS] = { .name = "sent-packets", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_SENT_BYTES64] = { .name = "sent-bytes64", .type = YNL_PT_U64, }, + [TCA_CAKE_TIN_STATS_DROPPED_PACKETS] = { .name = "dropped-packets", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_DROPPED_BYTES64] = { .name = "dropped-bytes64", .type = YNL_PT_U64, }, + [TCA_CAKE_TIN_STATS_ACKS_DROPPED_PACKETS] = { .name = "acks-dropped-packets", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_ACKS_DROPPED_BYTES64] = { .name = "acks-dropped-bytes64", .type = YNL_PT_U64, }, + [TCA_CAKE_TIN_STATS_ECN_MARKED_PACKETS] = { .name = "ecn-marked-packets", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_ECN_MARKED_BYTES64] = { .name = "ecn-marked-bytes64", .type = YNL_PT_U64, }, + [TCA_CAKE_TIN_STATS_BACKLOG_PACKETS] = { .name = "backlog-packets", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_BACKLOG_BYTES] = { .name = "backlog-bytes", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_THRESHOLD_RATE64] = { .name = "threshold-rate64", .type = YNL_PT_U64, }, + [TCA_CAKE_TIN_STATS_TARGET_US] = { .name = "target-us", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_INTERVAL_US] = { .name = "interval-us", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_WAY_INDIRECT_HITS] = { .name = "way-indirect-hits", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_WAY_MISSES] = { .name = "way-misses", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_WAY_COLLISIONS] = { .name = "way-collisions", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_PEAK_DELAY_US] = { .name = "peak-delay-us", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_AVG_DELAY_US] = { .name = "avg-delay-us", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_BASE_DELAY_US] = { .name = "base-delay-us", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_SPARSE_FLOWS] = { .name = "sparse-flows", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_BULK_FLOWS] = { .name = "bulk-flows", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_UNRESPONSIVE_FLOWS] = { .name = "unresponsive-flows", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_MAX_SKBLEN] = { .name = "max-skblen", .type = YNL_PT_U32, }, + [TCA_CAKE_TIN_STATS_FLOW_QUANTUM] = { .name = "flow-quantum", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_cake_tin_stats_attrs_nest = { + .max_attr = TCA_CAKE_TIN_STATS_MAX, + .table = tc_cake_tin_stats_attrs_policy, +}; + +const struct ynl_policy_attr tc_flower_key_enc_opt_geneve_attrs_policy[TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX + 1] = { + [TCA_FLOWER_KEY_ENC_OPT_GENEVE_CLASS] = { .name = "class", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_ENC_OPT_GENEVE_TYPE] = { .name = "type", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ENC_OPT_GENEVE_DATA] = { .name = "data", .type = YNL_PT_BINARY,}, +}; + +const struct ynl_policy_nest tc_flower_key_enc_opt_geneve_attrs_nest = { + .max_attr = TCA_FLOWER_KEY_ENC_OPT_GENEVE_MAX, + .table = tc_flower_key_enc_opt_geneve_attrs_policy, +}; + +const struct ynl_policy_attr tc_flower_key_enc_opt_vxlan_attrs_policy[TCA_FLOWER_KEY_ENC_OPT_VXLAN_MAX + 1] = { + [TCA_FLOWER_KEY_ENC_OPT_VXLAN_GBP] = { .name = "gbp", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_flower_key_enc_opt_vxlan_attrs_nest = { + .max_attr = TCA_FLOWER_KEY_ENC_OPT_VXLAN_MAX, + .table = tc_flower_key_enc_opt_vxlan_attrs_policy, +}; + +const struct ynl_policy_attr tc_flower_key_enc_opt_erspan_attrs_policy[TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX + 1] = { + [TCA_FLOWER_KEY_ENC_OPT_ERSPAN_VER] = { .name = "ver", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX] = { .name = "index", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR] = { .name = "dir", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ENC_OPT_ERSPAN_HWID] = { .name = "hwid", .type = YNL_PT_U8, }, +}; + +const struct ynl_policy_nest tc_flower_key_enc_opt_erspan_attrs_nest = { + .max_attr = TCA_FLOWER_KEY_ENC_OPT_ERSPAN_MAX, + .table = tc_flower_key_enc_opt_erspan_attrs_policy, +}; + +const struct ynl_policy_attr tc_flower_key_enc_opt_gtp_attrs_policy[TCA_FLOWER_KEY_ENC_OPT_GTP_MAX + 1] = { + [TCA_FLOWER_KEY_ENC_OPT_GTP_PDU_TYPE] = { .name = "pdu-type", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ENC_OPT_GTP_QFI] = { .name = "qfi", .type = YNL_PT_U8, }, +}; + +const struct ynl_policy_nest tc_flower_key_enc_opt_gtp_attrs_nest = { + .max_attr = TCA_FLOWER_KEY_ENC_OPT_GTP_MAX, + .table = tc_flower_key_enc_opt_gtp_attrs_policy, +}; + +const struct ynl_policy_attr tc_tca_gred_vq_entry_attrs_policy[TCA_GRED_VQ_MAX + 1] = { + [TCA_GRED_VQ_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_GRED_VQ_DP] = { .name = "dp", .type = YNL_PT_U32, }, + [TCA_GRED_VQ_STAT_BYTES] = { .name = "stat-bytes", .type = YNL_PT_U64, }, + [TCA_GRED_VQ_STAT_PACKETS] = { .name = "stat-packets", .type = YNL_PT_U32, }, + [TCA_GRED_VQ_STAT_BACKLOG] = { .name = "stat-backlog", .type = YNL_PT_U32, }, + [TCA_GRED_VQ_STAT_PROB_DROP] = { .name = "stat-prob-drop", .type = YNL_PT_U32, }, + [TCA_GRED_VQ_STAT_PROB_MARK] = { .name = "stat-prob-mark", .type = YNL_PT_U32, }, + [TCA_GRED_VQ_STAT_FORCED_DROP] = { .name = "stat-forced-drop", .type = YNL_PT_U32, }, + [TCA_GRED_VQ_STAT_FORCED_MARK] = { .name = "stat-forced-mark", .type = YNL_PT_U32, }, + [TCA_GRED_VQ_STAT_PDROP] = { .name = "stat-pdrop", .type = YNL_PT_U32, }, + [TCA_GRED_VQ_STAT_OTHER] = { .name = "stat-other", .type = YNL_PT_U32, }, + [TCA_GRED_VQ_FLAGS] = { .name = "flags", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_tca_gred_vq_entry_attrs_nest = { + .max_attr = TCA_GRED_VQ_MAX, + .table = tc_tca_gred_vq_entry_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_bpf_attrs_policy[TCA_ACT_BPF_MAX + 1] = { + [TCA_ACT_BPF_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_ACT_BPF_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_ACT_BPF_OPS_LEN] = { .name = "ops-len", .type = YNL_PT_U16, }, + [TCA_ACT_BPF_OPS] = { .name = "ops", .type = YNL_PT_BINARY,}, + [TCA_ACT_BPF_FD] = { .name = "fd", .type = YNL_PT_U32, }, + [TCA_ACT_BPF_NAME] = { .name = "name", .type = YNL_PT_NUL_STR, }, + [TCA_ACT_BPF_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_ACT_BPF_TAG] = { .name = "tag", .type = YNL_PT_BINARY,}, + [TCA_ACT_BPF_ID] = { .name = "id", .type = YNL_PT_BINARY,}, +}; + +const struct ynl_policy_nest tc_act_bpf_attrs_nest = { + .max_attr = TCA_ACT_BPF_MAX, + .table = tc_act_bpf_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_connmark_attrs_policy[TCA_CONNMARK_MAX + 1] = { + [TCA_CONNMARK_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_CONNMARK_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_CONNMARK_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, +}; + +const struct ynl_policy_nest tc_act_connmark_attrs_nest = { + .max_attr = TCA_CONNMARK_MAX, + .table = tc_act_connmark_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_csum_attrs_policy[TCA_CSUM_MAX + 1] = { + [TCA_CSUM_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_CSUM_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_CSUM_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, +}; + +const struct ynl_policy_nest tc_act_csum_attrs_nest = { + .max_attr = TCA_CSUM_MAX, + .table = tc_act_csum_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_ct_attrs_policy[TCA_CT_MAX + 1] = { + [TCA_CT_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_CT_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_CT_ACTION] = { .name = "action", .type = YNL_PT_U16, }, + [TCA_CT_ZONE] = { .name = "zone", .type = YNL_PT_U16, }, + [TCA_CT_MARK] = { .name = "mark", .type = YNL_PT_U32, }, + [TCA_CT_MARK_MASK] = { .name = "mark-mask", .type = YNL_PT_U32, }, + [TCA_CT_LABELS] = { .name = "labels", .type = YNL_PT_BINARY,}, + [TCA_CT_LABELS_MASK] = { .name = "labels-mask", .type = YNL_PT_BINARY,}, + [TCA_CT_NAT_IPV4_MIN] = { .name = "nat-ipv4-min", .type = YNL_PT_U32, }, + [TCA_CT_NAT_IPV4_MAX] = { .name = "nat-ipv4-max", .type = YNL_PT_U32, }, + [TCA_CT_NAT_IPV6_MIN] = { .name = "nat-ipv6-min", .type = YNL_PT_BINARY,}, + [TCA_CT_NAT_IPV6_MAX] = { .name = "nat-ipv6-max", .type = YNL_PT_BINARY,}, + [TCA_CT_NAT_PORT_MIN] = { .name = "nat-port-min", .type = YNL_PT_U16, }, + [TCA_CT_NAT_PORT_MAX] = { .name = "nat-port-max", .type = YNL_PT_U16, }, + [TCA_CT_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_CT_HELPER_NAME] = { .name = "helper-name", .type = YNL_PT_NUL_STR, }, + [TCA_CT_HELPER_FAMILY] = { .name = "helper-family", .type = YNL_PT_U8, }, + [TCA_CT_HELPER_PROTO] = { .name = "helper-proto", .type = YNL_PT_U8, }, +}; + +const struct ynl_policy_nest tc_act_ct_attrs_nest = { + .max_attr = TCA_CT_MAX, + .table = tc_act_ct_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_ctinfo_attrs_policy[TCA_CTINFO_MAX + 1] = { + [TCA_CTINFO_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_CTINFO_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_CTINFO_ACT] = { .name = "act", .type = YNL_PT_BINARY,}, + [TCA_CTINFO_ZONE] = { .name = "zone", .type = YNL_PT_U16, }, + [TCA_CTINFO_PARMS_DSCP_MASK] = { .name = "parms-dscp-mask", .type = YNL_PT_U32, }, + [TCA_CTINFO_PARMS_DSCP_STATEMASK] = { .name = "parms-dscp-statemask", .type = YNL_PT_U32, }, + [TCA_CTINFO_PARMS_CPMARK_MASK] = { .name = "parms-cpmark-mask", .type = YNL_PT_U32, }, + [TCA_CTINFO_STATS_DSCP_SET] = { .name = "stats-dscp-set", .type = YNL_PT_U64, }, + [TCA_CTINFO_STATS_DSCP_ERROR] = { .name = "stats-dscp-error", .type = YNL_PT_U64, }, + [TCA_CTINFO_STATS_CPMARK_SET] = { .name = "stats-cpmark-set", .type = YNL_PT_U64, }, +}; + +const struct ynl_policy_nest tc_act_ctinfo_attrs_nest = { + .max_attr = TCA_CTINFO_MAX, + .table = tc_act_ctinfo_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_gact_attrs_policy[TCA_GACT_MAX + 1] = { + [TCA_GACT_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_GACT_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_GACT_PROB] = { .name = "prob", .type = YNL_PT_BINARY,}, + [TCA_GACT_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, +}; + +const struct ynl_policy_nest tc_act_gact_attrs_nest = { + .max_attr = TCA_GACT_MAX, + .table = tc_act_gact_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_gate_attrs_policy[TCA_GATE_MAX + 1] = { + [TCA_GATE_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_GATE_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_GATE_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_GATE_PRIORITY] = { .name = "priority", .type = YNL_PT_U32, }, + [TCA_GATE_ENTRY_LIST] = { .name = "entry-list", .type = YNL_PT_BINARY,}, + [TCA_GATE_BASE_TIME] = { .name = "base-time", .type = YNL_PT_U64, }, + [TCA_GATE_CYCLE_TIME] = { .name = "cycle-time", .type = YNL_PT_U64, }, + [TCA_GATE_CYCLE_TIME_EXT] = { .name = "cycle-time-ext", .type = YNL_PT_U64, }, + [TCA_GATE_FLAGS] = { .name = "flags", .type = YNL_PT_U32, }, + [TCA_GATE_CLOCKID] = { .name = "clockid", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_act_gate_attrs_nest = { + .max_attr = TCA_GATE_MAX, + .table = tc_act_gate_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_ife_attrs_policy[TCA_IFE_MAX + 1] = { + [TCA_IFE_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_IFE_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_IFE_DMAC] = { .name = "dmac", .type = YNL_PT_BINARY,}, + [TCA_IFE_SMAC] = { .name = "smac", .type = YNL_PT_BINARY,}, + [TCA_IFE_TYPE] = { .name = "type", .type = YNL_PT_U16, }, + [TCA_IFE_METALST] = { .name = "metalst", .type = YNL_PT_BINARY,}, + [TCA_IFE_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, +}; + +const struct ynl_policy_nest tc_act_ife_attrs_nest = { + .max_attr = TCA_IFE_MAX, + .table = tc_act_ife_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_mirred_attrs_policy[TCA_MIRRED_MAX + 1] = { + [TCA_MIRRED_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_MIRRED_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_MIRRED_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_MIRRED_BLOCKID] = { .name = "blockid", .type = YNL_PT_BINARY,}, +}; + +const struct ynl_policy_nest tc_act_mirred_attrs_nest = { + .max_attr = TCA_MIRRED_MAX, + .table = tc_act_mirred_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_mpls_attrs_policy[TCA_MPLS_MAX + 1] = { + [TCA_MPLS_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_MPLS_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_MPLS_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_MPLS_PROTO] = { .name = "proto", .type = YNL_PT_U16, }, + [TCA_MPLS_LABEL] = { .name = "label", .type = YNL_PT_U32, }, + [TCA_MPLS_TC] = { .name = "tc", .type = YNL_PT_U8, }, + [TCA_MPLS_TTL] = { .name = "ttl", .type = YNL_PT_U8, }, + [TCA_MPLS_BOS] = { .name = "bos", .type = YNL_PT_U8, }, +}; + +const struct ynl_policy_nest tc_act_mpls_attrs_nest = { + .max_attr = TCA_MPLS_MAX, + .table = tc_act_mpls_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_nat_attrs_policy[TCA_NAT_MAX + 1] = { + [TCA_NAT_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_NAT_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_NAT_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, +}; + +const struct ynl_policy_nest tc_act_nat_attrs_nest = { + .max_attr = TCA_NAT_MAX, + .table = tc_act_nat_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_pedit_attrs_policy[TCA_PEDIT_MAX + 1] = { + [TCA_PEDIT_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_PEDIT_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_PEDIT_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_PEDIT_PARMS_EX] = { .name = "parms-ex", .type = YNL_PT_BINARY,}, + [TCA_PEDIT_KEYS_EX] = { .name = "keys-ex", .type = YNL_PT_BINARY,}, + [TCA_PEDIT_KEY_EX] = { .name = "key-ex", .type = YNL_PT_BINARY,}, +}; + +const struct ynl_policy_nest tc_act_pedit_attrs_nest = { + .max_attr = TCA_PEDIT_MAX, + .table = tc_act_pedit_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_sample_attrs_policy[TCA_SAMPLE_MAX + 1] = { + [TCA_SAMPLE_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_SAMPLE_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_SAMPLE_RATE] = { .name = "rate", .type = YNL_PT_U32, }, + [TCA_SAMPLE_TRUNC_SIZE] = { .name = "trunc-size", .type = YNL_PT_U32, }, + [TCA_SAMPLE_PSAMPLE_GROUP] = { .name = "psample-group", .type = YNL_PT_U32, }, + [TCA_SAMPLE_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, +}; + +const struct ynl_policy_nest tc_act_sample_attrs_nest = { + .max_attr = TCA_SAMPLE_MAX, + .table = tc_act_sample_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_simple_attrs_policy[TCA_DEF_MAX + 1] = { + [TCA_DEF_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_DEF_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_DEF_DATA] = { .name = "data", .type = YNL_PT_BINARY,}, + [TCA_DEF_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, +}; + +const struct ynl_policy_nest tc_act_simple_attrs_nest = { + .max_attr = TCA_DEF_MAX, + .table = tc_act_simple_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_skbedit_attrs_policy[TCA_SKBEDIT_MAX + 1] = { + [TCA_SKBEDIT_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_SKBEDIT_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_SKBEDIT_PRIORITY] = { .name = "priority", .type = YNL_PT_U32, }, + [TCA_SKBEDIT_QUEUE_MAPPING] = { .name = "queue-mapping", .type = YNL_PT_U16, }, + [TCA_SKBEDIT_MARK] = { .name = "mark", .type = YNL_PT_U32, }, + [TCA_SKBEDIT_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_SKBEDIT_PTYPE] = { .name = "ptype", .type = YNL_PT_U16, }, + [TCA_SKBEDIT_MASK] = { .name = "mask", .type = YNL_PT_U32, }, + [TCA_SKBEDIT_FLAGS] = { .name = "flags", .type = YNL_PT_U64, }, + [TCA_SKBEDIT_QUEUE_MAPPING_MAX] = { .name = "queue-mapping-max", .type = YNL_PT_U16, }, +}; + +const struct ynl_policy_nest tc_act_skbedit_attrs_nest = { + .max_attr = TCA_SKBEDIT_MAX, + .table = tc_act_skbedit_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_skbmod_attrs_policy[TCA_SKBMOD_MAX + 1] = { + [TCA_SKBMOD_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_SKBMOD_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_SKBMOD_DMAC] = { .name = "dmac", .type = YNL_PT_BINARY,}, + [TCA_SKBMOD_SMAC] = { .name = "smac", .type = YNL_PT_BINARY,}, + [TCA_SKBMOD_ETYPE] = { .name = "etype", .type = YNL_PT_BINARY,}, + [TCA_SKBMOD_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, +}; + +const struct ynl_policy_nest tc_act_skbmod_attrs_nest = { + .max_attr = TCA_SKBMOD_MAX, + .table = tc_act_skbmod_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_tunnel_key_attrs_policy[TCA_TUNNEL_KEY_MAX + 1] = { + [TCA_TUNNEL_KEY_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_TUNNEL_KEY_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_TUNNEL_KEY_ENC_IPV4_SRC] = { .name = "enc-ipv4-src", .type = YNL_PT_U32, }, + [TCA_TUNNEL_KEY_ENC_IPV4_DST] = { .name = "enc-ipv4-dst", .type = YNL_PT_U32, }, + [TCA_TUNNEL_KEY_ENC_IPV6_SRC] = { .name = "enc-ipv6-src", .type = YNL_PT_BINARY,}, + [TCA_TUNNEL_KEY_ENC_IPV6_DST] = { .name = "enc-ipv6-dst", .type = YNL_PT_BINARY,}, + [TCA_TUNNEL_KEY_ENC_KEY_ID] = { .name = "enc-key-id", .type = YNL_PT_U64, }, + [TCA_TUNNEL_KEY_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_TUNNEL_KEY_ENC_DST_PORT] = { .name = "enc-dst-port", .type = YNL_PT_U16, }, + [TCA_TUNNEL_KEY_NO_CSUM] = { .name = "no-csum", .type = YNL_PT_U8, }, + [TCA_TUNNEL_KEY_ENC_OPTS] = { .name = "enc-opts", .type = YNL_PT_BINARY,}, + [TCA_TUNNEL_KEY_ENC_TOS] = { .name = "enc-tos", .type = YNL_PT_U8, }, + [TCA_TUNNEL_KEY_ENC_TTL] = { .name = "enc-ttl", .type = YNL_PT_U8, }, + [TCA_TUNNEL_KEY_NO_FRAG] = { .name = "no-frag", .type = YNL_PT_FLAG, }, +}; + +const struct ynl_policy_nest tc_act_tunnel_key_attrs_nest = { + .max_attr = TCA_TUNNEL_KEY_MAX, + .table = tc_act_tunnel_key_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_vlan_attrs_policy[TCA_VLAN_MAX + 1] = { + [TCA_VLAN_TM] = { .name = "tm", .type = YNL_PT_BINARY,}, + [TCA_VLAN_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_VLAN_PUSH_VLAN_ID] = { .name = "push-vlan-id", .type = YNL_PT_U16, }, + [TCA_VLAN_PUSH_VLAN_PROTOCOL] = { .name = "push-vlan-protocol", .type = YNL_PT_U16, }, + [TCA_VLAN_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_VLAN_PUSH_VLAN_PRIORITY] = { .name = "push-vlan-priority", .type = YNL_PT_U8, }, + [TCA_VLAN_PUSH_ETH_DST] = { .name = "push-eth-dst", .type = YNL_PT_BINARY,}, + [TCA_VLAN_PUSH_ETH_SRC] = { .name = "push-eth-src", .type = YNL_PT_BINARY,}, +}; + +const struct ynl_policy_nest tc_act_vlan_attrs_nest = { + .max_attr = TCA_VLAN_MAX, + .table = tc_act_vlan_attrs_policy, +}; + +const struct ynl_policy_attr tc_flow_attrs_policy[TCA_FLOW_MAX + 1] = { + [TCA_FLOW_KEYS] = { .name = "keys", .type = YNL_PT_U32, }, + [TCA_FLOW_MODE] = { .name = "mode", .type = YNL_PT_U32, }, + [TCA_FLOW_BASECLASS] = { .name = "baseclass", .type = YNL_PT_U32, }, + [TCA_FLOW_RSHIFT] = { .name = "rshift", .type = YNL_PT_U32, }, + [TCA_FLOW_ADDEND] = { .name = "addend", .type = YNL_PT_U32, }, + [TCA_FLOW_MASK] = { .name = "mask", .type = YNL_PT_U32, }, + [TCA_FLOW_XOR] = { .name = "xor", .type = YNL_PT_U32, }, + [TCA_FLOW_DIVISOR] = { .name = "divisor", .type = YNL_PT_U32, }, + [TCA_FLOW_ACT] = { .name = "act", .type = YNL_PT_BINARY,}, + [TCA_FLOW_POLICE] = { .name = "police", .type = YNL_PT_NEST, .nest = &tc_police_attrs_nest, }, + [TCA_FLOW_EMATCHES] = { .name = "ematches", .type = YNL_PT_BINARY,}, + [TCA_FLOW_PERTURB] = { .name = "perturb", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_flow_attrs_nest = { + .max_attr = TCA_FLOW_MAX, + .table = tc_flow_attrs_policy, +}; + +const struct ynl_policy_attr tc_netem_attrs_policy[TCA_NETEM_MAX + 1] = { + [TCA_NETEM_CORR] = { .name = "corr", .type = YNL_PT_BINARY,}, + [TCA_NETEM_DELAY_DIST] = { .name = "delay-dist", .type = YNL_PT_BINARY,}, + [TCA_NETEM_REORDER] = { .name = "reorder", .type = YNL_PT_BINARY,}, + [TCA_NETEM_CORRUPT] = { .name = "corrupt", .type = YNL_PT_BINARY,}, + [TCA_NETEM_LOSS] = { .name = "loss", .type = YNL_PT_NEST, .nest = &tc_netem_loss_attrs_nest, }, + [TCA_NETEM_RATE] = { .name = "rate", .type = YNL_PT_BINARY,}, + [TCA_NETEM_ECN] = { .name = "ecn", .type = YNL_PT_U32, }, + [TCA_NETEM_RATE64] = { .name = "rate64", .type = YNL_PT_U64, }, + [TCA_NETEM_PAD] = { .name = "pad", .type = YNL_PT_U32, }, + [TCA_NETEM_LATENCY64] = { .name = "latency64", .type = YNL_PT_U64, }, + [TCA_NETEM_JITTER64] = { .name = "jitter64", .type = YNL_PT_U64, }, + [TCA_NETEM_SLOT] = { .name = "slot", .type = YNL_PT_BINARY,}, + [TCA_NETEM_SLOT_DIST] = { .name = "slot-dist", .type = YNL_PT_BINARY,}, + [TCA_NETEM_PRNG_SEED] = { .name = "prng-seed", .type = YNL_PT_U64, }, +}; + +const struct ynl_policy_nest tc_netem_attrs_nest = { + .max_attr = TCA_NETEM_MAX, + .table = tc_netem_attrs_policy, +}; + +const struct ynl_policy_attr tc_cake_stats_attrs_policy[TCA_CAKE_STATS_MAX + 1] = { + [TCA_CAKE_STATS_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_CAKE_STATS_CAPACITY_ESTIMATE64] = { .name = "capacity-estimate64", .type = YNL_PT_U64, }, + [TCA_CAKE_STATS_MEMORY_LIMIT] = { .name = "memory-limit", .type = YNL_PT_U32, }, + [TCA_CAKE_STATS_MEMORY_USED] = { .name = "memory-used", .type = YNL_PT_U32, }, + [TCA_CAKE_STATS_AVG_NETOFF] = { .name = "avg-netoff", .type = YNL_PT_U32, }, + [TCA_CAKE_STATS_MIN_NETLEN] = { .name = "min-netlen", .type = YNL_PT_U32, }, + [TCA_CAKE_STATS_MAX_NETLEN] = { .name = "max-netlen", .type = YNL_PT_U32, }, + [TCA_CAKE_STATS_MIN_ADJLEN] = { .name = "min-adjlen", .type = YNL_PT_U32, }, + [TCA_CAKE_STATS_MAX_ADJLEN] = { .name = "max-adjlen", .type = YNL_PT_U32, }, + [TCA_CAKE_STATS_TIN_STATS] = { .name = "tin-stats", .type = YNL_PT_NEST, .nest = &tc_cake_tin_stats_attrs_nest, }, + [TCA_CAKE_STATS_DEFICIT] = { .name = "deficit", .type = YNL_PT_U32, }, + [TCA_CAKE_STATS_COBALT_COUNT] = { .name = "cobalt-count", .type = YNL_PT_U32, }, + [TCA_CAKE_STATS_DROPPING] = { .name = "dropping", .type = YNL_PT_U32, }, + [TCA_CAKE_STATS_DROP_NEXT_US] = { .name = "drop-next-us", .type = YNL_PT_U32, }, + [TCA_CAKE_STATS_P_DROP] = { .name = "p-drop", .type = YNL_PT_U32, }, + [TCA_CAKE_STATS_BLUE_TIMER_US] = { .name = "blue-timer-us", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_cake_stats_attrs_nest = { + .max_attr = TCA_CAKE_STATS_MAX, + .table = tc_cake_stats_attrs_policy, +}; + +const struct ynl_policy_attr tc_flower_key_enc_opts_attrs_policy[TCA_FLOWER_KEY_ENC_OPTS_MAX + 1] = { + [TCA_FLOWER_KEY_ENC_OPTS_GENEVE] = { .name = "geneve", .type = YNL_PT_NEST, .nest = &tc_flower_key_enc_opt_geneve_attrs_nest, }, + [TCA_FLOWER_KEY_ENC_OPTS_VXLAN] = { .name = "vxlan", .type = YNL_PT_NEST, .nest = &tc_flower_key_enc_opt_vxlan_attrs_nest, }, + [TCA_FLOWER_KEY_ENC_OPTS_ERSPAN] = { .name = "erspan", .type = YNL_PT_NEST, .nest = &tc_flower_key_enc_opt_erspan_attrs_nest, }, + [TCA_FLOWER_KEY_ENC_OPTS_GTP] = { .name = "gtp", .type = YNL_PT_NEST, .nest = &tc_flower_key_enc_opt_gtp_attrs_nest, }, +}; + +const struct ynl_policy_nest tc_flower_key_enc_opts_attrs_nest = { + .max_attr = TCA_FLOWER_KEY_ENC_OPTS_MAX, + .table = tc_flower_key_enc_opts_attrs_policy, +}; + +const struct ynl_policy_attr tc_tca_gred_vq_list_attrs_policy[TCA_GRED_VQ_MAX + 1] = { + [TCA_GRED_VQ_ENTRY] = { .name = "entry", .type = YNL_PT_NEST, .nest = &tc_tca_gred_vq_entry_attrs_nest, }, +}; + +const struct ynl_policy_nest tc_tca_gred_vq_list_attrs_nest = { + .max_attr = TCA_GRED_VQ_MAX, + .table = tc_tca_gred_vq_list_attrs_policy, +}; + +const struct ynl_policy_attr tc_taprio_sched_entry_list_policy[TCA_TAPRIO_SCHED_MAX + 1] = { + [TCA_TAPRIO_SCHED_ENTRY] = { .name = "entry", .type = YNL_PT_NEST, .nest = &tc_taprio_sched_entry_nest, }, +}; + +const struct ynl_policy_nest tc_taprio_sched_entry_list_nest = { + .max_attr = TCA_TAPRIO_SCHED_MAX, + .table = tc_taprio_sched_entry_list_policy, +}; + +const struct ynl_policy_attr tc_act_options_msg_policy[] = { + [0] = { .type = YNL_PT_SUBMSG, .name = "bpf", .nest = &tc_act_bpf_attrs_nest, }, + [1] = { .type = YNL_PT_SUBMSG, .name = "connmark", .nest = &tc_act_connmark_attrs_nest, }, + [2] = { .type = YNL_PT_SUBMSG, .name = "csum", .nest = &tc_act_csum_attrs_nest, }, + [3] = { .type = YNL_PT_SUBMSG, .name = "ct", .nest = &tc_act_ct_attrs_nest, }, + [4] = { .type = YNL_PT_SUBMSG, .name = "ctinfo", .nest = &tc_act_ctinfo_attrs_nest, }, + [5] = { .type = YNL_PT_SUBMSG, .name = "gact", .nest = &tc_act_gact_attrs_nest, }, + [6] = { .type = YNL_PT_SUBMSG, .name = "gate", .nest = &tc_act_gate_attrs_nest, }, + [7] = { .type = YNL_PT_SUBMSG, .name = "ife", .nest = &tc_act_ife_attrs_nest, }, + [8] = { .type = YNL_PT_SUBMSG, .name = "mirred", .nest = &tc_act_mirred_attrs_nest, }, + [9] = { .type = YNL_PT_SUBMSG, .name = "mpls", .nest = &tc_act_mpls_attrs_nest, }, + [10] = { .type = YNL_PT_SUBMSG, .name = "nat", .nest = &tc_act_nat_attrs_nest, }, + [11] = { .type = YNL_PT_SUBMSG, .name = "pedit", .nest = &tc_act_pedit_attrs_nest, }, + [12] = { .type = YNL_PT_SUBMSG, .name = "police", .nest = &tc_police_attrs_nest, }, + [13] = { .type = YNL_PT_SUBMSG, .name = "sample", .nest = &tc_act_sample_attrs_nest, }, + [14] = { .type = YNL_PT_SUBMSG, .name = "simple", .nest = &tc_act_simple_attrs_nest, }, + [15] = { .type = YNL_PT_SUBMSG, .name = "skbedit", .nest = &tc_act_skbedit_attrs_nest, }, + [16] = { .type = YNL_PT_SUBMSG, .name = "skbmod", .nest = &tc_act_skbmod_attrs_nest, }, + [17] = { .type = YNL_PT_SUBMSG, .name = "tunnel_key", .nest = &tc_act_tunnel_key_attrs_nest, }, + [18] = { .type = YNL_PT_SUBMSG, .name = "vlan", .nest = &tc_act_vlan_attrs_nest, }, +}; + +const struct ynl_policy_nest tc_act_options_msg_nest = { + .max_attr = 18, + .table = tc_act_options_msg_policy, +}; + +const struct ynl_policy_attr tc_tca_stats_app_msg_policy[] = { + [0] = { .type = YNL_PT_SUBMSG, .name = "cake", .nest = &tc_cake_stats_attrs_nest, }, + [1] = { .type = YNL_PT_SUBMSG, .name = "choke", }, + [2] = { .type = YNL_PT_SUBMSG, .name = "codel", }, + [3] = { .type = YNL_PT_SUBMSG, .name = "fq", }, + [4] = { .type = YNL_PT_SUBMSG, .name = "fq_codel", }, + [5] = { .type = YNL_PT_SUBMSG, .name = "fq_pie", }, + [6] = { .type = YNL_PT_SUBMSG, .name = "hhf", }, + [7] = { .type = YNL_PT_SUBMSG, .name = "pie", }, + [8] = { .type = YNL_PT_SUBMSG, .name = "red", }, + [9] = { .type = YNL_PT_SUBMSG, .name = "sfb", }, + [10] = { .type = YNL_PT_SUBMSG, .name = "sfq", }, +}; + +const struct ynl_policy_nest tc_tca_stats_app_msg_nest = { + .max_attr = 10, + .table = tc_tca_stats_app_msg_policy, +}; + +const struct ynl_policy_attr tc_tca_stats_attrs_policy[TCA_STATS_MAX + 1] = { + [TCA_STATS_BASIC] = { .name = "basic", .type = YNL_PT_BINARY,}, + [TCA_STATS_RATE_EST] = { .name = "rate-est", .type = YNL_PT_BINARY,}, + [TCA_STATS_QUEUE] = { .name = "queue", .type = YNL_PT_BINARY,}, + [TCA_STATS_APP] = { .name = "app", .type = YNL_PT_NEST, .nest = &tc_tca_stats_app_msg_nest, .is_submsg = 1, }, + [TCA_STATS_RATE_EST64] = { .name = "rate-est64", .type = YNL_PT_BINARY,}, + [TCA_STATS_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_STATS_BASIC_HW] = { .name = "basic-hw", .type = YNL_PT_BINARY,}, + [TCA_STATS_PKT64] = { .name = "pkt64", .type = YNL_PT_U64, }, +}; + +const struct ynl_policy_nest tc_tca_stats_attrs_nest = { + .max_attr = TCA_STATS_MAX, + .table = tc_tca_stats_attrs_policy, +}; + +const struct ynl_policy_attr tc_gred_attrs_policy[TCA_GRED_MAX + 1] = { + [TCA_GRED_PARMS] = { .name = "parms", .type = YNL_PT_BINARY,}, + [TCA_GRED_STAB] = { .name = "stab", .type = YNL_PT_BINARY,}, + [TCA_GRED_DPS] = { .name = "dps", .type = YNL_PT_BINARY,}, + [TCA_GRED_MAX_P] = { .name = "max-p", .type = YNL_PT_BINARY,}, + [TCA_GRED_LIMIT] = { .name = "limit", .type = YNL_PT_U32, }, + [TCA_GRED_VQ_LIST] = { .name = "vq-list", .type = YNL_PT_NEST, .nest = &tc_tca_gred_vq_list_attrs_nest, }, +}; + +const struct ynl_policy_nest tc_gred_attrs_nest = { + .max_attr = TCA_GRED_MAX, + .table = tc_gred_attrs_policy, +}; + +const struct ynl_policy_attr tc_taprio_attrs_policy[TCA_TAPRIO_ATTR_MAX + 1] = { + [TCA_TAPRIO_ATTR_PRIOMAP] = { .name = "priomap", .type = YNL_PT_BINARY,}, + [TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST] = { .name = "sched-entry-list", .type = YNL_PT_NEST, .nest = &tc_taprio_sched_entry_list_nest, }, + [TCA_TAPRIO_ATTR_SCHED_BASE_TIME] = { .name = "sched-base-time", .type = YNL_PT_U64, }, + [TCA_TAPRIO_ATTR_SCHED_SINGLE_ENTRY] = { .name = "sched-single-entry", .type = YNL_PT_NEST, .nest = &tc_taprio_sched_entry_nest, }, + [TCA_TAPRIO_ATTR_SCHED_CLOCKID] = { .name = "sched-clockid", .type = YNL_PT_U32, }, + [TCA_TAPRIO_ATTR_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_TAPRIO_ATTR_ADMIN_SCHED] = { .name = "admin-sched", .type = YNL_PT_BINARY,}, + [TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME] = { .name = "sched-cycle-time", .type = YNL_PT_U64, }, + [TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION] = { .name = "sched-cycle-time-extension", .type = YNL_PT_U64, }, + [TCA_TAPRIO_ATTR_FLAGS] = { .name = "flags", .type = YNL_PT_U32, }, + [TCA_TAPRIO_ATTR_TXTIME_DELAY] = { .name = "txtime-delay", .type = YNL_PT_U32, }, + [TCA_TAPRIO_ATTR_TC_ENTRY] = { .name = "tc-entry", .type = YNL_PT_NEST, .nest = &tc_taprio_tc_entry_attrs_nest, }, +}; + +const struct ynl_policy_nest tc_taprio_attrs_nest = { + .max_attr = TCA_TAPRIO_ATTR_MAX, + .table = tc_taprio_attrs_policy, +}; + +const struct ynl_policy_attr tc_act_attrs_policy[TCA_ACT_MAX + 1] = { + [TCA_ACT_KIND] = { .name = "kind", .type = YNL_PT_NUL_STR, .is_selector = 1, }, + [TCA_ACT_OPTIONS] = { .name = "options", .type = YNL_PT_NEST, .nest = &tc_act_options_msg_nest, .is_submsg = 1, .selector_type = 1 }, + [TCA_ACT_INDEX] = { .name = "index", .type = YNL_PT_U32, }, + [TCA_ACT_STATS] = { .name = "stats", .type = YNL_PT_NEST, .nest = &tc_tca_stats_attrs_nest, }, + [TCA_ACT_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_ACT_COOKIE] = { .name = "cookie", .type = YNL_PT_BINARY,}, + [TCA_ACT_FLAGS] = { .name = "flags", .type = YNL_PT_BITFIELD32, }, + [TCA_ACT_HW_STATS] = { .name = "hw-stats", .type = YNL_PT_BITFIELD32, }, + [TCA_ACT_USED_HW_STATS] = { .name = "used-hw-stats", .type = YNL_PT_BITFIELD32, }, + [TCA_ACT_IN_HW_COUNT] = { .name = "in-hw-count", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_act_attrs_nest = { + .max_attr = TCA_ACT_MAX, + .table = tc_act_attrs_policy, +}; + +const struct ynl_policy_attr tc_basic_attrs_policy[TCA_BASIC_MAX + 1] = { + [TCA_BASIC_CLASSID] = { .name = "classid", .type = YNL_PT_U32, }, + [TCA_BASIC_EMATCHES] = { .name = "ematches", .type = YNL_PT_NEST, .nest = &tc_ematch_attrs_nest, }, + [TCA_BASIC_ACT] = { .name = "act", .type = YNL_PT_NEST, .nest = &tc_act_attrs_nest, }, + [TCA_BASIC_POLICE] = { .name = "police", .type = YNL_PT_NEST, .nest = &tc_police_attrs_nest, }, + [TCA_BASIC_PCNT] = { .name = "pcnt", .type = YNL_PT_BINARY,}, + [TCA_BASIC_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, +}; + +const struct ynl_policy_nest tc_basic_attrs_nest = { + .max_attr = TCA_BASIC_MAX, + .table = tc_basic_attrs_policy, +}; + +const struct ynl_policy_attr tc_bpf_attrs_policy[TCA_BPF_MAX + 1] = { + [TCA_BPF_ACT] = { .name = "act", .type = YNL_PT_NEST, .nest = &tc_act_attrs_nest, }, + [TCA_BPF_POLICE] = { .name = "police", .type = YNL_PT_NEST, .nest = &tc_police_attrs_nest, }, + [TCA_BPF_CLASSID] = { .name = "classid", .type = YNL_PT_U32, }, + [TCA_BPF_OPS_LEN] = { .name = "ops-len", .type = YNL_PT_U16, }, + [TCA_BPF_OPS] = { .name = "ops", .type = YNL_PT_BINARY,}, + [TCA_BPF_FD] = { .name = "fd", .type = YNL_PT_U32, }, + [TCA_BPF_NAME] = { .name = "name", .type = YNL_PT_NUL_STR, }, + [TCA_BPF_FLAGS] = { .name = "flags", .type = YNL_PT_U32, }, + [TCA_BPF_FLAGS_GEN] = { .name = "flags-gen", .type = YNL_PT_U32, }, + [TCA_BPF_TAG] = { .name = "tag", .type = YNL_PT_BINARY,}, + [TCA_BPF_ID] = { .name = "id", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_bpf_attrs_nest = { + .max_attr = TCA_BPF_MAX, + .table = tc_bpf_attrs_policy, +}; + +const struct ynl_policy_attr tc_cgroup_attrs_policy[TCA_CGROUP_MAX + 1] = { + [TCA_CGROUP_ACT] = { .name = "act", .type = YNL_PT_NEST, .nest = &tc_act_attrs_nest, }, + [TCA_CGROUP_POLICE] = { .name = "police", .type = YNL_PT_NEST, .nest = &tc_police_attrs_nest, }, + [TCA_CGROUP_EMATCHES] = { .name = "ematches", .type = YNL_PT_BINARY,}, +}; + +const struct ynl_policy_nest tc_cgroup_attrs_nest = { + .max_attr = TCA_CGROUP_MAX, + .table = tc_cgroup_attrs_policy, +}; + +const struct ynl_policy_attr tc_flower_attrs_policy[TCA_FLOWER_MAX + 1] = { + [TCA_FLOWER_CLASSID] = { .name = "classid", .type = YNL_PT_U32, }, + [TCA_FLOWER_INDEV] = { .name = "indev", .type = YNL_PT_NUL_STR, }, + [TCA_FLOWER_ACT] = { .name = "act", .type = YNL_PT_NEST, .nest = &tc_act_attrs_nest, }, + [TCA_FLOWER_KEY_ETH_DST] = { .name = "key-eth-dst", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_ETH_DST_MASK] = { .name = "key-eth-dst-mask", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_ETH_SRC] = { .name = "key-eth-src", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_ETH_SRC_MASK] = { .name = "key-eth-src-mask", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_ETH_TYPE] = { .name = "key-eth-type", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_IP_PROTO] = { .name = "key-ip-proto", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_IPV4_SRC] = { .name = "key-ipv4-src", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_IPV4_SRC_MASK] = { .name = "key-ipv4-src-mask", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_IPV4_DST] = { .name = "key-ipv4-dst", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_IPV4_DST_MASK] = { .name = "key-ipv4-dst-mask", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_IPV6_SRC] = { .name = "key-ipv6-src", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_IPV6_SRC_MASK] = { .name = "key-ipv6-src-mask", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_IPV6_DST] = { .name = "key-ipv6-dst", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_IPV6_DST_MASK] = { .name = "key-ipv6-dst-mask", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_TCP_SRC] = { .name = "key-tcp-src", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_TCP_DST] = { .name = "key-tcp-dst", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_UDP_SRC] = { .name = "key-udp-src", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_UDP_DST] = { .name = "key-udp-dst", .type = YNL_PT_U16, }, + [TCA_FLOWER_FLAGS] = { .name = "flags", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_VLAN_ID] = { .name = "key-vlan-id", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_VLAN_PRIO] = { .name = "key-vlan-prio", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_VLAN_ETH_TYPE] = { .name = "key-vlan-eth-type", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_ENC_KEY_ID] = { .name = "key-enc-key-id", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_ENC_IPV4_SRC] = { .name = "key-enc-ipv4-src", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK] = { .name = "key-enc-ipv4-src-mask", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_ENC_IPV4_DST] = { .name = "key-enc-ipv4-dst", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_ENC_IPV4_DST_MASK] = { .name = "key-enc-ipv4-dst-mask", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_ENC_IPV6_SRC] = { .name = "key-enc-ipv6-src", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK] = { .name = "key-enc-ipv6-src-mask", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_ENC_IPV6_DST] = { .name = "key-enc-ipv6-dst", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_ENC_IPV6_DST_MASK] = { .name = "key-enc-ipv6-dst-mask", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_TCP_SRC_MASK] = { .name = "key-tcp-src-mask", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_TCP_DST_MASK] = { .name = "key-tcp-dst-mask", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_UDP_SRC_MASK] = { .name = "key-udp-src-mask", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_UDP_DST_MASK] = { .name = "key-udp-dst-mask", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_SCTP_SRC_MASK] = { .name = "key-sctp-src-mask", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_SCTP_DST_MASK] = { .name = "key-sctp-dst-mask", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_SCTP_SRC] = { .name = "key-sctp-src", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_SCTP_DST] = { .name = "key-sctp-dst", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_ENC_UDP_SRC_PORT] = { .name = "key-enc-udp-src-port", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK] = { .name = "key-enc-udp-src-port-mask", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_ENC_UDP_DST_PORT] = { .name = "key-enc-udp-dst-port", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK] = { .name = "key-enc-udp-dst-port-mask", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_FLAGS] = { .name = "key-flags", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_FLAGS_MASK] = { .name = "key-flags-mask", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_ICMPV4_CODE] = { .name = "key-icmpv4-code", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ICMPV4_CODE_MASK] = { .name = "key-icmpv4-code-mask", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ICMPV4_TYPE] = { .name = "key-icmpv4-type", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ICMPV4_TYPE_MASK] = { .name = "key-icmpv4-type-mask", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ICMPV6_CODE] = { .name = "key-icmpv6-code", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ICMPV6_CODE_MASK] = { .name = "key-icmpv6-code-mask", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ICMPV6_TYPE] = { .name = "key-icmpv6-type", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ICMPV6_TYPE_MASK] = { .name = "key-icmpv6-type-mask", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ARP_SIP] = { .name = "key-arp-sip", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_ARP_SIP_MASK] = { .name = "key-arp-sip-mask", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_ARP_TIP] = { .name = "key-arp-tip", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_ARP_TIP_MASK] = { .name = "key-arp-tip-mask", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_ARP_OP] = { .name = "key-arp-op", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ARP_OP_MASK] = { .name = "key-arp-op-mask", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ARP_SHA] = { .name = "key-arp-sha", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_ARP_SHA_MASK] = { .name = "key-arp-sha-mask", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_ARP_THA] = { .name = "key-arp-tha", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_ARP_THA_MASK] = { .name = "key-arp-tha-mask", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_MPLS_TTL] = { .name = "key-mpls-ttl", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_MPLS_BOS] = { .name = "key-mpls-bos", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_MPLS_TC] = { .name = "key-mpls-tc", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_MPLS_LABEL] = { .name = "key-mpls-label", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_TCP_FLAGS] = { .name = "key-tcp-flags", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_TCP_FLAGS_MASK] = { .name = "key-tcp-flags-mask", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_IP_TOS] = { .name = "key-ip-tos", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_IP_TOS_MASK] = { .name = "key-ip-tos-mask", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_IP_TTL] = { .name = "key-ip-ttl", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_IP_TTL_MASK] = { .name = "key-ip-ttl-mask", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_CVLAN_ID] = { .name = "key-cvlan-id", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_CVLAN_PRIO] = { .name = "key-cvlan-prio", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_CVLAN_ETH_TYPE] = { .name = "key-cvlan-eth-type", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_ENC_IP_TOS] = { .name = "key-enc-ip-tos", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ENC_IP_TOS_MASK] = { .name = "key-enc-ip-tos-mask", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ENC_IP_TTL] = { .name = "key-enc-ip-ttl", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ENC_IP_TTL_MASK] = { .name = "key-enc-ip-ttl-mask", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_ENC_OPTS] = { .name = "key-enc-opts", .type = YNL_PT_NEST, .nest = &tc_flower_key_enc_opts_attrs_nest, }, + [TCA_FLOWER_KEY_ENC_OPTS_MASK] = { .name = "key-enc-opts-mask", .type = YNL_PT_NEST, .nest = &tc_flower_key_enc_opts_attrs_nest, }, + [TCA_FLOWER_IN_HW_COUNT] = { .name = "in-hw-count", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_PORT_SRC_MIN] = { .name = "key-port-src-min", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_PORT_SRC_MAX] = { .name = "key-port-src-max", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_PORT_DST_MIN] = { .name = "key-port-dst-min", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_PORT_DST_MAX] = { .name = "key-port-dst-max", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_CT_STATE] = { .name = "key-ct-state", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_CT_STATE_MASK] = { .name = "key-ct-state-mask", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_CT_ZONE] = { .name = "key-ct-zone", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_CT_ZONE_MASK] = { .name = "key-ct-zone-mask", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_CT_MARK] = { .name = "key-ct-mark", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_CT_MARK_MASK] = { .name = "key-ct-mark-mask", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_CT_LABELS] = { .name = "key-ct-labels", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_CT_LABELS_MASK] = { .name = "key-ct-labels-mask", .type = YNL_PT_BINARY,}, + [TCA_FLOWER_KEY_MPLS_OPTS] = { .name = "key-mpls-opts", .type = YNL_PT_NEST, .nest = &tc_flower_key_mpls_opt_attrs_nest, }, + [TCA_FLOWER_KEY_HASH] = { .name = "key-hash", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_HASH_MASK] = { .name = "key-hash-mask", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_NUM_OF_VLANS] = { .name = "key-num-of-vlans", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_PPPOE_SID] = { .name = "key-pppoe-sid", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_PPP_PROTO] = { .name = "key-ppp-proto", .type = YNL_PT_U16, }, + [TCA_FLOWER_KEY_L2TPV3_SID] = { .name = "key-l2tpv3-sid", .type = YNL_PT_U32, }, + [TCA_FLOWER_L2_MISS] = { .name = "l2-miss", .type = YNL_PT_U8, }, + [TCA_FLOWER_KEY_CFM] = { .name = "key-cfm", .type = YNL_PT_NEST, .nest = &tc_flower_key_cfm_attrs_nest, }, + [TCA_FLOWER_KEY_SPI] = { .name = "key-spi", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_SPI_MASK] = { .name = "key-spi-mask", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_ENC_FLAGS] = { .name = "key-enc-flags", .type = YNL_PT_U32, }, + [TCA_FLOWER_KEY_ENC_FLAGS_MASK] = { .name = "key-enc-flags-mask", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_flower_attrs_nest = { + .max_attr = TCA_FLOWER_MAX, + .table = tc_flower_attrs_policy, +}; + +const struct ynl_policy_attr tc_fw_attrs_policy[TCA_FW_MAX + 1] = { + [TCA_FW_CLASSID] = { .name = "classid", .type = YNL_PT_U32, }, + [TCA_FW_POLICE] = { .name = "police", .type = YNL_PT_NEST, .nest = &tc_police_attrs_nest, }, + [TCA_FW_INDEV] = { .name = "indev", .type = YNL_PT_NUL_STR, }, + [TCA_FW_ACT] = { .name = "act", .type = YNL_PT_NEST, .nest = &tc_act_attrs_nest, }, + [TCA_FW_MASK] = { .name = "mask", .type = YNL_PT_U32, }, +}; + +const struct ynl_policy_nest tc_fw_attrs_nest = { + .max_attr = TCA_FW_MAX, + .table = tc_fw_attrs_policy, +}; + +const struct ynl_policy_attr tc_matchall_attrs_policy[TCA_MATCHALL_MAX + 1] = { + [TCA_MATCHALL_CLASSID] = { .name = "classid", .type = YNL_PT_U32, }, + [TCA_MATCHALL_ACT] = { .name = "act", .type = YNL_PT_NEST, .nest = &tc_act_attrs_nest, }, + [TCA_MATCHALL_FLAGS] = { .name = "flags", .type = YNL_PT_U32, }, + [TCA_MATCHALL_PCNT] = { .name = "pcnt", .type = YNL_PT_BINARY,}, + [TCA_MATCHALL_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, +}; + +const struct ynl_policy_nest tc_matchall_attrs_nest = { + .max_attr = TCA_MATCHALL_MAX, + .table = tc_matchall_attrs_policy, +}; + +const struct ynl_policy_attr tc_route_attrs_policy[TCA_ROUTE4_MAX + 1] = { + [TCA_ROUTE4_CLASSID] = { .name = "classid", .type = YNL_PT_U32, }, + [TCA_ROUTE4_TO] = { .name = "to", .type = YNL_PT_U32, }, + [TCA_ROUTE4_FROM] = { .name = "from", .type = YNL_PT_U32, }, + [TCA_ROUTE4_IIF] = { .name = "iif", .type = YNL_PT_U32, }, + [TCA_ROUTE4_POLICE] = { .name = "police", .type = YNL_PT_NEST, .nest = &tc_police_attrs_nest, }, + [TCA_ROUTE4_ACT] = { .name = "act", .type = YNL_PT_NEST, .nest = &tc_act_attrs_nest, }, +}; + +const struct ynl_policy_nest tc_route_attrs_nest = { + .max_attr = TCA_ROUTE4_MAX, + .table = tc_route_attrs_policy, +}; + +const struct ynl_policy_attr tc_u32_attrs_policy[TCA_U32_MAX + 1] = { + [TCA_U32_CLASSID] = { .name = "classid", .type = YNL_PT_U32, }, + [TCA_U32_HASH] = { .name = "hash", .type = YNL_PT_U32, }, + [TCA_U32_LINK] = { .name = "link", .type = YNL_PT_U32, }, + [TCA_U32_DIVISOR] = { .name = "divisor", .type = YNL_PT_U32, }, + [TCA_U32_SEL] = { .name = "sel", .type = YNL_PT_BINARY,}, + [TCA_U32_POLICE] = { .name = "police", .type = YNL_PT_NEST, .nest = &tc_police_attrs_nest, }, + [TCA_U32_ACT] = { .name = "act", .type = YNL_PT_NEST, .nest = &tc_act_attrs_nest, }, + [TCA_U32_INDEV] = { .name = "indev", .type = YNL_PT_NUL_STR, }, + [TCA_U32_PCNT] = { .name = "pcnt", .type = YNL_PT_BINARY,}, + [TCA_U32_MARK] = { .name = "mark", .type = YNL_PT_BINARY,}, + [TCA_U32_FLAGS] = { .name = "flags", .type = YNL_PT_U32, }, + [TCA_U32_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, +}; + +const struct ynl_policy_nest tc_u32_attrs_nest = { + .max_attr = TCA_U32_MAX, + .table = tc_u32_attrs_policy, +}; + +const struct ynl_policy_attr tc_ets_attrs_policy[TCA_ETS_MAX + 1] = { + [TCA_ETS_NBANDS] = { .name = "nbands", .type = YNL_PT_U8, }, + [TCA_ETS_NSTRICT] = { .name = "nstrict", .type = YNL_PT_U8, }, + [TCA_ETS_QUANTA] = { .name = "quanta", .type = YNL_PT_NEST, .nest = &tc_ets_attrs_nest, }, + [TCA_ETS_QUANTA_BAND] = { .name = "quanta-band", .type = YNL_PT_U32, }, + [TCA_ETS_PRIOMAP] = { .name = "priomap", .type = YNL_PT_NEST, .nest = &tc_ets_attrs_nest, }, + [TCA_ETS_PRIOMAP_BAND] = { .name = "priomap-band", .type = YNL_PT_U8, }, +}; + +const struct ynl_policy_nest tc_ets_attrs_nest = { + .max_attr = TCA_ETS_MAX, + .table = tc_ets_attrs_policy, +}; + +const struct ynl_policy_attr tc_options_msg_policy[] = { + [0] = { .type = YNL_PT_SUBMSG, .name = "basic", .nest = &tc_basic_attrs_nest, }, + [1] = { .type = YNL_PT_SUBMSG, .name = "bpf", .nest = &tc_bpf_attrs_nest, }, + [2] = { .type = YNL_PT_SUBMSG, .name = "bfifo", }, + [3] = { .type = YNL_PT_SUBMSG, .name = "cake", .nest = &tc_cake_attrs_nest, }, + [4] = { .type = YNL_PT_SUBMSG, .name = "cbs", .nest = &tc_cbs_attrs_nest, }, + [5] = { .type = YNL_PT_SUBMSG, .name = "cgroup", .nest = &tc_cgroup_attrs_nest, }, + [6] = { .type = YNL_PT_SUBMSG, .name = "choke", .nest = &tc_choke_attrs_nest, }, + [7] = { .type = YNL_PT_SUBMSG, .name = "clsact", }, + [8] = { .type = YNL_PT_SUBMSG, .name = "codel", .nest = &tc_codel_attrs_nest, }, + [9] = { .type = YNL_PT_SUBMSG, .name = "drr", .nest = &tc_drr_attrs_nest, }, + [10] = { .type = YNL_PT_SUBMSG, .name = "etf", .nest = &tc_etf_attrs_nest, }, + [11] = { .type = YNL_PT_SUBMSG, .name = "ets", .nest = &tc_ets_attrs_nest, }, + [12] = { .type = YNL_PT_SUBMSG, .name = "flow", .nest = &tc_flow_attrs_nest, }, + [13] = { .type = YNL_PT_SUBMSG, .name = "flower", .nest = &tc_flower_attrs_nest, }, + [14] = { .type = YNL_PT_SUBMSG, .name = "fq", .nest = &tc_fq_attrs_nest, }, + [15] = { .type = YNL_PT_SUBMSG, .name = "fq_codel", .nest = &tc_fq_codel_attrs_nest, }, + [16] = { .type = YNL_PT_SUBMSG, .name = "fq_pie", .nest = &tc_fq_pie_attrs_nest, }, + [17] = { .type = YNL_PT_SUBMSG, .name = "fw", .nest = &tc_fw_attrs_nest, }, + [18] = { .type = YNL_PT_SUBMSG, .name = "gred", .nest = &tc_gred_attrs_nest, }, + [19] = { .type = YNL_PT_SUBMSG, .name = "hfsc", }, + [20] = { .type = YNL_PT_SUBMSG, .name = "hhf", .nest = &tc_hhf_attrs_nest, }, + [21] = { .type = YNL_PT_SUBMSG, .name = "htb", .nest = &tc_htb_attrs_nest, }, + [22] = { .type = YNL_PT_SUBMSG, .name = "ingress", }, + [23] = { .type = YNL_PT_SUBMSG, .name = "matchall", .nest = &tc_matchall_attrs_nest, }, + [24] = { .type = YNL_PT_SUBMSG, .name = "mq", }, + [25] = { .type = YNL_PT_SUBMSG, .name = "mqprio", }, + [26] = { .type = YNL_PT_SUBMSG, .name = "multiq", }, + [27] = { .type = YNL_PT_SUBMSG, .name = "netem", .nest = &tc_netem_attrs_nest, }, + [28] = { .type = YNL_PT_SUBMSG, .name = "pfifo", }, + [29] = { .type = YNL_PT_SUBMSG, .name = "pfifo_fast", }, + [30] = { .type = YNL_PT_SUBMSG, .name = "pfifo_head_drop", }, + [31] = { .type = YNL_PT_SUBMSG, .name = "pie", .nest = &tc_pie_attrs_nest, }, + [32] = { .type = YNL_PT_SUBMSG, .name = "plug", }, + [33] = { .type = YNL_PT_SUBMSG, .name = "prio", }, + [34] = { .type = YNL_PT_SUBMSG, .name = "qfq", .nest = &tc_qfq_attrs_nest, }, + [35] = { .type = YNL_PT_SUBMSG, .name = "red", .nest = &tc_red_attrs_nest, }, + [36] = { .type = YNL_PT_SUBMSG, .name = "route", .nest = &tc_route_attrs_nest, }, + [37] = { .type = YNL_PT_SUBMSG, .name = "sfb", }, + [38] = { .type = YNL_PT_SUBMSG, .name = "sfq", }, + [39] = { .type = YNL_PT_SUBMSG, .name = "taprio", .nest = &tc_taprio_attrs_nest, }, + [40] = { .type = YNL_PT_SUBMSG, .name = "tbf", .nest = &tc_tbf_attrs_nest, }, + [41] = { .type = YNL_PT_SUBMSG, .name = "u32", .nest = &tc_u32_attrs_nest, }, +}; + +const struct ynl_policy_nest tc_options_msg_nest = { + .max_attr = 41, + .table = tc_options_msg_policy, +}; + +const struct ynl_policy_attr tc_attrs_policy[TCA_MAX + 1] = { + [TCA_KIND] = { .name = "kind", .type = YNL_PT_NUL_STR, .is_selector = 1, }, + [TCA_OPTIONS] = { .name = "options", .type = YNL_PT_NEST, .nest = &tc_options_msg_nest, .is_submsg = 1, .selector_type = 1 }, + [TCA_STATS] = { .name = "stats", .type = YNL_PT_BINARY,}, + [TCA_XSTATS] = { .name = "xstats", .type = YNL_PT_NEST, .nest = &tc_tca_stats_app_msg_nest, .is_submsg = 1, .selector_type = 1 }, + [TCA_RATE] = { .name = "rate", .type = YNL_PT_BINARY,}, + [TCA_FCNT] = { .name = "fcnt", .type = YNL_PT_U32, }, + [TCA_STATS2] = { .name = "stats2", .type = YNL_PT_NEST, .nest = &tc_tca_stats_attrs_nest, }, + [TCA_STAB] = { .name = "stab", .type = YNL_PT_NEST, .nest = &tc_tca_stab_attrs_nest, }, + [TCA_PAD] = { .name = "pad", .type = YNL_PT_IGNORE, }, + [TCA_DUMP_INVISIBLE] = { .name = "dump-invisible", .type = YNL_PT_FLAG, }, + [TCA_CHAIN] = { .name = "chain", .type = YNL_PT_U32, }, + [TCA_HW_OFFLOAD] = { .name = "hw-offload", .type = YNL_PT_U8, }, + [TCA_INGRESS_BLOCK] = { .name = "ingress-block", .type = YNL_PT_U32, }, + [TCA_EGRESS_BLOCK] = { .name = "egress-block", .type = YNL_PT_U32, }, + [TCA_DUMP_FLAGS] = { .name = "dump-flags", .type = YNL_PT_BITFIELD32, }, + [TCA_EXT_WARN_MSG] = { .name = "ext-warn-msg", .type = YNL_PT_NUL_STR, }, +}; + +const struct ynl_policy_nest tc_attrs_nest = { + .max_attr = TCA_MAX, + .table = tc_attrs_policy, +}; + +/* Common nested types */ +void tc_tca_stab_attrs_free(struct tc_tca_stab_attrs *obj); +int tc_tca_stab_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_cake_attrs_free(struct tc_cake_attrs *obj); +int tc_cake_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_cake_attrs *obj); +int tc_cake_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_cbs_attrs_free(struct tc_cbs_attrs *obj); +int tc_cbs_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_cbs_attrs *obj); +int tc_cbs_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested); +void tc_choke_attrs_free(struct tc_choke_attrs *obj); +int tc_choke_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_choke_attrs *obj); +int tc_choke_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_codel_attrs_free(struct tc_codel_attrs *obj); +int tc_codel_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_codel_attrs *obj); +int tc_codel_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_drr_attrs_free(struct tc_drr_attrs *obj); +int tc_drr_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_drr_attrs *obj); +int tc_drr_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested); +void tc_etf_attrs_free(struct tc_etf_attrs *obj); +int tc_etf_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_etf_attrs *obj); +int tc_etf_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested); +void tc_fq_attrs_free(struct tc_fq_attrs *obj); +int tc_fq_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_fq_attrs *obj); +int tc_fq_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested); +void tc_fq_codel_attrs_free(struct tc_fq_codel_attrs *obj); +int tc_fq_codel_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_fq_codel_attrs *obj); +int tc_fq_codel_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_fq_pie_attrs_free(struct tc_fq_pie_attrs *obj); +int tc_fq_pie_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_fq_pie_attrs *obj); +int tc_fq_pie_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_hhf_attrs_free(struct tc_hhf_attrs *obj); +int tc_hhf_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_hhf_attrs *obj); +int tc_hhf_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested); +void tc_htb_attrs_free(struct tc_htb_attrs *obj); +int tc_htb_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_htb_attrs *obj); +int tc_htb_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested); +void tc_pie_attrs_free(struct tc_pie_attrs *obj); +int tc_pie_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_pie_attrs *obj); +int tc_pie_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested); +void tc_qfq_attrs_free(struct tc_qfq_attrs *obj); +int tc_qfq_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_qfq_attrs *obj); +int tc_qfq_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested); +void tc_red_attrs_free(struct tc_red_attrs *obj); +int tc_red_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_red_attrs *obj); +int tc_red_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested); +void tc_tbf_attrs_free(struct tc_tbf_attrs *obj); +int tc_tbf_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_tbf_attrs *obj); +int tc_tbf_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested); +void tc_ematch_attrs_free(struct tc_ematch_attrs *obj); +int tc_ematch_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_ematch_attrs *obj); +int tc_ematch_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_police_attrs_free(struct tc_police_attrs *obj); +int tc_police_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_police_attrs *obj); +int tc_police_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void +tc_flower_key_mpls_opt_attrs_free(struct tc_flower_key_mpls_opt_attrs *obj); +int tc_flower_key_mpls_opt_attrs_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_flower_key_mpls_opt_attrs *obj); +int tc_flower_key_mpls_opt_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_flower_key_cfm_attrs_free(struct tc_flower_key_cfm_attrs *obj); +int tc_flower_key_cfm_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_flower_key_cfm_attrs *obj); +int tc_flower_key_cfm_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_netem_loss_attrs_free(struct tc_netem_loss_attrs *obj); +int tc_netem_loss_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_netem_loss_attrs *obj); +int tc_netem_loss_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_taprio_sched_entry_free(struct tc_taprio_sched_entry *obj); +int tc_taprio_sched_entry_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_taprio_sched_entry *obj); +int tc_taprio_sched_entry_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_taprio_tc_entry_attrs_free(struct tc_taprio_tc_entry_attrs *obj); +int tc_taprio_tc_entry_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_taprio_tc_entry_attrs *obj); +int tc_taprio_tc_entry_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_cake_tin_stats_attrs_free(struct tc_cake_tin_stats_attrs *obj); +int tc_cake_tin_stats_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_cake_tin_stats_attrs *obj); +int tc_cake_tin_stats_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested, __u32 idx); +void +tc_flower_key_enc_opt_geneve_attrs_free(struct tc_flower_key_enc_opt_geneve_attrs *obj); +int tc_flower_key_enc_opt_geneve_attrs_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_flower_key_enc_opt_geneve_attrs *obj); +int tc_flower_key_enc_opt_geneve_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void +tc_flower_key_enc_opt_vxlan_attrs_free(struct tc_flower_key_enc_opt_vxlan_attrs *obj); +int tc_flower_key_enc_opt_vxlan_attrs_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_flower_key_enc_opt_vxlan_attrs *obj); +int tc_flower_key_enc_opt_vxlan_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void +tc_flower_key_enc_opt_erspan_attrs_free(struct tc_flower_key_enc_opt_erspan_attrs *obj); +int tc_flower_key_enc_opt_erspan_attrs_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_flower_key_enc_opt_erspan_attrs *obj); +int tc_flower_key_enc_opt_erspan_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void +tc_flower_key_enc_opt_gtp_attrs_free(struct tc_flower_key_enc_opt_gtp_attrs *obj); +int tc_flower_key_enc_opt_gtp_attrs_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_flower_key_enc_opt_gtp_attrs *obj); +int tc_flower_key_enc_opt_gtp_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_tca_gred_vq_entry_attrs_free(struct tc_tca_gred_vq_entry_attrs *obj); +int tc_tca_gred_vq_entry_attrs_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_tca_gred_vq_entry_attrs *obj); +int tc_tca_gred_vq_entry_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_bpf_attrs_free(struct tc_act_bpf_attrs *obj); +int tc_act_bpf_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_bpf_attrs *obj); +int tc_act_bpf_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_connmark_attrs_free(struct tc_act_connmark_attrs *obj); +int tc_act_connmark_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_connmark_attrs *obj); +int tc_act_connmark_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_csum_attrs_free(struct tc_act_csum_attrs *obj); +int tc_act_csum_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_csum_attrs *obj); +int tc_act_csum_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_ct_attrs_free(struct tc_act_ct_attrs *obj); +int tc_act_ct_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_ct_attrs *obj); +int tc_act_ct_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_ctinfo_attrs_free(struct tc_act_ctinfo_attrs *obj); +int tc_act_ctinfo_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_ctinfo_attrs *obj); +int tc_act_ctinfo_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_gact_attrs_free(struct tc_act_gact_attrs *obj); +int tc_act_gact_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_gact_attrs *obj); +int tc_act_gact_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_gate_attrs_free(struct tc_act_gate_attrs *obj); +int tc_act_gate_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_gate_attrs *obj); +int tc_act_gate_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_ife_attrs_free(struct tc_act_ife_attrs *obj); +int tc_act_ife_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_ife_attrs *obj); +int tc_act_ife_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_mirred_attrs_free(struct tc_act_mirred_attrs *obj); +int tc_act_mirred_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_mirred_attrs *obj); +int tc_act_mirred_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_mpls_attrs_free(struct tc_act_mpls_attrs *obj); +int tc_act_mpls_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_mpls_attrs *obj); +int tc_act_mpls_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_nat_attrs_free(struct tc_act_nat_attrs *obj); +int tc_act_nat_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_nat_attrs *obj); +int tc_act_nat_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_pedit_attrs_free(struct tc_act_pedit_attrs *obj); +int tc_act_pedit_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_pedit_attrs *obj); +int tc_act_pedit_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_sample_attrs_free(struct tc_act_sample_attrs *obj); +int tc_act_sample_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_sample_attrs *obj); +int tc_act_sample_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_simple_attrs_free(struct tc_act_simple_attrs *obj); +int tc_act_simple_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_simple_attrs *obj); +int tc_act_simple_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_skbedit_attrs_free(struct tc_act_skbedit_attrs *obj); +int tc_act_skbedit_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_skbedit_attrs *obj); +int tc_act_skbedit_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_skbmod_attrs_free(struct tc_act_skbmod_attrs *obj); +int tc_act_skbmod_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_skbmod_attrs *obj); +int tc_act_skbmod_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_tunnel_key_attrs_free(struct tc_act_tunnel_key_attrs *obj); +int tc_act_tunnel_key_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_tunnel_key_attrs *obj); +int tc_act_tunnel_key_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_vlan_attrs_free(struct tc_act_vlan_attrs *obj); +int tc_act_vlan_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_vlan_attrs *obj); +int tc_act_vlan_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_flow_attrs_free(struct tc_flow_attrs *obj); +int tc_flow_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_flow_attrs *obj); +int tc_flow_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_netem_attrs_free(struct tc_netem_attrs *obj); +int tc_netem_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_netem_attrs *obj); +int tc_netem_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_cake_stats_attrs_free(struct tc_cake_stats_attrs *obj); +int tc_cake_stats_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_cake_stats_attrs *obj); +int tc_cake_stats_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void +tc_flower_key_enc_opts_attrs_free(struct tc_flower_key_enc_opts_attrs *obj); +int tc_flower_key_enc_opts_attrs_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_flower_key_enc_opts_attrs *obj); +int tc_flower_key_enc_opts_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_tca_gred_vq_list_attrs_free(struct tc_tca_gred_vq_list_attrs *obj); +int tc_tca_gred_vq_list_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_tca_gred_vq_list_attrs *obj); +int tc_tca_gred_vq_list_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_taprio_sched_entry_list_free(struct tc_taprio_sched_entry_list *obj); +int tc_taprio_sched_entry_list_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_taprio_sched_entry_list *obj); +int tc_taprio_sched_entry_list_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_options_msg_free(struct tc_act_options_msg *obj); +int tc_act_options_msg_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_options_msg *obj); +int tc_act_options_msg_parse(struct ynl_parse_arg *yarg, const char *sel, + const struct nlattr *nested); +void tc_tca_stats_app_msg_free(struct tc_tca_stats_app_msg *obj); +int tc_tca_stats_app_msg_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_tca_stats_app_msg *obj); +int tc_tca_stats_app_msg_parse(struct ynl_parse_arg *yarg, const char *sel, + const struct nlattr *nested); +void tc_tca_stats_attrs_free(struct tc_tca_stats_attrs *obj); +int tc_tca_stats_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_tca_stats_attrs *obj); +int tc_tca_stats_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested, + const char *_sel_kind); +void tc_gred_attrs_free(struct tc_gred_attrs *obj); +int tc_gred_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_gred_attrs *obj); +int tc_gred_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_taprio_attrs_free(struct tc_taprio_attrs *obj); +int tc_taprio_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_taprio_attrs *obj); +int tc_taprio_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_act_attrs_free(struct tc_act_attrs *obj); +int tc_act_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_attrs *obj); +int tc_act_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested, + __u32 idx); +void tc_basic_attrs_free(struct tc_basic_attrs *obj); +int tc_basic_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_basic_attrs *obj); +int tc_basic_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_bpf_attrs_free(struct tc_bpf_attrs *obj); +int tc_bpf_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_bpf_attrs *obj); +int tc_bpf_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested); +void tc_cgroup_attrs_free(struct tc_cgroup_attrs *obj); +int tc_cgroup_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_cgroup_attrs *obj); +int tc_cgroup_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_flower_attrs_free(struct tc_flower_attrs *obj); +int tc_flower_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_flower_attrs *obj); +int tc_flower_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_fw_attrs_free(struct tc_fw_attrs *obj); +int tc_fw_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_fw_attrs *obj); +int tc_fw_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested); +void tc_matchall_attrs_free(struct tc_matchall_attrs *obj); +int tc_matchall_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_matchall_attrs *obj); +int tc_matchall_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_route_attrs_free(struct tc_route_attrs *obj); +int tc_route_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_route_attrs *obj); +int tc_route_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested); +void tc_u32_attrs_free(struct tc_u32_attrs *obj); +int tc_u32_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_u32_attrs *obj); +int tc_u32_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested); +void tc_ets_attrs_free(struct tc_ets_attrs *obj); +int tc_ets_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_ets_attrs *obj); +int tc_ets_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested); +void tc_options_msg_free(struct tc_options_msg *obj); +int tc_options_msg_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_options_msg *obj); +int tc_options_msg_parse(struct ynl_parse_arg *yarg, const char *sel, + const struct nlattr *nested); + +void tc_tca_stab_attrs_free(struct tc_tca_stab_attrs *obj) +{ + free(obj->base); + free(obj->data); +} + +int tc_tca_stab_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_tca_stab_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_STAB_BASE) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.base = len; + if (len < sizeof(struct tc_sizespec)) + dst->base = calloc(1, sizeof(struct tc_sizespec)); + else + dst->base = malloc(len); + memcpy(dst->base, ynl_attr_data(attr), len); + } else if (type == TCA_STAB_DATA) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.data = len; + dst->data = malloc(len); + memcpy(dst->data, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_cake_attrs_free(struct tc_cake_attrs *obj) +{ +} + +int tc_cake_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_cake_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.base_rate64) + ynl_attr_put_u64(nlh, TCA_CAKE_BASE_RATE64, obj->base_rate64); + if (obj->_present.diffserv_mode) + ynl_attr_put_u32(nlh, TCA_CAKE_DIFFSERV_MODE, obj->diffserv_mode); + if (obj->_present.atm) + ynl_attr_put_u32(nlh, TCA_CAKE_ATM, obj->atm); + if (obj->_present.flow_mode) + ynl_attr_put_u32(nlh, TCA_CAKE_FLOW_MODE, obj->flow_mode); + if (obj->_present.overhead) + ynl_attr_put_u32(nlh, TCA_CAKE_OVERHEAD, obj->overhead); + if (obj->_present.rtt) + ynl_attr_put_u32(nlh, TCA_CAKE_RTT, obj->rtt); + if (obj->_present.target) + ynl_attr_put_u32(nlh, TCA_CAKE_TARGET, obj->target); + if (obj->_present.autorate) + ynl_attr_put_u32(nlh, TCA_CAKE_AUTORATE, obj->autorate); + if (obj->_present.memory) + ynl_attr_put_u32(nlh, TCA_CAKE_MEMORY, obj->memory); + if (obj->_present.nat) + ynl_attr_put_u32(nlh, TCA_CAKE_NAT, obj->nat); + if (obj->_present.raw) + ynl_attr_put_u32(nlh, TCA_CAKE_RAW, obj->raw); + if (obj->_present.wash) + ynl_attr_put_u32(nlh, TCA_CAKE_WASH, obj->wash); + if (obj->_present.mpu) + ynl_attr_put_u32(nlh, TCA_CAKE_MPU, obj->mpu); + if (obj->_present.ingress) + ynl_attr_put_u32(nlh, TCA_CAKE_INGRESS, obj->ingress); + if (obj->_present.ack_filter) + ynl_attr_put_u32(nlh, TCA_CAKE_ACK_FILTER, obj->ack_filter); + if (obj->_present.split_gso) + ynl_attr_put_u32(nlh, TCA_CAKE_SPLIT_GSO, obj->split_gso); + if (obj->_present.fwmark) + ynl_attr_put_u32(nlh, TCA_CAKE_FWMARK, obj->fwmark); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_cake_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_cake_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_CAKE_BASE_RATE64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.base_rate64 = 1; + dst->base_rate64 = ynl_attr_get_u64(attr); + } else if (type == TCA_CAKE_DIFFSERV_MODE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.diffserv_mode = 1; + dst->diffserv_mode = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_ATM) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.atm = 1; + dst->atm = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_FLOW_MODE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flow_mode = 1; + dst->flow_mode = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_OVERHEAD) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.overhead = 1; + dst->overhead = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_RTT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.rtt = 1; + dst->rtt = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TARGET) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.target = 1; + dst->target = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_AUTORATE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.autorate = 1; + dst->autorate = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_MEMORY) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.memory = 1; + dst->memory = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_NAT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.nat = 1; + dst->nat = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_RAW) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.raw = 1; + dst->raw = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_WASH) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.wash = 1; + dst->wash = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_MPU) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.mpu = 1; + dst->mpu = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_INGRESS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ingress = 1; + dst->ingress = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_ACK_FILTER) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ack_filter = 1; + dst->ack_filter = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_SPLIT_GSO) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.split_gso = 1; + dst->split_gso = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_FWMARK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.fwmark = 1; + dst->fwmark = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_cbs_attrs_free(struct tc_cbs_attrs *obj) +{ + free(obj->parms); +} + +int tc_cbs_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_cbs_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_CBS_PARMS, obj->parms, obj->_len.parms); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_cbs_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) +{ + struct tc_cbs_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_CBS_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + if (len < sizeof(struct tc_cbs_qopt)) + dst->parms = calloc(1, sizeof(struct tc_cbs_qopt)); + else + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_choke_attrs_free(struct tc_choke_attrs *obj) +{ + free(obj->parms); + free(obj->stab); +} + +int tc_choke_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_choke_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_CHOKE_PARMS, obj->parms, obj->_len.parms); + if (obj->_len.stab) + ynl_attr_put(nlh, TCA_CHOKE_STAB, obj->stab, obj->_len.stab); + if (obj->_present.max_p) + ynl_attr_put_u32(nlh, TCA_CHOKE_MAX_P, obj->max_p); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_choke_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_choke_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_CHOKE_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + if (len < sizeof(struct tc_red_qopt)) + dst->parms = calloc(1, sizeof(struct tc_red_qopt)); + else + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_CHOKE_STAB) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.stab = len; + dst->stab = malloc(len); + memcpy(dst->stab, ynl_attr_data(attr), len); + } else if (type == TCA_CHOKE_MAX_P) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.max_p = 1; + dst->max_p = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_codel_attrs_free(struct tc_codel_attrs *obj) +{ +} + +int tc_codel_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_codel_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.target) + ynl_attr_put_u32(nlh, TCA_CODEL_TARGET, obj->target); + if (obj->_present.limit) + ynl_attr_put_u32(nlh, TCA_CODEL_LIMIT, obj->limit); + if (obj->_present.interval) + ynl_attr_put_u32(nlh, TCA_CODEL_INTERVAL, obj->interval); + if (obj->_present.ecn) + ynl_attr_put_u32(nlh, TCA_CODEL_ECN, obj->ecn); + if (obj->_present.ce_threshold) + ynl_attr_put_u32(nlh, TCA_CODEL_CE_THRESHOLD, obj->ce_threshold); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_codel_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_codel_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_CODEL_TARGET) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.target = 1; + dst->target = ynl_attr_get_u32(attr); + } else if (type == TCA_CODEL_LIMIT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.limit = 1; + dst->limit = ynl_attr_get_u32(attr); + } else if (type == TCA_CODEL_INTERVAL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.interval = 1; + dst->interval = ynl_attr_get_u32(attr); + } else if (type == TCA_CODEL_ECN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ecn = 1; + dst->ecn = ynl_attr_get_u32(attr); + } else if (type == TCA_CODEL_CE_THRESHOLD) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ce_threshold = 1; + dst->ce_threshold = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_drr_attrs_free(struct tc_drr_attrs *obj) +{ +} + +int tc_drr_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_drr_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.quantum) + ynl_attr_put_u32(nlh, TCA_DRR_QUANTUM, obj->quantum); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_drr_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) +{ + struct tc_drr_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_DRR_QUANTUM) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.quantum = 1; + dst->quantum = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_etf_attrs_free(struct tc_etf_attrs *obj) +{ + free(obj->parms); +} + +int tc_etf_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_etf_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_ETF_PARMS, obj->parms, obj->_len.parms); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_etf_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) +{ + struct tc_etf_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_ETF_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + if (len < sizeof(struct tc_etf_qopt)) + dst->parms = calloc(1, sizeof(struct tc_etf_qopt)); + else + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_fq_attrs_free(struct tc_fq_attrs *obj) +{ + free(obj->priomap); + free(obj->weights); +} + +int tc_fq_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_fq_attrs *obj) +{ + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.plimit) + ynl_attr_put_u32(nlh, TCA_FQ_PLIMIT, obj->plimit); + if (obj->_present.flow_plimit) + ynl_attr_put_u32(nlh, TCA_FQ_FLOW_PLIMIT, obj->flow_plimit); + if (obj->_present.quantum) + ynl_attr_put_u32(nlh, TCA_FQ_QUANTUM, obj->quantum); + if (obj->_present.initial_quantum) + ynl_attr_put_u32(nlh, TCA_FQ_INITIAL_QUANTUM, obj->initial_quantum); + if (obj->_present.rate_enable) + ynl_attr_put_u32(nlh, TCA_FQ_RATE_ENABLE, obj->rate_enable); + if (obj->_present.flow_default_rate) + ynl_attr_put_u32(nlh, TCA_FQ_FLOW_DEFAULT_RATE, obj->flow_default_rate); + if (obj->_present.flow_max_rate) + ynl_attr_put_u32(nlh, TCA_FQ_FLOW_MAX_RATE, obj->flow_max_rate); + if (obj->_present.buckets_log) + ynl_attr_put_u32(nlh, TCA_FQ_BUCKETS_LOG, obj->buckets_log); + if (obj->_present.flow_refill_delay) + ynl_attr_put_u32(nlh, TCA_FQ_FLOW_REFILL_DELAY, obj->flow_refill_delay); + if (obj->_present.orphan_mask) + ynl_attr_put_u32(nlh, TCA_FQ_ORPHAN_MASK, obj->orphan_mask); + if (obj->_present.low_rate_threshold) + ynl_attr_put_u32(nlh, TCA_FQ_LOW_RATE_THRESHOLD, obj->low_rate_threshold); + if (obj->_present.ce_threshold) + ynl_attr_put_u32(nlh, TCA_FQ_CE_THRESHOLD, obj->ce_threshold); + if (obj->_present.timer_slack) + ynl_attr_put_u32(nlh, TCA_FQ_TIMER_SLACK, obj->timer_slack); + if (obj->_present.horizon) + ynl_attr_put_u32(nlh, TCA_FQ_HORIZON, obj->horizon); + if (obj->_present.horizon_drop) + ynl_attr_put_u8(nlh, TCA_FQ_HORIZON_DROP, obj->horizon_drop); + if (obj->_len.priomap) + ynl_attr_put(nlh, TCA_FQ_PRIOMAP, obj->priomap, obj->_len.priomap); + if (obj->_count.weights) { + i = obj->_count.weights * sizeof(__s32); + ynl_attr_put(nlh, TCA_FQ_WEIGHTS, obj->weights, i); + } + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_fq_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) +{ + struct tc_fq_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_FQ_PLIMIT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.plimit = 1; + dst->plimit = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_FLOW_PLIMIT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flow_plimit = 1; + dst->flow_plimit = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_QUANTUM) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.quantum = 1; + dst->quantum = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_INITIAL_QUANTUM) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.initial_quantum = 1; + dst->initial_quantum = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_RATE_ENABLE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.rate_enable = 1; + dst->rate_enable = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_FLOW_DEFAULT_RATE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flow_default_rate = 1; + dst->flow_default_rate = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_FLOW_MAX_RATE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flow_max_rate = 1; + dst->flow_max_rate = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_BUCKETS_LOG) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.buckets_log = 1; + dst->buckets_log = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_FLOW_REFILL_DELAY) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flow_refill_delay = 1; + dst->flow_refill_delay = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_ORPHAN_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.orphan_mask = 1; + dst->orphan_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_LOW_RATE_THRESHOLD) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.low_rate_threshold = 1; + dst->low_rate_threshold = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_CE_THRESHOLD) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ce_threshold = 1; + dst->ce_threshold = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_TIMER_SLACK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.timer_slack = 1; + dst->timer_slack = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_HORIZON) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.horizon = 1; + dst->horizon = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_HORIZON_DROP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.horizon_drop = 1; + dst->horizon_drop = ynl_attr_get_u8(attr); + } else if (type == TCA_FQ_PRIOMAP) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.priomap = len; + if (len < sizeof(struct tc_prio_qopt)) + dst->priomap = calloc(1, sizeof(struct tc_prio_qopt)); + else + dst->priomap = malloc(len); + memcpy(dst->priomap, ynl_attr_data(attr), len); + } else if (type == TCA_FQ_WEIGHTS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_count.weights = len / sizeof(__s32); + len = dst->_count.weights * sizeof(__s32); + dst->weights = malloc(len); + memcpy(dst->weights, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_fq_codel_attrs_free(struct tc_fq_codel_attrs *obj) +{ +} + +int tc_fq_codel_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_fq_codel_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.target) + ynl_attr_put_u32(nlh, TCA_FQ_CODEL_TARGET, obj->target); + if (obj->_present.limit) + ynl_attr_put_u32(nlh, TCA_FQ_CODEL_LIMIT, obj->limit); + if (obj->_present.interval) + ynl_attr_put_u32(nlh, TCA_FQ_CODEL_INTERVAL, obj->interval); + if (obj->_present.ecn) + ynl_attr_put_u32(nlh, TCA_FQ_CODEL_ECN, obj->ecn); + if (obj->_present.flows) + ynl_attr_put_u32(nlh, TCA_FQ_CODEL_FLOWS, obj->flows); + if (obj->_present.quantum) + ynl_attr_put_u32(nlh, TCA_FQ_CODEL_QUANTUM, obj->quantum); + if (obj->_present.ce_threshold) + ynl_attr_put_u32(nlh, TCA_FQ_CODEL_CE_THRESHOLD, obj->ce_threshold); + if (obj->_present.drop_batch_size) + ynl_attr_put_u32(nlh, TCA_FQ_CODEL_DROP_BATCH_SIZE, obj->drop_batch_size); + if (obj->_present.memory_limit) + ynl_attr_put_u32(nlh, TCA_FQ_CODEL_MEMORY_LIMIT, obj->memory_limit); + if (obj->_present.ce_threshold_selector) + ynl_attr_put_u8(nlh, TCA_FQ_CODEL_CE_THRESHOLD_SELECTOR, obj->ce_threshold_selector); + if (obj->_present.ce_threshold_mask) + ynl_attr_put_u8(nlh, TCA_FQ_CODEL_CE_THRESHOLD_MASK, obj->ce_threshold_mask); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_fq_codel_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_fq_codel_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_FQ_CODEL_TARGET) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.target = 1; + dst->target = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_CODEL_LIMIT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.limit = 1; + dst->limit = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_CODEL_INTERVAL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.interval = 1; + dst->interval = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_CODEL_ECN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ecn = 1; + dst->ecn = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_CODEL_FLOWS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flows = 1; + dst->flows = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_CODEL_QUANTUM) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.quantum = 1; + dst->quantum = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_CODEL_CE_THRESHOLD) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ce_threshold = 1; + dst->ce_threshold = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_CODEL_DROP_BATCH_SIZE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.drop_batch_size = 1; + dst->drop_batch_size = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_CODEL_MEMORY_LIMIT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.memory_limit = 1; + dst->memory_limit = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_CODEL_CE_THRESHOLD_SELECTOR) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ce_threshold_selector = 1; + dst->ce_threshold_selector = ynl_attr_get_u8(attr); + } else if (type == TCA_FQ_CODEL_CE_THRESHOLD_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ce_threshold_mask = 1; + dst->ce_threshold_mask = ynl_attr_get_u8(attr); + } + } + + return 0; +} + +void tc_fq_pie_attrs_free(struct tc_fq_pie_attrs *obj) +{ +} + +int tc_fq_pie_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_fq_pie_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.limit) + ynl_attr_put_u32(nlh, TCA_FQ_PIE_LIMIT, obj->limit); + if (obj->_present.flows) + ynl_attr_put_u32(nlh, TCA_FQ_PIE_FLOWS, obj->flows); + if (obj->_present.target) + ynl_attr_put_u32(nlh, TCA_FQ_PIE_TARGET, obj->target); + if (obj->_present.tupdate) + ynl_attr_put_u32(nlh, TCA_FQ_PIE_TUPDATE, obj->tupdate); + if (obj->_present.alpha) + ynl_attr_put_u32(nlh, TCA_FQ_PIE_ALPHA, obj->alpha); + if (obj->_present.beta) + ynl_attr_put_u32(nlh, TCA_FQ_PIE_BETA, obj->beta); + if (obj->_present.quantum) + ynl_attr_put_u32(nlh, TCA_FQ_PIE_QUANTUM, obj->quantum); + if (obj->_present.memory_limit) + ynl_attr_put_u32(nlh, TCA_FQ_PIE_MEMORY_LIMIT, obj->memory_limit); + if (obj->_present.ecn_prob) + ynl_attr_put_u32(nlh, TCA_FQ_PIE_ECN_PROB, obj->ecn_prob); + if (obj->_present.ecn) + ynl_attr_put_u32(nlh, TCA_FQ_PIE_ECN, obj->ecn); + if (obj->_present.bytemode) + ynl_attr_put_u32(nlh, TCA_FQ_PIE_BYTEMODE, obj->bytemode); + if (obj->_present.dq_rate_estimator) + ynl_attr_put_u32(nlh, TCA_FQ_PIE_DQ_RATE_ESTIMATOR, obj->dq_rate_estimator); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_fq_pie_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_fq_pie_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_FQ_PIE_LIMIT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.limit = 1; + dst->limit = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_PIE_FLOWS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flows = 1; + dst->flows = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_PIE_TARGET) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.target = 1; + dst->target = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_PIE_TUPDATE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.tupdate = 1; + dst->tupdate = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_PIE_ALPHA) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.alpha = 1; + dst->alpha = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_PIE_BETA) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.beta = 1; + dst->beta = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_PIE_QUANTUM) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.quantum = 1; + dst->quantum = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_PIE_MEMORY_LIMIT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.memory_limit = 1; + dst->memory_limit = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_PIE_ECN_PROB) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ecn_prob = 1; + dst->ecn_prob = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_PIE_ECN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ecn = 1; + dst->ecn = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_PIE_BYTEMODE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.bytemode = 1; + dst->bytemode = ynl_attr_get_u32(attr); + } else if (type == TCA_FQ_PIE_DQ_RATE_ESTIMATOR) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.dq_rate_estimator = 1; + dst->dq_rate_estimator = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_hhf_attrs_free(struct tc_hhf_attrs *obj) +{ +} + +int tc_hhf_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_hhf_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.backlog_limit) + ynl_attr_put_u32(nlh, TCA_HHF_BACKLOG_LIMIT, obj->backlog_limit); + if (obj->_present.quantum) + ynl_attr_put_u32(nlh, TCA_HHF_QUANTUM, obj->quantum); + if (obj->_present.hh_flows_limit) + ynl_attr_put_u32(nlh, TCA_HHF_HH_FLOWS_LIMIT, obj->hh_flows_limit); + if (obj->_present.reset_timeout) + ynl_attr_put_u32(nlh, TCA_HHF_RESET_TIMEOUT, obj->reset_timeout); + if (obj->_present.admit_bytes) + ynl_attr_put_u32(nlh, TCA_HHF_ADMIT_BYTES, obj->admit_bytes); + if (obj->_present.evict_timeout) + ynl_attr_put_u32(nlh, TCA_HHF_EVICT_TIMEOUT, obj->evict_timeout); + if (obj->_present.non_hh_weight) + ynl_attr_put_u32(nlh, TCA_HHF_NON_HH_WEIGHT, obj->non_hh_weight); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_hhf_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) +{ + struct tc_hhf_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_HHF_BACKLOG_LIMIT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.backlog_limit = 1; + dst->backlog_limit = ynl_attr_get_u32(attr); + } else if (type == TCA_HHF_QUANTUM) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.quantum = 1; + dst->quantum = ynl_attr_get_u32(attr); + } else if (type == TCA_HHF_HH_FLOWS_LIMIT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.hh_flows_limit = 1; + dst->hh_flows_limit = ynl_attr_get_u32(attr); + } else if (type == TCA_HHF_RESET_TIMEOUT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.reset_timeout = 1; + dst->reset_timeout = ynl_attr_get_u32(attr); + } else if (type == TCA_HHF_ADMIT_BYTES) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.admit_bytes = 1; + dst->admit_bytes = ynl_attr_get_u32(attr); + } else if (type == TCA_HHF_EVICT_TIMEOUT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.evict_timeout = 1; + dst->evict_timeout = ynl_attr_get_u32(attr); + } else if (type == TCA_HHF_NON_HH_WEIGHT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.non_hh_weight = 1; + dst->non_hh_weight = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_htb_attrs_free(struct tc_htb_attrs *obj) +{ + free(obj->parms); + free(obj->init); + free(obj->ctab); + free(obj->rtab); +} + +int tc_htb_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_htb_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_HTB_PARMS, obj->parms, obj->_len.parms); + if (obj->_len.init) + ynl_attr_put(nlh, TCA_HTB_INIT, obj->init, obj->_len.init); + if (obj->_len.ctab) + ynl_attr_put(nlh, TCA_HTB_CTAB, obj->ctab, obj->_len.ctab); + if (obj->_len.rtab) + ynl_attr_put(nlh, TCA_HTB_RTAB, obj->rtab, obj->_len.rtab); + if (obj->_present.direct_qlen) + ynl_attr_put_u32(nlh, TCA_HTB_DIRECT_QLEN, obj->direct_qlen); + if (obj->_present.rate64) + ynl_attr_put_u64(nlh, TCA_HTB_RATE64, obj->rate64); + if (obj->_present.ceil64) + ynl_attr_put_u64(nlh, TCA_HTB_CEIL64, obj->ceil64); + if (obj->_present.offload) + ynl_attr_put(nlh, TCA_HTB_OFFLOAD, NULL, 0); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_htb_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) +{ + struct tc_htb_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_HTB_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + if (len < sizeof(struct tc_htb_opt)) + dst->parms = calloc(1, sizeof(struct tc_htb_opt)); + else + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_HTB_INIT) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.init = len; + if (len < sizeof(struct tc_htb_glob)) + dst->init = calloc(1, sizeof(struct tc_htb_glob)); + else + dst->init = malloc(len); + memcpy(dst->init, ynl_attr_data(attr), len); + } else if (type == TCA_HTB_CTAB) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.ctab = len; + dst->ctab = malloc(len); + memcpy(dst->ctab, ynl_attr_data(attr), len); + } else if (type == TCA_HTB_RTAB) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.rtab = len; + dst->rtab = malloc(len); + memcpy(dst->rtab, ynl_attr_data(attr), len); + } else if (type == TCA_HTB_DIRECT_QLEN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.direct_qlen = 1; + dst->direct_qlen = ynl_attr_get_u32(attr); + } else if (type == TCA_HTB_RATE64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.rate64 = 1; + dst->rate64 = ynl_attr_get_u64(attr); + } else if (type == TCA_HTB_CEIL64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ceil64 = 1; + dst->ceil64 = ynl_attr_get_u64(attr); + } else if (type == TCA_HTB_OFFLOAD) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.offload = 1; + } + } + + return 0; +} + +void tc_pie_attrs_free(struct tc_pie_attrs *obj) +{ +} + +int tc_pie_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_pie_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.target) + ynl_attr_put_u32(nlh, TCA_PIE_TARGET, obj->target); + if (obj->_present.limit) + ynl_attr_put_u32(nlh, TCA_PIE_LIMIT, obj->limit); + if (obj->_present.tupdate) + ynl_attr_put_u32(nlh, TCA_PIE_TUPDATE, obj->tupdate); + if (obj->_present.alpha) + ynl_attr_put_u32(nlh, TCA_PIE_ALPHA, obj->alpha); + if (obj->_present.beta) + ynl_attr_put_u32(nlh, TCA_PIE_BETA, obj->beta); + if (obj->_present.ecn) + ynl_attr_put_u32(nlh, TCA_PIE_ECN, obj->ecn); + if (obj->_present.bytemode) + ynl_attr_put_u32(nlh, TCA_PIE_BYTEMODE, obj->bytemode); + if (obj->_present.dq_rate_estimator) + ynl_attr_put_u32(nlh, TCA_PIE_DQ_RATE_ESTIMATOR, obj->dq_rate_estimator); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_pie_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) +{ + struct tc_pie_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_PIE_TARGET) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.target = 1; + dst->target = ynl_attr_get_u32(attr); + } else if (type == TCA_PIE_LIMIT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.limit = 1; + dst->limit = ynl_attr_get_u32(attr); + } else if (type == TCA_PIE_TUPDATE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.tupdate = 1; + dst->tupdate = ynl_attr_get_u32(attr); + } else if (type == TCA_PIE_ALPHA) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.alpha = 1; + dst->alpha = ynl_attr_get_u32(attr); + } else if (type == TCA_PIE_BETA) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.beta = 1; + dst->beta = ynl_attr_get_u32(attr); + } else if (type == TCA_PIE_ECN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ecn = 1; + dst->ecn = ynl_attr_get_u32(attr); + } else if (type == TCA_PIE_BYTEMODE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.bytemode = 1; + dst->bytemode = ynl_attr_get_u32(attr); + } else if (type == TCA_PIE_DQ_RATE_ESTIMATOR) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.dq_rate_estimator = 1; + dst->dq_rate_estimator = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_qfq_attrs_free(struct tc_qfq_attrs *obj) +{ +} + +int tc_qfq_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_qfq_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.weight) + ynl_attr_put_u32(nlh, TCA_QFQ_WEIGHT, obj->weight); + if (obj->_present.lmax) + ynl_attr_put_u32(nlh, TCA_QFQ_LMAX, obj->lmax); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_qfq_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) +{ + struct tc_qfq_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_QFQ_WEIGHT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.weight = 1; + dst->weight = ynl_attr_get_u32(attr); + } else if (type == TCA_QFQ_LMAX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.lmax = 1; + dst->lmax = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_red_attrs_free(struct tc_red_attrs *obj) +{ + free(obj->parms); + free(obj->stab); +} + +int tc_red_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_red_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_RED_PARMS, obj->parms, obj->_len.parms); + if (obj->_len.stab) + ynl_attr_put(nlh, TCA_RED_STAB, obj->stab, obj->_len.stab); + if (obj->_present.max_p) + ynl_attr_put_u32(nlh, TCA_RED_MAX_P, obj->max_p); + if (obj->_present.flags) + ynl_attr_put(nlh, TCA_RED_FLAGS, &obj->flags, sizeof(struct nla_bitfield32)); + if (obj->_present.early_drop_block) + ynl_attr_put_u32(nlh, TCA_RED_EARLY_DROP_BLOCK, obj->early_drop_block); + if (obj->_present.mark_block) + ynl_attr_put_u32(nlh, TCA_RED_MARK_BLOCK, obj->mark_block); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_red_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) +{ + struct tc_red_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_RED_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + if (len < sizeof(struct tc_red_qopt)) + dst->parms = calloc(1, sizeof(struct tc_red_qopt)); + else + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_RED_STAB) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.stab = len; + dst->stab = malloc(len); + memcpy(dst->stab, ynl_attr_data(attr), len); + } else if (type == TCA_RED_MAX_P) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.max_p = 1; + dst->max_p = ynl_attr_get_u32(attr); + } else if (type == TCA_RED_FLAGS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flags = 1; + memcpy(&dst->flags, ynl_attr_data(attr), sizeof(struct nla_bitfield32)); + } else if (type == TCA_RED_EARLY_DROP_BLOCK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.early_drop_block = 1; + dst->early_drop_block = ynl_attr_get_u32(attr); + } else if (type == TCA_RED_MARK_BLOCK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.mark_block = 1; + dst->mark_block = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_tbf_attrs_free(struct tc_tbf_attrs *obj) +{ + free(obj->parms); + free(obj->rtab); + free(obj->ptab); +} + +int tc_tbf_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_tbf_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_TBF_PARMS, obj->parms, obj->_len.parms); + if (obj->_len.rtab) + ynl_attr_put(nlh, TCA_TBF_RTAB, obj->rtab, obj->_len.rtab); + if (obj->_len.ptab) + ynl_attr_put(nlh, TCA_TBF_PTAB, obj->ptab, obj->_len.ptab); + if (obj->_present.rate64) + ynl_attr_put_u64(nlh, TCA_TBF_RATE64, obj->rate64); + if (obj->_present.prate64) + ynl_attr_put_u64(nlh, TCA_TBF_PRATE64, obj->prate64); + if (obj->_present.burst) + ynl_attr_put_u32(nlh, TCA_TBF_BURST, obj->burst); + if (obj->_present.pburst) + ynl_attr_put_u32(nlh, TCA_TBF_PBURST, obj->pburst); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_tbf_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) +{ + struct tc_tbf_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_TBF_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + if (len < sizeof(struct tc_tbf_qopt)) + dst->parms = calloc(1, sizeof(struct tc_tbf_qopt)); + else + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_TBF_RTAB) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.rtab = len; + dst->rtab = malloc(len); + memcpy(dst->rtab, ynl_attr_data(attr), len); + } else if (type == TCA_TBF_PTAB) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.ptab = len; + dst->ptab = malloc(len); + memcpy(dst->ptab, ynl_attr_data(attr), len); + } else if (type == TCA_TBF_RATE64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.rate64 = 1; + dst->rate64 = ynl_attr_get_u64(attr); + } else if (type == TCA_TBF_PRATE64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.prate64 = 1; + dst->prate64 = ynl_attr_get_u64(attr); + } else if (type == TCA_TBF_BURST) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.burst = 1; + dst->burst = ynl_attr_get_u32(attr); + } else if (type == TCA_TBF_PBURST) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.pburst = 1; + dst->pburst = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_ematch_attrs_free(struct tc_ematch_attrs *obj) +{ + free(obj->tree_hdr); + free(obj->tree_list); +} + +int tc_ematch_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_ematch_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tree_hdr) + ynl_attr_put(nlh, TCA_EMATCH_TREE_HDR, obj->tree_hdr, obj->_len.tree_hdr); + if (obj->_len.tree_list) + ynl_attr_put(nlh, TCA_EMATCH_TREE_LIST, obj->tree_list, obj->_len.tree_list); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_ematch_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_ematch_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_EMATCH_TREE_HDR) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tree_hdr = len; + if (len < sizeof(struct tcf_ematch_tree_hdr)) + dst->tree_hdr = calloc(1, sizeof(struct tcf_ematch_tree_hdr)); + else + dst->tree_hdr = malloc(len); + memcpy(dst->tree_hdr, ynl_attr_data(attr), len); + } else if (type == TCA_EMATCH_TREE_LIST) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tree_list = len; + dst->tree_list = malloc(len); + memcpy(dst->tree_list, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_police_attrs_free(struct tc_police_attrs *obj) +{ + free(obj->tbf); + free(obj->rate); + free(obj->peakrate); + free(obj->tm); +} + +int tc_police_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_police_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tbf) + ynl_attr_put(nlh, TCA_POLICE_TBF, obj->tbf, obj->_len.tbf); + if (obj->_len.rate) + ynl_attr_put(nlh, TCA_POLICE_RATE, obj->rate, obj->_len.rate); + if (obj->_len.peakrate) + ynl_attr_put(nlh, TCA_POLICE_PEAKRATE, obj->peakrate, obj->_len.peakrate); + if (obj->_present.avrate) + ynl_attr_put_u32(nlh, TCA_POLICE_AVRATE, obj->avrate); + if (obj->_present.result) + ynl_attr_put_u32(nlh, TCA_POLICE_RESULT, obj->result); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_POLICE_TM, obj->tm, obj->_len.tm); + if (obj->_present.rate64) + ynl_attr_put_u64(nlh, TCA_POLICE_RATE64, obj->rate64); + if (obj->_present.peakrate64) + ynl_attr_put_u64(nlh, TCA_POLICE_PEAKRATE64, obj->peakrate64); + if (obj->_present.pktrate64) + ynl_attr_put_u64(nlh, TCA_POLICE_PKTRATE64, obj->pktrate64); + if (obj->_present.pktburst64) + ynl_attr_put_u64(nlh, TCA_POLICE_PKTBURST64, obj->pktburst64); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_police_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_police_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_POLICE_TBF) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tbf = len; + if (len < sizeof(struct tc_police)) + dst->tbf = calloc(1, sizeof(struct tc_police)); + else + dst->tbf = malloc(len); + memcpy(dst->tbf, ynl_attr_data(attr), len); + } else if (type == TCA_POLICE_RATE) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.rate = len; + dst->rate = malloc(len); + memcpy(dst->rate, ynl_attr_data(attr), len); + } else if (type == TCA_POLICE_PEAKRATE) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.peakrate = len; + dst->peakrate = malloc(len); + memcpy(dst->peakrate, ynl_attr_data(attr), len); + } else if (type == TCA_POLICE_AVRATE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.avrate = 1; + dst->avrate = ynl_attr_get_u32(attr); + } else if (type == TCA_POLICE_RESULT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.result = 1; + dst->result = ynl_attr_get_u32(attr); + } else if (type == TCA_POLICE_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_POLICE_RATE64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.rate64 = 1; + dst->rate64 = ynl_attr_get_u64(attr); + } else if (type == TCA_POLICE_PEAKRATE64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.peakrate64 = 1; + dst->peakrate64 = ynl_attr_get_u64(attr); + } else if (type == TCA_POLICE_PKTRATE64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.pktrate64 = 1; + dst->pktrate64 = ynl_attr_get_u64(attr); + } else if (type == TCA_POLICE_PKTBURST64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.pktburst64 = 1; + dst->pktburst64 = ynl_attr_get_u64(attr); + } + } + + return 0; +} + +void +tc_flower_key_mpls_opt_attrs_free(struct tc_flower_key_mpls_opt_attrs *obj) +{ +} + +int tc_flower_key_mpls_opt_attrs_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_flower_key_mpls_opt_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.lse_depth) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_MPLS_OPT_LSE_DEPTH, obj->lse_depth); + if (obj->_present.lse_ttl) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_MPLS_OPT_LSE_TTL, obj->lse_ttl); + if (obj->_present.lse_bos) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_MPLS_OPT_LSE_BOS, obj->lse_bos); + if (obj->_present.lse_tc) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_MPLS_OPT_LSE_TC, obj->lse_tc); + if (obj->_present.lse_label) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_MPLS_OPT_LSE_LABEL, obj->lse_label); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_flower_key_mpls_opt_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_flower_key_mpls_opt_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_FLOWER_KEY_MPLS_OPT_LSE_DEPTH) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.lse_depth = 1; + dst->lse_depth = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_MPLS_OPT_LSE_TTL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.lse_ttl = 1; + dst->lse_ttl = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_MPLS_OPT_LSE_BOS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.lse_bos = 1; + dst->lse_bos = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_MPLS_OPT_LSE_TC) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.lse_tc = 1; + dst->lse_tc = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_MPLS_OPT_LSE_LABEL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.lse_label = 1; + dst->lse_label = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_flower_key_cfm_attrs_free(struct tc_flower_key_cfm_attrs *obj) +{ +} + +int tc_flower_key_cfm_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_flower_key_cfm_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.md_level) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_CFM_MD_LEVEL, obj->md_level); + if (obj->_present.opcode) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_CFM_OPCODE, obj->opcode); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_flower_key_cfm_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_flower_key_cfm_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_FLOWER_KEY_CFM_MD_LEVEL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.md_level = 1; + dst->md_level = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_CFM_OPCODE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.opcode = 1; + dst->opcode = ynl_attr_get_u8(attr); + } + } + + return 0; +} + +void tc_netem_loss_attrs_free(struct tc_netem_loss_attrs *obj) +{ + free(obj->gi); + free(obj->ge); +} + +int tc_netem_loss_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_netem_loss_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.gi) + ynl_attr_put(nlh, NETEM_LOSS_GI, obj->gi, obj->_len.gi); + if (obj->_len.ge) + ynl_attr_put(nlh, NETEM_LOSS_GE, obj->ge, obj->_len.ge); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_netem_loss_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_netem_loss_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == NETEM_LOSS_GI) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.gi = len; + if (len < sizeof(struct tc_netem_gimodel)) + dst->gi = calloc(1, sizeof(struct tc_netem_gimodel)); + else + dst->gi = malloc(len); + memcpy(dst->gi, ynl_attr_data(attr), len); + } else if (type == NETEM_LOSS_GE) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.ge = len; + if (len < sizeof(struct tc_netem_gemodel)) + dst->ge = calloc(1, sizeof(struct tc_netem_gemodel)); + else + dst->ge = malloc(len); + memcpy(dst->ge, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_taprio_sched_entry_free(struct tc_taprio_sched_entry *obj) +{ +} + +int tc_taprio_sched_entry_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_taprio_sched_entry *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.index) + ynl_attr_put_u32(nlh, TCA_TAPRIO_SCHED_ENTRY_INDEX, obj->index); + if (obj->_present.cmd) + ynl_attr_put_u8(nlh, TCA_TAPRIO_SCHED_ENTRY_CMD, obj->cmd); + if (obj->_present.gate_mask) + ynl_attr_put_u32(nlh, TCA_TAPRIO_SCHED_ENTRY_GATE_MASK, obj->gate_mask); + if (obj->_present.interval) + ynl_attr_put_u32(nlh, TCA_TAPRIO_SCHED_ENTRY_INTERVAL, obj->interval); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_taprio_sched_entry_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_taprio_sched_entry *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_TAPRIO_SCHED_ENTRY_INDEX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.index = 1; + dst->index = ynl_attr_get_u32(attr); + } else if (type == TCA_TAPRIO_SCHED_ENTRY_CMD) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.cmd = 1; + dst->cmd = ynl_attr_get_u8(attr); + } else if (type == TCA_TAPRIO_SCHED_ENTRY_GATE_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.gate_mask = 1; + dst->gate_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_TAPRIO_SCHED_ENTRY_INTERVAL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.interval = 1; + dst->interval = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_taprio_tc_entry_attrs_free(struct tc_taprio_tc_entry_attrs *obj) +{ +} + +int tc_taprio_tc_entry_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_taprio_tc_entry_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.index) + ynl_attr_put_u32(nlh, TCA_TAPRIO_TC_ENTRY_INDEX, obj->index); + if (obj->_present.max_sdu) + ynl_attr_put_u32(nlh, TCA_TAPRIO_TC_ENTRY_MAX_SDU, obj->max_sdu); + if (obj->_present.fp) + ynl_attr_put_u32(nlh, TCA_TAPRIO_TC_ENTRY_FP, obj->fp); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_taprio_tc_entry_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_taprio_tc_entry_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_TAPRIO_TC_ENTRY_INDEX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.index = 1; + dst->index = ynl_attr_get_u32(attr); + } else if (type == TCA_TAPRIO_TC_ENTRY_MAX_SDU) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.max_sdu = 1; + dst->max_sdu = ynl_attr_get_u32(attr); + } else if (type == TCA_TAPRIO_TC_ENTRY_FP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.fp = 1; + dst->fp = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_cake_tin_stats_attrs_free(struct tc_cake_tin_stats_attrs *obj) +{ +} + +int tc_cake_tin_stats_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_cake_tin_stats_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.sent_packets) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_SENT_PACKETS, obj->sent_packets); + if (obj->_present.sent_bytes64) + ynl_attr_put_u64(nlh, TCA_CAKE_TIN_STATS_SENT_BYTES64, obj->sent_bytes64); + if (obj->_present.dropped_packets) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_DROPPED_PACKETS, obj->dropped_packets); + if (obj->_present.dropped_bytes64) + ynl_attr_put_u64(nlh, TCA_CAKE_TIN_STATS_DROPPED_BYTES64, obj->dropped_bytes64); + if (obj->_present.acks_dropped_packets) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_ACKS_DROPPED_PACKETS, obj->acks_dropped_packets); + if (obj->_present.acks_dropped_bytes64) + ynl_attr_put_u64(nlh, TCA_CAKE_TIN_STATS_ACKS_DROPPED_BYTES64, obj->acks_dropped_bytes64); + if (obj->_present.ecn_marked_packets) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_ECN_MARKED_PACKETS, obj->ecn_marked_packets); + if (obj->_present.ecn_marked_bytes64) + ynl_attr_put_u64(nlh, TCA_CAKE_TIN_STATS_ECN_MARKED_BYTES64, obj->ecn_marked_bytes64); + if (obj->_present.backlog_packets) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_BACKLOG_PACKETS, obj->backlog_packets); + if (obj->_present.backlog_bytes) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_BACKLOG_BYTES, obj->backlog_bytes); + if (obj->_present.threshold_rate64) + ynl_attr_put_u64(nlh, TCA_CAKE_TIN_STATS_THRESHOLD_RATE64, obj->threshold_rate64); + if (obj->_present.target_us) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_TARGET_US, obj->target_us); + if (obj->_present.interval_us) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_INTERVAL_US, obj->interval_us); + if (obj->_present.way_indirect_hits) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_WAY_INDIRECT_HITS, obj->way_indirect_hits); + if (obj->_present.way_misses) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_WAY_MISSES, obj->way_misses); + if (obj->_present.way_collisions) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_WAY_COLLISIONS, obj->way_collisions); + if (obj->_present.peak_delay_us) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_PEAK_DELAY_US, obj->peak_delay_us); + if (obj->_present.avg_delay_us) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_AVG_DELAY_US, obj->avg_delay_us); + if (obj->_present.base_delay_us) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_BASE_DELAY_US, obj->base_delay_us); + if (obj->_present.sparse_flows) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_SPARSE_FLOWS, obj->sparse_flows); + if (obj->_present.bulk_flows) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_BULK_FLOWS, obj->bulk_flows); + if (obj->_present.unresponsive_flows) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_UNRESPONSIVE_FLOWS, obj->unresponsive_flows); + if (obj->_present.max_skblen) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_MAX_SKBLEN, obj->max_skblen); + if (obj->_present.flow_quantum) + ynl_attr_put_u32(nlh, TCA_CAKE_TIN_STATS_FLOW_QUANTUM, obj->flow_quantum); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_cake_tin_stats_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested, __u32 idx) +{ + struct tc_cake_tin_stats_attrs *dst = yarg->data; + const struct nlattr *attr; + + dst->idx = idx; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_CAKE_TIN_STATS_SENT_PACKETS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.sent_packets = 1; + dst->sent_packets = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_SENT_BYTES64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.sent_bytes64 = 1; + dst->sent_bytes64 = ynl_attr_get_u64(attr); + } else if (type == TCA_CAKE_TIN_STATS_DROPPED_PACKETS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.dropped_packets = 1; + dst->dropped_packets = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_DROPPED_BYTES64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.dropped_bytes64 = 1; + dst->dropped_bytes64 = ynl_attr_get_u64(attr); + } else if (type == TCA_CAKE_TIN_STATS_ACKS_DROPPED_PACKETS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.acks_dropped_packets = 1; + dst->acks_dropped_packets = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_ACKS_DROPPED_BYTES64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.acks_dropped_bytes64 = 1; + dst->acks_dropped_bytes64 = ynl_attr_get_u64(attr); + } else if (type == TCA_CAKE_TIN_STATS_ECN_MARKED_PACKETS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ecn_marked_packets = 1; + dst->ecn_marked_packets = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_ECN_MARKED_BYTES64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ecn_marked_bytes64 = 1; + dst->ecn_marked_bytes64 = ynl_attr_get_u64(attr); + } else if (type == TCA_CAKE_TIN_STATS_BACKLOG_PACKETS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.backlog_packets = 1; + dst->backlog_packets = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_BACKLOG_BYTES) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.backlog_bytes = 1; + dst->backlog_bytes = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_THRESHOLD_RATE64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.threshold_rate64 = 1; + dst->threshold_rate64 = ynl_attr_get_u64(attr); + } else if (type == TCA_CAKE_TIN_STATS_TARGET_US) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.target_us = 1; + dst->target_us = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_INTERVAL_US) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.interval_us = 1; + dst->interval_us = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_WAY_INDIRECT_HITS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.way_indirect_hits = 1; + dst->way_indirect_hits = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_WAY_MISSES) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.way_misses = 1; + dst->way_misses = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_WAY_COLLISIONS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.way_collisions = 1; + dst->way_collisions = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_PEAK_DELAY_US) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.peak_delay_us = 1; + dst->peak_delay_us = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_AVG_DELAY_US) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.avg_delay_us = 1; + dst->avg_delay_us = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_BASE_DELAY_US) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.base_delay_us = 1; + dst->base_delay_us = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_SPARSE_FLOWS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.sparse_flows = 1; + dst->sparse_flows = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_BULK_FLOWS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.bulk_flows = 1; + dst->bulk_flows = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_UNRESPONSIVE_FLOWS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.unresponsive_flows = 1; + dst->unresponsive_flows = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_MAX_SKBLEN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.max_skblen = 1; + dst->max_skblen = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_TIN_STATS_FLOW_QUANTUM) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flow_quantum = 1; + dst->flow_quantum = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void +tc_flower_key_enc_opt_geneve_attrs_free(struct tc_flower_key_enc_opt_geneve_attrs *obj) +{ + free(obj->data); +} + +int tc_flower_key_enc_opt_geneve_attrs_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_flower_key_enc_opt_geneve_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.class) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_ENC_OPT_GENEVE_CLASS, obj->class); + if (obj->_present.type) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ENC_OPT_GENEVE_TYPE, obj->type); + if (obj->_len.data) + ynl_attr_put(nlh, TCA_FLOWER_KEY_ENC_OPT_GENEVE_DATA, obj->data, obj->_len.data); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_flower_key_enc_opt_geneve_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_flower_key_enc_opt_geneve_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_FLOWER_KEY_ENC_OPT_GENEVE_CLASS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.class = 1; + dst->class = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_ENC_OPT_GENEVE_TYPE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.type = 1; + dst->type = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ENC_OPT_GENEVE_DATA) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.data = len; + dst->data = malloc(len); + memcpy(dst->data, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void +tc_flower_key_enc_opt_vxlan_attrs_free(struct tc_flower_key_enc_opt_vxlan_attrs *obj) +{ +} + +int tc_flower_key_enc_opt_vxlan_attrs_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_flower_key_enc_opt_vxlan_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.gbp) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_ENC_OPT_VXLAN_GBP, obj->gbp); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_flower_key_enc_opt_vxlan_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_flower_key_enc_opt_vxlan_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_FLOWER_KEY_ENC_OPT_VXLAN_GBP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.gbp = 1; + dst->gbp = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void +tc_flower_key_enc_opt_erspan_attrs_free(struct tc_flower_key_enc_opt_erspan_attrs *obj) +{ +} + +int tc_flower_key_enc_opt_erspan_attrs_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_flower_key_enc_opt_erspan_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.ver) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ENC_OPT_ERSPAN_VER, obj->ver); + if (obj->_present.index) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX, obj->index); + if (obj->_present.dir) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR, obj->dir); + if (obj->_present.hwid) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ENC_OPT_ERSPAN_HWID, obj->hwid); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_flower_key_enc_opt_erspan_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_flower_key_enc_opt_erspan_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_FLOWER_KEY_ENC_OPT_ERSPAN_VER) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ver = 1; + dst->ver = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ENC_OPT_ERSPAN_INDEX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.index = 1; + dst->index = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_ENC_OPT_ERSPAN_DIR) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.dir = 1; + dst->dir = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ENC_OPT_ERSPAN_HWID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.hwid = 1; + dst->hwid = ynl_attr_get_u8(attr); + } + } + + return 0; +} + +void +tc_flower_key_enc_opt_gtp_attrs_free(struct tc_flower_key_enc_opt_gtp_attrs *obj) +{ +} + +int tc_flower_key_enc_opt_gtp_attrs_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_flower_key_enc_opt_gtp_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.pdu_type) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ENC_OPT_GTP_PDU_TYPE, obj->pdu_type); + if (obj->_present.qfi) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ENC_OPT_GTP_QFI, obj->qfi); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_flower_key_enc_opt_gtp_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_flower_key_enc_opt_gtp_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_FLOWER_KEY_ENC_OPT_GTP_PDU_TYPE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.pdu_type = 1; + dst->pdu_type = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ENC_OPT_GTP_QFI) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.qfi = 1; + dst->qfi = ynl_attr_get_u8(attr); + } + } + + return 0; +} + +void tc_tca_gred_vq_entry_attrs_free(struct tc_tca_gred_vq_entry_attrs *obj) +{ +} + +int tc_tca_gred_vq_entry_attrs_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_tca_gred_vq_entry_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.dp) + ynl_attr_put_u32(nlh, TCA_GRED_VQ_DP, obj->dp); + if (obj->_present.stat_bytes) + ynl_attr_put_u64(nlh, TCA_GRED_VQ_STAT_BYTES, obj->stat_bytes); + if (obj->_present.stat_packets) + ynl_attr_put_u32(nlh, TCA_GRED_VQ_STAT_PACKETS, obj->stat_packets); + if (obj->_present.stat_backlog) + ynl_attr_put_u32(nlh, TCA_GRED_VQ_STAT_BACKLOG, obj->stat_backlog); + if (obj->_present.stat_prob_drop) + ynl_attr_put_u32(nlh, TCA_GRED_VQ_STAT_PROB_DROP, obj->stat_prob_drop); + if (obj->_present.stat_prob_mark) + ynl_attr_put_u32(nlh, TCA_GRED_VQ_STAT_PROB_MARK, obj->stat_prob_mark); + if (obj->_present.stat_forced_drop) + ynl_attr_put_u32(nlh, TCA_GRED_VQ_STAT_FORCED_DROP, obj->stat_forced_drop); + if (obj->_present.stat_forced_mark) + ynl_attr_put_u32(nlh, TCA_GRED_VQ_STAT_FORCED_MARK, obj->stat_forced_mark); + if (obj->_present.stat_pdrop) + ynl_attr_put_u32(nlh, TCA_GRED_VQ_STAT_PDROP, obj->stat_pdrop); + if (obj->_present.stat_other) + ynl_attr_put_u32(nlh, TCA_GRED_VQ_STAT_OTHER, obj->stat_other); + if (obj->_present.flags) + ynl_attr_put_u32(nlh, TCA_GRED_VQ_FLAGS, obj->flags); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_tca_gred_vq_entry_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_tca_gred_vq_entry_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_GRED_VQ_DP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.dp = 1; + dst->dp = ynl_attr_get_u32(attr); + } else if (type == TCA_GRED_VQ_STAT_BYTES) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stat_bytes = 1; + dst->stat_bytes = ynl_attr_get_u64(attr); + } else if (type == TCA_GRED_VQ_STAT_PACKETS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stat_packets = 1; + dst->stat_packets = ynl_attr_get_u32(attr); + } else if (type == TCA_GRED_VQ_STAT_BACKLOG) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stat_backlog = 1; + dst->stat_backlog = ynl_attr_get_u32(attr); + } else if (type == TCA_GRED_VQ_STAT_PROB_DROP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stat_prob_drop = 1; + dst->stat_prob_drop = ynl_attr_get_u32(attr); + } else if (type == TCA_GRED_VQ_STAT_PROB_MARK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stat_prob_mark = 1; + dst->stat_prob_mark = ynl_attr_get_u32(attr); + } else if (type == TCA_GRED_VQ_STAT_FORCED_DROP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stat_forced_drop = 1; + dst->stat_forced_drop = ynl_attr_get_u32(attr); + } else if (type == TCA_GRED_VQ_STAT_FORCED_MARK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stat_forced_mark = 1; + dst->stat_forced_mark = ynl_attr_get_u32(attr); + } else if (type == TCA_GRED_VQ_STAT_PDROP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stat_pdrop = 1; + dst->stat_pdrop = ynl_attr_get_u32(attr); + } else if (type == TCA_GRED_VQ_STAT_OTHER) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stat_other = 1; + dst->stat_other = ynl_attr_get_u32(attr); + } else if (type == TCA_GRED_VQ_FLAGS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flags = 1; + dst->flags = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_act_bpf_attrs_free(struct tc_act_bpf_attrs *obj) +{ + free(obj->tm); + free(obj->parms); + free(obj->ops); + free(obj->name); + free(obj->tag); + free(obj->id); +} + +int tc_act_bpf_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_bpf_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_ACT_BPF_TM, obj->tm, obj->_len.tm); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_ACT_BPF_PARMS, obj->parms, obj->_len.parms); + if (obj->_present.ops_len) + ynl_attr_put_u16(nlh, TCA_ACT_BPF_OPS_LEN, obj->ops_len); + if (obj->_len.ops) + ynl_attr_put(nlh, TCA_ACT_BPF_OPS, obj->ops, obj->_len.ops); + if (obj->_present.fd) + ynl_attr_put_u32(nlh, TCA_ACT_BPF_FD, obj->fd); + if (obj->_len.name) + ynl_attr_put_str(nlh, TCA_ACT_BPF_NAME, obj->name); + if (obj->_len.tag) + ynl_attr_put(nlh, TCA_ACT_BPF_TAG, obj->tag, obj->_len.tag); + if (obj->_len.id) + ynl_attr_put(nlh, TCA_ACT_BPF_ID, obj->id, obj->_len.id); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_bpf_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_bpf_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_ACT_BPF_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_ACT_BPF_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_ACT_BPF_OPS_LEN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ops_len = 1; + dst->ops_len = ynl_attr_get_u16(attr); + } else if (type == TCA_ACT_BPF_OPS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.ops = len; + dst->ops = malloc(len); + memcpy(dst->ops, ynl_attr_data(attr), len); + } else if (type == TCA_ACT_BPF_FD) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.fd = 1; + dst->fd = ynl_attr_get_u32(attr); + } else if (type == TCA_ACT_BPF_NAME) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = strnlen(ynl_attr_get_str(attr), ynl_attr_data_len(attr)); + dst->_len.name = len; + dst->name = malloc(len + 1); + memcpy(dst->name, ynl_attr_get_str(attr), len); + dst->name[len] = 0; + } else if (type == TCA_ACT_BPF_TAG) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tag = len; + dst->tag = malloc(len); + memcpy(dst->tag, ynl_attr_data(attr), len); + } else if (type == TCA_ACT_BPF_ID) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.id = len; + dst->id = malloc(len); + memcpy(dst->id, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_act_connmark_attrs_free(struct tc_act_connmark_attrs *obj) +{ + free(obj->parms); + free(obj->tm); +} + +int tc_act_connmark_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_connmark_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_CONNMARK_PARMS, obj->parms, obj->_len.parms); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_CONNMARK_TM, obj->tm, obj->_len.tm); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_connmark_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_connmark_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_CONNMARK_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_CONNMARK_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_act_csum_attrs_free(struct tc_act_csum_attrs *obj) +{ + free(obj->parms); + free(obj->tm); +} + +int tc_act_csum_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_csum_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_CSUM_PARMS, obj->parms, obj->_len.parms); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_CSUM_TM, obj->tm, obj->_len.tm); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_csum_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_csum_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_CSUM_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_CSUM_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_act_ct_attrs_free(struct tc_act_ct_attrs *obj) +{ + free(obj->parms); + free(obj->tm); + free(obj->labels); + free(obj->labels_mask); + free(obj->nat_ipv6_min); + free(obj->nat_ipv6_max); + free(obj->helper_name); +} + +int tc_act_ct_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_ct_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_CT_PARMS, obj->parms, obj->_len.parms); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_CT_TM, obj->tm, obj->_len.tm); + if (obj->_present.action) + ynl_attr_put_u16(nlh, TCA_CT_ACTION, obj->action); + if (obj->_present.zone) + ynl_attr_put_u16(nlh, TCA_CT_ZONE, obj->zone); + if (obj->_present.mark) + ynl_attr_put_u32(nlh, TCA_CT_MARK, obj->mark); + if (obj->_present.mark_mask) + ynl_attr_put_u32(nlh, TCA_CT_MARK_MASK, obj->mark_mask); + if (obj->_len.labels) + ynl_attr_put(nlh, TCA_CT_LABELS, obj->labels, obj->_len.labels); + if (obj->_len.labels_mask) + ynl_attr_put(nlh, TCA_CT_LABELS_MASK, obj->labels_mask, obj->_len.labels_mask); + if (obj->_present.nat_ipv4_min) + ynl_attr_put_u32(nlh, TCA_CT_NAT_IPV4_MIN, obj->nat_ipv4_min); + if (obj->_present.nat_ipv4_max) + ynl_attr_put_u32(nlh, TCA_CT_NAT_IPV4_MAX, obj->nat_ipv4_max); + if (obj->_len.nat_ipv6_min) + ynl_attr_put(nlh, TCA_CT_NAT_IPV6_MIN, obj->nat_ipv6_min, obj->_len.nat_ipv6_min); + if (obj->_len.nat_ipv6_max) + ynl_attr_put(nlh, TCA_CT_NAT_IPV6_MAX, obj->nat_ipv6_max, obj->_len.nat_ipv6_max); + if (obj->_present.nat_port_min) + ynl_attr_put_u16(nlh, TCA_CT_NAT_PORT_MIN, obj->nat_port_min); + if (obj->_present.nat_port_max) + ynl_attr_put_u16(nlh, TCA_CT_NAT_PORT_MAX, obj->nat_port_max); + if (obj->_len.helper_name) + ynl_attr_put_str(nlh, TCA_CT_HELPER_NAME, obj->helper_name); + if (obj->_present.helper_family) + ynl_attr_put_u8(nlh, TCA_CT_HELPER_FAMILY, obj->helper_family); + if (obj->_present.helper_proto) + ynl_attr_put_u8(nlh, TCA_CT_HELPER_PROTO, obj->helper_proto); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_ct_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_ct_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_CT_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_CT_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_CT_ACTION) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.action = 1; + dst->action = ynl_attr_get_u16(attr); + } else if (type == TCA_CT_ZONE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.zone = 1; + dst->zone = ynl_attr_get_u16(attr); + } else if (type == TCA_CT_MARK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.mark = 1; + dst->mark = ynl_attr_get_u32(attr); + } else if (type == TCA_CT_MARK_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.mark_mask = 1; + dst->mark_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_CT_LABELS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.labels = len; + dst->labels = malloc(len); + memcpy(dst->labels, ynl_attr_data(attr), len); + } else if (type == TCA_CT_LABELS_MASK) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.labels_mask = len; + dst->labels_mask = malloc(len); + memcpy(dst->labels_mask, ynl_attr_data(attr), len); + } else if (type == TCA_CT_NAT_IPV4_MIN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.nat_ipv4_min = 1; + dst->nat_ipv4_min = ynl_attr_get_u32(attr); + } else if (type == TCA_CT_NAT_IPV4_MAX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.nat_ipv4_max = 1; + dst->nat_ipv4_max = ynl_attr_get_u32(attr); + } else if (type == TCA_CT_NAT_IPV6_MIN) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.nat_ipv6_min = len; + dst->nat_ipv6_min = malloc(len); + memcpy(dst->nat_ipv6_min, ynl_attr_data(attr), len); + } else if (type == TCA_CT_NAT_IPV6_MAX) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.nat_ipv6_max = len; + dst->nat_ipv6_max = malloc(len); + memcpy(dst->nat_ipv6_max, ynl_attr_data(attr), len); + } else if (type == TCA_CT_NAT_PORT_MIN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.nat_port_min = 1; + dst->nat_port_min = ynl_attr_get_u16(attr); + } else if (type == TCA_CT_NAT_PORT_MAX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.nat_port_max = 1; + dst->nat_port_max = ynl_attr_get_u16(attr); + } else if (type == TCA_CT_HELPER_NAME) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = strnlen(ynl_attr_get_str(attr), ynl_attr_data_len(attr)); + dst->_len.helper_name = len; + dst->helper_name = malloc(len + 1); + memcpy(dst->helper_name, ynl_attr_get_str(attr), len); + dst->helper_name[len] = 0; + } else if (type == TCA_CT_HELPER_FAMILY) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.helper_family = 1; + dst->helper_family = ynl_attr_get_u8(attr); + } else if (type == TCA_CT_HELPER_PROTO) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.helper_proto = 1; + dst->helper_proto = ynl_attr_get_u8(attr); + } + } + + return 0; +} + +void tc_act_ctinfo_attrs_free(struct tc_act_ctinfo_attrs *obj) +{ + free(obj->tm); + free(obj->act); +} + +int tc_act_ctinfo_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_ctinfo_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_CTINFO_TM, obj->tm, obj->_len.tm); + if (obj->_len.act) + ynl_attr_put(nlh, TCA_CTINFO_ACT, obj->act, obj->_len.act); + if (obj->_present.zone) + ynl_attr_put_u16(nlh, TCA_CTINFO_ZONE, obj->zone); + if (obj->_present.parms_dscp_mask) + ynl_attr_put_u32(nlh, TCA_CTINFO_PARMS_DSCP_MASK, obj->parms_dscp_mask); + if (obj->_present.parms_dscp_statemask) + ynl_attr_put_u32(nlh, TCA_CTINFO_PARMS_DSCP_STATEMASK, obj->parms_dscp_statemask); + if (obj->_present.parms_cpmark_mask) + ynl_attr_put_u32(nlh, TCA_CTINFO_PARMS_CPMARK_MASK, obj->parms_cpmark_mask); + if (obj->_present.stats_dscp_set) + ynl_attr_put_u64(nlh, TCA_CTINFO_STATS_DSCP_SET, obj->stats_dscp_set); + if (obj->_present.stats_dscp_error) + ynl_attr_put_u64(nlh, TCA_CTINFO_STATS_DSCP_ERROR, obj->stats_dscp_error); + if (obj->_present.stats_cpmark_set) + ynl_attr_put_u64(nlh, TCA_CTINFO_STATS_CPMARK_SET, obj->stats_cpmark_set); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_ctinfo_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_ctinfo_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_CTINFO_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_CTINFO_ACT) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.act = len; + dst->act = malloc(len); + memcpy(dst->act, ynl_attr_data(attr), len); + } else if (type == TCA_CTINFO_ZONE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.zone = 1; + dst->zone = ynl_attr_get_u16(attr); + } else if (type == TCA_CTINFO_PARMS_DSCP_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.parms_dscp_mask = 1; + dst->parms_dscp_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_CTINFO_PARMS_DSCP_STATEMASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.parms_dscp_statemask = 1; + dst->parms_dscp_statemask = ynl_attr_get_u32(attr); + } else if (type == TCA_CTINFO_PARMS_CPMARK_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.parms_cpmark_mask = 1; + dst->parms_cpmark_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_CTINFO_STATS_DSCP_SET) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stats_dscp_set = 1; + dst->stats_dscp_set = ynl_attr_get_u64(attr); + } else if (type == TCA_CTINFO_STATS_DSCP_ERROR) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stats_dscp_error = 1; + dst->stats_dscp_error = ynl_attr_get_u64(attr); + } else if (type == TCA_CTINFO_STATS_CPMARK_SET) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stats_cpmark_set = 1; + dst->stats_cpmark_set = ynl_attr_get_u64(attr); + } + } + + return 0; +} + +void tc_act_gact_attrs_free(struct tc_act_gact_attrs *obj) +{ + free(obj->tm); + free(obj->parms); + free(obj->prob); +} + +int tc_act_gact_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_gact_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_GACT_TM, obj->tm, obj->_len.tm); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_GACT_PARMS, obj->parms, obj->_len.parms); + if (obj->_len.prob) + ynl_attr_put(nlh, TCA_GACT_PROB, obj->prob, obj->_len.prob); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_gact_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_gact_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_GACT_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_GACT_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + if (len < sizeof(struct tc_gact)) + dst->parms = calloc(1, sizeof(struct tc_gact)); + else + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_GACT_PROB) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.prob = len; + if (len < sizeof(struct tc_gact_p)) + dst->prob = calloc(1, sizeof(struct tc_gact_p)); + else + dst->prob = malloc(len); + memcpy(dst->prob, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_act_gate_attrs_free(struct tc_act_gate_attrs *obj) +{ + free(obj->tm); + free(obj->parms); + free(obj->entry_list); +} + +int tc_act_gate_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_gate_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_GATE_TM, obj->tm, obj->_len.tm); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_GATE_PARMS, obj->parms, obj->_len.parms); + if (obj->_present.priority) + ynl_attr_put_s32(nlh, TCA_GATE_PRIORITY, obj->priority); + if (obj->_len.entry_list) + ynl_attr_put(nlh, TCA_GATE_ENTRY_LIST, obj->entry_list, obj->_len.entry_list); + if (obj->_present.base_time) + ynl_attr_put_u64(nlh, TCA_GATE_BASE_TIME, obj->base_time); + if (obj->_present.cycle_time) + ynl_attr_put_u64(nlh, TCA_GATE_CYCLE_TIME, obj->cycle_time); + if (obj->_present.cycle_time_ext) + ynl_attr_put_u64(nlh, TCA_GATE_CYCLE_TIME_EXT, obj->cycle_time_ext); + if (obj->_present.flags) + ynl_attr_put_u32(nlh, TCA_GATE_FLAGS, obj->flags); + if (obj->_present.clockid) + ynl_attr_put_s32(nlh, TCA_GATE_CLOCKID, obj->clockid); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_gate_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_gate_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_GATE_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_GATE_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_GATE_PRIORITY) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.priority = 1; + dst->priority = ynl_attr_get_s32(attr); + } else if (type == TCA_GATE_ENTRY_LIST) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.entry_list = len; + dst->entry_list = malloc(len); + memcpy(dst->entry_list, ynl_attr_data(attr), len); + } else if (type == TCA_GATE_BASE_TIME) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.base_time = 1; + dst->base_time = ynl_attr_get_u64(attr); + } else if (type == TCA_GATE_CYCLE_TIME) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.cycle_time = 1; + dst->cycle_time = ynl_attr_get_u64(attr); + } else if (type == TCA_GATE_CYCLE_TIME_EXT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.cycle_time_ext = 1; + dst->cycle_time_ext = ynl_attr_get_u64(attr); + } else if (type == TCA_GATE_FLAGS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flags = 1; + dst->flags = ynl_attr_get_u32(attr); + } else if (type == TCA_GATE_CLOCKID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.clockid = 1; + dst->clockid = ynl_attr_get_s32(attr); + } + } + + return 0; +} + +void tc_act_ife_attrs_free(struct tc_act_ife_attrs *obj) +{ + free(obj->parms); + free(obj->tm); + free(obj->dmac); + free(obj->smac); + free(obj->metalst); +} + +int tc_act_ife_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_ife_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_IFE_PARMS, obj->parms, obj->_len.parms); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_IFE_TM, obj->tm, obj->_len.tm); + if (obj->_len.dmac) + ynl_attr_put(nlh, TCA_IFE_DMAC, obj->dmac, obj->_len.dmac); + if (obj->_len.smac) + ynl_attr_put(nlh, TCA_IFE_SMAC, obj->smac, obj->_len.smac); + if (obj->_present.type) + ynl_attr_put_u16(nlh, TCA_IFE_TYPE, obj->type); + if (obj->_len.metalst) + ynl_attr_put(nlh, TCA_IFE_METALST, obj->metalst, obj->_len.metalst); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_ife_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_ife_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_IFE_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_IFE_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_IFE_DMAC) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.dmac = len; + dst->dmac = malloc(len); + memcpy(dst->dmac, ynl_attr_data(attr), len); + } else if (type == TCA_IFE_SMAC) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.smac = len; + dst->smac = malloc(len); + memcpy(dst->smac, ynl_attr_data(attr), len); + } else if (type == TCA_IFE_TYPE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.type = 1; + dst->type = ynl_attr_get_u16(attr); + } else if (type == TCA_IFE_METALST) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.metalst = len; + dst->metalst = malloc(len); + memcpy(dst->metalst, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_act_mirred_attrs_free(struct tc_act_mirred_attrs *obj) +{ + free(obj->tm); + free(obj->parms); + free(obj->blockid); +} + +int tc_act_mirred_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_mirred_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_MIRRED_TM, obj->tm, obj->_len.tm); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_MIRRED_PARMS, obj->parms, obj->_len.parms); + if (obj->_len.blockid) + ynl_attr_put(nlh, TCA_MIRRED_BLOCKID, obj->blockid, obj->_len.blockid); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_mirred_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_mirred_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_MIRRED_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_MIRRED_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_MIRRED_BLOCKID) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.blockid = len; + dst->blockid = malloc(len); + memcpy(dst->blockid, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_act_mpls_attrs_free(struct tc_act_mpls_attrs *obj) +{ + free(obj->tm); + free(obj->parms); +} + +int tc_act_mpls_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_mpls_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_MPLS_TM, obj->tm, obj->_len.tm); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_MPLS_PARMS, obj->parms, obj->_len.parms); + if (obj->_present.proto) + ynl_attr_put_u16(nlh, TCA_MPLS_PROTO, obj->proto); + if (obj->_present.label) + ynl_attr_put_u32(nlh, TCA_MPLS_LABEL, obj->label); + if (obj->_present.tc) + ynl_attr_put_u8(nlh, TCA_MPLS_TC, obj->tc); + if (obj->_present.ttl) + ynl_attr_put_u8(nlh, TCA_MPLS_TTL, obj->ttl); + if (obj->_present.bos) + ynl_attr_put_u8(nlh, TCA_MPLS_BOS, obj->bos); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_mpls_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_mpls_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_MPLS_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_MPLS_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + if (len < sizeof(struct tc_mpls)) + dst->parms = calloc(1, sizeof(struct tc_mpls)); + else + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_MPLS_PROTO) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.proto = 1; + dst->proto = ynl_attr_get_u16(attr); + } else if (type == TCA_MPLS_LABEL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.label = 1; + dst->label = ynl_attr_get_u32(attr); + } else if (type == TCA_MPLS_TC) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.tc = 1; + dst->tc = ynl_attr_get_u8(attr); + } else if (type == TCA_MPLS_TTL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ttl = 1; + dst->ttl = ynl_attr_get_u8(attr); + } else if (type == TCA_MPLS_BOS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.bos = 1; + dst->bos = ynl_attr_get_u8(attr); + } + } + + return 0; +} + +void tc_act_nat_attrs_free(struct tc_act_nat_attrs *obj) +{ + free(obj->parms); + free(obj->tm); +} + +int tc_act_nat_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_nat_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_NAT_PARMS, obj->parms, obj->_len.parms); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_NAT_TM, obj->tm, obj->_len.tm); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_nat_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_nat_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_NAT_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_NAT_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_act_pedit_attrs_free(struct tc_act_pedit_attrs *obj) +{ + free(obj->tm); + free(obj->parms); + free(obj->parms_ex); + free(obj->keys_ex); + free(obj->key_ex); +} + +int tc_act_pedit_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_pedit_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_PEDIT_TM, obj->tm, obj->_len.tm); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_PEDIT_PARMS, obj->parms, obj->_len.parms); + if (obj->_len.parms_ex) + ynl_attr_put(nlh, TCA_PEDIT_PARMS_EX, obj->parms_ex, obj->_len.parms_ex); + if (obj->_len.keys_ex) + ynl_attr_put(nlh, TCA_PEDIT_KEYS_EX, obj->keys_ex, obj->_len.keys_ex); + if (obj->_len.key_ex) + ynl_attr_put(nlh, TCA_PEDIT_KEY_EX, obj->key_ex, obj->_len.key_ex); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_pedit_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_pedit_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_PEDIT_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_PEDIT_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + if (len < sizeof(struct tc_pedit_sel)) + dst->parms = calloc(1, sizeof(struct tc_pedit_sel)); + else + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_PEDIT_PARMS_EX) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms_ex = len; + dst->parms_ex = malloc(len); + memcpy(dst->parms_ex, ynl_attr_data(attr), len); + } else if (type == TCA_PEDIT_KEYS_EX) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.keys_ex = len; + dst->keys_ex = malloc(len); + memcpy(dst->keys_ex, ynl_attr_data(attr), len); + } else if (type == TCA_PEDIT_KEY_EX) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_ex = len; + dst->key_ex = malloc(len); + memcpy(dst->key_ex, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_act_sample_attrs_free(struct tc_act_sample_attrs *obj) +{ + free(obj->tm); + free(obj->parms); +} + +int tc_act_sample_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_sample_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_SAMPLE_TM, obj->tm, obj->_len.tm); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_SAMPLE_PARMS, obj->parms, obj->_len.parms); + if (obj->_present.rate) + ynl_attr_put_u32(nlh, TCA_SAMPLE_RATE, obj->rate); + if (obj->_present.trunc_size) + ynl_attr_put_u32(nlh, TCA_SAMPLE_TRUNC_SIZE, obj->trunc_size); + if (obj->_present.psample_group) + ynl_attr_put_u32(nlh, TCA_SAMPLE_PSAMPLE_GROUP, obj->psample_group); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_sample_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_sample_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_SAMPLE_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_SAMPLE_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + if (len < sizeof(struct tc_gact)) + dst->parms = calloc(1, sizeof(struct tc_gact)); + else + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_SAMPLE_RATE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.rate = 1; + dst->rate = ynl_attr_get_u32(attr); + } else if (type == TCA_SAMPLE_TRUNC_SIZE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.trunc_size = 1; + dst->trunc_size = ynl_attr_get_u32(attr); + } else if (type == TCA_SAMPLE_PSAMPLE_GROUP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.psample_group = 1; + dst->psample_group = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_act_simple_attrs_free(struct tc_act_simple_attrs *obj) +{ + free(obj->tm); + free(obj->parms); + free(obj->data); +} + +int tc_act_simple_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_simple_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_DEF_TM, obj->tm, obj->_len.tm); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_DEF_PARMS, obj->parms, obj->_len.parms); + if (obj->_len.data) + ynl_attr_put(nlh, TCA_DEF_DATA, obj->data, obj->_len.data); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_simple_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_simple_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_DEF_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_DEF_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_DEF_DATA) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.data = len; + dst->data = malloc(len); + memcpy(dst->data, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_act_skbedit_attrs_free(struct tc_act_skbedit_attrs *obj) +{ + free(obj->tm); + free(obj->parms); +} + +int tc_act_skbedit_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_skbedit_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_SKBEDIT_TM, obj->tm, obj->_len.tm); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_SKBEDIT_PARMS, obj->parms, obj->_len.parms); + if (obj->_present.priority) + ynl_attr_put_u32(nlh, TCA_SKBEDIT_PRIORITY, obj->priority); + if (obj->_present.queue_mapping) + ynl_attr_put_u16(nlh, TCA_SKBEDIT_QUEUE_MAPPING, obj->queue_mapping); + if (obj->_present.mark) + ynl_attr_put_u32(nlh, TCA_SKBEDIT_MARK, obj->mark); + if (obj->_present.ptype) + ynl_attr_put_u16(nlh, TCA_SKBEDIT_PTYPE, obj->ptype); + if (obj->_present.mask) + ynl_attr_put_u32(nlh, TCA_SKBEDIT_MASK, obj->mask); + if (obj->_present.flags) + ynl_attr_put_u64(nlh, TCA_SKBEDIT_FLAGS, obj->flags); + if (obj->_present.queue_mapping_max) + ynl_attr_put_u16(nlh, TCA_SKBEDIT_QUEUE_MAPPING_MAX, obj->queue_mapping_max); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_skbedit_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_skbedit_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_SKBEDIT_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_SKBEDIT_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_SKBEDIT_PRIORITY) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.priority = 1; + dst->priority = ynl_attr_get_u32(attr); + } else if (type == TCA_SKBEDIT_QUEUE_MAPPING) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.queue_mapping = 1; + dst->queue_mapping = ynl_attr_get_u16(attr); + } else if (type == TCA_SKBEDIT_MARK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.mark = 1; + dst->mark = ynl_attr_get_u32(attr); + } else if (type == TCA_SKBEDIT_PTYPE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ptype = 1; + dst->ptype = ynl_attr_get_u16(attr); + } else if (type == TCA_SKBEDIT_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.mask = 1; + dst->mask = ynl_attr_get_u32(attr); + } else if (type == TCA_SKBEDIT_FLAGS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flags = 1; + dst->flags = ynl_attr_get_u64(attr); + } else if (type == TCA_SKBEDIT_QUEUE_MAPPING_MAX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.queue_mapping_max = 1; + dst->queue_mapping_max = ynl_attr_get_u16(attr); + } + } + + return 0; +} + +void tc_act_skbmod_attrs_free(struct tc_act_skbmod_attrs *obj) +{ + free(obj->tm); + free(obj->parms); + free(obj->dmac); + free(obj->smac); + free(obj->etype); +} + +int tc_act_skbmod_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_skbmod_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_SKBMOD_TM, obj->tm, obj->_len.tm); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_SKBMOD_PARMS, obj->parms, obj->_len.parms); + if (obj->_len.dmac) + ynl_attr_put(nlh, TCA_SKBMOD_DMAC, obj->dmac, obj->_len.dmac); + if (obj->_len.smac) + ynl_attr_put(nlh, TCA_SKBMOD_SMAC, obj->smac, obj->_len.smac); + if (obj->_len.etype) + ynl_attr_put(nlh, TCA_SKBMOD_ETYPE, obj->etype, obj->_len.etype); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_skbmod_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_skbmod_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_SKBMOD_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_SKBMOD_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_SKBMOD_DMAC) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.dmac = len; + dst->dmac = malloc(len); + memcpy(dst->dmac, ynl_attr_data(attr), len); + } else if (type == TCA_SKBMOD_SMAC) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.smac = len; + dst->smac = malloc(len); + memcpy(dst->smac, ynl_attr_data(attr), len); + } else if (type == TCA_SKBMOD_ETYPE) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.etype = len; + dst->etype = malloc(len); + memcpy(dst->etype, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_act_tunnel_key_attrs_free(struct tc_act_tunnel_key_attrs *obj) +{ + free(obj->tm); + free(obj->parms); + free(obj->enc_ipv6_src); + free(obj->enc_ipv6_dst); + free(obj->enc_opts); +} + +int tc_act_tunnel_key_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_tunnel_key_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_TUNNEL_KEY_TM, obj->tm, obj->_len.tm); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_TUNNEL_KEY_PARMS, obj->parms, obj->_len.parms); + if (obj->_present.enc_ipv4_src) + ynl_attr_put_u32(nlh, TCA_TUNNEL_KEY_ENC_IPV4_SRC, obj->enc_ipv4_src); + if (obj->_present.enc_ipv4_dst) + ynl_attr_put_u32(nlh, TCA_TUNNEL_KEY_ENC_IPV4_DST, obj->enc_ipv4_dst); + if (obj->_len.enc_ipv6_src) + ynl_attr_put(nlh, TCA_TUNNEL_KEY_ENC_IPV6_SRC, obj->enc_ipv6_src, obj->_len.enc_ipv6_src); + if (obj->_len.enc_ipv6_dst) + ynl_attr_put(nlh, TCA_TUNNEL_KEY_ENC_IPV6_DST, obj->enc_ipv6_dst, obj->_len.enc_ipv6_dst); + if (obj->_present.enc_key_id) + ynl_attr_put_u64(nlh, TCA_TUNNEL_KEY_ENC_KEY_ID, obj->enc_key_id); + if (obj->_present.enc_dst_port) + ynl_attr_put_u16(nlh, TCA_TUNNEL_KEY_ENC_DST_PORT, obj->enc_dst_port); + if (obj->_present.no_csum) + ynl_attr_put_u8(nlh, TCA_TUNNEL_KEY_NO_CSUM, obj->no_csum); + if (obj->_len.enc_opts) + ynl_attr_put(nlh, TCA_TUNNEL_KEY_ENC_OPTS, obj->enc_opts, obj->_len.enc_opts); + if (obj->_present.enc_tos) + ynl_attr_put_u8(nlh, TCA_TUNNEL_KEY_ENC_TOS, obj->enc_tos); + if (obj->_present.enc_ttl) + ynl_attr_put_u8(nlh, TCA_TUNNEL_KEY_ENC_TTL, obj->enc_ttl); + if (obj->_present.no_frag) + ynl_attr_put(nlh, TCA_TUNNEL_KEY_NO_FRAG, NULL, 0); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_tunnel_key_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_tunnel_key_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_TUNNEL_KEY_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_TUNNEL_KEY_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_TUNNEL_KEY_ENC_IPV4_SRC) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.enc_ipv4_src = 1; + dst->enc_ipv4_src = ynl_attr_get_u32(attr); + } else if (type == TCA_TUNNEL_KEY_ENC_IPV4_DST) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.enc_ipv4_dst = 1; + dst->enc_ipv4_dst = ynl_attr_get_u32(attr); + } else if (type == TCA_TUNNEL_KEY_ENC_IPV6_SRC) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.enc_ipv6_src = len; + dst->enc_ipv6_src = malloc(len); + memcpy(dst->enc_ipv6_src, ynl_attr_data(attr), len); + } else if (type == TCA_TUNNEL_KEY_ENC_IPV6_DST) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.enc_ipv6_dst = len; + dst->enc_ipv6_dst = malloc(len); + memcpy(dst->enc_ipv6_dst, ynl_attr_data(attr), len); + } else if (type == TCA_TUNNEL_KEY_ENC_KEY_ID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.enc_key_id = 1; + dst->enc_key_id = ynl_attr_get_u64(attr); + } else if (type == TCA_TUNNEL_KEY_ENC_DST_PORT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.enc_dst_port = 1; + dst->enc_dst_port = ynl_attr_get_u16(attr); + } else if (type == TCA_TUNNEL_KEY_NO_CSUM) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.no_csum = 1; + dst->no_csum = ynl_attr_get_u8(attr); + } else if (type == TCA_TUNNEL_KEY_ENC_OPTS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.enc_opts = len; + dst->enc_opts = malloc(len); + memcpy(dst->enc_opts, ynl_attr_data(attr), len); + } else if (type == TCA_TUNNEL_KEY_ENC_TOS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.enc_tos = 1; + dst->enc_tos = ynl_attr_get_u8(attr); + } else if (type == TCA_TUNNEL_KEY_ENC_TTL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.enc_ttl = 1; + dst->enc_ttl = ynl_attr_get_u8(attr); + } else if (type == TCA_TUNNEL_KEY_NO_FRAG) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.no_frag = 1; + } + } + + return 0; +} + +void tc_act_vlan_attrs_free(struct tc_act_vlan_attrs *obj) +{ + free(obj->tm); + free(obj->parms); + free(obj->push_eth_dst); + free(obj->push_eth_src); +} + +int tc_act_vlan_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_vlan_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.tm) + ynl_attr_put(nlh, TCA_VLAN_TM, obj->tm, obj->_len.tm); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_VLAN_PARMS, obj->parms, obj->_len.parms); + if (obj->_present.push_vlan_id) + ynl_attr_put_u16(nlh, TCA_VLAN_PUSH_VLAN_ID, obj->push_vlan_id); + if (obj->_present.push_vlan_protocol) + ynl_attr_put_u16(nlh, TCA_VLAN_PUSH_VLAN_PROTOCOL, obj->push_vlan_protocol); + if (obj->_present.push_vlan_priority) + ynl_attr_put_u8(nlh, TCA_VLAN_PUSH_VLAN_PRIORITY, obj->push_vlan_priority); + if (obj->_len.push_eth_dst) + ynl_attr_put(nlh, TCA_VLAN_PUSH_ETH_DST, obj->push_eth_dst, obj->_len.push_eth_dst); + if (obj->_len.push_eth_src) + ynl_attr_put(nlh, TCA_VLAN_PUSH_ETH_SRC, obj->push_eth_src, obj->_len.push_eth_src); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_vlan_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_act_vlan_attrs *dst = yarg->data; + const struct nlattr *attr; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_VLAN_TM) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tm = len; + if (len < sizeof(struct tcf_t)) + dst->tm = calloc(1, sizeof(struct tcf_t)); + else + dst->tm = malloc(len); + memcpy(dst->tm, ynl_attr_data(attr), len); + } else if (type == TCA_VLAN_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + if (len < sizeof(struct tc_vlan)) + dst->parms = calloc(1, sizeof(struct tc_vlan)); + else + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_VLAN_PUSH_VLAN_ID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.push_vlan_id = 1; + dst->push_vlan_id = ynl_attr_get_u16(attr); + } else if (type == TCA_VLAN_PUSH_VLAN_PROTOCOL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.push_vlan_protocol = 1; + dst->push_vlan_protocol = ynl_attr_get_u16(attr); + } else if (type == TCA_VLAN_PUSH_VLAN_PRIORITY) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.push_vlan_priority = 1; + dst->push_vlan_priority = ynl_attr_get_u8(attr); + } else if (type == TCA_VLAN_PUSH_ETH_DST) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.push_eth_dst = len; + dst->push_eth_dst = malloc(len); + memcpy(dst->push_eth_dst, ynl_attr_data(attr), len); + } else if (type == TCA_VLAN_PUSH_ETH_SRC) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.push_eth_src = len; + dst->push_eth_src = malloc(len); + memcpy(dst->push_eth_src, ynl_attr_data(attr), len); + } + } + + return 0; +} + +void tc_flow_attrs_free(struct tc_flow_attrs *obj) +{ + free(obj->act); + tc_police_attrs_free(&obj->police); + free(obj->ematches); +} + +int tc_flow_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_flow_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.keys) + ynl_attr_put_u32(nlh, TCA_FLOW_KEYS, obj->keys); + if (obj->_present.mode) + ynl_attr_put_u32(nlh, TCA_FLOW_MODE, obj->mode); + if (obj->_present.baseclass) + ynl_attr_put_u32(nlh, TCA_FLOW_BASECLASS, obj->baseclass); + if (obj->_present.rshift) + ynl_attr_put_u32(nlh, TCA_FLOW_RSHIFT, obj->rshift); + if (obj->_present.addend) + ynl_attr_put_u32(nlh, TCA_FLOW_ADDEND, obj->addend); + if (obj->_present.mask) + ynl_attr_put_u32(nlh, TCA_FLOW_MASK, obj->mask); + if (obj->_present.xor) + ynl_attr_put_u32(nlh, TCA_FLOW_XOR, obj->xor); + if (obj->_present.divisor) + ynl_attr_put_u32(nlh, TCA_FLOW_DIVISOR, obj->divisor); + if (obj->_len.act) + ynl_attr_put(nlh, TCA_FLOW_ACT, obj->act, obj->_len.act); + if (obj->_present.police) + tc_police_attrs_put(nlh, TCA_FLOW_POLICE, &obj->police); + if (obj->_len.ematches) + ynl_attr_put(nlh, TCA_FLOW_EMATCHES, obj->ematches, obj->_len.ematches); + if (obj->_present.perturb) + ynl_attr_put_u32(nlh, TCA_FLOW_PERTURB, obj->perturb); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_flow_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_flow_attrs *dst = yarg->data; + const struct nlattr *attr; + struct ynl_parse_arg parg; + + parg.ys = yarg->ys; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_FLOW_KEYS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.keys = 1; + dst->keys = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOW_MODE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.mode = 1; + dst->mode = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOW_BASECLASS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.baseclass = 1; + dst->baseclass = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOW_RSHIFT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.rshift = 1; + dst->rshift = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOW_ADDEND) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.addend = 1; + dst->addend = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOW_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.mask = 1; + dst->mask = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOW_XOR) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.xor = 1; + dst->xor = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOW_DIVISOR) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.divisor = 1; + dst->divisor = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOW_ACT) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.act = len; + dst->act = malloc(len); + memcpy(dst->act, ynl_attr_data(attr), len); + } else if (type == TCA_FLOW_POLICE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.police = 1; + + parg.rsp_policy = &tc_police_attrs_nest; + parg.data = &dst->police; + if (tc_police_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_FLOW_EMATCHES) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.ematches = len; + dst->ematches = malloc(len); + memcpy(dst->ematches, ynl_attr_data(attr), len); + } else if (type == TCA_FLOW_PERTURB) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.perturb = 1; + dst->perturb = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_netem_attrs_free(struct tc_netem_attrs *obj) +{ + free(obj->corr); + free(obj->delay_dist); + free(obj->reorder); + free(obj->corrupt); + tc_netem_loss_attrs_free(&obj->loss); + free(obj->rate); + free(obj->slot); + free(obj->slot_dist); +} + +int tc_netem_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_netem_attrs *obj) +{ + struct nlattr *nest; + unsigned int i; + void *hdr; + + nest = ynl_attr_nest_start(nlh, attr_type); + hdr = ynl_nlmsg_put_extra_header(nlh, sizeof(struct tc_netem_qopt)); + memcpy(hdr, &obj->_hdr, sizeof(struct tc_netem_qopt)); + if (obj->_len.corr) + ynl_attr_put(nlh, TCA_NETEM_CORR, obj->corr, obj->_len.corr); + if (obj->_count.delay_dist) { + i = obj->_count.delay_dist * sizeof(__s16); + ynl_attr_put(nlh, TCA_NETEM_DELAY_DIST, obj->delay_dist, i); + } + if (obj->_len.reorder) + ynl_attr_put(nlh, TCA_NETEM_REORDER, obj->reorder, obj->_len.reorder); + if (obj->_len.corrupt) + ynl_attr_put(nlh, TCA_NETEM_CORRUPT, obj->corrupt, obj->_len.corrupt); + if (obj->_present.loss) + tc_netem_loss_attrs_put(nlh, TCA_NETEM_LOSS, &obj->loss); + if (obj->_len.rate) + ynl_attr_put(nlh, TCA_NETEM_RATE, obj->rate, obj->_len.rate); + if (obj->_present.ecn) + ynl_attr_put_u32(nlh, TCA_NETEM_ECN, obj->ecn); + if (obj->_present.rate64) + ynl_attr_put_u64(nlh, TCA_NETEM_RATE64, obj->rate64); + if (obj->_present.pad) + ynl_attr_put_u32(nlh, TCA_NETEM_PAD, obj->pad); + if (obj->_present.latency64) + ynl_attr_put_s64(nlh, TCA_NETEM_LATENCY64, obj->latency64); + if (obj->_present.jitter64) + ynl_attr_put_s64(nlh, TCA_NETEM_JITTER64, obj->jitter64); + if (obj->_len.slot) + ynl_attr_put(nlh, TCA_NETEM_SLOT, obj->slot, obj->_len.slot); + if (obj->_count.slot_dist) { + i = obj->_count.slot_dist * sizeof(__s16); + ynl_attr_put(nlh, TCA_NETEM_SLOT_DIST, obj->slot_dist, i); + } + if (obj->_present.prng_seed) + ynl_attr_put_u64(nlh, TCA_NETEM_PRNG_SEED, obj->prng_seed); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_netem_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_netem_attrs *dst = yarg->data; + const struct nlattr *attr; + struct ynl_parse_arg parg; + void *hdr; + + parg.ys = yarg->ys; + + hdr = ynl_attr_data(nested); + memcpy(&dst->_hdr, hdr, sizeof(struct tc_netem_qopt)); + + ynl_attr_for_each_nested_off(attr, nested, sizeof(struct tc_netem_qopt)) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_NETEM_CORR) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.corr = len; + if (len < sizeof(struct tc_netem_corr)) + dst->corr = calloc(1, sizeof(struct tc_netem_corr)); + else + dst->corr = malloc(len); + memcpy(dst->corr, ynl_attr_data(attr), len); + } else if (type == TCA_NETEM_DELAY_DIST) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_count.delay_dist = len / sizeof(__s16); + len = dst->_count.delay_dist * sizeof(__s16); + dst->delay_dist = malloc(len); + memcpy(dst->delay_dist, ynl_attr_data(attr), len); + } else if (type == TCA_NETEM_REORDER) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.reorder = len; + if (len < sizeof(struct tc_netem_reorder)) + dst->reorder = calloc(1, sizeof(struct tc_netem_reorder)); + else + dst->reorder = malloc(len); + memcpy(dst->reorder, ynl_attr_data(attr), len); + } else if (type == TCA_NETEM_CORRUPT) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.corrupt = len; + if (len < sizeof(struct tc_netem_corrupt)) + dst->corrupt = calloc(1, sizeof(struct tc_netem_corrupt)); + else + dst->corrupt = malloc(len); + memcpy(dst->corrupt, ynl_attr_data(attr), len); + } else if (type == TCA_NETEM_LOSS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.loss = 1; + + parg.rsp_policy = &tc_netem_loss_attrs_nest; + parg.data = &dst->loss; + if (tc_netem_loss_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_NETEM_RATE) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.rate = len; + if (len < sizeof(struct tc_netem_rate)) + dst->rate = calloc(1, sizeof(struct tc_netem_rate)); + else + dst->rate = malloc(len); + memcpy(dst->rate, ynl_attr_data(attr), len); + } else if (type == TCA_NETEM_ECN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ecn = 1; + dst->ecn = ynl_attr_get_u32(attr); + } else if (type == TCA_NETEM_RATE64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.rate64 = 1; + dst->rate64 = ynl_attr_get_u64(attr); + } else if (type == TCA_NETEM_PAD) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.pad = 1; + dst->pad = ynl_attr_get_u32(attr); + } else if (type == TCA_NETEM_LATENCY64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.latency64 = 1; + dst->latency64 = ynl_attr_get_s64(attr); + } else if (type == TCA_NETEM_JITTER64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.jitter64 = 1; + dst->jitter64 = ynl_attr_get_s64(attr); + } else if (type == TCA_NETEM_SLOT) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.slot = len; + if (len < sizeof(struct tc_netem_slot)) + dst->slot = calloc(1, sizeof(struct tc_netem_slot)); + else + dst->slot = malloc(len); + memcpy(dst->slot, ynl_attr_data(attr), len); + } else if (type == TCA_NETEM_SLOT_DIST) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_count.slot_dist = len / sizeof(__s16); + len = dst->_count.slot_dist * sizeof(__s16); + dst->slot_dist = malloc(len); + memcpy(dst->slot_dist, ynl_attr_data(attr), len); + } else if (type == TCA_NETEM_PRNG_SEED) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.prng_seed = 1; + dst->prng_seed = ynl_attr_get_u64(attr); + } + } + + return 0; +} + +void tc_cake_stats_attrs_free(struct tc_cake_stats_attrs *obj) +{ + free(obj->tin_stats); +} + +int tc_cake_stats_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_cake_stats_attrs *obj) +{ + struct nlattr *array; + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.capacity_estimate64) + ynl_attr_put_u64(nlh, TCA_CAKE_STATS_CAPACITY_ESTIMATE64, obj->capacity_estimate64); + if (obj->_present.memory_limit) + ynl_attr_put_u32(nlh, TCA_CAKE_STATS_MEMORY_LIMIT, obj->memory_limit); + if (obj->_present.memory_used) + ynl_attr_put_u32(nlh, TCA_CAKE_STATS_MEMORY_USED, obj->memory_used); + if (obj->_present.avg_netoff) + ynl_attr_put_u32(nlh, TCA_CAKE_STATS_AVG_NETOFF, obj->avg_netoff); + if (obj->_present.min_netlen) + ynl_attr_put_u32(nlh, TCA_CAKE_STATS_MIN_NETLEN, obj->min_netlen); + if (obj->_present.max_netlen) + ynl_attr_put_u32(nlh, TCA_CAKE_STATS_MAX_NETLEN, obj->max_netlen); + if (obj->_present.min_adjlen) + ynl_attr_put_u32(nlh, TCA_CAKE_STATS_MIN_ADJLEN, obj->min_adjlen); + if (obj->_present.max_adjlen) + ynl_attr_put_u32(nlh, TCA_CAKE_STATS_MAX_ADJLEN, obj->max_adjlen); + array = ynl_attr_nest_start(nlh, TCA_CAKE_STATS_TIN_STATS); + for (i = 0; i < obj->_count.tin_stats; i++) + tc_cake_tin_stats_attrs_put(nlh, i, &obj->tin_stats[i]); + ynl_attr_nest_end(nlh, array); + if (obj->_present.deficit) + ynl_attr_put_s32(nlh, TCA_CAKE_STATS_DEFICIT, obj->deficit); + if (obj->_present.cobalt_count) + ynl_attr_put_u32(nlh, TCA_CAKE_STATS_COBALT_COUNT, obj->cobalt_count); + if (obj->_present.dropping) + ynl_attr_put_u32(nlh, TCA_CAKE_STATS_DROPPING, obj->dropping); + if (obj->_present.drop_next_us) + ynl_attr_put_s32(nlh, TCA_CAKE_STATS_DROP_NEXT_US, obj->drop_next_us); + if (obj->_present.p_drop) + ynl_attr_put_u32(nlh, TCA_CAKE_STATS_P_DROP, obj->p_drop); + if (obj->_present.blue_timer_us) + ynl_attr_put_s32(nlh, TCA_CAKE_STATS_BLUE_TIMER_US, obj->blue_timer_us); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_cake_stats_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_cake_stats_attrs *dst = yarg->data; + const struct nlattr *attr_tin_stats; + unsigned int n_tin_stats = 0; + const struct nlattr *attr; + struct ynl_parse_arg parg; + int i; + + parg.ys = yarg->ys; + + if (dst->tin_stats) + return ynl_error_parse(yarg, "attribute already present (cake-stats-attrs.tin-stats)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_CAKE_STATS_CAPACITY_ESTIMATE64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.capacity_estimate64 = 1; + dst->capacity_estimate64 = ynl_attr_get_u64(attr); + } else if (type == TCA_CAKE_STATS_MEMORY_LIMIT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.memory_limit = 1; + dst->memory_limit = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_STATS_MEMORY_USED) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.memory_used = 1; + dst->memory_used = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_STATS_AVG_NETOFF) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.avg_netoff = 1; + dst->avg_netoff = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_STATS_MIN_NETLEN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.min_netlen = 1; + dst->min_netlen = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_STATS_MAX_NETLEN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.max_netlen = 1; + dst->max_netlen = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_STATS_MIN_ADJLEN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.min_adjlen = 1; + dst->min_adjlen = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_STATS_MAX_ADJLEN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.max_adjlen = 1; + dst->max_adjlen = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_STATS_TIN_STATS) { + const struct nlattr *attr2; + + attr_tin_stats = attr; + ynl_attr_for_each_nested(attr2, attr) { + if (ynl_attr_validate(yarg, attr2)) + return YNL_PARSE_CB_ERROR; + dst->_count.tin_stats++; + } + } else if (type == TCA_CAKE_STATS_DEFICIT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.deficit = 1; + dst->deficit = ynl_attr_get_s32(attr); + } else if (type == TCA_CAKE_STATS_COBALT_COUNT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.cobalt_count = 1; + dst->cobalt_count = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_STATS_DROPPING) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.dropping = 1; + dst->dropping = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_STATS_DROP_NEXT_US) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.drop_next_us = 1; + dst->drop_next_us = ynl_attr_get_s32(attr); + } else if (type == TCA_CAKE_STATS_P_DROP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.p_drop = 1; + dst->p_drop = ynl_attr_get_u32(attr); + } else if (type == TCA_CAKE_STATS_BLUE_TIMER_US) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.blue_timer_us = 1; + dst->blue_timer_us = ynl_attr_get_s32(attr); + } + } + + if (n_tin_stats) { + dst->tin_stats = calloc(n_tin_stats, sizeof(*dst->tin_stats)); + dst->_count.tin_stats = n_tin_stats; + i = 0; + parg.rsp_policy = &tc_cake_tin_stats_attrs_nest; + ynl_attr_for_each_nested(attr, attr_tin_stats) { + parg.data = &dst->tin_stats[i]; + if (tc_cake_tin_stats_attrs_parse(&parg, attr, ynl_attr_type(attr))) + return YNL_PARSE_CB_ERROR; + i++; + } + } + + return 0; +} + +void +tc_flower_key_enc_opts_attrs_free(struct tc_flower_key_enc_opts_attrs *obj) +{ + tc_flower_key_enc_opt_geneve_attrs_free(&obj->geneve); + tc_flower_key_enc_opt_vxlan_attrs_free(&obj->vxlan); + tc_flower_key_enc_opt_erspan_attrs_free(&obj->erspan); + tc_flower_key_enc_opt_gtp_attrs_free(&obj->gtp); +} + +int tc_flower_key_enc_opts_attrs_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_flower_key_enc_opts_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.geneve) + tc_flower_key_enc_opt_geneve_attrs_put(nlh, TCA_FLOWER_KEY_ENC_OPTS_GENEVE, &obj->geneve); + if (obj->_present.vxlan) + tc_flower_key_enc_opt_vxlan_attrs_put(nlh, TCA_FLOWER_KEY_ENC_OPTS_VXLAN, &obj->vxlan); + if (obj->_present.erspan) + tc_flower_key_enc_opt_erspan_attrs_put(nlh, TCA_FLOWER_KEY_ENC_OPTS_ERSPAN, &obj->erspan); + if (obj->_present.gtp) + tc_flower_key_enc_opt_gtp_attrs_put(nlh, TCA_FLOWER_KEY_ENC_OPTS_GTP, &obj->gtp); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_flower_key_enc_opts_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_flower_key_enc_opts_attrs *dst = yarg->data; + const struct nlattr *attr; + struct ynl_parse_arg parg; + + parg.ys = yarg->ys; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_FLOWER_KEY_ENC_OPTS_GENEVE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.geneve = 1; + + parg.rsp_policy = &tc_flower_key_enc_opt_geneve_attrs_nest; + parg.data = &dst->geneve; + if (tc_flower_key_enc_opt_geneve_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_FLOWER_KEY_ENC_OPTS_VXLAN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.vxlan = 1; + + parg.rsp_policy = &tc_flower_key_enc_opt_vxlan_attrs_nest; + parg.data = &dst->vxlan; + if (tc_flower_key_enc_opt_vxlan_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_FLOWER_KEY_ENC_OPTS_ERSPAN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.erspan = 1; + + parg.rsp_policy = &tc_flower_key_enc_opt_erspan_attrs_nest; + parg.data = &dst->erspan; + if (tc_flower_key_enc_opt_erspan_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_FLOWER_KEY_ENC_OPTS_GTP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.gtp = 1; + + parg.rsp_policy = &tc_flower_key_enc_opt_gtp_attrs_nest; + parg.data = &dst->gtp; + if (tc_flower_key_enc_opt_gtp_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } + } + + return 0; +} + +void tc_tca_gred_vq_list_attrs_free(struct tc_tca_gred_vq_list_attrs *obj) +{ + unsigned int i; + + for (i = 0; i < obj->_count.entry; i++) + tc_tca_gred_vq_entry_attrs_free(&obj->entry[i]); + free(obj->entry); +} + +int tc_tca_gred_vq_list_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_tca_gred_vq_list_attrs *obj) +{ + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + for (i = 0; i < obj->_count.entry; i++) + tc_tca_gred_vq_entry_attrs_put(nlh, TCA_GRED_VQ_ENTRY, &obj->entry[i]); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_tca_gred_vq_list_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_tca_gred_vq_list_attrs *dst = yarg->data; + const struct nlattr *attr; + struct ynl_parse_arg parg; + unsigned int n_entry = 0; + int i; + + parg.ys = yarg->ys; + + if (dst->entry) + return ynl_error_parse(yarg, "attribute already present (tca-gred-vq-list-attrs.entry)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_GRED_VQ_ENTRY) { + n_entry++; + } + } + + if (n_entry) { + dst->entry = calloc(n_entry, sizeof(*dst->entry)); + dst->_count.entry = n_entry; + i = 0; + parg.rsp_policy = &tc_tca_gred_vq_entry_attrs_nest; + ynl_attr_for_each_nested(attr, nested) { + if (ynl_attr_type(attr) == TCA_GRED_VQ_ENTRY) { + parg.data = &dst->entry[i]; + if (tc_tca_gred_vq_entry_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + i++; + } + } + } + + return 0; +} + +void tc_taprio_sched_entry_list_free(struct tc_taprio_sched_entry_list *obj) +{ + unsigned int i; + + for (i = 0; i < obj->_count.entry; i++) + tc_taprio_sched_entry_free(&obj->entry[i]); + free(obj->entry); +} + +int tc_taprio_sched_entry_list_put(struct nlmsghdr *nlh, + unsigned int attr_type, + struct tc_taprio_sched_entry_list *obj) +{ + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + for (i = 0; i < obj->_count.entry; i++) + tc_taprio_sched_entry_put(nlh, TCA_TAPRIO_SCHED_ENTRY, &obj->entry[i]); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_taprio_sched_entry_list_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_taprio_sched_entry_list *dst = yarg->data; + const struct nlattr *attr; + struct ynl_parse_arg parg; + unsigned int n_entry = 0; + int i; + + parg.ys = yarg->ys; + + if (dst->entry) + return ynl_error_parse(yarg, "attribute already present (taprio-sched-entry-list.entry)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_TAPRIO_SCHED_ENTRY) { + n_entry++; + } + } + + if (n_entry) { + dst->entry = calloc(n_entry, sizeof(*dst->entry)); + dst->_count.entry = n_entry; + i = 0; + parg.rsp_policy = &tc_taprio_sched_entry_nest; + ynl_attr_for_each_nested(attr, nested) { + if (ynl_attr_type(attr) == TCA_TAPRIO_SCHED_ENTRY) { + parg.data = &dst->entry[i]; + if (tc_taprio_sched_entry_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + i++; + } + } + } + + return 0; +} + +void tc_act_options_msg_free(struct tc_act_options_msg *obj) +{ + tc_act_bpf_attrs_free(&obj->bpf); + tc_act_connmark_attrs_free(&obj->connmark); + tc_act_csum_attrs_free(&obj->csum); + tc_act_ct_attrs_free(&obj->ct); + tc_act_ctinfo_attrs_free(&obj->ctinfo); + tc_act_gact_attrs_free(&obj->gact); + tc_act_gate_attrs_free(&obj->gate); + tc_act_ife_attrs_free(&obj->ife); + tc_act_mirred_attrs_free(&obj->mirred); + tc_act_mpls_attrs_free(&obj->mpls); + tc_act_nat_attrs_free(&obj->nat); + tc_act_pedit_attrs_free(&obj->pedit); + tc_police_attrs_free(&obj->police); + tc_act_sample_attrs_free(&obj->sample); + tc_act_simple_attrs_free(&obj->simple); + tc_act_skbedit_attrs_free(&obj->skbedit); + tc_act_skbmod_attrs_free(&obj->skbmod); + tc_act_tunnel_key_attrs_free(&obj->tunnel_key); + tc_act_vlan_attrs_free(&obj->vlan); +} + +int tc_act_options_msg_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_options_msg *obj) +{ + if (obj->_present.bpf) + tc_act_bpf_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->bpf); + if (obj->_present.connmark) + tc_act_connmark_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->connmark); + if (obj->_present.csum) + tc_act_csum_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->csum); + if (obj->_present.ct) + tc_act_ct_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->ct); + if (obj->_present.ctinfo) + tc_act_ctinfo_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->ctinfo); + if (obj->_present.gact) + tc_act_gact_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->gact); + if (obj->_present.gate) + tc_act_gate_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->gate); + if (obj->_present.ife) + tc_act_ife_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->ife); + if (obj->_present.mirred) + tc_act_mirred_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->mirred); + if (obj->_present.mpls) + tc_act_mpls_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->mpls); + if (obj->_present.nat) + tc_act_nat_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->nat); + if (obj->_present.pedit) + tc_act_pedit_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->pedit); + if (obj->_present.police) + tc_police_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->police); + if (obj->_present.sample) + tc_act_sample_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->sample); + if (obj->_present.simple) + tc_act_simple_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->simple); + if (obj->_present.skbedit) + tc_act_skbedit_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->skbedit); + if (obj->_present.skbmod) + tc_act_skbmod_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->skbmod); + if (obj->_present.tunnel_key) + tc_act_tunnel_key_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->tunnel_key); + if (obj->_present.vlan) + tc_act_vlan_attrs_put(nlh, TCA_ACT_OPTIONS, &obj->vlan); + + return 0; +} + +int tc_act_options_msg_parse(struct ynl_parse_arg *yarg, const char *sel, + const struct nlattr *nested) +{ + struct tc_act_options_msg *dst = yarg->data; + const struct nlattr *attr = nested; + struct ynl_parse_arg parg; + + parg.ys = yarg->ys; + + if (!strcmp(sel, "bpf")) { + parg.rsp_policy = &tc_act_bpf_attrs_nest; + parg.data = &dst->bpf; + if (tc_act_bpf_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.bpf = 1; + } else if (!strcmp(sel, "connmark")) { + parg.rsp_policy = &tc_act_connmark_attrs_nest; + parg.data = &dst->connmark; + if (tc_act_connmark_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.connmark = 1; + } else if (!strcmp(sel, "csum")) { + parg.rsp_policy = &tc_act_csum_attrs_nest; + parg.data = &dst->csum; + if (tc_act_csum_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.csum = 1; + } else if (!strcmp(sel, "ct")) { + parg.rsp_policy = &tc_act_ct_attrs_nest; + parg.data = &dst->ct; + if (tc_act_ct_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ct = 1; + } else if (!strcmp(sel, "ctinfo")) { + parg.rsp_policy = &tc_act_ctinfo_attrs_nest; + parg.data = &dst->ctinfo; + if (tc_act_ctinfo_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ctinfo = 1; + } else if (!strcmp(sel, "gact")) { + parg.rsp_policy = &tc_act_gact_attrs_nest; + parg.data = &dst->gact; + if (tc_act_gact_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.gact = 1; + } else if (!strcmp(sel, "gate")) { + parg.rsp_policy = &tc_act_gate_attrs_nest; + parg.data = &dst->gate; + if (tc_act_gate_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.gate = 1; + } else if (!strcmp(sel, "ife")) { + parg.rsp_policy = &tc_act_ife_attrs_nest; + parg.data = &dst->ife; + if (tc_act_ife_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ife = 1; + } else if (!strcmp(sel, "mirred")) { + parg.rsp_policy = &tc_act_mirred_attrs_nest; + parg.data = &dst->mirred; + if (tc_act_mirred_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.mirred = 1; + } else if (!strcmp(sel, "mpls")) { + parg.rsp_policy = &tc_act_mpls_attrs_nest; + parg.data = &dst->mpls; + if (tc_act_mpls_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.mpls = 1; + } else if (!strcmp(sel, "nat")) { + parg.rsp_policy = &tc_act_nat_attrs_nest; + parg.data = &dst->nat; + if (tc_act_nat_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.nat = 1; + } else if (!strcmp(sel, "pedit")) { + parg.rsp_policy = &tc_act_pedit_attrs_nest; + parg.data = &dst->pedit; + if (tc_act_pedit_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.pedit = 1; + } else if (!strcmp(sel, "police")) { + parg.rsp_policy = &tc_police_attrs_nest; + parg.data = &dst->police; + if (tc_police_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.police = 1; + } else if (!strcmp(sel, "sample")) { + parg.rsp_policy = &tc_act_sample_attrs_nest; + parg.data = &dst->sample; + if (tc_act_sample_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.sample = 1; + } else if (!strcmp(sel, "simple")) { + parg.rsp_policy = &tc_act_simple_attrs_nest; + parg.data = &dst->simple; + if (tc_act_simple_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.simple = 1; + } else if (!strcmp(sel, "skbedit")) { + parg.rsp_policy = &tc_act_skbedit_attrs_nest; + parg.data = &dst->skbedit; + if (tc_act_skbedit_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.skbedit = 1; + } else if (!strcmp(sel, "skbmod")) { + parg.rsp_policy = &tc_act_skbmod_attrs_nest; + parg.data = &dst->skbmod; + if (tc_act_skbmod_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.skbmod = 1; + } else if (!strcmp(sel, "tunnel_key")) { + parg.rsp_policy = &tc_act_tunnel_key_attrs_nest; + parg.data = &dst->tunnel_key; + if (tc_act_tunnel_key_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.tunnel_key = 1; + } else if (!strcmp(sel, "vlan")) { + parg.rsp_policy = &tc_act_vlan_attrs_nest; + parg.data = &dst->vlan; + if (tc_act_vlan_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.vlan = 1; + } + return 0; +} + +void tc_tca_stats_app_msg_free(struct tc_tca_stats_app_msg *obj) +{ + tc_cake_stats_attrs_free(&obj->cake); + free(obj->choke); + free(obj->codel); + free(obj->fq); + free(obj->fq_codel); + free(obj->fq_pie); + free(obj->hhf); + free(obj->pie); + free(obj->red); + free(obj->sfb); + free(obj->sfq); +} + +int tc_tca_stats_app_msg_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_tca_stats_app_msg *obj) +{ + if (obj->_present.cake) + tc_cake_stats_attrs_put(nlh, TCA_XSTATS, &obj->cake); + if (obj->_len.choke) + ynl_attr_put(nlh, TCA_XSTATS, obj->choke, obj->_len.choke); + if (obj->_len.codel) + ynl_attr_put(nlh, TCA_XSTATS, obj->codel, obj->_len.codel); + if (obj->_len.fq) + ynl_attr_put(nlh, TCA_XSTATS, obj->fq, obj->_len.fq); + if (obj->_len.fq_codel) + ynl_attr_put(nlh, TCA_XSTATS, obj->fq_codel, obj->_len.fq_codel); + if (obj->_len.fq_pie) + ynl_attr_put(nlh, TCA_XSTATS, obj->fq_pie, obj->_len.fq_pie); + if (obj->_len.hhf) + ynl_attr_put(nlh, TCA_XSTATS, obj->hhf, obj->_len.hhf); + if (obj->_len.pie) + ynl_attr_put(nlh, TCA_XSTATS, obj->pie, obj->_len.pie); + if (obj->_len.red) + ynl_attr_put(nlh, TCA_XSTATS, obj->red, obj->_len.red); + if (obj->_len.sfb) + ynl_attr_put(nlh, TCA_XSTATS, obj->sfb, obj->_len.sfb); + if (obj->_len.sfq) + ynl_attr_put(nlh, TCA_XSTATS, obj->sfq, obj->_len.sfq); + + return 0; +} + +int tc_tca_stats_app_msg_parse(struct ynl_parse_arg *yarg, const char *sel, + const struct nlattr *nested) +{ + struct tc_tca_stats_app_msg *dst = yarg->data; + const struct nlattr *attr = nested; + struct ynl_parse_arg parg; + unsigned int len; + + parg.ys = yarg->ys; + + if (!strcmp(sel, "cake")) { + parg.rsp_policy = &tc_cake_stats_attrs_nest; + parg.data = &dst->cake; + if (tc_cake_stats_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.cake = 1; + } else if (!strcmp(sel, "choke")) { + len = ynl_attr_data_len(attr); + dst->_len.choke = len; + if (len < sizeof(struct tc_choke_xstats)) + dst->choke = calloc(1, sizeof(struct tc_choke_xstats)); + else + dst->choke = malloc(len); + memcpy(dst->choke, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "codel")) { + len = ynl_attr_data_len(attr); + dst->_len.codel = len; + if (len < sizeof(struct tc_codel_xstats)) + dst->codel = calloc(1, sizeof(struct tc_codel_xstats)); + else + dst->codel = malloc(len); + memcpy(dst->codel, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "fq")) { + len = ynl_attr_data_len(attr); + dst->_len.fq = len; + if (len < sizeof(struct tc_fq_qd_stats)) + dst->fq = calloc(1, sizeof(struct tc_fq_qd_stats)); + else + dst->fq = malloc(len); + memcpy(dst->fq, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "fq_codel")) { + len = ynl_attr_data_len(attr); + dst->_len.fq_codel = len; + if (len < sizeof(struct tc_fq_codel_xstats)) + dst->fq_codel = calloc(1, sizeof(struct tc_fq_codel_xstats)); + else + dst->fq_codel = malloc(len); + memcpy(dst->fq_codel, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "fq_pie")) { + len = ynl_attr_data_len(attr); + dst->_len.fq_pie = len; + if (len < sizeof(struct tc_fq_pie_xstats)) + dst->fq_pie = calloc(1, sizeof(struct tc_fq_pie_xstats)); + else + dst->fq_pie = malloc(len); + memcpy(dst->fq_pie, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "hhf")) { + len = ynl_attr_data_len(attr); + dst->_len.hhf = len; + if (len < sizeof(struct tc_hhf_xstats)) + dst->hhf = calloc(1, sizeof(struct tc_hhf_xstats)); + else + dst->hhf = malloc(len); + memcpy(dst->hhf, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "pie")) { + len = ynl_attr_data_len(attr); + dst->_len.pie = len; + if (len < sizeof(struct tc_pie_xstats)) + dst->pie = calloc(1, sizeof(struct tc_pie_xstats)); + else + dst->pie = malloc(len); + memcpy(dst->pie, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "red")) { + len = ynl_attr_data_len(attr); + dst->_len.red = len; + if (len < sizeof(struct tc_red_xstats)) + dst->red = calloc(1, sizeof(struct tc_red_xstats)); + else + dst->red = malloc(len); + memcpy(dst->red, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "sfb")) { + len = ynl_attr_data_len(attr); + dst->_len.sfb = len; + if (len < sizeof(struct tc_sfb_xstats)) + dst->sfb = calloc(1, sizeof(struct tc_sfb_xstats)); + else + dst->sfb = malloc(len); + memcpy(dst->sfb, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "sfq")) { + len = ynl_attr_data_len(attr); + dst->_len.sfq = len; + if (len < sizeof(struct tc_sfq_xstats)) + dst->sfq = calloc(1, sizeof(struct tc_sfq_xstats)); + else + dst->sfq = malloc(len); + memcpy(dst->sfq, ynl_attr_data(attr), len); + } + return 0; +} + +void tc_tca_stats_attrs_free(struct tc_tca_stats_attrs *obj) +{ + free(obj->basic); + free(obj->rate_est); + free(obj->queue); + tc_tca_stats_app_msg_free(&obj->app); + free(obj->rate_est64); + free(obj->basic_hw); +} + +int tc_tca_stats_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_tca_stats_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.basic) + ynl_attr_put(nlh, TCA_STATS_BASIC, obj->basic, obj->_len.basic); + if (obj->_len.rate_est) + ynl_attr_put(nlh, TCA_STATS_RATE_EST, obj->rate_est, obj->_len.rate_est); + if (obj->_len.queue) + ynl_attr_put(nlh, TCA_STATS_QUEUE, obj->queue, obj->_len.queue); + if (obj->_present.app) + tc_tca_stats_app_msg_put(nlh, TCA_STATS_APP, &obj->app); + if (obj->_len.rate_est64) + ynl_attr_put(nlh, TCA_STATS_RATE_EST64, obj->rate_est64, obj->_len.rate_est64); + if (obj->_len.basic_hw) + ynl_attr_put(nlh, TCA_STATS_BASIC_HW, obj->basic_hw, obj->_len.basic_hw); + if (obj->_present.pkt64) + ynl_attr_put_u64(nlh, TCA_STATS_PKT64, obj->pkt64); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_tca_stats_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested, + const char *_sel_kind) +{ + struct tc_tca_stats_attrs *dst = yarg->data; + const struct nlattr *attr; + struct ynl_parse_arg parg; + + parg.ys = yarg->ys; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_STATS_BASIC) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.basic = len; + if (len < sizeof(struct gnet_stats_basic)) + dst->basic = calloc(1, sizeof(struct gnet_stats_basic)); + else + dst->basic = malloc(len); + memcpy(dst->basic, ynl_attr_data(attr), len); + } else if (type == TCA_STATS_RATE_EST) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.rate_est = len; + if (len < sizeof(struct gnet_stats_rate_est)) + dst->rate_est = calloc(1, sizeof(struct gnet_stats_rate_est)); + else + dst->rate_est = malloc(len); + memcpy(dst->rate_est, ynl_attr_data(attr), len); + } else if (type == TCA_STATS_QUEUE) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.queue = len; + if (len < sizeof(struct gnet_stats_queue)) + dst->queue = calloc(1, sizeof(struct gnet_stats_queue)); + else + dst->queue = malloc(len); + memcpy(dst->queue, ynl_attr_data(attr), len); + } else if (type == TCA_STATS_APP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.app = 1; + + parg.rsp_policy = &tc_tca_stats_app_msg_nest; + parg.data = &dst->app; + if (!_sel_kind) + return ynl_submsg_failed(yarg, "app", "kind"); + if (tc_tca_stats_app_msg_parse(&parg, _sel_kind, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_STATS_RATE_EST64) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.rate_est64 = len; + if (len < sizeof(struct gnet_stats_rate_est64)) + dst->rate_est64 = calloc(1, sizeof(struct gnet_stats_rate_est64)); + else + dst->rate_est64 = malloc(len); + memcpy(dst->rate_est64, ynl_attr_data(attr), len); + } else if (type == TCA_STATS_BASIC_HW) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.basic_hw = len; + if (len < sizeof(struct gnet_stats_basic)) + dst->basic_hw = calloc(1, sizeof(struct gnet_stats_basic)); + else + dst->basic_hw = malloc(len); + memcpy(dst->basic_hw, ynl_attr_data(attr), len); + } else if (type == TCA_STATS_PKT64) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.pkt64 = 1; + dst->pkt64 = ynl_attr_get_u64(attr); + } + } + + return 0; +} + +void tc_gred_attrs_free(struct tc_gred_attrs *obj) +{ + free(obj->parms); + free(obj->stab); + free(obj->dps); + free(obj->max_p); + tc_tca_gred_vq_list_attrs_free(&obj->vq_list); +} + +int tc_gred_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_gred_attrs *obj) +{ + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.parms) + ynl_attr_put(nlh, TCA_GRED_PARMS, obj->parms, obj->_len.parms); + if (obj->_count.stab) { + i = obj->_count.stab * sizeof(__u8); + ynl_attr_put(nlh, TCA_GRED_STAB, obj->stab, i); + } + if (obj->_len.dps) + ynl_attr_put(nlh, TCA_GRED_DPS, obj->dps, obj->_len.dps); + if (obj->_count.max_p) { + i = obj->_count.max_p * sizeof(__u32); + ynl_attr_put(nlh, TCA_GRED_MAX_P, obj->max_p, i); + } + if (obj->_present.limit) + ynl_attr_put_u32(nlh, TCA_GRED_LIMIT, obj->limit); + if (obj->_present.vq_list) + tc_tca_gred_vq_list_attrs_put(nlh, TCA_GRED_VQ_LIST, &obj->vq_list); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_gred_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_gred_attrs *dst = yarg->data; + const struct nlattr *attr; + struct ynl_parse_arg parg; + + parg.ys = yarg->ys; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_GRED_PARMS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.parms = len; + dst->parms = malloc(len); + memcpy(dst->parms, ynl_attr_data(attr), len); + } else if (type == TCA_GRED_STAB) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_count.stab = len / sizeof(__u8); + len = dst->_count.stab * sizeof(__u8); + dst->stab = malloc(len); + memcpy(dst->stab, ynl_attr_data(attr), len); + } else if (type == TCA_GRED_DPS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.dps = len; + if (len < sizeof(struct tc_gred_sopt)) + dst->dps = calloc(1, sizeof(struct tc_gred_sopt)); + else + dst->dps = malloc(len); + memcpy(dst->dps, ynl_attr_data(attr), len); + } else if (type == TCA_GRED_MAX_P) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_count.max_p = len / sizeof(__u32); + len = dst->_count.max_p * sizeof(__u32); + dst->max_p = malloc(len); + memcpy(dst->max_p, ynl_attr_data(attr), len); + } else if (type == TCA_GRED_LIMIT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.limit = 1; + dst->limit = ynl_attr_get_u32(attr); + } else if (type == TCA_GRED_VQ_LIST) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.vq_list = 1; + + parg.rsp_policy = &tc_tca_gred_vq_list_attrs_nest; + parg.data = &dst->vq_list; + if (tc_tca_gred_vq_list_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } + } + + return 0; +} + +void tc_taprio_attrs_free(struct tc_taprio_attrs *obj) +{ + free(obj->priomap); + tc_taprio_sched_entry_list_free(&obj->sched_entry_list); + tc_taprio_sched_entry_free(&obj->sched_single_entry); + free(obj->admin_sched); + tc_taprio_tc_entry_attrs_free(&obj->tc_entry); +} + +int tc_taprio_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_taprio_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.priomap) + ynl_attr_put(nlh, TCA_TAPRIO_ATTR_PRIOMAP, obj->priomap, obj->_len.priomap); + if (obj->_present.sched_entry_list) + tc_taprio_sched_entry_list_put(nlh, TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST, &obj->sched_entry_list); + if (obj->_present.sched_base_time) + ynl_attr_put_s64(nlh, TCA_TAPRIO_ATTR_SCHED_BASE_TIME, obj->sched_base_time); + if (obj->_present.sched_single_entry) + tc_taprio_sched_entry_put(nlh, TCA_TAPRIO_ATTR_SCHED_SINGLE_ENTRY, &obj->sched_single_entry); + if (obj->_present.sched_clockid) + ynl_attr_put_s32(nlh, TCA_TAPRIO_ATTR_SCHED_CLOCKID, obj->sched_clockid); + if (obj->_len.admin_sched) + ynl_attr_put(nlh, TCA_TAPRIO_ATTR_ADMIN_SCHED, obj->admin_sched, obj->_len.admin_sched); + if (obj->_present.sched_cycle_time) + ynl_attr_put_s64(nlh, TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME, obj->sched_cycle_time); + if (obj->_present.sched_cycle_time_extension) + ynl_attr_put_s64(nlh, TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION, obj->sched_cycle_time_extension); + if (obj->_present.flags) + ynl_attr_put_u32(nlh, TCA_TAPRIO_ATTR_FLAGS, obj->flags); + if (obj->_present.txtime_delay) + ynl_attr_put_u32(nlh, TCA_TAPRIO_ATTR_TXTIME_DELAY, obj->txtime_delay); + if (obj->_present.tc_entry) + tc_taprio_tc_entry_attrs_put(nlh, TCA_TAPRIO_ATTR_TC_ENTRY, &obj->tc_entry); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_taprio_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_taprio_attrs *dst = yarg->data; + const struct nlattr *attr; + struct ynl_parse_arg parg; + + parg.ys = yarg->ys; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_TAPRIO_ATTR_PRIOMAP) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.priomap = len; + if (len < sizeof(struct tc_mqprio_qopt)) + dst->priomap = calloc(1, sizeof(struct tc_mqprio_qopt)); + else + dst->priomap = malloc(len); + memcpy(dst->priomap, ynl_attr_data(attr), len); + } else if (type == TCA_TAPRIO_ATTR_SCHED_ENTRY_LIST) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.sched_entry_list = 1; + + parg.rsp_policy = &tc_taprio_sched_entry_list_nest; + parg.data = &dst->sched_entry_list; + if (tc_taprio_sched_entry_list_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_TAPRIO_ATTR_SCHED_BASE_TIME) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.sched_base_time = 1; + dst->sched_base_time = ynl_attr_get_s64(attr); + } else if (type == TCA_TAPRIO_ATTR_SCHED_SINGLE_ENTRY) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.sched_single_entry = 1; + + parg.rsp_policy = &tc_taprio_sched_entry_nest; + parg.data = &dst->sched_single_entry; + if (tc_taprio_sched_entry_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_TAPRIO_ATTR_SCHED_CLOCKID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.sched_clockid = 1; + dst->sched_clockid = ynl_attr_get_s32(attr); + } else if (type == TCA_TAPRIO_ATTR_ADMIN_SCHED) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.admin_sched = len; + dst->admin_sched = malloc(len); + memcpy(dst->admin_sched, ynl_attr_data(attr), len); + } else if (type == TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.sched_cycle_time = 1; + dst->sched_cycle_time = ynl_attr_get_s64(attr); + } else if (type == TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME_EXTENSION) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.sched_cycle_time_extension = 1; + dst->sched_cycle_time_extension = ynl_attr_get_s64(attr); + } else if (type == TCA_TAPRIO_ATTR_FLAGS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flags = 1; + dst->flags = ynl_attr_get_u32(attr); + } else if (type == TCA_TAPRIO_ATTR_TXTIME_DELAY) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.txtime_delay = 1; + dst->txtime_delay = ynl_attr_get_u32(attr); + } else if (type == TCA_TAPRIO_ATTR_TC_ENTRY) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.tc_entry = 1; + + parg.rsp_policy = &tc_taprio_tc_entry_attrs_nest; + parg.data = &dst->tc_entry; + if (tc_taprio_tc_entry_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } + } + + return 0; +} + +void tc_act_attrs_free(struct tc_act_attrs *obj) +{ + free(obj->kind); + tc_act_options_msg_free(&obj->options); + tc_tca_stats_attrs_free(&obj->stats); + free(obj->cookie); +} + +int tc_act_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_act_attrs *obj) +{ + struct nlattr *nest; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_len.kind) + ynl_attr_put_str(nlh, TCA_ACT_KIND, obj->kind); + if (obj->_present.options) + tc_act_options_msg_put(nlh, TCA_ACT_OPTIONS, &obj->options); + if (obj->_present.index) + ynl_attr_put_u32(nlh, TCA_ACT_INDEX, obj->index); + if (obj->_present.stats) + tc_tca_stats_attrs_put(nlh, TCA_ACT_STATS, &obj->stats); + if (obj->_len.cookie) + ynl_attr_put(nlh, TCA_ACT_COOKIE, obj->cookie, obj->_len.cookie); + if (obj->_present.flags) + ynl_attr_put(nlh, TCA_ACT_FLAGS, &obj->flags, sizeof(struct nla_bitfield32)); + if (obj->_present.hw_stats) + ynl_attr_put(nlh, TCA_ACT_HW_STATS, &obj->hw_stats, sizeof(struct nla_bitfield32)); + if (obj->_present.used_hw_stats) + ynl_attr_put(nlh, TCA_ACT_USED_HW_STATS, &obj->used_hw_stats, sizeof(struct nla_bitfield32)); + if (obj->_present.in_hw_count) + ynl_attr_put_u32(nlh, TCA_ACT_IN_HW_COUNT, obj->in_hw_count); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_act_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested, + __u32 idx) +{ + struct tc_act_attrs *dst = yarg->data; + const struct nlattr *attr; + struct ynl_parse_arg parg; + + parg.ys = yarg->ys; + + dst->idx = idx; + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_ACT_KIND) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = strnlen(ynl_attr_get_str(attr), ynl_attr_data_len(attr)); + dst->_len.kind = len; + dst->kind = malloc(len + 1); + memcpy(dst->kind, ynl_attr_get_str(attr), len); + dst->kind[len] = 0; + } else if (type == TCA_ACT_OPTIONS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.options = 1; + + parg.rsp_policy = &tc_act_options_msg_nest; + parg.data = &dst->options; + if (!dst->kind) + return ynl_submsg_failed(yarg, "options", "kind"); + if (tc_act_options_msg_parse(&parg, dst->kind, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_ACT_INDEX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.index = 1; + dst->index = ynl_attr_get_u32(attr); + } else if (type == TCA_ACT_STATS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stats = 1; + + parg.rsp_policy = &tc_tca_stats_attrs_nest; + parg.data = &dst->stats; + if (tc_tca_stats_attrs_parse(&parg, attr, dst->kind)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_ACT_COOKIE) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.cookie = len; + dst->cookie = malloc(len); + memcpy(dst->cookie, ynl_attr_data(attr), len); + } else if (type == TCA_ACT_FLAGS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flags = 1; + memcpy(&dst->flags, ynl_attr_data(attr), sizeof(struct nla_bitfield32)); + } else if (type == TCA_ACT_HW_STATS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.hw_stats = 1; + memcpy(&dst->hw_stats, ynl_attr_data(attr), sizeof(struct nla_bitfield32)); + } else if (type == TCA_ACT_USED_HW_STATS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.used_hw_stats = 1; + memcpy(&dst->used_hw_stats, ynl_attr_data(attr), sizeof(struct nla_bitfield32)); + } else if (type == TCA_ACT_IN_HW_COUNT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.in_hw_count = 1; + dst->in_hw_count = ynl_attr_get_u32(attr); + } + } + + return 0; +} + +void tc_basic_attrs_free(struct tc_basic_attrs *obj) +{ + tc_ematch_attrs_free(&obj->ematches); + free(obj->act); + tc_police_attrs_free(&obj->police); + free(obj->pcnt); +} + +int tc_basic_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_basic_attrs *obj) +{ + struct nlattr *array; + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.classid) + ynl_attr_put_u32(nlh, TCA_BASIC_CLASSID, obj->classid); + if (obj->_present.ematches) + tc_ematch_attrs_put(nlh, TCA_BASIC_EMATCHES, &obj->ematches); + array = ynl_attr_nest_start(nlh, TCA_BASIC_ACT); + for (i = 0; i < obj->_count.act; i++) + tc_act_attrs_put(nlh, i, &obj->act[i]); + ynl_attr_nest_end(nlh, array); + if (obj->_present.police) + tc_police_attrs_put(nlh, TCA_BASIC_POLICE, &obj->police); + if (obj->_len.pcnt) + ynl_attr_put(nlh, TCA_BASIC_PCNT, obj->pcnt, obj->_len.pcnt); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_basic_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_basic_attrs *dst = yarg->data; + const struct nlattr *attr_act; + const struct nlattr *attr; + struct ynl_parse_arg parg; + unsigned int n_act = 0; + int i; + + parg.ys = yarg->ys; + + if (dst->act) + return ynl_error_parse(yarg, "attribute already present (basic-attrs.act)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_BASIC_CLASSID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.classid = 1; + dst->classid = ynl_attr_get_u32(attr); + } else if (type == TCA_BASIC_EMATCHES) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ematches = 1; + + parg.rsp_policy = &tc_ematch_attrs_nest; + parg.data = &dst->ematches; + if (tc_ematch_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_BASIC_ACT) { + const struct nlattr *attr2; + + attr_act = attr; + ynl_attr_for_each_nested(attr2, attr) { + if (ynl_attr_validate(yarg, attr2)) + return YNL_PARSE_CB_ERROR; + dst->_count.act++; + } + } else if (type == TCA_BASIC_POLICE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.police = 1; + + parg.rsp_policy = &tc_police_attrs_nest; + parg.data = &dst->police; + if (tc_police_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_BASIC_PCNT) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.pcnt = len; + if (len < sizeof(struct tc_basic_pcnt)) + dst->pcnt = calloc(1, sizeof(struct tc_basic_pcnt)); + else + dst->pcnt = malloc(len); + memcpy(dst->pcnt, ynl_attr_data(attr), len); + } + } + + if (n_act) { + dst->act = calloc(n_act, sizeof(*dst->act)); + dst->_count.act = n_act; + i = 0; + parg.rsp_policy = &tc_act_attrs_nest; + ynl_attr_for_each_nested(attr, attr_act) { + parg.data = &dst->act[i]; + if (tc_act_attrs_parse(&parg, attr, ynl_attr_type(attr))) + return YNL_PARSE_CB_ERROR; + i++; + } + } + + return 0; +} + +void tc_bpf_attrs_free(struct tc_bpf_attrs *obj) +{ + free(obj->act); + tc_police_attrs_free(&obj->police); + free(obj->ops); + free(obj->name); + free(obj->tag); +} + +int tc_bpf_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_bpf_attrs *obj) +{ + struct nlattr *array; + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + array = ynl_attr_nest_start(nlh, TCA_BPF_ACT); + for (i = 0; i < obj->_count.act; i++) + tc_act_attrs_put(nlh, i, &obj->act[i]); + ynl_attr_nest_end(nlh, array); + if (obj->_present.police) + tc_police_attrs_put(nlh, TCA_BPF_POLICE, &obj->police); + if (obj->_present.classid) + ynl_attr_put_u32(nlh, TCA_BPF_CLASSID, obj->classid); + if (obj->_present.ops_len) + ynl_attr_put_u16(nlh, TCA_BPF_OPS_LEN, obj->ops_len); + if (obj->_len.ops) + ynl_attr_put(nlh, TCA_BPF_OPS, obj->ops, obj->_len.ops); + if (obj->_present.fd) + ynl_attr_put_u32(nlh, TCA_BPF_FD, obj->fd); + if (obj->_len.name) + ynl_attr_put_str(nlh, TCA_BPF_NAME, obj->name); + if (obj->_present.flags) + ynl_attr_put_u32(nlh, TCA_BPF_FLAGS, obj->flags); + if (obj->_present.flags_gen) + ynl_attr_put_u32(nlh, TCA_BPF_FLAGS_GEN, obj->flags_gen); + if (obj->_len.tag) + ynl_attr_put(nlh, TCA_BPF_TAG, obj->tag, obj->_len.tag); + if (obj->_present.id) + ynl_attr_put_u32(nlh, TCA_BPF_ID, obj->id); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_bpf_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) +{ + struct tc_bpf_attrs *dst = yarg->data; + const struct nlattr *attr_act; + const struct nlattr *attr; + struct ynl_parse_arg parg; + unsigned int n_act = 0; + int i; + + parg.ys = yarg->ys; + + if (dst->act) + return ynl_error_parse(yarg, "attribute already present (bpf-attrs.act)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_BPF_ACT) { + const struct nlattr *attr2; + + attr_act = attr; + ynl_attr_for_each_nested(attr2, attr) { + if (ynl_attr_validate(yarg, attr2)) + return YNL_PARSE_CB_ERROR; + dst->_count.act++; + } + } else if (type == TCA_BPF_POLICE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.police = 1; + + parg.rsp_policy = &tc_police_attrs_nest; + parg.data = &dst->police; + if (tc_police_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_BPF_CLASSID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.classid = 1; + dst->classid = ynl_attr_get_u32(attr); + } else if (type == TCA_BPF_OPS_LEN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ops_len = 1; + dst->ops_len = ynl_attr_get_u16(attr); + } else if (type == TCA_BPF_OPS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.ops = len; + dst->ops = malloc(len); + memcpy(dst->ops, ynl_attr_data(attr), len); + } else if (type == TCA_BPF_FD) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.fd = 1; + dst->fd = ynl_attr_get_u32(attr); + } else if (type == TCA_BPF_NAME) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = strnlen(ynl_attr_get_str(attr), ynl_attr_data_len(attr)); + dst->_len.name = len; + dst->name = malloc(len + 1); + memcpy(dst->name, ynl_attr_get_str(attr), len); + dst->name[len] = 0; + } else if (type == TCA_BPF_FLAGS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flags = 1; + dst->flags = ynl_attr_get_u32(attr); + } else if (type == TCA_BPF_FLAGS_GEN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flags_gen = 1; + dst->flags_gen = ynl_attr_get_u32(attr); + } else if (type == TCA_BPF_TAG) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.tag = len; + dst->tag = malloc(len); + memcpy(dst->tag, ynl_attr_data(attr), len); + } else if (type == TCA_BPF_ID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.id = 1; + dst->id = ynl_attr_get_u32(attr); + } + } + + if (n_act) { + dst->act = calloc(n_act, sizeof(*dst->act)); + dst->_count.act = n_act; + i = 0; + parg.rsp_policy = &tc_act_attrs_nest; + ynl_attr_for_each_nested(attr, attr_act) { + parg.data = &dst->act[i]; + if (tc_act_attrs_parse(&parg, attr, ynl_attr_type(attr))) + return YNL_PARSE_CB_ERROR; + i++; + } + } + + return 0; +} + +void tc_cgroup_attrs_free(struct tc_cgroup_attrs *obj) +{ + free(obj->act); + tc_police_attrs_free(&obj->police); + free(obj->ematches); +} + +int tc_cgroup_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_cgroup_attrs *obj) +{ + struct nlattr *array; + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + array = ynl_attr_nest_start(nlh, TCA_CGROUP_ACT); + for (i = 0; i < obj->_count.act; i++) + tc_act_attrs_put(nlh, i, &obj->act[i]); + ynl_attr_nest_end(nlh, array); + if (obj->_present.police) + tc_police_attrs_put(nlh, TCA_CGROUP_POLICE, &obj->police); + if (obj->_len.ematches) + ynl_attr_put(nlh, TCA_CGROUP_EMATCHES, obj->ematches, obj->_len.ematches); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_cgroup_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_cgroup_attrs *dst = yarg->data; + const struct nlattr *attr_act; + const struct nlattr *attr; + struct ynl_parse_arg parg; + unsigned int n_act = 0; + int i; + + parg.ys = yarg->ys; + + if (dst->act) + return ynl_error_parse(yarg, "attribute already present (cgroup-attrs.act)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_CGROUP_ACT) { + const struct nlattr *attr2; + + attr_act = attr; + ynl_attr_for_each_nested(attr2, attr) { + if (ynl_attr_validate(yarg, attr2)) + return YNL_PARSE_CB_ERROR; + dst->_count.act++; + } + } else if (type == TCA_CGROUP_POLICE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.police = 1; + + parg.rsp_policy = &tc_police_attrs_nest; + parg.data = &dst->police; + if (tc_police_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_CGROUP_EMATCHES) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.ematches = len; + dst->ematches = malloc(len); + memcpy(dst->ematches, ynl_attr_data(attr), len); + } + } + + if (n_act) { + dst->act = calloc(n_act, sizeof(*dst->act)); + dst->_count.act = n_act; + i = 0; + parg.rsp_policy = &tc_act_attrs_nest; + ynl_attr_for_each_nested(attr, attr_act) { + parg.data = &dst->act[i]; + if (tc_act_attrs_parse(&parg, attr, ynl_attr_type(attr))) + return YNL_PARSE_CB_ERROR; + i++; + } + } + + return 0; +} + +void tc_flower_attrs_free(struct tc_flower_attrs *obj) +{ + free(obj->indev); + free(obj->act); + free(obj->key_eth_dst); + free(obj->key_eth_dst_mask); + free(obj->key_eth_src); + free(obj->key_eth_src_mask); + free(obj->key_ipv6_src); + free(obj->key_ipv6_src_mask); + free(obj->key_ipv6_dst); + free(obj->key_ipv6_dst_mask); + free(obj->key_enc_ipv6_src); + free(obj->key_enc_ipv6_src_mask); + free(obj->key_enc_ipv6_dst); + free(obj->key_enc_ipv6_dst_mask); + free(obj->key_arp_sha); + free(obj->key_arp_sha_mask); + free(obj->key_arp_tha); + free(obj->key_arp_tha_mask); + tc_flower_key_enc_opts_attrs_free(&obj->key_enc_opts); + tc_flower_key_enc_opts_attrs_free(&obj->key_enc_opts_mask); + free(obj->key_ct_labels); + free(obj->key_ct_labels_mask); + tc_flower_key_mpls_opt_attrs_free(&obj->key_mpls_opts); + tc_flower_key_cfm_attrs_free(&obj->key_cfm); +} + +int tc_flower_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_flower_attrs *obj) +{ + struct nlattr *array; + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.classid) + ynl_attr_put_u32(nlh, TCA_FLOWER_CLASSID, obj->classid); + if (obj->_len.indev) + ynl_attr_put_str(nlh, TCA_FLOWER_INDEV, obj->indev); + array = ynl_attr_nest_start(nlh, TCA_FLOWER_ACT); + for (i = 0; i < obj->_count.act; i++) + tc_act_attrs_put(nlh, i, &obj->act[i]); + ynl_attr_nest_end(nlh, array); + if (obj->_len.key_eth_dst) + ynl_attr_put(nlh, TCA_FLOWER_KEY_ETH_DST, obj->key_eth_dst, obj->_len.key_eth_dst); + if (obj->_len.key_eth_dst_mask) + ynl_attr_put(nlh, TCA_FLOWER_KEY_ETH_DST_MASK, obj->key_eth_dst_mask, obj->_len.key_eth_dst_mask); + if (obj->_len.key_eth_src) + ynl_attr_put(nlh, TCA_FLOWER_KEY_ETH_SRC, obj->key_eth_src, obj->_len.key_eth_src); + if (obj->_len.key_eth_src_mask) + ynl_attr_put(nlh, TCA_FLOWER_KEY_ETH_SRC_MASK, obj->key_eth_src_mask, obj->_len.key_eth_src_mask); + if (obj->_present.key_eth_type) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_ETH_TYPE, obj->key_eth_type); + if (obj->_present.key_ip_proto) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_IP_PROTO, obj->key_ip_proto); + if (obj->_present.key_ipv4_src) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_IPV4_SRC, obj->key_ipv4_src); + if (obj->_present.key_ipv4_src_mask) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_IPV4_SRC_MASK, obj->key_ipv4_src_mask); + if (obj->_present.key_ipv4_dst) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_IPV4_DST, obj->key_ipv4_dst); + if (obj->_present.key_ipv4_dst_mask) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_IPV4_DST_MASK, obj->key_ipv4_dst_mask); + if (obj->_len.key_ipv6_src) + ynl_attr_put(nlh, TCA_FLOWER_KEY_IPV6_SRC, obj->key_ipv6_src, obj->_len.key_ipv6_src); + if (obj->_len.key_ipv6_src_mask) + ynl_attr_put(nlh, TCA_FLOWER_KEY_IPV6_SRC_MASK, obj->key_ipv6_src_mask, obj->_len.key_ipv6_src_mask); + if (obj->_len.key_ipv6_dst) + ynl_attr_put(nlh, TCA_FLOWER_KEY_IPV6_DST, obj->key_ipv6_dst, obj->_len.key_ipv6_dst); + if (obj->_len.key_ipv6_dst_mask) + ynl_attr_put(nlh, TCA_FLOWER_KEY_IPV6_DST_MASK, obj->key_ipv6_dst_mask, obj->_len.key_ipv6_dst_mask); + if (obj->_present.key_tcp_src) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_TCP_SRC, obj->key_tcp_src); + if (obj->_present.key_tcp_dst) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_TCP_DST, obj->key_tcp_dst); + if (obj->_present.key_udp_src) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_UDP_SRC, obj->key_udp_src); + if (obj->_present.key_udp_dst) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_UDP_DST, obj->key_udp_dst); + if (obj->_present.flags) + ynl_attr_put_u32(nlh, TCA_FLOWER_FLAGS, obj->flags); + if (obj->_present.key_vlan_id) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_VLAN_ID, obj->key_vlan_id); + if (obj->_present.key_vlan_prio) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_VLAN_PRIO, obj->key_vlan_prio); + if (obj->_present.key_vlan_eth_type) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_VLAN_ETH_TYPE, obj->key_vlan_eth_type); + if (obj->_present.key_enc_key_id) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_ENC_KEY_ID, obj->key_enc_key_id); + if (obj->_present.key_enc_ipv4_src) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_ENC_IPV4_SRC, obj->key_enc_ipv4_src); + if (obj->_present.key_enc_ipv4_src_mask) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK, obj->key_enc_ipv4_src_mask); + if (obj->_present.key_enc_ipv4_dst) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_ENC_IPV4_DST, obj->key_enc_ipv4_dst); + if (obj->_present.key_enc_ipv4_dst_mask) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_ENC_IPV4_DST_MASK, obj->key_enc_ipv4_dst_mask); + if (obj->_len.key_enc_ipv6_src) + ynl_attr_put(nlh, TCA_FLOWER_KEY_ENC_IPV6_SRC, obj->key_enc_ipv6_src, obj->_len.key_enc_ipv6_src); + if (obj->_len.key_enc_ipv6_src_mask) + ynl_attr_put(nlh, TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK, obj->key_enc_ipv6_src_mask, obj->_len.key_enc_ipv6_src_mask); + if (obj->_len.key_enc_ipv6_dst) + ynl_attr_put(nlh, TCA_FLOWER_KEY_ENC_IPV6_DST, obj->key_enc_ipv6_dst, obj->_len.key_enc_ipv6_dst); + if (obj->_len.key_enc_ipv6_dst_mask) + ynl_attr_put(nlh, TCA_FLOWER_KEY_ENC_IPV6_DST_MASK, obj->key_enc_ipv6_dst_mask, obj->_len.key_enc_ipv6_dst_mask); + if (obj->_present.key_tcp_src_mask) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_TCP_SRC_MASK, obj->key_tcp_src_mask); + if (obj->_present.key_tcp_dst_mask) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_TCP_DST_MASK, obj->key_tcp_dst_mask); + if (obj->_present.key_udp_src_mask) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_UDP_SRC_MASK, obj->key_udp_src_mask); + if (obj->_present.key_udp_dst_mask) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_UDP_DST_MASK, obj->key_udp_dst_mask); + if (obj->_present.key_sctp_src_mask) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_SCTP_SRC_MASK, obj->key_sctp_src_mask); + if (obj->_present.key_sctp_dst_mask) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_SCTP_DST_MASK, obj->key_sctp_dst_mask); + if (obj->_present.key_sctp_src) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_SCTP_SRC, obj->key_sctp_src); + if (obj->_present.key_sctp_dst) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_SCTP_DST, obj->key_sctp_dst); + if (obj->_present.key_enc_udp_src_port) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_ENC_UDP_SRC_PORT, obj->key_enc_udp_src_port); + if (obj->_present.key_enc_udp_src_port_mask) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK, obj->key_enc_udp_src_port_mask); + if (obj->_present.key_enc_udp_dst_port) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_ENC_UDP_DST_PORT, obj->key_enc_udp_dst_port); + if (obj->_present.key_enc_udp_dst_port_mask) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK, obj->key_enc_udp_dst_port_mask); + if (obj->_present.key_flags) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_FLAGS, obj->key_flags); + if (obj->_present.key_flags_mask) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_FLAGS_MASK, obj->key_flags_mask); + if (obj->_present.key_icmpv4_code) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ICMPV4_CODE, obj->key_icmpv4_code); + if (obj->_present.key_icmpv4_code_mask) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ICMPV4_CODE_MASK, obj->key_icmpv4_code_mask); + if (obj->_present.key_icmpv4_type) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ICMPV4_TYPE, obj->key_icmpv4_type); + if (obj->_present.key_icmpv4_type_mask) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ICMPV4_TYPE_MASK, obj->key_icmpv4_type_mask); + if (obj->_present.key_icmpv6_code) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ICMPV6_CODE, obj->key_icmpv6_code); + if (obj->_present.key_icmpv6_code_mask) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ICMPV6_CODE_MASK, obj->key_icmpv6_code_mask); + if (obj->_present.key_icmpv6_type) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ICMPV6_TYPE, obj->key_icmpv6_type); + if (obj->_present.key_icmpv6_type_mask) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ICMPV6_TYPE_MASK, obj->key_icmpv6_type_mask); + if (obj->_present.key_arp_sip) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_ARP_SIP, obj->key_arp_sip); + if (obj->_present.key_arp_sip_mask) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_ARP_SIP_MASK, obj->key_arp_sip_mask); + if (obj->_present.key_arp_tip) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_ARP_TIP, obj->key_arp_tip); + if (obj->_present.key_arp_tip_mask) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_ARP_TIP_MASK, obj->key_arp_tip_mask); + if (obj->_present.key_arp_op) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ARP_OP, obj->key_arp_op); + if (obj->_present.key_arp_op_mask) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ARP_OP_MASK, obj->key_arp_op_mask); + if (obj->_len.key_arp_sha) + ynl_attr_put(nlh, TCA_FLOWER_KEY_ARP_SHA, obj->key_arp_sha, obj->_len.key_arp_sha); + if (obj->_len.key_arp_sha_mask) + ynl_attr_put(nlh, TCA_FLOWER_KEY_ARP_SHA_MASK, obj->key_arp_sha_mask, obj->_len.key_arp_sha_mask); + if (obj->_len.key_arp_tha) + ynl_attr_put(nlh, TCA_FLOWER_KEY_ARP_THA, obj->key_arp_tha, obj->_len.key_arp_tha); + if (obj->_len.key_arp_tha_mask) + ynl_attr_put(nlh, TCA_FLOWER_KEY_ARP_THA_MASK, obj->key_arp_tha_mask, obj->_len.key_arp_tha_mask); + if (obj->_present.key_mpls_ttl) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_MPLS_TTL, obj->key_mpls_ttl); + if (obj->_present.key_mpls_bos) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_MPLS_BOS, obj->key_mpls_bos); + if (obj->_present.key_mpls_tc) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_MPLS_TC, obj->key_mpls_tc); + if (obj->_present.key_mpls_label) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_MPLS_LABEL, obj->key_mpls_label); + if (obj->_present.key_tcp_flags) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_TCP_FLAGS, obj->key_tcp_flags); + if (obj->_present.key_tcp_flags_mask) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_TCP_FLAGS_MASK, obj->key_tcp_flags_mask); + if (obj->_present.key_ip_tos) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_IP_TOS, obj->key_ip_tos); + if (obj->_present.key_ip_tos_mask) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_IP_TOS_MASK, obj->key_ip_tos_mask); + if (obj->_present.key_ip_ttl) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_IP_TTL, obj->key_ip_ttl); + if (obj->_present.key_ip_ttl_mask) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_IP_TTL_MASK, obj->key_ip_ttl_mask); + if (obj->_present.key_cvlan_id) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_CVLAN_ID, obj->key_cvlan_id); + if (obj->_present.key_cvlan_prio) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_CVLAN_PRIO, obj->key_cvlan_prio); + if (obj->_present.key_cvlan_eth_type) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_CVLAN_ETH_TYPE, obj->key_cvlan_eth_type); + if (obj->_present.key_enc_ip_tos) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ENC_IP_TOS, obj->key_enc_ip_tos); + if (obj->_present.key_enc_ip_tos_mask) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ENC_IP_TOS_MASK, obj->key_enc_ip_tos_mask); + if (obj->_present.key_enc_ip_ttl) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ENC_IP_TTL, obj->key_enc_ip_ttl); + if (obj->_present.key_enc_ip_ttl_mask) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_ENC_IP_TTL_MASK, obj->key_enc_ip_ttl_mask); + if (obj->_present.key_enc_opts) + tc_flower_key_enc_opts_attrs_put(nlh, TCA_FLOWER_KEY_ENC_OPTS, &obj->key_enc_opts); + if (obj->_present.key_enc_opts_mask) + tc_flower_key_enc_opts_attrs_put(nlh, TCA_FLOWER_KEY_ENC_OPTS_MASK, &obj->key_enc_opts_mask); + if (obj->_present.in_hw_count) + ynl_attr_put_u32(nlh, TCA_FLOWER_IN_HW_COUNT, obj->in_hw_count); + if (obj->_present.key_port_src_min) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_PORT_SRC_MIN, obj->key_port_src_min); + if (obj->_present.key_port_src_max) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_PORT_SRC_MAX, obj->key_port_src_max); + if (obj->_present.key_port_dst_min) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_PORT_DST_MIN, obj->key_port_dst_min); + if (obj->_present.key_port_dst_max) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_PORT_DST_MAX, obj->key_port_dst_max); + if (obj->_present.key_ct_state) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_CT_STATE, obj->key_ct_state); + if (obj->_present.key_ct_state_mask) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_CT_STATE_MASK, obj->key_ct_state_mask); + if (obj->_present.key_ct_zone) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_CT_ZONE, obj->key_ct_zone); + if (obj->_present.key_ct_zone_mask) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_CT_ZONE_MASK, obj->key_ct_zone_mask); + if (obj->_present.key_ct_mark) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_CT_MARK, obj->key_ct_mark); + if (obj->_present.key_ct_mark_mask) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_CT_MARK_MASK, obj->key_ct_mark_mask); + if (obj->_len.key_ct_labels) + ynl_attr_put(nlh, TCA_FLOWER_KEY_CT_LABELS, obj->key_ct_labels, obj->_len.key_ct_labels); + if (obj->_len.key_ct_labels_mask) + ynl_attr_put(nlh, TCA_FLOWER_KEY_CT_LABELS_MASK, obj->key_ct_labels_mask, obj->_len.key_ct_labels_mask); + if (obj->_present.key_mpls_opts) + tc_flower_key_mpls_opt_attrs_put(nlh, TCA_FLOWER_KEY_MPLS_OPTS, &obj->key_mpls_opts); + if (obj->_present.key_hash) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_HASH, obj->key_hash); + if (obj->_present.key_hash_mask) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_HASH_MASK, obj->key_hash_mask); + if (obj->_present.key_num_of_vlans) + ynl_attr_put_u8(nlh, TCA_FLOWER_KEY_NUM_OF_VLANS, obj->key_num_of_vlans); + if (obj->_present.key_pppoe_sid) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_PPPOE_SID, obj->key_pppoe_sid); + if (obj->_present.key_ppp_proto) + ynl_attr_put_u16(nlh, TCA_FLOWER_KEY_PPP_PROTO, obj->key_ppp_proto); + if (obj->_present.key_l2tpv3_sid) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_L2TPV3_SID, obj->key_l2tpv3_sid); + if (obj->_present.l2_miss) + ynl_attr_put_u8(nlh, TCA_FLOWER_L2_MISS, obj->l2_miss); + if (obj->_present.key_cfm) + tc_flower_key_cfm_attrs_put(nlh, TCA_FLOWER_KEY_CFM, &obj->key_cfm); + if (obj->_present.key_spi) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_SPI, obj->key_spi); + if (obj->_present.key_spi_mask) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_SPI_MASK, obj->key_spi_mask); + if (obj->_present.key_enc_flags) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_ENC_FLAGS, obj->key_enc_flags); + if (obj->_present.key_enc_flags_mask) + ynl_attr_put_u32(nlh, TCA_FLOWER_KEY_ENC_FLAGS_MASK, obj->key_enc_flags_mask); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_flower_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_flower_attrs *dst = yarg->data; + const struct nlattr *attr_act; + const struct nlattr *attr; + struct ynl_parse_arg parg; + unsigned int n_act = 0; + int i; + + parg.ys = yarg->ys; + + if (dst->act) + return ynl_error_parse(yarg, "attribute already present (flower-attrs.act)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_FLOWER_CLASSID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.classid = 1; + dst->classid = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_INDEV) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = strnlen(ynl_attr_get_str(attr), ynl_attr_data_len(attr)); + dst->_len.indev = len; + dst->indev = malloc(len + 1); + memcpy(dst->indev, ynl_attr_get_str(attr), len); + dst->indev[len] = 0; + } else if (type == TCA_FLOWER_ACT) { + const struct nlattr *attr2; + + attr_act = attr; + ynl_attr_for_each_nested(attr2, attr) { + if (ynl_attr_validate(yarg, attr2)) + return YNL_PARSE_CB_ERROR; + dst->_count.act++; + } + } else if (type == TCA_FLOWER_KEY_ETH_DST) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_eth_dst = len; + dst->key_eth_dst = malloc(len); + memcpy(dst->key_eth_dst, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_ETH_DST_MASK) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_eth_dst_mask = len; + dst->key_eth_dst_mask = malloc(len); + memcpy(dst->key_eth_dst_mask, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_ETH_SRC) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_eth_src = len; + dst->key_eth_src = malloc(len); + memcpy(dst->key_eth_src, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_ETH_SRC_MASK) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_eth_src_mask = len; + dst->key_eth_src_mask = malloc(len); + memcpy(dst->key_eth_src_mask, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_ETH_TYPE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_eth_type = 1; + dst->key_eth_type = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_IP_PROTO) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ip_proto = 1; + dst->key_ip_proto = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_IPV4_SRC) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ipv4_src = 1; + dst->key_ipv4_src = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_IPV4_SRC_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ipv4_src_mask = 1; + dst->key_ipv4_src_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_IPV4_DST) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ipv4_dst = 1; + dst->key_ipv4_dst = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_IPV4_DST_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ipv4_dst_mask = 1; + dst->key_ipv4_dst_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_IPV6_SRC) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_ipv6_src = len; + dst->key_ipv6_src = malloc(len); + memcpy(dst->key_ipv6_src, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_IPV6_SRC_MASK) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_ipv6_src_mask = len; + dst->key_ipv6_src_mask = malloc(len); + memcpy(dst->key_ipv6_src_mask, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_IPV6_DST) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_ipv6_dst = len; + dst->key_ipv6_dst = malloc(len); + memcpy(dst->key_ipv6_dst, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_IPV6_DST_MASK) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_ipv6_dst_mask = len; + dst->key_ipv6_dst_mask = malloc(len); + memcpy(dst->key_ipv6_dst_mask, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_TCP_SRC) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_tcp_src = 1; + dst->key_tcp_src = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_TCP_DST) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_tcp_dst = 1; + dst->key_tcp_dst = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_UDP_SRC) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_udp_src = 1; + dst->key_udp_src = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_UDP_DST) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_udp_dst = 1; + dst->key_udp_dst = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_FLAGS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flags = 1; + dst->flags = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_VLAN_ID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_vlan_id = 1; + dst->key_vlan_id = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_VLAN_PRIO) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_vlan_prio = 1; + dst->key_vlan_prio = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_VLAN_ETH_TYPE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_vlan_eth_type = 1; + dst->key_vlan_eth_type = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_ENC_KEY_ID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_key_id = 1; + dst->key_enc_key_id = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_ENC_IPV4_SRC) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_ipv4_src = 1; + dst->key_enc_ipv4_src = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_ENC_IPV4_SRC_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_ipv4_src_mask = 1; + dst->key_enc_ipv4_src_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_ENC_IPV4_DST) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_ipv4_dst = 1; + dst->key_enc_ipv4_dst = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_ENC_IPV4_DST_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_ipv4_dst_mask = 1; + dst->key_enc_ipv4_dst_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_ENC_IPV6_SRC) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_enc_ipv6_src = len; + dst->key_enc_ipv6_src = malloc(len); + memcpy(dst->key_enc_ipv6_src, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_ENC_IPV6_SRC_MASK) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_enc_ipv6_src_mask = len; + dst->key_enc_ipv6_src_mask = malloc(len); + memcpy(dst->key_enc_ipv6_src_mask, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_ENC_IPV6_DST) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_enc_ipv6_dst = len; + dst->key_enc_ipv6_dst = malloc(len); + memcpy(dst->key_enc_ipv6_dst, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_ENC_IPV6_DST_MASK) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_enc_ipv6_dst_mask = len; + dst->key_enc_ipv6_dst_mask = malloc(len); + memcpy(dst->key_enc_ipv6_dst_mask, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_TCP_SRC_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_tcp_src_mask = 1; + dst->key_tcp_src_mask = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_TCP_DST_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_tcp_dst_mask = 1; + dst->key_tcp_dst_mask = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_UDP_SRC_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_udp_src_mask = 1; + dst->key_udp_src_mask = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_UDP_DST_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_udp_dst_mask = 1; + dst->key_udp_dst_mask = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_SCTP_SRC_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_sctp_src_mask = 1; + dst->key_sctp_src_mask = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_SCTP_DST_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_sctp_dst_mask = 1; + dst->key_sctp_dst_mask = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_SCTP_SRC) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_sctp_src = 1; + dst->key_sctp_src = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_SCTP_DST) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_sctp_dst = 1; + dst->key_sctp_dst = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_ENC_UDP_SRC_PORT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_udp_src_port = 1; + dst->key_enc_udp_src_port = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_udp_src_port_mask = 1; + dst->key_enc_udp_src_port_mask = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_ENC_UDP_DST_PORT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_udp_dst_port = 1; + dst->key_enc_udp_dst_port = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_udp_dst_port_mask = 1; + dst->key_enc_udp_dst_port_mask = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_FLAGS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_flags = 1; + dst->key_flags = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_FLAGS_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_flags_mask = 1; + dst->key_flags_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_ICMPV4_CODE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_icmpv4_code = 1; + dst->key_icmpv4_code = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ICMPV4_CODE_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_icmpv4_code_mask = 1; + dst->key_icmpv4_code_mask = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ICMPV4_TYPE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_icmpv4_type = 1; + dst->key_icmpv4_type = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ICMPV4_TYPE_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_icmpv4_type_mask = 1; + dst->key_icmpv4_type_mask = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ICMPV6_CODE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_icmpv6_code = 1; + dst->key_icmpv6_code = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ICMPV6_CODE_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_icmpv6_code_mask = 1; + dst->key_icmpv6_code_mask = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ICMPV6_TYPE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_icmpv6_type = 1; + dst->key_icmpv6_type = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ICMPV6_TYPE_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_icmpv6_type_mask = 1; + dst->key_icmpv6_type_mask = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ARP_SIP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_arp_sip = 1; + dst->key_arp_sip = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_ARP_SIP_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_arp_sip_mask = 1; + dst->key_arp_sip_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_ARP_TIP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_arp_tip = 1; + dst->key_arp_tip = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_ARP_TIP_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_arp_tip_mask = 1; + dst->key_arp_tip_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_ARP_OP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_arp_op = 1; + dst->key_arp_op = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ARP_OP_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_arp_op_mask = 1; + dst->key_arp_op_mask = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ARP_SHA) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_arp_sha = len; + dst->key_arp_sha = malloc(len); + memcpy(dst->key_arp_sha, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_ARP_SHA_MASK) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_arp_sha_mask = len; + dst->key_arp_sha_mask = malloc(len); + memcpy(dst->key_arp_sha_mask, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_ARP_THA) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_arp_tha = len; + dst->key_arp_tha = malloc(len); + memcpy(dst->key_arp_tha, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_ARP_THA_MASK) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_arp_tha_mask = len; + dst->key_arp_tha_mask = malloc(len); + memcpy(dst->key_arp_tha_mask, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_MPLS_TTL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_mpls_ttl = 1; + dst->key_mpls_ttl = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_MPLS_BOS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_mpls_bos = 1; + dst->key_mpls_bos = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_MPLS_TC) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_mpls_tc = 1; + dst->key_mpls_tc = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_MPLS_LABEL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_mpls_label = 1; + dst->key_mpls_label = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_TCP_FLAGS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_tcp_flags = 1; + dst->key_tcp_flags = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_TCP_FLAGS_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_tcp_flags_mask = 1; + dst->key_tcp_flags_mask = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_IP_TOS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ip_tos = 1; + dst->key_ip_tos = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_IP_TOS_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ip_tos_mask = 1; + dst->key_ip_tos_mask = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_IP_TTL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ip_ttl = 1; + dst->key_ip_ttl = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_IP_TTL_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ip_ttl_mask = 1; + dst->key_ip_ttl_mask = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_CVLAN_ID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_cvlan_id = 1; + dst->key_cvlan_id = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_CVLAN_PRIO) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_cvlan_prio = 1; + dst->key_cvlan_prio = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_CVLAN_ETH_TYPE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_cvlan_eth_type = 1; + dst->key_cvlan_eth_type = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_ENC_IP_TOS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_ip_tos = 1; + dst->key_enc_ip_tos = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ENC_IP_TOS_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_ip_tos_mask = 1; + dst->key_enc_ip_tos_mask = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ENC_IP_TTL) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_ip_ttl = 1; + dst->key_enc_ip_ttl = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ENC_IP_TTL_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_ip_ttl_mask = 1; + dst->key_enc_ip_ttl_mask = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_ENC_OPTS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_opts = 1; + + parg.rsp_policy = &tc_flower_key_enc_opts_attrs_nest; + parg.data = &dst->key_enc_opts; + if (tc_flower_key_enc_opts_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_FLOWER_KEY_ENC_OPTS_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_opts_mask = 1; + + parg.rsp_policy = &tc_flower_key_enc_opts_attrs_nest; + parg.data = &dst->key_enc_opts_mask; + if (tc_flower_key_enc_opts_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_FLOWER_IN_HW_COUNT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.in_hw_count = 1; + dst->in_hw_count = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_PORT_SRC_MIN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_port_src_min = 1; + dst->key_port_src_min = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_PORT_SRC_MAX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_port_src_max = 1; + dst->key_port_src_max = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_PORT_DST_MIN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_port_dst_min = 1; + dst->key_port_dst_min = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_PORT_DST_MAX) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_port_dst_max = 1; + dst->key_port_dst_max = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_CT_STATE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ct_state = 1; + dst->key_ct_state = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_CT_STATE_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ct_state_mask = 1; + dst->key_ct_state_mask = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_CT_ZONE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ct_zone = 1; + dst->key_ct_zone = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_CT_ZONE_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ct_zone_mask = 1; + dst->key_ct_zone_mask = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_CT_MARK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ct_mark = 1; + dst->key_ct_mark = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_CT_MARK_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ct_mark_mask = 1; + dst->key_ct_mark_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_CT_LABELS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_ct_labels = len; + dst->key_ct_labels = malloc(len); + memcpy(dst->key_ct_labels, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_CT_LABELS_MASK) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.key_ct_labels_mask = len; + dst->key_ct_labels_mask = malloc(len); + memcpy(dst->key_ct_labels_mask, ynl_attr_data(attr), len); + } else if (type == TCA_FLOWER_KEY_MPLS_OPTS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_mpls_opts = 1; + + parg.rsp_policy = &tc_flower_key_mpls_opt_attrs_nest; + parg.data = &dst->key_mpls_opts; + if (tc_flower_key_mpls_opt_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_FLOWER_KEY_HASH) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_hash = 1; + dst->key_hash = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_HASH_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_hash_mask = 1; + dst->key_hash_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_NUM_OF_VLANS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_num_of_vlans = 1; + dst->key_num_of_vlans = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_PPPOE_SID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_pppoe_sid = 1; + dst->key_pppoe_sid = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_PPP_PROTO) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_ppp_proto = 1; + dst->key_ppp_proto = ynl_attr_get_u16(attr); + } else if (type == TCA_FLOWER_KEY_L2TPV3_SID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_l2tpv3_sid = 1; + dst->key_l2tpv3_sid = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_L2_MISS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.l2_miss = 1; + dst->l2_miss = ynl_attr_get_u8(attr); + } else if (type == TCA_FLOWER_KEY_CFM) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_cfm = 1; + + parg.rsp_policy = &tc_flower_key_cfm_attrs_nest; + parg.data = &dst->key_cfm; + if (tc_flower_key_cfm_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_FLOWER_KEY_SPI) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_spi = 1; + dst->key_spi = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_SPI_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_spi_mask = 1; + dst->key_spi_mask = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_ENC_FLAGS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_flags = 1; + dst->key_enc_flags = ynl_attr_get_u32(attr); + } else if (type == TCA_FLOWER_KEY_ENC_FLAGS_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.key_enc_flags_mask = 1; + dst->key_enc_flags_mask = ynl_attr_get_u32(attr); + } + } + + if (n_act) { + dst->act = calloc(n_act, sizeof(*dst->act)); + dst->_count.act = n_act; + i = 0; + parg.rsp_policy = &tc_act_attrs_nest; + ynl_attr_for_each_nested(attr, attr_act) { + parg.data = &dst->act[i]; + if (tc_act_attrs_parse(&parg, attr, ynl_attr_type(attr))) + return YNL_PARSE_CB_ERROR; + i++; + } + } + + return 0; +} + +void tc_fw_attrs_free(struct tc_fw_attrs *obj) +{ + tc_police_attrs_free(&obj->police); + free(obj->indev); + free(obj->act); +} + +int tc_fw_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_fw_attrs *obj) +{ + struct nlattr *array; + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.classid) + ynl_attr_put_u32(nlh, TCA_FW_CLASSID, obj->classid); + if (obj->_present.police) + tc_police_attrs_put(nlh, TCA_FW_POLICE, &obj->police); + if (obj->_len.indev) + ynl_attr_put_str(nlh, TCA_FW_INDEV, obj->indev); + array = ynl_attr_nest_start(nlh, TCA_FW_ACT); + for (i = 0; i < obj->_count.act; i++) + tc_act_attrs_put(nlh, i, &obj->act[i]); + ynl_attr_nest_end(nlh, array); + if (obj->_present.mask) + ynl_attr_put_u32(nlh, TCA_FW_MASK, obj->mask); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_fw_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) +{ + struct tc_fw_attrs *dst = yarg->data; + const struct nlattr *attr_act; + const struct nlattr *attr; + struct ynl_parse_arg parg; + unsigned int n_act = 0; + int i; + + parg.ys = yarg->ys; + + if (dst->act) + return ynl_error_parse(yarg, "attribute already present (fw-attrs.act)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_FW_CLASSID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.classid = 1; + dst->classid = ynl_attr_get_u32(attr); + } else if (type == TCA_FW_POLICE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.police = 1; + + parg.rsp_policy = &tc_police_attrs_nest; + parg.data = &dst->police; + if (tc_police_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_FW_INDEV) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = strnlen(ynl_attr_get_str(attr), ynl_attr_data_len(attr)); + dst->_len.indev = len; + dst->indev = malloc(len + 1); + memcpy(dst->indev, ynl_attr_get_str(attr), len); + dst->indev[len] = 0; + } else if (type == TCA_FW_ACT) { + const struct nlattr *attr2; + + attr_act = attr; + ynl_attr_for_each_nested(attr2, attr) { + if (ynl_attr_validate(yarg, attr2)) + return YNL_PARSE_CB_ERROR; + dst->_count.act++; + } + } else if (type == TCA_FW_MASK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.mask = 1; + dst->mask = ynl_attr_get_u32(attr); + } + } + + if (n_act) { + dst->act = calloc(n_act, sizeof(*dst->act)); + dst->_count.act = n_act; + i = 0; + parg.rsp_policy = &tc_act_attrs_nest; + ynl_attr_for_each_nested(attr, attr_act) { + parg.data = &dst->act[i]; + if (tc_act_attrs_parse(&parg, attr, ynl_attr_type(attr))) + return YNL_PARSE_CB_ERROR; + i++; + } + } + + return 0; +} + +void tc_matchall_attrs_free(struct tc_matchall_attrs *obj) +{ + free(obj->act); + free(obj->pcnt); +} + +int tc_matchall_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_matchall_attrs *obj) +{ + struct nlattr *array; + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.classid) + ynl_attr_put_u32(nlh, TCA_MATCHALL_CLASSID, obj->classid); + array = ynl_attr_nest_start(nlh, TCA_MATCHALL_ACT); + for (i = 0; i < obj->_count.act; i++) + tc_act_attrs_put(nlh, i, &obj->act[i]); + ynl_attr_nest_end(nlh, array); + if (obj->_present.flags) + ynl_attr_put_u32(nlh, TCA_MATCHALL_FLAGS, obj->flags); + if (obj->_len.pcnt) + ynl_attr_put(nlh, TCA_MATCHALL_PCNT, obj->pcnt, obj->_len.pcnt); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_matchall_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_matchall_attrs *dst = yarg->data; + const struct nlattr *attr_act; + const struct nlattr *attr; + struct ynl_parse_arg parg; + unsigned int n_act = 0; + int i; + + parg.ys = yarg->ys; + + if (dst->act) + return ynl_error_parse(yarg, "attribute already present (matchall-attrs.act)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_MATCHALL_CLASSID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.classid = 1; + dst->classid = ynl_attr_get_u32(attr); + } else if (type == TCA_MATCHALL_ACT) { + const struct nlattr *attr2; + + attr_act = attr; + ynl_attr_for_each_nested(attr2, attr) { + if (ynl_attr_validate(yarg, attr2)) + return YNL_PARSE_CB_ERROR; + dst->_count.act++; + } + } else if (type == TCA_MATCHALL_FLAGS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flags = 1; + dst->flags = ynl_attr_get_u32(attr); + } else if (type == TCA_MATCHALL_PCNT) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.pcnt = len; + if (len < sizeof(struct tc_matchall_pcnt)) + dst->pcnt = calloc(1, sizeof(struct tc_matchall_pcnt)); + else + dst->pcnt = malloc(len); + memcpy(dst->pcnt, ynl_attr_data(attr), len); + } + } + + if (n_act) { + dst->act = calloc(n_act, sizeof(*dst->act)); + dst->_count.act = n_act; + i = 0; + parg.rsp_policy = &tc_act_attrs_nest; + ynl_attr_for_each_nested(attr, attr_act) { + parg.data = &dst->act[i]; + if (tc_act_attrs_parse(&parg, attr, ynl_attr_type(attr))) + return YNL_PARSE_CB_ERROR; + i++; + } + } + + return 0; +} + +void tc_route_attrs_free(struct tc_route_attrs *obj) +{ + tc_police_attrs_free(&obj->police); + free(obj->act); +} + +int tc_route_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_route_attrs *obj) +{ + struct nlattr *array; + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.classid) + ynl_attr_put_u32(nlh, TCA_ROUTE4_CLASSID, obj->classid); + if (obj->_present.to) + ynl_attr_put_u32(nlh, TCA_ROUTE4_TO, obj->to); + if (obj->_present.from) + ynl_attr_put_u32(nlh, TCA_ROUTE4_FROM, obj->from); + if (obj->_present.iif) + ynl_attr_put_u32(nlh, TCA_ROUTE4_IIF, obj->iif); + if (obj->_present.police) + tc_police_attrs_put(nlh, TCA_ROUTE4_POLICE, &obj->police); + array = ynl_attr_nest_start(nlh, TCA_ROUTE4_ACT); + for (i = 0; i < obj->_count.act; i++) + tc_act_attrs_put(nlh, i, &obj->act[i]); + ynl_attr_nest_end(nlh, array); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_route_attrs_parse(struct ynl_parse_arg *yarg, + const struct nlattr *nested) +{ + struct tc_route_attrs *dst = yarg->data; + const struct nlattr *attr_act; + const struct nlattr *attr; + struct ynl_parse_arg parg; + unsigned int n_act = 0; + int i; + + parg.ys = yarg->ys; + + if (dst->act) + return ynl_error_parse(yarg, "attribute already present (route-attrs.act)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_ROUTE4_CLASSID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.classid = 1; + dst->classid = ynl_attr_get_u32(attr); + } else if (type == TCA_ROUTE4_TO) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.to = 1; + dst->to = ynl_attr_get_u32(attr); + } else if (type == TCA_ROUTE4_FROM) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.from = 1; + dst->from = ynl_attr_get_u32(attr); + } else if (type == TCA_ROUTE4_IIF) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.iif = 1; + dst->iif = ynl_attr_get_u32(attr); + } else if (type == TCA_ROUTE4_POLICE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.police = 1; + + parg.rsp_policy = &tc_police_attrs_nest; + parg.data = &dst->police; + if (tc_police_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_ROUTE4_ACT) { + const struct nlattr *attr2; + + attr_act = attr; + ynl_attr_for_each_nested(attr2, attr) { + if (ynl_attr_validate(yarg, attr2)) + return YNL_PARSE_CB_ERROR; + dst->_count.act++; + } + } + } + + if (n_act) { + dst->act = calloc(n_act, sizeof(*dst->act)); + dst->_count.act = n_act; + i = 0; + parg.rsp_policy = &tc_act_attrs_nest; + ynl_attr_for_each_nested(attr, attr_act) { + parg.data = &dst->act[i]; + if (tc_act_attrs_parse(&parg, attr, ynl_attr_type(attr))) + return YNL_PARSE_CB_ERROR; + i++; + } + } + + return 0; +} + +void tc_u32_attrs_free(struct tc_u32_attrs *obj) +{ + free(obj->sel); + tc_police_attrs_free(&obj->police); + free(obj->act); + free(obj->indev); + free(obj->pcnt); + free(obj->mark); +} + +int tc_u32_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_u32_attrs *obj) +{ + struct nlattr *array; + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.classid) + ynl_attr_put_u32(nlh, TCA_U32_CLASSID, obj->classid); + if (obj->_present.hash) + ynl_attr_put_u32(nlh, TCA_U32_HASH, obj->hash); + if (obj->_present.link) + ynl_attr_put_u32(nlh, TCA_U32_LINK, obj->link); + if (obj->_present.divisor) + ynl_attr_put_u32(nlh, TCA_U32_DIVISOR, obj->divisor); + if (obj->_len.sel) + ynl_attr_put(nlh, TCA_U32_SEL, obj->sel, obj->_len.sel); + if (obj->_present.police) + tc_police_attrs_put(nlh, TCA_U32_POLICE, &obj->police); + array = ynl_attr_nest_start(nlh, TCA_U32_ACT); + for (i = 0; i < obj->_count.act; i++) + tc_act_attrs_put(nlh, i, &obj->act[i]); + ynl_attr_nest_end(nlh, array); + if (obj->_len.indev) + ynl_attr_put_str(nlh, TCA_U32_INDEV, obj->indev); + if (obj->_len.pcnt) + ynl_attr_put(nlh, TCA_U32_PCNT, obj->pcnt, obj->_len.pcnt); + if (obj->_len.mark) + ynl_attr_put(nlh, TCA_U32_MARK, obj->mark, obj->_len.mark); + if (obj->_present.flags) + ynl_attr_put_u32(nlh, TCA_U32_FLAGS, obj->flags); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_u32_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) +{ + struct tc_u32_attrs *dst = yarg->data; + const struct nlattr *attr_act; + const struct nlattr *attr; + struct ynl_parse_arg parg; + unsigned int n_act = 0; + int i; + + parg.ys = yarg->ys; + + if (dst->act) + return ynl_error_parse(yarg, "attribute already present (u32-attrs.act)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_U32_CLASSID) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.classid = 1; + dst->classid = ynl_attr_get_u32(attr); + } else if (type == TCA_U32_HASH) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.hash = 1; + dst->hash = ynl_attr_get_u32(attr); + } else if (type == TCA_U32_LINK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.link = 1; + dst->link = ynl_attr_get_u32(attr); + } else if (type == TCA_U32_DIVISOR) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.divisor = 1; + dst->divisor = ynl_attr_get_u32(attr); + } else if (type == TCA_U32_SEL) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.sel = len; + if (len < sizeof(struct tc_u32_sel)) + dst->sel = calloc(1, sizeof(struct tc_u32_sel)); + else + dst->sel = malloc(len); + memcpy(dst->sel, ynl_attr_data(attr), len); + } else if (type == TCA_U32_POLICE) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.police = 1; + + parg.rsp_policy = &tc_police_attrs_nest; + parg.data = &dst->police; + if (tc_police_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_U32_ACT) { + const struct nlattr *attr2; + + attr_act = attr; + ynl_attr_for_each_nested(attr2, attr) { + if (ynl_attr_validate(yarg, attr2)) + return YNL_PARSE_CB_ERROR; + dst->_count.act++; + } + } else if (type == TCA_U32_INDEV) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = strnlen(ynl_attr_get_str(attr), ynl_attr_data_len(attr)); + dst->_len.indev = len; + dst->indev = malloc(len + 1); + memcpy(dst->indev, ynl_attr_get_str(attr), len); + dst->indev[len] = 0; + } else if (type == TCA_U32_PCNT) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.pcnt = len; + if (len < sizeof(struct tc_u32_pcnt)) + dst->pcnt = calloc(1, sizeof(struct tc_u32_pcnt)); + else + dst->pcnt = malloc(len); + memcpy(dst->pcnt, ynl_attr_data(attr), len); + } else if (type == TCA_U32_MARK) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.mark = len; + if (len < sizeof(struct tc_u32_mark)) + dst->mark = calloc(1, sizeof(struct tc_u32_mark)); + else + dst->mark = malloc(len); + memcpy(dst->mark, ynl_attr_data(attr), len); + } else if (type == TCA_U32_FLAGS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flags = 1; + dst->flags = ynl_attr_get_u32(attr); + } + } + + if (n_act) { + dst->act = calloc(n_act, sizeof(*dst->act)); + dst->_count.act = n_act; + i = 0; + parg.rsp_policy = &tc_act_attrs_nest; + ynl_attr_for_each_nested(attr, attr_act) { + parg.data = &dst->act[i]; + if (tc_act_attrs_parse(&parg, attr, ynl_attr_type(attr))) + return YNL_PARSE_CB_ERROR; + i++; + } + } + + return 0; +} + +void tc_ets_attrs_free(struct tc_ets_attrs *obj) +{ + if (obj->quanta) + tc_ets_attrs_free(obj->quanta); + free(obj->quanta_band); + if (obj->priomap) + tc_ets_attrs_free(obj->priomap); + free(obj->priomap_band); +} + +int tc_ets_attrs_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_ets_attrs *obj) +{ + struct nlattr *nest; + unsigned int i; + + nest = ynl_attr_nest_start(nlh, attr_type); + if (obj->_present.nbands) + ynl_attr_put_u8(nlh, TCA_ETS_NBANDS, obj->nbands); + if (obj->_present.nstrict) + ynl_attr_put_u8(nlh, TCA_ETS_NSTRICT, obj->nstrict); + if (obj->_present.quanta) + tc_ets_attrs_put(nlh, TCA_ETS_QUANTA, obj->quanta); + for (i = 0; i < obj->_count.quanta_band; i++) + ynl_attr_put_u32(nlh, TCA_ETS_QUANTA_BAND, obj->quanta_band[i]); + if (obj->_present.priomap) + tc_ets_attrs_put(nlh, TCA_ETS_PRIOMAP, obj->priomap); + for (i = 0; i < obj->_count.priomap_band; i++) + ynl_attr_put_u8(nlh, TCA_ETS_PRIOMAP_BAND, obj->priomap_band[i]); + ynl_attr_nest_end(nlh, nest); + + return 0; +} + +int tc_ets_attrs_parse(struct ynl_parse_arg *yarg, const struct nlattr *nested) +{ + struct tc_ets_attrs *dst = yarg->data; + unsigned int n_priomap_band = 0; + unsigned int n_quanta_band = 0; + const struct nlattr *attr; + struct ynl_parse_arg parg; + int i; + + parg.ys = yarg->ys; + + if (dst->priomap_band) + return ynl_error_parse(yarg, "attribute already present (ets-attrs.priomap-band)"); + if (dst->quanta_band) + return ynl_error_parse(yarg, "attribute already present (ets-attrs.quanta-band)"); + + ynl_attr_for_each_nested(attr, nested) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_ETS_NBANDS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.nbands = 1; + dst->nbands = ynl_attr_get_u8(attr); + } else if (type == TCA_ETS_NSTRICT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.nstrict = 1; + dst->nstrict = ynl_attr_get_u8(attr); + } else if (type == TCA_ETS_QUANTA) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.quanta = 1; + + parg.rsp_policy = &tc_ets_attrs_nest; + parg.data = &dst->quanta; + if (tc_ets_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_ETS_QUANTA_BAND) { + n_quanta_band++; + } else if (type == TCA_ETS_PRIOMAP) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.priomap = 1; + + parg.rsp_policy = &tc_ets_attrs_nest; + parg.data = &dst->priomap; + if (tc_ets_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_ETS_PRIOMAP_BAND) { + n_priomap_band++; + } + } + + if (n_priomap_band) { + dst->priomap_band = calloc(n_priomap_band, sizeof(*dst->priomap_band)); + dst->_count.priomap_band = n_priomap_band; + i = 0; + ynl_attr_for_each_nested(attr, nested) { + if (ynl_attr_type(attr) == TCA_ETS_PRIOMAP_BAND) { + dst->priomap_band[i] = ynl_attr_get_u8(attr); + i++; + } + } + } + if (n_quanta_band) { + dst->quanta_band = calloc(n_quanta_band, sizeof(*dst->quanta_band)); + dst->_count.quanta_band = n_quanta_band; + i = 0; + ynl_attr_for_each_nested(attr, nested) { + if (ynl_attr_type(attr) == TCA_ETS_QUANTA_BAND) { + dst->quanta_band[i] = ynl_attr_get_u32(attr); + i++; + } + } + } + + return 0; +} + +void tc_options_msg_free(struct tc_options_msg *obj) +{ + tc_basic_attrs_free(&obj->basic); + tc_bpf_attrs_free(&obj->bpf); + free(obj->bfifo); + tc_cake_attrs_free(&obj->cake); + tc_cbs_attrs_free(&obj->cbs); + tc_cgroup_attrs_free(&obj->cgroup); + tc_choke_attrs_free(&obj->choke); + tc_codel_attrs_free(&obj->codel); + tc_drr_attrs_free(&obj->drr); + tc_etf_attrs_free(&obj->etf); + if (obj->ets) + tc_ets_attrs_free(obj->ets); + tc_flow_attrs_free(&obj->flow); + tc_flower_attrs_free(&obj->flower); + tc_fq_attrs_free(&obj->fq); + tc_fq_codel_attrs_free(&obj->fq_codel); + tc_fq_pie_attrs_free(&obj->fq_pie); + tc_fw_attrs_free(&obj->fw); + tc_gred_attrs_free(&obj->gred); + free(obj->hfsc); + tc_hhf_attrs_free(&obj->hhf); + tc_htb_attrs_free(&obj->htb); + tc_matchall_attrs_free(&obj->matchall); + free(obj->mqprio); + free(obj->multiq); + tc_netem_attrs_free(&obj->netem); + free(obj->pfifo); + free(obj->pfifo_fast); + free(obj->pfifo_head_drop); + tc_pie_attrs_free(&obj->pie); + free(obj->plug); + free(obj->prio); + tc_qfq_attrs_free(&obj->qfq); + tc_red_attrs_free(&obj->red); + tc_route_attrs_free(&obj->route); + free(obj->sfb); + free(obj->sfq); + tc_taprio_attrs_free(&obj->taprio); + tc_tbf_attrs_free(&obj->tbf); + tc_u32_attrs_free(&obj->u32); +} + +int tc_options_msg_put(struct nlmsghdr *nlh, unsigned int attr_type, + struct tc_options_msg *obj) +{ + if (obj->_present.basic) + tc_basic_attrs_put(nlh, TCA_OPTIONS, &obj->basic); + if (obj->_present.bpf) + tc_bpf_attrs_put(nlh, TCA_OPTIONS, &obj->bpf); + if (obj->_len.bfifo) + ynl_attr_put(nlh, TCA_OPTIONS, obj->bfifo, obj->_len.bfifo); + if (obj->_present.cake) + tc_cake_attrs_put(nlh, TCA_OPTIONS, &obj->cake); + if (obj->_present.cbs) + tc_cbs_attrs_put(nlh, TCA_OPTIONS, &obj->cbs); + if (obj->_present.cgroup) + tc_cgroup_attrs_put(nlh, TCA_OPTIONS, &obj->cgroup); + if (obj->_present.choke) + tc_choke_attrs_put(nlh, TCA_OPTIONS, &obj->choke); + if (obj->_present.clsact) + ynl_attr_put(nlh, TCA_OPTIONS, NULL, 0); + if (obj->_present.codel) + tc_codel_attrs_put(nlh, TCA_OPTIONS, &obj->codel); + if (obj->_present.drr) + tc_drr_attrs_put(nlh, TCA_OPTIONS, &obj->drr); + if (obj->_present.etf) + tc_etf_attrs_put(nlh, TCA_OPTIONS, &obj->etf); + if (obj->_present.ets) + tc_ets_attrs_put(nlh, TCA_OPTIONS, obj->ets); + if (obj->_present.flow) + tc_flow_attrs_put(nlh, TCA_OPTIONS, &obj->flow); + if (obj->_present.flower) + tc_flower_attrs_put(nlh, TCA_OPTIONS, &obj->flower); + if (obj->_present.fq) + tc_fq_attrs_put(nlh, TCA_OPTIONS, &obj->fq); + if (obj->_present.fq_codel) + tc_fq_codel_attrs_put(nlh, TCA_OPTIONS, &obj->fq_codel); + if (obj->_present.fq_pie) + tc_fq_pie_attrs_put(nlh, TCA_OPTIONS, &obj->fq_pie); + if (obj->_present.fw) + tc_fw_attrs_put(nlh, TCA_OPTIONS, &obj->fw); + if (obj->_present.gred) + tc_gred_attrs_put(nlh, TCA_OPTIONS, &obj->gred); + if (obj->_len.hfsc) + ynl_attr_put(nlh, TCA_OPTIONS, obj->hfsc, obj->_len.hfsc); + if (obj->_present.hhf) + tc_hhf_attrs_put(nlh, TCA_OPTIONS, &obj->hhf); + if (obj->_present.htb) + tc_htb_attrs_put(nlh, TCA_OPTIONS, &obj->htb); + if (obj->_present.ingress) + ynl_attr_put(nlh, TCA_OPTIONS, NULL, 0); + if (obj->_present.matchall) + tc_matchall_attrs_put(nlh, TCA_OPTIONS, &obj->matchall); + if (obj->_present.mq) + ynl_attr_put(nlh, TCA_OPTIONS, NULL, 0); + if (obj->_len.mqprio) + ynl_attr_put(nlh, TCA_OPTIONS, obj->mqprio, obj->_len.mqprio); + if (obj->_len.multiq) + ynl_attr_put(nlh, TCA_OPTIONS, obj->multiq, obj->_len.multiq); + if (obj->_present.netem) + tc_netem_attrs_put(nlh, TCA_OPTIONS, &obj->netem); + if (obj->_len.pfifo) + ynl_attr_put(nlh, TCA_OPTIONS, obj->pfifo, obj->_len.pfifo); + if (obj->_len.pfifo_fast) + ynl_attr_put(nlh, TCA_OPTIONS, obj->pfifo_fast, obj->_len.pfifo_fast); + if (obj->_len.pfifo_head_drop) + ynl_attr_put(nlh, TCA_OPTIONS, obj->pfifo_head_drop, obj->_len.pfifo_head_drop); + if (obj->_present.pie) + tc_pie_attrs_put(nlh, TCA_OPTIONS, &obj->pie); + if (obj->_len.plug) + ynl_attr_put(nlh, TCA_OPTIONS, obj->plug, obj->_len.plug); + if (obj->_len.prio) + ynl_attr_put(nlh, TCA_OPTIONS, obj->prio, obj->_len.prio); + if (obj->_present.qfq) + tc_qfq_attrs_put(nlh, TCA_OPTIONS, &obj->qfq); + if (obj->_present.red) + tc_red_attrs_put(nlh, TCA_OPTIONS, &obj->red); + if (obj->_present.route) + tc_route_attrs_put(nlh, TCA_OPTIONS, &obj->route); + if (obj->_len.sfb) + ynl_attr_put(nlh, TCA_OPTIONS, obj->sfb, obj->_len.sfb); + if (obj->_len.sfq) + ynl_attr_put(nlh, TCA_OPTIONS, obj->sfq, obj->_len.sfq); + if (obj->_present.taprio) + tc_taprio_attrs_put(nlh, TCA_OPTIONS, &obj->taprio); + if (obj->_present.tbf) + tc_tbf_attrs_put(nlh, TCA_OPTIONS, &obj->tbf); + if (obj->_present.u32) + tc_u32_attrs_put(nlh, TCA_OPTIONS, &obj->u32); + + return 0; +} + +int tc_options_msg_parse(struct ynl_parse_arg *yarg, const char *sel, + const struct nlattr *nested) +{ + struct tc_options_msg *dst = yarg->data; + const struct nlattr *attr = nested; + struct ynl_parse_arg parg; + unsigned int len; + + parg.ys = yarg->ys; + + if (!strcmp(sel, "basic")) { + parg.rsp_policy = &tc_basic_attrs_nest; + parg.data = &dst->basic; + if (tc_basic_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.basic = 1; + } else if (!strcmp(sel, "bpf")) { + parg.rsp_policy = &tc_bpf_attrs_nest; + parg.data = &dst->bpf; + if (tc_bpf_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.bpf = 1; + } else if (!strcmp(sel, "bfifo")) { + len = ynl_attr_data_len(attr); + dst->_len.bfifo = len; + if (len < sizeof(struct tc_fifo_qopt)) + dst->bfifo = calloc(1, sizeof(struct tc_fifo_qopt)); + else + dst->bfifo = malloc(len); + memcpy(dst->bfifo, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "cake")) { + parg.rsp_policy = &tc_cake_attrs_nest; + parg.data = &dst->cake; + if (tc_cake_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.cake = 1; + } else if (!strcmp(sel, "cbs")) { + parg.rsp_policy = &tc_cbs_attrs_nest; + parg.data = &dst->cbs; + if (tc_cbs_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.cbs = 1; + } else if (!strcmp(sel, "cgroup")) { + parg.rsp_policy = &tc_cgroup_attrs_nest; + parg.data = &dst->cgroup; + if (tc_cgroup_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.cgroup = 1; + } else if (!strcmp(sel, "choke")) { + parg.rsp_policy = &tc_choke_attrs_nest; + parg.data = &dst->choke; + if (tc_choke_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.choke = 1; + } else if (!strcmp(sel, "clsact")) { + dst->_present.clsact = 1; + } else if (!strcmp(sel, "codel")) { + parg.rsp_policy = &tc_codel_attrs_nest; + parg.data = &dst->codel; + if (tc_codel_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.codel = 1; + } else if (!strcmp(sel, "drr")) { + parg.rsp_policy = &tc_drr_attrs_nest; + parg.data = &dst->drr; + if (tc_drr_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.drr = 1; + } else if (!strcmp(sel, "etf")) { + parg.rsp_policy = &tc_etf_attrs_nest; + parg.data = &dst->etf; + if (tc_etf_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.etf = 1; + } else if (!strcmp(sel, "ets")) { + parg.rsp_policy = &tc_ets_attrs_nest; + parg.data = &dst->ets; + if (tc_ets_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ets = 1; + } else if (!strcmp(sel, "flow")) { + parg.rsp_policy = &tc_flow_attrs_nest; + parg.data = &dst->flow; + if (tc_flow_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flow = 1; + } else if (!strcmp(sel, "flower")) { + parg.rsp_policy = &tc_flower_attrs_nest; + parg.data = &dst->flower; + if (tc_flower_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.flower = 1; + } else if (!strcmp(sel, "fq")) { + parg.rsp_policy = &tc_fq_attrs_nest; + parg.data = &dst->fq; + if (tc_fq_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.fq = 1; + } else if (!strcmp(sel, "fq_codel")) { + parg.rsp_policy = &tc_fq_codel_attrs_nest; + parg.data = &dst->fq_codel; + if (tc_fq_codel_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.fq_codel = 1; + } else if (!strcmp(sel, "fq_pie")) { + parg.rsp_policy = &tc_fq_pie_attrs_nest; + parg.data = &dst->fq_pie; + if (tc_fq_pie_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.fq_pie = 1; + } else if (!strcmp(sel, "fw")) { + parg.rsp_policy = &tc_fw_attrs_nest; + parg.data = &dst->fw; + if (tc_fw_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.fw = 1; + } else if (!strcmp(sel, "gred")) { + parg.rsp_policy = &tc_gred_attrs_nest; + parg.data = &dst->gred; + if (tc_gred_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.gred = 1; + } else if (!strcmp(sel, "hfsc")) { + len = ynl_attr_data_len(attr); + dst->_len.hfsc = len; + if (len < sizeof(struct tc_hfsc_qopt)) + dst->hfsc = calloc(1, sizeof(struct tc_hfsc_qopt)); + else + dst->hfsc = malloc(len); + memcpy(dst->hfsc, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "hhf")) { + parg.rsp_policy = &tc_hhf_attrs_nest; + parg.data = &dst->hhf; + if (tc_hhf_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.hhf = 1; + } else if (!strcmp(sel, "htb")) { + parg.rsp_policy = &tc_htb_attrs_nest; + parg.data = &dst->htb; + if (tc_htb_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.htb = 1; + } else if (!strcmp(sel, "ingress")) { + dst->_present.ingress = 1; + } else if (!strcmp(sel, "matchall")) { + parg.rsp_policy = &tc_matchall_attrs_nest; + parg.data = &dst->matchall; + if (tc_matchall_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.matchall = 1; + } else if (!strcmp(sel, "mq")) { + dst->_present.mq = 1; + } else if (!strcmp(sel, "mqprio")) { + len = ynl_attr_data_len(attr); + dst->_len.mqprio = len; + if (len < sizeof(struct tc_mqprio_qopt)) + dst->mqprio = calloc(1, sizeof(struct tc_mqprio_qopt)); + else + dst->mqprio = malloc(len); + memcpy(dst->mqprio, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "multiq")) { + len = ynl_attr_data_len(attr); + dst->_len.multiq = len; + if (len < sizeof(struct tc_multiq_qopt)) + dst->multiq = calloc(1, sizeof(struct tc_multiq_qopt)); + else + dst->multiq = malloc(len); + memcpy(dst->multiq, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "netem")) { + parg.rsp_policy = &tc_netem_attrs_nest; + parg.data = &dst->netem; + if (tc_netem_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.netem = 1; + } else if (!strcmp(sel, "pfifo")) { + len = ynl_attr_data_len(attr); + dst->_len.pfifo = len; + if (len < sizeof(struct tc_fifo_qopt)) + dst->pfifo = calloc(1, sizeof(struct tc_fifo_qopt)); + else + dst->pfifo = malloc(len); + memcpy(dst->pfifo, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "pfifo_fast")) { + len = ynl_attr_data_len(attr); + dst->_len.pfifo_fast = len; + if (len < sizeof(struct tc_prio_qopt)) + dst->pfifo_fast = calloc(1, sizeof(struct tc_prio_qopt)); + else + dst->pfifo_fast = malloc(len); + memcpy(dst->pfifo_fast, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "pfifo_head_drop")) { + len = ynl_attr_data_len(attr); + dst->_len.pfifo_head_drop = len; + if (len < sizeof(struct tc_fifo_qopt)) + dst->pfifo_head_drop = calloc(1, sizeof(struct tc_fifo_qopt)); + else + dst->pfifo_head_drop = malloc(len); + memcpy(dst->pfifo_head_drop, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "pie")) { + parg.rsp_policy = &tc_pie_attrs_nest; + parg.data = &dst->pie; + if (tc_pie_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.pie = 1; + } else if (!strcmp(sel, "plug")) { + len = ynl_attr_data_len(attr); + dst->_len.plug = len; + if (len < sizeof(struct tc_plug_qopt)) + dst->plug = calloc(1, sizeof(struct tc_plug_qopt)); + else + dst->plug = malloc(len); + memcpy(dst->plug, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "prio")) { + len = ynl_attr_data_len(attr); + dst->_len.prio = len; + if (len < sizeof(struct tc_prio_qopt)) + dst->prio = calloc(1, sizeof(struct tc_prio_qopt)); + else + dst->prio = malloc(len); + memcpy(dst->prio, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "qfq")) { + parg.rsp_policy = &tc_qfq_attrs_nest; + parg.data = &dst->qfq; + if (tc_qfq_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.qfq = 1; + } else if (!strcmp(sel, "red")) { + parg.rsp_policy = &tc_red_attrs_nest; + parg.data = &dst->red; + if (tc_red_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.red = 1; + } else if (!strcmp(sel, "route")) { + parg.rsp_policy = &tc_route_attrs_nest; + parg.data = &dst->route; + if (tc_route_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.route = 1; + } else if (!strcmp(sel, "sfb")) { + len = ynl_attr_data_len(attr); + dst->_len.sfb = len; + if (len < sizeof(struct tc_sfb_qopt)) + dst->sfb = calloc(1, sizeof(struct tc_sfb_qopt)); + else + dst->sfb = malloc(len); + memcpy(dst->sfb, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "sfq")) { + len = ynl_attr_data_len(attr); + dst->_len.sfq = len; + if (len < sizeof(struct tc_sfq_qopt_v1)) + dst->sfq = calloc(1, sizeof(struct tc_sfq_qopt_v1)); + else + dst->sfq = malloc(len); + memcpy(dst->sfq, ynl_attr_data(attr), len); + } else if (!strcmp(sel, "taprio")) { + parg.rsp_policy = &tc_taprio_attrs_nest; + parg.data = &dst->taprio; + if (tc_taprio_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.taprio = 1; + } else if (!strcmp(sel, "tbf")) { + parg.rsp_policy = &tc_tbf_attrs_nest; + parg.data = &dst->tbf; + if (tc_tbf_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.tbf = 1; + } else if (!strcmp(sel, "u32")) { + parg.rsp_policy = &tc_u32_attrs_nest; + parg.data = &dst->u32; + if (tc_u32_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.u32 = 1; + } + return 0; +} + +/* ============== RTM_NEWQDISC ============== */ +/* RTM_NEWQDISC - do */ +void tc_newqdisc_req_free(struct tc_newqdisc_req *req) +{ + free(req->kind); + tc_options_msg_free(&req->options); + free(req->rate); + free(req); +} + +int tc_newqdisc(struct ynl_sock *ys, struct tc_newqdisc_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct nlmsghdr *nlh; + size_t hdr_len; + void *hdr; + int err; + + nlh = ynl_msg_start_req(ys, RTM_NEWQDISC, req->_nlmsg_flags); + ys->req_policy = &tc_attrs_nest; + ys->req_hdr_len = sizeof(struct tcmsg); + + hdr_len = sizeof(req->_hdr); + hdr = ynl_nlmsg_put_extra_header(nlh, hdr_len); + memcpy(hdr, &req->_hdr, hdr_len); + + if (req->_len.kind) + ynl_attr_put_str(nlh, TCA_KIND, req->kind); + if (req->_present.options) + tc_options_msg_put(nlh, TCA_OPTIONS, &req->options); + if (req->_len.rate) + ynl_attr_put(nlh, TCA_RATE, req->rate, req->_len.rate); + if (req->_present.chain) + ynl_attr_put_u32(nlh, TCA_CHAIN, req->chain); + if (req->_present.ingress_block) + ynl_attr_put_u32(nlh, TCA_INGRESS_BLOCK, req->ingress_block); + if (req->_present.egress_block) + ynl_attr_put_u32(nlh, TCA_EGRESS_BLOCK, req->egress_block); + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + return -1; + + return 0; +} + +/* ============== RTM_DELQDISC ============== */ +/* RTM_DELQDISC - do */ +void tc_delqdisc_req_free(struct tc_delqdisc_req *req) +{ + free(req); +} + +int tc_delqdisc(struct ynl_sock *ys, struct tc_delqdisc_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct nlmsghdr *nlh; + size_t hdr_len; + void *hdr; + int err; + + nlh = ynl_msg_start_req(ys, RTM_DELQDISC, req->_nlmsg_flags); + ys->req_policy = &tc_attrs_nest; + ys->req_hdr_len = sizeof(struct tcmsg); + + hdr_len = sizeof(req->_hdr); + hdr = ynl_nlmsg_put_extra_header(nlh, hdr_len); + memcpy(hdr, &req->_hdr, hdr_len); + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + return -1; + + return 0; +} + +/* ============== RTM_GETQDISC ============== */ +/* RTM_GETQDISC - do */ +void tc_getqdisc_req_free(struct tc_getqdisc_req *req) +{ + free(req); +} + +void tc_getqdisc_rsp_free(struct tc_getqdisc_rsp *rsp) +{ + free(rsp->kind); + tc_options_msg_free(&rsp->options); + free(rsp->stats); + tc_tca_stats_app_msg_free(&rsp->xstats); + free(rsp->rate); + tc_tca_stats_attrs_free(&rsp->stats2); + tc_tca_stab_attrs_free(&rsp->stab); + free(rsp); +} + +int tc_getqdisc_rsp_parse(const struct nlmsghdr *nlh, + struct ynl_parse_arg *yarg) +{ + struct tc_getqdisc_rsp *dst; + const struct nlattr *attr; + struct ynl_parse_arg parg; + void *hdr; + + dst = yarg->data; + parg.ys = yarg->ys; + + hdr = ynl_nlmsg_data(nlh); + memcpy(&dst->_hdr, hdr, sizeof(struct tcmsg)); + + ynl_attr_for_each(attr, nlh, sizeof(struct tcmsg)) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_KIND) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = strnlen(ynl_attr_get_str(attr), ynl_attr_data_len(attr)); + dst->_len.kind = len; + dst->kind = malloc(len + 1); + memcpy(dst->kind, ynl_attr_get_str(attr), len); + dst->kind[len] = 0; + } else if (type == TCA_OPTIONS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.options = 1; + + parg.rsp_policy = &tc_options_msg_nest; + parg.data = &dst->options; + if (!dst->kind) + return ynl_submsg_failed(yarg, "options", "kind"); + if (tc_options_msg_parse(&parg, dst->kind, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_STATS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.stats = len; + if (len < sizeof(struct tc_stats)) + dst->stats = calloc(1, sizeof(struct tc_stats)); + else + dst->stats = malloc(len); + memcpy(dst->stats, ynl_attr_data(attr), len); + } else if (type == TCA_XSTATS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.xstats = 1; + + parg.rsp_policy = &tc_tca_stats_app_msg_nest; + parg.data = &dst->xstats; + if (!dst->kind) + return ynl_submsg_failed(yarg, "xstats", "kind"); + if (tc_tca_stats_app_msg_parse(&parg, dst->kind, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_RATE) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.rate = len; + if (len < sizeof(struct gnet_estimator)) + dst->rate = calloc(1, sizeof(struct gnet_estimator)); + else + dst->rate = malloc(len); + memcpy(dst->rate, ynl_attr_data(attr), len); + } else if (type == TCA_FCNT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.fcnt = 1; + dst->fcnt = ynl_attr_get_u32(attr); + } else if (type == TCA_STATS2) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stats2 = 1; + + parg.rsp_policy = &tc_tca_stats_attrs_nest; + parg.data = &dst->stats2; + if (tc_tca_stats_attrs_parse(&parg, attr, dst->kind)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_STAB) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stab = 1; + + parg.rsp_policy = &tc_tca_stab_attrs_nest; + parg.data = &dst->stab; + if (tc_tca_stab_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_CHAIN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.chain = 1; + dst->chain = ynl_attr_get_u32(attr); + } else if (type == TCA_INGRESS_BLOCK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ingress_block = 1; + dst->ingress_block = ynl_attr_get_u32(attr); + } else if (type == TCA_EGRESS_BLOCK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.egress_block = 1; + dst->egress_block = ynl_attr_get_u32(attr); + } + } + + return YNL_PARSE_CB_OK; +} + +struct tc_getqdisc_rsp * +tc_getqdisc(struct ynl_sock *ys, struct tc_getqdisc_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct tc_getqdisc_rsp *rsp; + struct nlmsghdr *nlh; + size_t hdr_len; + void *hdr; + int err; + + nlh = ynl_msg_start_req(ys, RTM_GETQDISC, req->_nlmsg_flags); + ys->req_policy = &tc_attrs_nest; + ys->req_hdr_len = sizeof(struct tcmsg); + yrs.yarg.rsp_policy = &tc_attrs_nest; + + hdr_len = sizeof(req->_hdr); + hdr = ynl_nlmsg_put_extra_header(nlh, hdr_len); + memcpy(hdr, &req->_hdr, hdr_len); + + if (req->_present.dump_invisible) + ynl_attr_put(nlh, TCA_DUMP_INVISIBLE, NULL, 0); + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = tc_getqdisc_rsp_parse; + yrs.rsp_cmd = 36; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + tc_getqdisc_rsp_free(rsp); + return NULL; +} + +/* RTM_GETQDISC - dump */ +void tc_getqdisc_req_dump_free(struct tc_getqdisc_req_dump *req) +{ + free(req); +} + +void tc_getqdisc_list_free(struct tc_getqdisc_list *rsp) +{ + struct tc_getqdisc_list *next = rsp; + + while ((void *)next != YNL_LIST_END) { + rsp = next; + next = rsp->next; + + free(rsp->obj.kind); + tc_options_msg_free(&rsp->obj.options); + free(rsp->obj.stats); + tc_tca_stats_app_msg_free(&rsp->obj.xstats); + free(rsp->obj.rate); + tc_tca_stats_attrs_free(&rsp->obj.stats2); + tc_tca_stab_attrs_free(&rsp->obj.stab); + free(rsp); + } +} + +struct tc_getqdisc_list * +tc_getqdisc_dump(struct ynl_sock *ys, struct tc_getqdisc_req_dump *req) +{ + struct ynl_dump_state yds = {}; + struct nlmsghdr *nlh; + size_t hdr_len; + void *hdr; + int err; + + yds.yarg.ys = ys; + yds.yarg.rsp_policy = &tc_attrs_nest; + yds.yarg.data = NULL; + yds.alloc_sz = sizeof(struct tc_getqdisc_list); + yds.cb = tc_getqdisc_rsp_parse; + yds.rsp_cmd = 36; + + nlh = ynl_msg_start_dump(ys, RTM_GETQDISC); + hdr_len = sizeof(req->_hdr); + hdr = ynl_nlmsg_put_extra_header(nlh, hdr_len); + memcpy(hdr, &req->_hdr, hdr_len); + + ys->req_policy = &tc_attrs_nest; + ys->req_hdr_len = sizeof(struct tcmsg); + + if (req->_present.dump_invisible) + ynl_attr_put(nlh, TCA_DUMP_INVISIBLE, NULL, 0); + + err = ynl_exec_dump(ys, nlh, &yds); + if (err < 0) + goto free_list; + + return yds.first; + +free_list: + tc_getqdisc_list_free(yds.first); + return NULL; +} + +/* ============== RTM_NEWTCLASS ============== */ +/* RTM_NEWTCLASS - do */ +void tc_newtclass_req_free(struct tc_newtclass_req *req) +{ + free(req->kind); + tc_options_msg_free(&req->options); + free(req->rate); + free(req); +} + +int tc_newtclass(struct ynl_sock *ys, struct tc_newtclass_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct nlmsghdr *nlh; + size_t hdr_len; + void *hdr; + int err; + + nlh = ynl_msg_start_req(ys, RTM_NEWTCLASS, req->_nlmsg_flags); + ys->req_policy = &tc_attrs_nest; + ys->req_hdr_len = sizeof(struct tcmsg); + + hdr_len = sizeof(req->_hdr); + hdr = ynl_nlmsg_put_extra_header(nlh, hdr_len); + memcpy(hdr, &req->_hdr, hdr_len); + + if (req->_len.kind) + ynl_attr_put_str(nlh, TCA_KIND, req->kind); + if (req->_present.options) + tc_options_msg_put(nlh, TCA_OPTIONS, &req->options); + if (req->_len.rate) + ynl_attr_put(nlh, TCA_RATE, req->rate, req->_len.rate); + if (req->_present.chain) + ynl_attr_put_u32(nlh, TCA_CHAIN, req->chain); + if (req->_present.ingress_block) + ynl_attr_put_u32(nlh, TCA_INGRESS_BLOCK, req->ingress_block); + if (req->_present.egress_block) + ynl_attr_put_u32(nlh, TCA_EGRESS_BLOCK, req->egress_block); + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + return -1; + + return 0; +} + +/* ============== RTM_DELTCLASS ============== */ +/* RTM_DELTCLASS - do */ +void tc_deltclass_req_free(struct tc_deltclass_req *req) +{ + free(req); +} + +int tc_deltclass(struct ynl_sock *ys, struct tc_deltclass_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct nlmsghdr *nlh; + size_t hdr_len; + void *hdr; + int err; + + nlh = ynl_msg_start_req(ys, RTM_DELTCLASS, req->_nlmsg_flags); + ys->req_policy = &tc_attrs_nest; + ys->req_hdr_len = sizeof(struct tcmsg); + + hdr_len = sizeof(req->_hdr); + hdr = ynl_nlmsg_put_extra_header(nlh, hdr_len); + memcpy(hdr, &req->_hdr, hdr_len); + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + return -1; + + return 0; +} + +/* ============== RTM_GETTCLASS ============== */ +/* RTM_GETTCLASS - do */ +void tc_gettclass_req_free(struct tc_gettclass_req *req) +{ + free(req); +} + +void tc_gettclass_rsp_free(struct tc_gettclass_rsp *rsp) +{ + free(rsp->kind); + tc_options_msg_free(&rsp->options); + free(rsp->stats); + tc_tca_stats_app_msg_free(&rsp->xstats); + free(rsp->rate); + tc_tca_stats_attrs_free(&rsp->stats2); + tc_tca_stab_attrs_free(&rsp->stab); + free(rsp); +} + +int tc_gettclass_rsp_parse(const struct nlmsghdr *nlh, + struct ynl_parse_arg *yarg) +{ + struct tc_gettclass_rsp *dst; + const struct nlattr *attr; + struct ynl_parse_arg parg; + void *hdr; + + dst = yarg->data; + parg.ys = yarg->ys; + + hdr = ynl_nlmsg_data(nlh); + memcpy(&dst->_hdr, hdr, sizeof(struct tcmsg)); + + ynl_attr_for_each(attr, nlh, sizeof(struct tcmsg)) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_KIND) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = strnlen(ynl_attr_get_str(attr), ynl_attr_data_len(attr)); + dst->_len.kind = len; + dst->kind = malloc(len + 1); + memcpy(dst->kind, ynl_attr_get_str(attr), len); + dst->kind[len] = 0; + } else if (type == TCA_OPTIONS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.options = 1; + + parg.rsp_policy = &tc_options_msg_nest; + parg.data = &dst->options; + if (!dst->kind) + return ynl_submsg_failed(yarg, "options", "kind"); + if (tc_options_msg_parse(&parg, dst->kind, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_STATS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.stats = len; + if (len < sizeof(struct tc_stats)) + dst->stats = calloc(1, sizeof(struct tc_stats)); + else + dst->stats = malloc(len); + memcpy(dst->stats, ynl_attr_data(attr), len); + } else if (type == TCA_XSTATS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.xstats = 1; + + parg.rsp_policy = &tc_tca_stats_app_msg_nest; + parg.data = &dst->xstats; + if (!dst->kind) + return ynl_submsg_failed(yarg, "xstats", "kind"); + if (tc_tca_stats_app_msg_parse(&parg, dst->kind, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_RATE) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.rate = len; + if (len < sizeof(struct gnet_estimator)) + dst->rate = calloc(1, sizeof(struct gnet_estimator)); + else + dst->rate = malloc(len); + memcpy(dst->rate, ynl_attr_data(attr), len); + } else if (type == TCA_FCNT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.fcnt = 1; + dst->fcnt = ynl_attr_get_u32(attr); + } else if (type == TCA_STATS2) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stats2 = 1; + + parg.rsp_policy = &tc_tca_stats_attrs_nest; + parg.data = &dst->stats2; + if (tc_tca_stats_attrs_parse(&parg, attr, dst->kind)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_STAB) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stab = 1; + + parg.rsp_policy = &tc_tca_stab_attrs_nest; + parg.data = &dst->stab; + if (tc_tca_stab_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_CHAIN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.chain = 1; + dst->chain = ynl_attr_get_u32(attr); + } else if (type == TCA_INGRESS_BLOCK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ingress_block = 1; + dst->ingress_block = ynl_attr_get_u32(attr); + } else if (type == TCA_EGRESS_BLOCK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.egress_block = 1; + dst->egress_block = ynl_attr_get_u32(attr); + } + } + + return YNL_PARSE_CB_OK; +} + +struct tc_gettclass_rsp * +tc_gettclass(struct ynl_sock *ys, struct tc_gettclass_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct tc_gettclass_rsp *rsp; + struct nlmsghdr *nlh; + size_t hdr_len; + void *hdr; + int err; + + nlh = ynl_msg_start_req(ys, RTM_GETTCLASS, req->_nlmsg_flags); + ys->req_policy = &tc_attrs_nest; + ys->req_hdr_len = sizeof(struct tcmsg); + yrs.yarg.rsp_policy = &tc_attrs_nest; + + hdr_len = sizeof(req->_hdr); + hdr = ynl_nlmsg_put_extra_header(nlh, hdr_len); + memcpy(hdr, &req->_hdr, hdr_len); + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = tc_gettclass_rsp_parse; + yrs.rsp_cmd = 40; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + tc_gettclass_rsp_free(rsp); + return NULL; +} + +/* ============== RTM_NEWTFILTER ============== */ +/* RTM_NEWTFILTER - do */ +void tc_newtfilter_req_free(struct tc_newtfilter_req *req) +{ + free(req->kind); + tc_options_msg_free(&req->options); + free(req->rate); + free(req); +} + +int tc_newtfilter(struct ynl_sock *ys, struct tc_newtfilter_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct nlmsghdr *nlh; + size_t hdr_len; + void *hdr; + int err; + + nlh = ynl_msg_start_req(ys, RTM_NEWTFILTER, req->_nlmsg_flags); + ys->req_policy = &tc_attrs_nest; + ys->req_hdr_len = sizeof(struct tcmsg); + + hdr_len = sizeof(req->_hdr); + hdr = ynl_nlmsg_put_extra_header(nlh, hdr_len); + memcpy(hdr, &req->_hdr, hdr_len); + + if (req->_len.kind) + ynl_attr_put_str(nlh, TCA_KIND, req->kind); + if (req->_present.options) + tc_options_msg_put(nlh, TCA_OPTIONS, &req->options); + if (req->_len.rate) + ynl_attr_put(nlh, TCA_RATE, req->rate, req->_len.rate); + if (req->_present.chain) + ynl_attr_put_u32(nlh, TCA_CHAIN, req->chain); + if (req->_present.ingress_block) + ynl_attr_put_u32(nlh, TCA_INGRESS_BLOCK, req->ingress_block); + if (req->_present.egress_block) + ynl_attr_put_u32(nlh, TCA_EGRESS_BLOCK, req->egress_block); + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + return -1; + + return 0; +} + +/* ============== RTM_DELTFILTER ============== */ +/* RTM_DELTFILTER - do */ +void tc_deltfilter_req_free(struct tc_deltfilter_req *req) +{ + free(req->kind); + free(req); +} + +int tc_deltfilter(struct ynl_sock *ys, struct tc_deltfilter_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct nlmsghdr *nlh; + size_t hdr_len; + void *hdr; + int err; + + nlh = ynl_msg_start_req(ys, RTM_DELTFILTER, req->_nlmsg_flags); + ys->req_policy = &tc_attrs_nest; + ys->req_hdr_len = sizeof(struct tcmsg); + + hdr_len = sizeof(req->_hdr); + hdr = ynl_nlmsg_put_extra_header(nlh, hdr_len); + memcpy(hdr, &req->_hdr, hdr_len); + + if (req->_present.chain) + ynl_attr_put_u32(nlh, TCA_CHAIN, req->chain); + if (req->_len.kind) + ynl_attr_put_str(nlh, TCA_KIND, req->kind); + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + return -1; + + return 0; +} + +/* ============== RTM_GETTFILTER ============== */ +/* RTM_GETTFILTER - do */ +void tc_gettfilter_req_free(struct tc_gettfilter_req *req) +{ + free(req->kind); + free(req); +} + +void tc_gettfilter_rsp_free(struct tc_gettfilter_rsp *rsp) +{ + free(rsp->kind); + tc_options_msg_free(&rsp->options); + free(rsp->stats); + tc_tca_stats_app_msg_free(&rsp->xstats); + free(rsp->rate); + tc_tca_stats_attrs_free(&rsp->stats2); + tc_tca_stab_attrs_free(&rsp->stab); + free(rsp); +} + +int tc_gettfilter_rsp_parse(const struct nlmsghdr *nlh, + struct ynl_parse_arg *yarg) +{ + struct tc_gettfilter_rsp *dst; + const struct nlattr *attr; + struct ynl_parse_arg parg; + void *hdr; + + dst = yarg->data; + parg.ys = yarg->ys; + + hdr = ynl_nlmsg_data(nlh); + memcpy(&dst->_hdr, hdr, sizeof(struct tcmsg)); + + ynl_attr_for_each(attr, nlh, sizeof(struct tcmsg)) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_KIND) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = strnlen(ynl_attr_get_str(attr), ynl_attr_data_len(attr)); + dst->_len.kind = len; + dst->kind = malloc(len + 1); + memcpy(dst->kind, ynl_attr_get_str(attr), len); + dst->kind[len] = 0; + } else if (type == TCA_OPTIONS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.options = 1; + + parg.rsp_policy = &tc_options_msg_nest; + parg.data = &dst->options; + if (!dst->kind) + return ynl_submsg_failed(yarg, "options", "kind"); + if (tc_options_msg_parse(&parg, dst->kind, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_STATS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.stats = len; + if (len < sizeof(struct tc_stats)) + dst->stats = calloc(1, sizeof(struct tc_stats)); + else + dst->stats = malloc(len); + memcpy(dst->stats, ynl_attr_data(attr), len); + } else if (type == TCA_XSTATS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.xstats = 1; + + parg.rsp_policy = &tc_tca_stats_app_msg_nest; + parg.data = &dst->xstats; + if (!dst->kind) + return ynl_submsg_failed(yarg, "xstats", "kind"); + if (tc_tca_stats_app_msg_parse(&parg, dst->kind, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_RATE) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.rate = len; + if (len < sizeof(struct gnet_estimator)) + dst->rate = calloc(1, sizeof(struct gnet_estimator)); + else + dst->rate = malloc(len); + memcpy(dst->rate, ynl_attr_data(attr), len); + } else if (type == TCA_FCNT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.fcnt = 1; + dst->fcnt = ynl_attr_get_u32(attr); + } else if (type == TCA_STATS2) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stats2 = 1; + + parg.rsp_policy = &tc_tca_stats_attrs_nest; + parg.data = &dst->stats2; + if (tc_tca_stats_attrs_parse(&parg, attr, dst->kind)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_STAB) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stab = 1; + + parg.rsp_policy = &tc_tca_stab_attrs_nest; + parg.data = &dst->stab; + if (tc_tca_stab_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_CHAIN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.chain = 1; + dst->chain = ynl_attr_get_u32(attr); + } else if (type == TCA_INGRESS_BLOCK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ingress_block = 1; + dst->ingress_block = ynl_attr_get_u32(attr); + } else if (type == TCA_EGRESS_BLOCK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.egress_block = 1; + dst->egress_block = ynl_attr_get_u32(attr); + } + } + + return YNL_PARSE_CB_OK; +} + +struct tc_gettfilter_rsp * +tc_gettfilter(struct ynl_sock *ys, struct tc_gettfilter_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct tc_gettfilter_rsp *rsp; + struct nlmsghdr *nlh; + size_t hdr_len; + void *hdr; + int err; + + nlh = ynl_msg_start_req(ys, RTM_GETTFILTER, req->_nlmsg_flags); + ys->req_policy = &tc_attrs_nest; + ys->req_hdr_len = sizeof(struct tcmsg); + yrs.yarg.rsp_policy = &tc_attrs_nest; + + hdr_len = sizeof(req->_hdr); + hdr = ynl_nlmsg_put_extra_header(nlh, hdr_len); + memcpy(hdr, &req->_hdr, hdr_len); + + if (req->_present.chain) + ynl_attr_put_u32(nlh, TCA_CHAIN, req->chain); + if (req->_len.kind) + ynl_attr_put_str(nlh, TCA_KIND, req->kind); + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = tc_gettfilter_rsp_parse; + yrs.rsp_cmd = 44; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + tc_gettfilter_rsp_free(rsp); + return NULL; +} + +/* RTM_GETTFILTER - dump */ +void tc_gettfilter_req_dump_free(struct tc_gettfilter_req_dump *req) +{ + free(req); +} + +void tc_gettfilter_list_free(struct tc_gettfilter_list *rsp) +{ + struct tc_gettfilter_list *next = rsp; + + while ((void *)next != YNL_LIST_END) { + rsp = next; + next = rsp->next; + + free(rsp->obj.kind); + tc_options_msg_free(&rsp->obj.options); + free(rsp->obj.stats); + tc_tca_stats_app_msg_free(&rsp->obj.xstats); + free(rsp->obj.rate); + tc_tca_stats_attrs_free(&rsp->obj.stats2); + tc_tca_stab_attrs_free(&rsp->obj.stab); + free(rsp); + } +} + +struct tc_gettfilter_list * +tc_gettfilter_dump(struct ynl_sock *ys, struct tc_gettfilter_req_dump *req) +{ + struct ynl_dump_state yds = {}; + struct nlmsghdr *nlh; + size_t hdr_len; + void *hdr; + int err; + + yds.yarg.ys = ys; + yds.yarg.rsp_policy = &tc_attrs_nest; + yds.yarg.data = NULL; + yds.alloc_sz = sizeof(struct tc_gettfilter_list); + yds.cb = tc_gettfilter_rsp_parse; + yds.rsp_cmd = 44; + + nlh = ynl_msg_start_dump(ys, RTM_GETTFILTER); + hdr_len = sizeof(req->_hdr); + hdr = ynl_nlmsg_put_extra_header(nlh, hdr_len); + memcpy(hdr, &req->_hdr, hdr_len); + + ys->req_policy = &tc_attrs_nest; + ys->req_hdr_len = sizeof(struct tcmsg); + + if (req->_present.chain) + ynl_attr_put_u32(nlh, TCA_CHAIN, req->chain); + if (req->_present.dump_flags) + ynl_attr_put(nlh, TCA_DUMP_FLAGS, &req->dump_flags, sizeof(struct nla_bitfield32)); + + err = ynl_exec_dump(ys, nlh, &yds); + if (err < 0) + goto free_list; + + return yds.first; + +free_list: + tc_gettfilter_list_free(yds.first); + return NULL; +} + +/* ============== RTM_NEWCHAIN ============== */ +/* RTM_NEWCHAIN - do */ +void tc_newchain_req_free(struct tc_newchain_req *req) +{ + free(req->kind); + tc_options_msg_free(&req->options); + free(req->rate); + free(req); +} + +int tc_newchain(struct ynl_sock *ys, struct tc_newchain_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct nlmsghdr *nlh; + size_t hdr_len; + void *hdr; + int err; + + nlh = ynl_msg_start_req(ys, RTM_NEWCHAIN, req->_nlmsg_flags); + ys->req_policy = &tc_attrs_nest; + ys->req_hdr_len = sizeof(struct tcmsg); + + hdr_len = sizeof(req->_hdr); + hdr = ynl_nlmsg_put_extra_header(nlh, hdr_len); + memcpy(hdr, &req->_hdr, hdr_len); + + if (req->_len.kind) + ynl_attr_put_str(nlh, TCA_KIND, req->kind); + if (req->_present.options) + tc_options_msg_put(nlh, TCA_OPTIONS, &req->options); + if (req->_len.rate) + ynl_attr_put(nlh, TCA_RATE, req->rate, req->_len.rate); + if (req->_present.chain) + ynl_attr_put_u32(nlh, TCA_CHAIN, req->chain); + if (req->_present.ingress_block) + ynl_attr_put_u32(nlh, TCA_INGRESS_BLOCK, req->ingress_block); + if (req->_present.egress_block) + ynl_attr_put_u32(nlh, TCA_EGRESS_BLOCK, req->egress_block); + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + return -1; + + return 0; +} + +/* ============== RTM_DELCHAIN ============== */ +/* RTM_DELCHAIN - do */ +void tc_delchain_req_free(struct tc_delchain_req *req) +{ + free(req); +} + +int tc_delchain(struct ynl_sock *ys, struct tc_delchain_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct nlmsghdr *nlh; + size_t hdr_len; + void *hdr; + int err; + + nlh = ynl_msg_start_req(ys, RTM_DELCHAIN, req->_nlmsg_flags); + ys->req_policy = &tc_attrs_nest; + ys->req_hdr_len = sizeof(struct tcmsg); + + hdr_len = sizeof(req->_hdr); + hdr = ynl_nlmsg_put_extra_header(nlh, hdr_len); + memcpy(hdr, &req->_hdr, hdr_len); + + if (req->_present.chain) + ynl_attr_put_u32(nlh, TCA_CHAIN, req->chain); + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + return -1; + + return 0; +} + +/* ============== RTM_GETCHAIN ============== */ +/* RTM_GETCHAIN - do */ +void tc_getchain_req_free(struct tc_getchain_req *req) +{ + free(req); +} + +void tc_getchain_rsp_free(struct tc_getchain_rsp *rsp) +{ + free(rsp->kind); + tc_options_msg_free(&rsp->options); + free(rsp->stats); + tc_tca_stats_app_msg_free(&rsp->xstats); + free(rsp->rate); + tc_tca_stats_attrs_free(&rsp->stats2); + tc_tca_stab_attrs_free(&rsp->stab); + free(rsp); +} + +int tc_getchain_rsp_parse(const struct nlmsghdr *nlh, + struct ynl_parse_arg *yarg) +{ + struct tc_getchain_rsp *dst; + const struct nlattr *attr; + struct ynl_parse_arg parg; + void *hdr; + + dst = yarg->data; + parg.ys = yarg->ys; + + hdr = ynl_nlmsg_data(nlh); + memcpy(&dst->_hdr, hdr, sizeof(struct tcmsg)); + + ynl_attr_for_each(attr, nlh, sizeof(struct tcmsg)) { + unsigned int type = ynl_attr_type(attr); + + if (type == TCA_KIND) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = strnlen(ynl_attr_get_str(attr), ynl_attr_data_len(attr)); + dst->_len.kind = len; + dst->kind = malloc(len + 1); + memcpy(dst->kind, ynl_attr_get_str(attr), len); + dst->kind[len] = 0; + } else if (type == TCA_OPTIONS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.options = 1; + + parg.rsp_policy = &tc_options_msg_nest; + parg.data = &dst->options; + if (!dst->kind) + return ynl_submsg_failed(yarg, "options", "kind"); + if (tc_options_msg_parse(&parg, dst->kind, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_STATS) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.stats = len; + if (len < sizeof(struct tc_stats)) + dst->stats = calloc(1, sizeof(struct tc_stats)); + else + dst->stats = malloc(len); + memcpy(dst->stats, ynl_attr_data(attr), len); + } else if (type == TCA_XSTATS) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.xstats = 1; + + parg.rsp_policy = &tc_tca_stats_app_msg_nest; + parg.data = &dst->xstats; + if (!dst->kind) + return ynl_submsg_failed(yarg, "xstats", "kind"); + if (tc_tca_stats_app_msg_parse(&parg, dst->kind, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_RATE) { + unsigned int len; + + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + + len = ynl_attr_data_len(attr); + dst->_len.rate = len; + if (len < sizeof(struct gnet_estimator)) + dst->rate = calloc(1, sizeof(struct gnet_estimator)); + else + dst->rate = malloc(len); + memcpy(dst->rate, ynl_attr_data(attr), len); + } else if (type == TCA_FCNT) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.fcnt = 1; + dst->fcnt = ynl_attr_get_u32(attr); + } else if (type == TCA_STATS2) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stats2 = 1; + + parg.rsp_policy = &tc_tca_stats_attrs_nest; + parg.data = &dst->stats2; + if (tc_tca_stats_attrs_parse(&parg, attr, dst->kind)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_STAB) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.stab = 1; + + parg.rsp_policy = &tc_tca_stab_attrs_nest; + parg.data = &dst->stab; + if (tc_tca_stab_attrs_parse(&parg, attr)) + return YNL_PARSE_CB_ERROR; + } else if (type == TCA_CHAIN) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.chain = 1; + dst->chain = ynl_attr_get_u32(attr); + } else if (type == TCA_INGRESS_BLOCK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.ingress_block = 1; + dst->ingress_block = ynl_attr_get_u32(attr); + } else if (type == TCA_EGRESS_BLOCK) { + if (ynl_attr_validate(yarg, attr)) + return YNL_PARSE_CB_ERROR; + dst->_present.egress_block = 1; + dst->egress_block = ynl_attr_get_u32(attr); + } + } + + return YNL_PARSE_CB_OK; +} + +struct tc_getchain_rsp * +tc_getchain(struct ynl_sock *ys, struct tc_getchain_req *req) +{ + struct ynl_req_state yrs = { .yarg = { .ys = ys, }, }; + struct tc_getchain_rsp *rsp; + struct nlmsghdr *nlh; + size_t hdr_len; + void *hdr; + int err; + + nlh = ynl_msg_start_req(ys, RTM_GETCHAIN, req->_nlmsg_flags); + ys->req_policy = &tc_attrs_nest; + ys->req_hdr_len = sizeof(struct tcmsg); + yrs.yarg.rsp_policy = &tc_attrs_nest; + + hdr_len = sizeof(req->_hdr); + hdr = ynl_nlmsg_put_extra_header(nlh, hdr_len); + memcpy(hdr, &req->_hdr, hdr_len); + + if (req->_present.chain) + ynl_attr_put_u32(nlh, TCA_CHAIN, req->chain); + + rsp = calloc(1, sizeof(*rsp)); + yrs.yarg.data = rsp; + yrs.cb = tc_getchain_rsp_parse; + yrs.rsp_cmd = 100; + + err = ynl_exec(ys, nlh, &yrs); + if (err < 0) + goto err_free; + + return rsp; + +err_free: + tc_getchain_rsp_free(rsp); + return NULL; +} + +const struct ynl_family ynl_tc_family = { + .name = "tc", + .is_classic = true, + .classic_id = 0, +}; diff --git a/home/nipa/nipa_out/963794/ynl/new-code/tc-user.h b/home/nipa/nipa_out/963794/ynl/new-code/tc-user.h new file mode 100644 index 000000000000..7805a3d0471a --- /dev/null +++ b/home/nipa/nipa_out/963794/ynl/new-code/tc-user.h @@ -0,0 +1,18897 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/tc.yaml */ +/* YNL-GEN user header */ + +#ifndef _LINUX_TC_GEN_H +#define _LINUX_TC_GEN_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct ynl_sock; + +extern const struct ynl_family ynl_tc_family; + +/* Enums */ +const char *tc_op_str(int op); +const char *tc_cls_flags_str(int value); +const char *tc_flower_key_ctrl_flags_str(int value); + +/* Common nested types */ +struct tc_tca_stab_attrs { + struct { + __u32 base; + __u32 data; + } _len; + + struct tc_sizespec *base; + void *data; +}; + +struct tc_cake_attrs { + struct { + __u32 base_rate64:1; + __u32 diffserv_mode:1; + __u32 atm:1; + __u32 flow_mode:1; + __u32 overhead:1; + __u32 rtt:1; + __u32 target:1; + __u32 autorate:1; + __u32 memory:1; + __u32 nat:1; + __u32 raw:1; + __u32 wash:1; + __u32 mpu:1; + __u32 ingress:1; + __u32 ack_filter:1; + __u32 split_gso:1; + __u32 fwmark:1; + } _present; + + __u64 base_rate64; + __u32 diffserv_mode; + __u32 atm; + __u32 flow_mode; + __u32 overhead; + __u32 rtt; + __u32 target; + __u32 autorate; + __u32 memory; + __u32 nat; + __u32 raw; + __u32 wash; + __u32 mpu; + __u32 ingress; + __u32 ack_filter; + __u32 split_gso; + __u32 fwmark; +}; + +struct tc_cbs_attrs { + struct { + __u32 parms; + } _len; + + struct tc_cbs_qopt *parms; +}; + +struct tc_choke_attrs { + struct { + __u32 max_p:1; + } _present; + struct { + __u32 parms; + __u32 stab; + } _len; + + struct tc_red_qopt *parms; + void *stab; + __u32 max_p; +}; + +struct tc_codel_attrs { + struct { + __u32 target:1; + __u32 limit:1; + __u32 interval:1; + __u32 ecn:1; + __u32 ce_threshold:1; + } _present; + + __u32 target; + __u32 limit; + __u32 interval; + __u32 ecn; + __u32 ce_threshold; +}; + +struct tc_drr_attrs { + struct { + __u32 quantum:1; + } _present; + + __u32 quantum; +}; + +struct tc_etf_attrs { + struct { + __u32 parms; + } _len; + + struct tc_etf_qopt *parms; +}; + +struct tc_fq_attrs { + struct { + __u32 plimit:1; + __u32 flow_plimit:1; + __u32 quantum:1; + __u32 initial_quantum:1; + __u32 rate_enable:1; + __u32 flow_default_rate:1; + __u32 flow_max_rate:1; + __u32 buckets_log:1; + __u32 flow_refill_delay:1; + __u32 orphan_mask:1; + __u32 low_rate_threshold:1; + __u32 ce_threshold:1; + __u32 timer_slack:1; + __u32 horizon:1; + __u32 horizon_drop:1; + } _present; + struct { + __u32 priomap; + } _len; + struct { + __u32 weights; + } _count; + + __u32 plimit; + __u32 flow_plimit; + __u32 quantum; + __u32 initial_quantum; + __u32 rate_enable; + __u32 flow_default_rate; + __u32 flow_max_rate; + __u32 buckets_log; + __u32 flow_refill_delay; + __u32 orphan_mask; + __u32 low_rate_threshold; + __u32 ce_threshold; + __u32 timer_slack; + __u32 horizon; + __u8 horizon_drop; + struct tc_prio_qopt *priomap; + __s32 *weights; +}; + +struct tc_fq_codel_attrs { + struct { + __u32 target:1; + __u32 limit:1; + __u32 interval:1; + __u32 ecn:1; + __u32 flows:1; + __u32 quantum:1; + __u32 ce_threshold:1; + __u32 drop_batch_size:1; + __u32 memory_limit:1; + __u32 ce_threshold_selector:1; + __u32 ce_threshold_mask:1; + } _present; + + __u32 target; + __u32 limit; + __u32 interval; + __u32 ecn; + __u32 flows; + __u32 quantum; + __u32 ce_threshold; + __u32 drop_batch_size; + __u32 memory_limit; + __u8 ce_threshold_selector; + __u8 ce_threshold_mask; +}; + +struct tc_fq_pie_attrs { + struct { + __u32 limit:1; + __u32 flows:1; + __u32 target:1; + __u32 tupdate:1; + __u32 alpha:1; + __u32 beta:1; + __u32 quantum:1; + __u32 memory_limit:1; + __u32 ecn_prob:1; + __u32 ecn:1; + __u32 bytemode:1; + __u32 dq_rate_estimator:1; + } _present; + + __u32 limit; + __u32 flows; + __u32 target; + __u32 tupdate; + __u32 alpha; + __u32 beta; + __u32 quantum; + __u32 memory_limit; + __u32 ecn_prob; + __u32 ecn; + __u32 bytemode; + __u32 dq_rate_estimator; +}; + +struct tc_hhf_attrs { + struct { + __u32 backlog_limit:1; + __u32 quantum:1; + __u32 hh_flows_limit:1; + __u32 reset_timeout:1; + __u32 admit_bytes:1; + __u32 evict_timeout:1; + __u32 non_hh_weight:1; + } _present; + + __u32 backlog_limit; + __u32 quantum; + __u32 hh_flows_limit; + __u32 reset_timeout; + __u32 admit_bytes; + __u32 evict_timeout; + __u32 non_hh_weight; +}; + +struct tc_htb_attrs { + struct { + __u32 direct_qlen:1; + __u32 rate64:1; + __u32 ceil64:1; + __u32 offload:1; + } _present; + struct { + __u32 parms; + __u32 init; + __u32 ctab; + __u32 rtab; + } _len; + + struct tc_htb_opt *parms; + struct tc_htb_glob *init; + void *ctab; + void *rtab; + __u32 direct_qlen; + __u64 rate64; + __u64 ceil64; +}; + +struct tc_pie_attrs { + struct { + __u32 target:1; + __u32 limit:1; + __u32 tupdate:1; + __u32 alpha:1; + __u32 beta:1; + __u32 ecn:1; + __u32 bytemode:1; + __u32 dq_rate_estimator:1; + } _present; + + __u32 target; + __u32 limit; + __u32 tupdate; + __u32 alpha; + __u32 beta; + __u32 ecn; + __u32 bytemode; + __u32 dq_rate_estimator; +}; + +struct tc_qfq_attrs { + struct { + __u32 weight:1; + __u32 lmax:1; + } _present; + + __u32 weight; + __u32 lmax; +}; + +struct tc_red_attrs { + struct { + __u32 max_p:1; + __u32 flags:1; + __u32 early_drop_block:1; + __u32 mark_block:1; + } _present; + struct { + __u32 parms; + __u32 stab; + } _len; + + struct tc_red_qopt *parms; + void *stab; + __u32 max_p; + struct nla_bitfield32 flags; + __u32 early_drop_block; + __u32 mark_block; +}; + +struct tc_tbf_attrs { + struct { + __u32 rate64:1; + __u32 prate64:1; + __u32 burst:1; + __u32 pburst:1; + } _present; + struct { + __u32 parms; + __u32 rtab; + __u32 ptab; + } _len; + + struct tc_tbf_qopt *parms; + void *rtab; + void *ptab; + __u64 rate64; + __u64 prate64; + __u32 burst; + __u32 pburst; +}; + +struct tc_ematch_attrs { + struct { + __u32 tree_hdr; + __u32 tree_list; + } _len; + + struct tcf_ematch_tree_hdr *tree_hdr; + void *tree_list; +}; + +struct tc_police_attrs { + struct { + __u32 avrate:1; + __u32 result:1; + __u32 rate64:1; + __u32 peakrate64:1; + __u32 pktrate64:1; + __u32 pktburst64:1; + } _present; + struct { + __u32 tbf; + __u32 rate; + __u32 peakrate; + __u32 tm; + } _len; + + struct tc_police *tbf; + void *rate; + void *peakrate; + __u32 avrate; + __u32 result; + struct tcf_t *tm; + __u64 rate64; + __u64 peakrate64; + __u64 pktrate64; + __u64 pktburst64; +}; + +struct tc_flower_key_mpls_opt_attrs { + struct { + __u32 lse_depth:1; + __u32 lse_ttl:1; + __u32 lse_bos:1; + __u32 lse_tc:1; + __u32 lse_label:1; + } _present; + + __u8 lse_depth; + __u8 lse_ttl; + __u8 lse_bos; + __u8 lse_tc; + __u32 lse_label; +}; + +struct tc_flower_key_cfm_attrs { + struct { + __u32 md_level:1; + __u32 opcode:1; + } _present; + + __u8 md_level; + __u8 opcode; +}; + +struct tc_netem_loss_attrs { + struct { + __u32 gi; + __u32 ge; + } _len; + + struct tc_netem_gimodel *gi; + struct tc_netem_gemodel *ge; +}; + +struct tc_taprio_sched_entry { + struct { + __u32 index:1; + __u32 cmd:1; + __u32 gate_mask:1; + __u32 interval:1; + } _present; + + __u32 index; + __u8 cmd; + __u32 gate_mask; + __u32 interval; +}; + +void tc_taprio_sched_entry_free(struct tc_taprio_sched_entry *obj); + +struct tc_taprio_tc_entry_attrs { + struct { + __u32 index:1; + __u32 max_sdu:1; + __u32 fp:1; + } _present; + + __u32 index; + __u32 max_sdu; + __u32 fp; +}; + +struct tc_cake_tin_stats_attrs { + struct { + __u32 sent_packets:1; + __u32 sent_bytes64:1; + __u32 dropped_packets:1; + __u32 dropped_bytes64:1; + __u32 acks_dropped_packets:1; + __u32 acks_dropped_bytes64:1; + __u32 ecn_marked_packets:1; + __u32 ecn_marked_bytes64:1; + __u32 backlog_packets:1; + __u32 backlog_bytes:1; + __u32 threshold_rate64:1; + __u32 target_us:1; + __u32 interval_us:1; + __u32 way_indirect_hits:1; + __u32 way_misses:1; + __u32 way_collisions:1; + __u32 peak_delay_us:1; + __u32 avg_delay_us:1; + __u32 base_delay_us:1; + __u32 sparse_flows:1; + __u32 bulk_flows:1; + __u32 unresponsive_flows:1; + __u32 max_skblen:1; + __u32 flow_quantum:1; + } _present; + + __u32 idx; + __u32 sent_packets; + __u64 sent_bytes64; + __u32 dropped_packets; + __u64 dropped_bytes64; + __u32 acks_dropped_packets; + __u64 acks_dropped_bytes64; + __u32 ecn_marked_packets; + __u64 ecn_marked_bytes64; + __u32 backlog_packets; + __u32 backlog_bytes; + __u64 threshold_rate64; + __u32 target_us; + __u32 interval_us; + __u32 way_indirect_hits; + __u32 way_misses; + __u32 way_collisions; + __u32 peak_delay_us; + __u32 avg_delay_us; + __u32 base_delay_us; + __u32 sparse_flows; + __u32 bulk_flows; + __u32 unresponsive_flows; + __u32 max_skblen; + __u32 flow_quantum; +}; + +void tc_cake_tin_stats_attrs_free(struct tc_cake_tin_stats_attrs *obj); + +struct tc_flower_key_enc_opt_geneve_attrs { + struct { + __u32 class:1; + __u32 type:1; + } _present; + struct { + __u32 data; + } _len; + + __u16 class; + __u8 type; + void *data; +}; + +struct tc_flower_key_enc_opt_vxlan_attrs { + struct { + __u32 gbp:1; + } _present; + + __u32 gbp; +}; + +struct tc_flower_key_enc_opt_erspan_attrs { + struct { + __u32 ver:1; + __u32 index:1; + __u32 dir:1; + __u32 hwid:1; + } _present; + + __u8 ver; + __u32 index; + __u8 dir; + __u8 hwid; +}; + +struct tc_flower_key_enc_opt_gtp_attrs { + struct { + __u32 pdu_type:1; + __u32 qfi:1; + } _present; + + __u8 pdu_type; + __u8 qfi; +}; + +struct tc_tca_gred_vq_entry_attrs { + struct { + __u32 dp:1; + __u32 stat_bytes:1; + __u32 stat_packets:1; + __u32 stat_backlog:1; + __u32 stat_prob_drop:1; + __u32 stat_prob_mark:1; + __u32 stat_forced_drop:1; + __u32 stat_forced_mark:1; + __u32 stat_pdrop:1; + __u32 stat_other:1; + __u32 flags:1; + } _present; + + __u32 dp; + __u64 stat_bytes; + __u32 stat_packets; + __u32 stat_backlog; + __u32 stat_prob_drop; + __u32 stat_prob_mark; + __u32 stat_forced_drop; + __u32 stat_forced_mark; + __u32 stat_pdrop; + __u32 stat_other; + __u32 flags; +}; + +void tc_tca_gred_vq_entry_attrs_free(struct tc_tca_gred_vq_entry_attrs *obj); + +struct tc_act_bpf_attrs { + struct { + __u32 ops_len:1; + __u32 fd:1; + } _present; + struct { + __u32 tm; + __u32 parms; + __u32 ops; + __u32 name; + __u32 tag; + __u32 id; + } _len; + + struct tcf_t *tm; + void *parms; + __u16 ops_len; + void *ops; + __u32 fd; + char *name; + void *tag; + void *id; +}; + +struct tc_act_connmark_attrs { + struct { + __u32 parms; + __u32 tm; + } _len; + + void *parms; + struct tcf_t *tm; +}; + +struct tc_act_csum_attrs { + struct { + __u32 parms; + __u32 tm; + } _len; + + void *parms; + struct tcf_t *tm; +}; + +struct tc_act_ct_attrs { + struct { + __u32 action:1; + __u32 zone:1; + __u32 mark:1; + __u32 mark_mask:1; + __u32 nat_ipv4_min:1; + __u32 nat_ipv4_max:1; + __u32 nat_port_min:1; + __u32 nat_port_max:1; + __u32 helper_family:1; + __u32 helper_proto:1; + } _present; + struct { + __u32 parms; + __u32 tm; + __u32 labels; + __u32 labels_mask; + __u32 nat_ipv6_min; + __u32 nat_ipv6_max; + __u32 helper_name; + } _len; + + void *parms; + struct tcf_t *tm; + __u16 action; + __u16 zone; + __u32 mark; + __u32 mark_mask; + void *labels; + void *labels_mask; + __u32 nat_ipv4_min /* big-endian */; + __u32 nat_ipv4_max /* big-endian */; + void *nat_ipv6_min; + void *nat_ipv6_max; + __u16 nat_port_min /* big-endian */; + __u16 nat_port_max /* big-endian */; + char *helper_name; + __u8 helper_family; + __u8 helper_proto; +}; + +struct tc_act_ctinfo_attrs { + struct { + __u32 zone:1; + __u32 parms_dscp_mask:1; + __u32 parms_dscp_statemask:1; + __u32 parms_cpmark_mask:1; + __u32 stats_dscp_set:1; + __u32 stats_dscp_error:1; + __u32 stats_cpmark_set:1; + } _present; + struct { + __u32 tm; + __u32 act; + } _len; + + struct tcf_t *tm; + void *act; + __u16 zone; + __u32 parms_dscp_mask; + __u32 parms_dscp_statemask; + __u32 parms_cpmark_mask; + __u64 stats_dscp_set; + __u64 stats_dscp_error; + __u64 stats_cpmark_set; +}; + +struct tc_act_gact_attrs { + struct { + __u32 tm; + __u32 parms; + __u32 prob; + } _len; + + struct tcf_t *tm; + struct tc_gact *parms; + struct tc_gact_p *prob; +}; + +struct tc_act_gate_attrs { + struct { + __u32 priority:1; + __u32 base_time:1; + __u32 cycle_time:1; + __u32 cycle_time_ext:1; + __u32 flags:1; + __u32 clockid:1; + } _present; + struct { + __u32 tm; + __u32 parms; + __u32 entry_list; + } _len; + + struct tcf_t *tm; + void *parms; + __s32 priority; + void *entry_list; + __u64 base_time; + __u64 cycle_time; + __u64 cycle_time_ext; + __u32 flags; + __s32 clockid; +}; + +struct tc_act_ife_attrs { + struct { + __u32 type:1; + } _present; + struct { + __u32 parms; + __u32 tm; + __u32 dmac; + __u32 smac; + __u32 metalst; + } _len; + + void *parms; + struct tcf_t *tm; + void *dmac; + void *smac; + __u16 type; + void *metalst; +}; + +struct tc_act_mirred_attrs { + struct { + __u32 tm; + __u32 parms; + __u32 blockid; + } _len; + + struct tcf_t *tm; + void *parms; + void *blockid; +}; + +struct tc_act_mpls_attrs { + struct { + __u32 proto:1; + __u32 label:1; + __u32 tc:1; + __u32 ttl:1; + __u32 bos:1; + } _present; + struct { + __u32 tm; + __u32 parms; + } _len; + + struct tcf_t *tm; + struct tc_mpls *parms; + __u16 proto /* big-endian */; + __u32 label; + __u8 tc; + __u8 ttl; + __u8 bos; +}; + +struct tc_act_nat_attrs { + struct { + __u32 parms; + __u32 tm; + } _len; + + void *parms; + struct tcf_t *tm; +}; + +struct tc_act_pedit_attrs { + struct { + __u32 tm; + __u32 parms; + __u32 parms_ex; + __u32 keys_ex; + __u32 key_ex; + } _len; + + struct tcf_t *tm; + struct tc_pedit_sel *parms; + void *parms_ex; + void *keys_ex; + void *key_ex; +}; + +struct tc_act_sample_attrs { + struct { + __u32 rate:1; + __u32 trunc_size:1; + __u32 psample_group:1; + } _present; + struct { + __u32 tm; + __u32 parms; + } _len; + + struct tcf_t *tm; + struct tc_gact *parms; + __u32 rate; + __u32 trunc_size; + __u32 psample_group; +}; + +struct tc_act_simple_attrs { + struct { + __u32 tm; + __u32 parms; + __u32 data; + } _len; + + struct tcf_t *tm; + void *parms; + void *data; +}; + +struct tc_act_skbedit_attrs { + struct { + __u32 priority:1; + __u32 queue_mapping:1; + __u32 mark:1; + __u32 ptype:1; + __u32 mask:1; + __u32 flags:1; + __u32 queue_mapping_max:1; + } _present; + struct { + __u32 tm; + __u32 parms; + } _len; + + struct tcf_t *tm; + void *parms; + __u32 priority; + __u16 queue_mapping; + __u32 mark; + __u16 ptype; + __u32 mask; + __u64 flags; + __u16 queue_mapping_max; +}; + +struct tc_act_skbmod_attrs { + struct { + __u32 tm; + __u32 parms; + __u32 dmac; + __u32 smac; + __u32 etype; + } _len; + + struct tcf_t *tm; + void *parms; + void *dmac; + void *smac; + void *etype; +}; + +struct tc_act_tunnel_key_attrs { + struct { + __u32 enc_ipv4_src:1; + __u32 enc_ipv4_dst:1; + __u32 enc_key_id:1; + __u32 enc_dst_port:1; + __u32 no_csum:1; + __u32 enc_tos:1; + __u32 enc_ttl:1; + __u32 no_frag:1; + } _present; + struct { + __u32 tm; + __u32 parms; + __u32 enc_ipv6_src; + __u32 enc_ipv6_dst; + __u32 enc_opts; + } _len; + + struct tcf_t *tm; + void *parms; + __u32 enc_ipv4_src /* big-endian */; + __u32 enc_ipv4_dst /* big-endian */; + void *enc_ipv6_src; + void *enc_ipv6_dst; + __u64 enc_key_id /* big-endian */; + __u16 enc_dst_port /* big-endian */; + __u8 no_csum; + void *enc_opts; + __u8 enc_tos; + __u8 enc_ttl; +}; + +struct tc_act_vlan_attrs { + struct { + __u32 push_vlan_id:1; + __u32 push_vlan_protocol:1; + __u32 push_vlan_priority:1; + } _present; + struct { + __u32 tm; + __u32 parms; + __u32 push_eth_dst; + __u32 push_eth_src; + } _len; + + struct tcf_t *tm; + struct tc_vlan *parms; + __u16 push_vlan_id; + __u16 push_vlan_protocol; + __u8 push_vlan_priority; + void *push_eth_dst; + void *push_eth_src; +}; + +struct tc_flow_attrs { + struct { + __u32 keys:1; + __u32 mode:1; + __u32 baseclass:1; + __u32 rshift:1; + __u32 addend:1; + __u32 mask:1; + __u32 xor:1; + __u32 divisor:1; + __u32 police:1; + __u32 perturb:1; + } _present; + struct { + __u32 act; + __u32 ematches; + } _len; + + __u32 keys; + __u32 mode; + __u32 baseclass; + __u32 rshift; + __u32 addend; + __u32 mask; + __u32 xor; + __u32 divisor; + void *act; + struct tc_police_attrs police; + void *ematches; + __u32 perturb; +}; + +struct tc_netem_attrs { + struct tc_netem_qopt _hdr; + + struct { + __u32 loss:1; + __u32 ecn:1; + __u32 rate64:1; + __u32 pad:1; + __u32 latency64:1; + __u32 jitter64:1; + __u32 prng_seed:1; + } _present; + struct { + __u32 corr; + __u32 reorder; + __u32 corrupt; + __u32 rate; + __u32 slot; + } _len; + struct { + __u32 delay_dist; + __u32 slot_dist; + } _count; + + struct tc_netem_corr *corr; + __s16 *delay_dist; + struct tc_netem_reorder *reorder; + struct tc_netem_corrupt *corrupt; + struct tc_netem_loss_attrs loss; + struct tc_netem_rate *rate; + __u32 ecn; + __u64 rate64; + __u32 pad; + __s64 latency64; + __s64 jitter64; + struct tc_netem_slot *slot; + __s16 *slot_dist; + __u64 prng_seed; +}; + +struct tc_cake_stats_attrs { + struct { + __u32 capacity_estimate64:1; + __u32 memory_limit:1; + __u32 memory_used:1; + __u32 avg_netoff:1; + __u32 min_netlen:1; + __u32 max_netlen:1; + __u32 min_adjlen:1; + __u32 max_adjlen:1; + __u32 deficit:1; + __u32 cobalt_count:1; + __u32 dropping:1; + __u32 drop_next_us:1; + __u32 p_drop:1; + __u32 blue_timer_us:1; + } _present; + struct { + __u32 tin_stats; + } _count; + + __u64 capacity_estimate64; + __u32 memory_limit; + __u32 memory_used; + __u32 avg_netoff; + __u32 min_netlen; + __u32 max_netlen; + __u32 min_adjlen; + __u32 max_adjlen; + struct tc_cake_tin_stats_attrs *tin_stats; + __s32 deficit; + __u32 cobalt_count; + __u32 dropping; + __s32 drop_next_us; + __u32 p_drop; + __s32 blue_timer_us; +}; + +struct tc_flower_key_enc_opts_attrs { + struct { + __u32 geneve:1; + __u32 vxlan:1; + __u32 erspan:1; + __u32 gtp:1; + } _present; + + struct tc_flower_key_enc_opt_geneve_attrs geneve; + struct tc_flower_key_enc_opt_vxlan_attrs vxlan; + struct tc_flower_key_enc_opt_erspan_attrs erspan; + struct tc_flower_key_enc_opt_gtp_attrs gtp; +}; + +struct tc_tca_gred_vq_list_attrs { + struct { + __u32 entry; + } _count; + + struct tc_tca_gred_vq_entry_attrs *entry; +}; + +struct tc_taprio_sched_entry_list { + struct { + __u32 entry; + } _count; + + struct tc_taprio_sched_entry *entry; +}; + +struct tc_act_options_msg { + struct { + __u32 bpf:1; + __u32 connmark:1; + __u32 csum:1; + __u32 ct:1; + __u32 ctinfo:1; + __u32 gact:1; + __u32 gate:1; + __u32 ife:1; + __u32 mirred:1; + __u32 mpls:1; + __u32 nat:1; + __u32 pedit:1; + __u32 police:1; + __u32 sample:1; + __u32 simple:1; + __u32 skbedit:1; + __u32 skbmod:1; + __u32 tunnel_key:1; + __u32 vlan:1; + } _present; + + struct tc_act_bpf_attrs bpf; + struct tc_act_connmark_attrs connmark; + struct tc_act_csum_attrs csum; + struct tc_act_ct_attrs ct; + struct tc_act_ctinfo_attrs ctinfo; + struct tc_act_gact_attrs gact; + struct tc_act_gate_attrs gate; + struct tc_act_ife_attrs ife; + struct tc_act_mirred_attrs mirred; + struct tc_act_mpls_attrs mpls; + struct tc_act_nat_attrs nat; + struct tc_act_pedit_attrs pedit; + struct tc_police_attrs police; + struct tc_act_sample_attrs sample; + struct tc_act_simple_attrs simple; + struct tc_act_skbedit_attrs skbedit; + struct tc_act_skbmod_attrs skbmod; + struct tc_act_tunnel_key_attrs tunnel_key; + struct tc_act_vlan_attrs vlan; +}; + +struct tc_tca_stats_app_msg { + struct { + __u32 cake:1; + } _present; + struct { + __u32 choke; + __u32 codel; + __u32 fq; + __u32 fq_codel; + __u32 fq_pie; + __u32 hhf; + __u32 pie; + __u32 red; + __u32 sfb; + __u32 sfq; + } _len; + + struct tc_cake_stats_attrs cake; + struct tc_choke_xstats *choke; + struct tc_codel_xstats *codel; + struct tc_fq_qd_stats *fq; + struct tc_fq_codel_xstats *fq_codel; + struct tc_fq_pie_xstats *fq_pie; + struct tc_hhf_xstats *hhf; + struct tc_pie_xstats *pie; + struct tc_red_xstats *red; + struct tc_sfb_xstats *sfb; + struct tc_sfq_xstats *sfq; +}; + +struct tc_tca_stats_attrs { + struct { + __u32 app:1; + __u32 pkt64:1; + } _present; + struct { + __u32 basic; + __u32 rate_est; + __u32 queue; + __u32 rate_est64; + __u32 basic_hw; + } _len; + + struct gnet_stats_basic *basic; + struct gnet_stats_rate_est *rate_est; + struct gnet_stats_queue *queue; + struct tc_tca_stats_app_msg app; + struct gnet_stats_rate_est64 *rate_est64; + struct gnet_stats_basic *basic_hw; + __u64 pkt64; +}; + +struct tc_gred_attrs { + struct { + __u32 limit:1; + __u32 vq_list:1; + } _present; + struct { + __u32 parms; + __u32 dps; + } _len; + struct { + __u32 stab; + __u32 max_p; + } _count; + + void *parms; + __u8 *stab; + struct tc_gred_sopt *dps; + __u32 *max_p; + __u32 limit; + struct tc_tca_gred_vq_list_attrs vq_list; +}; + +struct tc_taprio_attrs { + struct { + __u32 sched_entry_list:1; + __u32 sched_base_time:1; + __u32 sched_single_entry:1; + __u32 sched_clockid:1; + __u32 sched_cycle_time:1; + __u32 sched_cycle_time_extension:1; + __u32 flags:1; + __u32 txtime_delay:1; + __u32 tc_entry:1; + } _present; + struct { + __u32 priomap; + __u32 admin_sched; + } _len; + + struct tc_mqprio_qopt *priomap; + struct tc_taprio_sched_entry_list sched_entry_list; + __s64 sched_base_time; + struct tc_taprio_sched_entry sched_single_entry; + __s32 sched_clockid; + void *admin_sched; + __s64 sched_cycle_time; + __s64 sched_cycle_time_extension; + __u32 flags; + __u32 txtime_delay; + struct tc_taprio_tc_entry_attrs tc_entry; +}; + +struct tc_act_attrs { + struct { + __u32 options:1; + __u32 index:1; + __u32 stats:1; + __u32 flags:1; + __u32 hw_stats:1; + __u32 used_hw_stats:1; + __u32 in_hw_count:1; + } _present; + struct { + __u32 kind; + __u32 cookie; + } _len; + + __u32 idx; + char *kind; + struct tc_act_options_msg options; + __u32 index; + struct tc_tca_stats_attrs stats; + void *cookie; + struct nla_bitfield32 flags; + struct nla_bitfield32 hw_stats; + struct nla_bitfield32 used_hw_stats; + __u32 in_hw_count; +}; + +void tc_act_attrs_free(struct tc_act_attrs *obj); + +struct tc_basic_attrs { + struct { + __u32 classid:1; + __u32 ematches:1; + __u32 police:1; + } _present; + struct { + __u32 pcnt; + } _len; + struct { + __u32 act; + } _count; + + __u32 classid; + struct tc_ematch_attrs ematches; + struct tc_act_attrs *act; + struct tc_police_attrs police; + struct tc_basic_pcnt *pcnt; +}; + +struct tc_bpf_attrs { + struct { + __u32 police:1; + __u32 classid:1; + __u32 ops_len:1; + __u32 fd:1; + __u32 flags:1; + __u32 flags_gen:1; + __u32 id:1; + } _present; + struct { + __u32 ops; + __u32 name; + __u32 tag; + } _len; + struct { + __u32 act; + } _count; + + struct tc_act_attrs *act; + struct tc_police_attrs police; + __u32 classid; + __u16 ops_len; + void *ops; + __u32 fd; + char *name; + __u32 flags; + __u32 flags_gen; + void *tag; + __u32 id; +}; + +struct tc_cgroup_attrs { + struct { + __u32 police:1; + } _present; + struct { + __u32 ematches; + } _len; + struct { + __u32 act; + } _count; + + struct tc_act_attrs *act; + struct tc_police_attrs police; + void *ematches; +}; + +struct tc_flower_attrs { + struct { + __u32 classid:1; + __u32 key_eth_type:1; + __u32 key_ip_proto:1; + __u32 key_ipv4_src:1; + __u32 key_ipv4_src_mask:1; + __u32 key_ipv4_dst:1; + __u32 key_ipv4_dst_mask:1; + __u32 key_tcp_src:1; + __u32 key_tcp_dst:1; + __u32 key_udp_src:1; + __u32 key_udp_dst:1; + __u32 flags:1; + __u32 key_vlan_id:1; + __u32 key_vlan_prio:1; + __u32 key_vlan_eth_type:1; + __u32 key_enc_key_id:1; + __u32 key_enc_ipv4_src:1; + __u32 key_enc_ipv4_src_mask:1; + __u32 key_enc_ipv4_dst:1; + __u32 key_enc_ipv4_dst_mask:1; + __u32 key_tcp_src_mask:1; + __u32 key_tcp_dst_mask:1; + __u32 key_udp_src_mask:1; + __u32 key_udp_dst_mask:1; + __u32 key_sctp_src_mask:1; + __u32 key_sctp_dst_mask:1; + __u32 key_sctp_src:1; + __u32 key_sctp_dst:1; + __u32 key_enc_udp_src_port:1; + __u32 key_enc_udp_src_port_mask:1; + __u32 key_enc_udp_dst_port:1; + __u32 key_enc_udp_dst_port_mask:1; + __u32 key_flags:1; + __u32 key_flags_mask:1; + __u32 key_icmpv4_code:1; + __u32 key_icmpv4_code_mask:1; + __u32 key_icmpv4_type:1; + __u32 key_icmpv4_type_mask:1; + __u32 key_icmpv6_code:1; + __u32 key_icmpv6_code_mask:1; + __u32 key_icmpv6_type:1; + __u32 key_icmpv6_type_mask:1; + __u32 key_arp_sip:1; + __u32 key_arp_sip_mask:1; + __u32 key_arp_tip:1; + __u32 key_arp_tip_mask:1; + __u32 key_arp_op:1; + __u32 key_arp_op_mask:1; + __u32 key_mpls_ttl:1; + __u32 key_mpls_bos:1; + __u32 key_mpls_tc:1; + __u32 key_mpls_label:1; + __u32 key_tcp_flags:1; + __u32 key_tcp_flags_mask:1; + __u32 key_ip_tos:1; + __u32 key_ip_tos_mask:1; + __u32 key_ip_ttl:1; + __u32 key_ip_ttl_mask:1; + __u32 key_cvlan_id:1; + __u32 key_cvlan_prio:1; + __u32 key_cvlan_eth_type:1; + __u32 key_enc_ip_tos:1; + __u32 key_enc_ip_tos_mask:1; + __u32 key_enc_ip_ttl:1; + __u32 key_enc_ip_ttl_mask:1; + __u32 key_enc_opts:1; + __u32 key_enc_opts_mask:1; + __u32 in_hw_count:1; + __u32 key_port_src_min:1; + __u32 key_port_src_max:1; + __u32 key_port_dst_min:1; + __u32 key_port_dst_max:1; + __u32 key_ct_state:1; + __u32 key_ct_state_mask:1; + __u32 key_ct_zone:1; + __u32 key_ct_zone_mask:1; + __u32 key_ct_mark:1; + __u32 key_ct_mark_mask:1; + __u32 key_mpls_opts:1; + __u32 key_hash:1; + __u32 key_hash_mask:1; + __u32 key_num_of_vlans:1; + __u32 key_pppoe_sid:1; + __u32 key_ppp_proto:1; + __u32 key_l2tpv3_sid:1; + __u32 l2_miss:1; + __u32 key_cfm:1; + __u32 key_spi:1; + __u32 key_spi_mask:1; + __u32 key_enc_flags:1; + __u32 key_enc_flags_mask:1; + } _present; + struct { + __u32 indev; + __u32 key_eth_dst; + __u32 key_eth_dst_mask; + __u32 key_eth_src; + __u32 key_eth_src_mask; + __u32 key_ipv6_src; + __u32 key_ipv6_src_mask; + __u32 key_ipv6_dst; + __u32 key_ipv6_dst_mask; + __u32 key_enc_ipv6_src; + __u32 key_enc_ipv6_src_mask; + __u32 key_enc_ipv6_dst; + __u32 key_enc_ipv6_dst_mask; + __u32 key_arp_sha; + __u32 key_arp_sha_mask; + __u32 key_arp_tha; + __u32 key_arp_tha_mask; + __u32 key_ct_labels; + __u32 key_ct_labels_mask; + } _len; + struct { + __u32 act; + } _count; + + __u32 classid; + char *indev; + struct tc_act_attrs *act; + void *key_eth_dst; + void *key_eth_dst_mask; + void *key_eth_src; + void *key_eth_src_mask; + __u16 key_eth_type /* big-endian */; + __u8 key_ip_proto; + __u32 key_ipv4_src /* big-endian */; + __u32 key_ipv4_src_mask /* big-endian */; + __u32 key_ipv4_dst /* big-endian */; + __u32 key_ipv4_dst_mask /* big-endian */; + void *key_ipv6_src; + void *key_ipv6_src_mask; + void *key_ipv6_dst; + void *key_ipv6_dst_mask; + __u16 key_tcp_src /* big-endian */; + __u16 key_tcp_dst /* big-endian */; + __u16 key_udp_src /* big-endian */; + __u16 key_udp_dst /* big-endian */; + __u32 flags; + __u16 key_vlan_id /* big-endian */; + __u8 key_vlan_prio; + __u16 key_vlan_eth_type /* big-endian */; + __u32 key_enc_key_id /* big-endian */; + __u32 key_enc_ipv4_src /* big-endian */; + __u32 key_enc_ipv4_src_mask /* big-endian */; + __u32 key_enc_ipv4_dst /* big-endian */; + __u32 key_enc_ipv4_dst_mask /* big-endian */; + void *key_enc_ipv6_src; + void *key_enc_ipv6_src_mask; + void *key_enc_ipv6_dst; + void *key_enc_ipv6_dst_mask; + __u16 key_tcp_src_mask /* big-endian */; + __u16 key_tcp_dst_mask /* big-endian */; + __u16 key_udp_src_mask /* big-endian */; + __u16 key_udp_dst_mask /* big-endian */; + __u16 key_sctp_src_mask /* big-endian */; + __u16 key_sctp_dst_mask /* big-endian */; + __u16 key_sctp_src /* big-endian */; + __u16 key_sctp_dst /* big-endian */; + __u16 key_enc_udp_src_port /* big-endian */; + __u16 key_enc_udp_src_port_mask /* big-endian */; + __u16 key_enc_udp_dst_port /* big-endian */; + __u16 key_enc_udp_dst_port_mask /* big-endian */; + __u32 key_flags /* big-endian */; + __u32 key_flags_mask /* big-endian */; + __u8 key_icmpv4_code; + __u8 key_icmpv4_code_mask; + __u8 key_icmpv4_type; + __u8 key_icmpv4_type_mask; + __u8 key_icmpv6_code; + __u8 key_icmpv6_code_mask; + __u8 key_icmpv6_type; + __u8 key_icmpv6_type_mask; + __u32 key_arp_sip /* big-endian */; + __u32 key_arp_sip_mask /* big-endian */; + __u32 key_arp_tip /* big-endian */; + __u32 key_arp_tip_mask /* big-endian */; + __u8 key_arp_op; + __u8 key_arp_op_mask; + void *key_arp_sha; + void *key_arp_sha_mask; + void *key_arp_tha; + void *key_arp_tha_mask; + __u8 key_mpls_ttl; + __u8 key_mpls_bos; + __u8 key_mpls_tc; + __u32 key_mpls_label /* big-endian */; + __u16 key_tcp_flags /* big-endian */; + __u16 key_tcp_flags_mask /* big-endian */; + __u8 key_ip_tos; + __u8 key_ip_tos_mask; + __u8 key_ip_ttl; + __u8 key_ip_ttl_mask; + __u16 key_cvlan_id /* big-endian */; + __u8 key_cvlan_prio; + __u16 key_cvlan_eth_type /* big-endian */; + __u8 key_enc_ip_tos; + __u8 key_enc_ip_tos_mask; + __u8 key_enc_ip_ttl; + __u8 key_enc_ip_ttl_mask; + struct tc_flower_key_enc_opts_attrs key_enc_opts; + struct tc_flower_key_enc_opts_attrs key_enc_opts_mask; + __u32 in_hw_count; + __u16 key_port_src_min /* big-endian */; + __u16 key_port_src_max /* big-endian */; + __u16 key_port_dst_min /* big-endian */; + __u16 key_port_dst_max /* big-endian */; + __u16 key_ct_state; + __u16 key_ct_state_mask; + __u16 key_ct_zone; + __u16 key_ct_zone_mask; + __u32 key_ct_mark; + __u32 key_ct_mark_mask; + void *key_ct_labels; + void *key_ct_labels_mask; + struct tc_flower_key_mpls_opt_attrs key_mpls_opts; + __u32 key_hash; + __u32 key_hash_mask; + __u8 key_num_of_vlans; + __u16 key_pppoe_sid /* big-endian */; + __u16 key_ppp_proto /* big-endian */; + __u32 key_l2tpv3_sid /* big-endian */; + __u8 l2_miss; + struct tc_flower_key_cfm_attrs key_cfm; + __u32 key_spi /* big-endian */; + __u32 key_spi_mask /* big-endian */; + __u32 key_enc_flags /* big-endian */; + __u32 key_enc_flags_mask /* big-endian */; +}; + +struct tc_fw_attrs { + struct { + __u32 classid:1; + __u32 police:1; + __u32 mask:1; + } _present; + struct { + __u32 indev; + } _len; + struct { + __u32 act; + } _count; + + __u32 classid; + struct tc_police_attrs police; + char *indev; + struct tc_act_attrs *act; + __u32 mask; +}; + +struct tc_matchall_attrs { + struct { + __u32 classid:1; + __u32 flags:1; + } _present; + struct { + __u32 pcnt; + } _len; + struct { + __u32 act; + } _count; + + __u32 classid; + struct tc_act_attrs *act; + __u32 flags; + struct tc_matchall_pcnt *pcnt; +}; + +struct tc_route_attrs { + struct { + __u32 classid:1; + __u32 to:1; + __u32 from:1; + __u32 iif:1; + __u32 police:1; + } _present; + struct { + __u32 act; + } _count; + + __u32 classid; + __u32 to; + __u32 from; + __u32 iif; + struct tc_police_attrs police; + struct tc_act_attrs *act; +}; + +struct tc_u32_attrs { + struct { + __u32 classid:1; + __u32 hash:1; + __u32 link:1; + __u32 divisor:1; + __u32 police:1; + __u32 flags:1; + } _present; + struct { + __u32 sel; + __u32 indev; + __u32 pcnt; + __u32 mark; + } _len; + struct { + __u32 act; + } _count; + + __u32 classid; + __u32 hash; + __u32 link; + __u32 divisor; + struct tc_u32_sel *sel; + struct tc_police_attrs police; + struct tc_act_attrs *act; + char *indev; + struct tc_u32_pcnt *pcnt; + struct tc_u32_mark *mark; + __u32 flags; +}; + +struct tc_ets_attrs { + struct { + __u32 nbands:1; + __u32 nstrict:1; + __u32 quanta:1; + __u32 priomap:1; + } _present; + struct { + __u32 quanta_band; + __u32 priomap_band; + } _count; + + __u8 nbands; + __u8 nstrict; + struct tc_ets_attrs *quanta; + __u32 *quanta_band; + struct tc_ets_attrs *priomap; + __u8 *priomap_band; +}; + +struct tc_options_msg { + struct { + __u32 basic:1; + __u32 bpf:1; + __u32 cake:1; + __u32 cbs:1; + __u32 cgroup:1; + __u32 choke:1; + __u32 clsact:1; + __u32 codel:1; + __u32 drr:1; + __u32 etf:1; + __u32 ets:1; + __u32 flow:1; + __u32 flower:1; + __u32 fq:1; + __u32 fq_codel:1; + __u32 fq_pie:1; + __u32 fw:1; + __u32 gred:1; + __u32 hhf:1; + __u32 htb:1; + __u32 ingress:1; + __u32 matchall:1; + __u32 mq:1; + __u32 netem:1; + __u32 pie:1; + __u32 qfq:1; + __u32 red:1; + __u32 route:1; + __u32 taprio:1; + __u32 tbf:1; + __u32 u32:1; + } _present; + struct { + __u32 bfifo; + __u32 hfsc; + __u32 mqprio; + __u32 multiq; + __u32 pfifo; + __u32 pfifo_fast; + __u32 pfifo_head_drop; + __u32 plug; + __u32 prio; + __u32 sfb; + __u32 sfq; + } _len; + + struct tc_basic_attrs basic; + struct tc_bpf_attrs bpf; + struct tc_fifo_qopt *bfifo; + struct tc_cake_attrs cake; + struct tc_cbs_attrs cbs; + struct tc_cgroup_attrs cgroup; + struct tc_choke_attrs choke; + struct tc_codel_attrs codel; + struct tc_drr_attrs drr; + struct tc_etf_attrs etf; + struct tc_ets_attrs *ets; + struct tc_flow_attrs flow; + struct tc_flower_attrs flower; + struct tc_fq_attrs fq; + struct tc_fq_codel_attrs fq_codel; + struct tc_fq_pie_attrs fq_pie; + struct tc_fw_attrs fw; + struct tc_gred_attrs gred; + struct tc_hfsc_qopt *hfsc; + struct tc_hhf_attrs hhf; + struct tc_htb_attrs htb; + struct tc_matchall_attrs matchall; + struct tc_mqprio_qopt *mqprio; + struct tc_multiq_qopt *multiq; + struct tc_netem_attrs netem; + struct tc_fifo_qopt *pfifo; + struct tc_prio_qopt *pfifo_fast; + struct tc_fifo_qopt *pfifo_head_drop; + struct tc_pie_attrs pie; + struct tc_plug_qopt *plug; + struct tc_prio_qopt *prio; + struct tc_qfq_attrs qfq; + struct tc_red_attrs red; + struct tc_route_attrs route; + struct tc_sfb_qopt *sfb; + struct tc_sfq_qopt_v1 *sfq; + struct tc_taprio_attrs taprio; + struct tc_tbf_attrs tbf; + struct tc_u32_attrs u32; +}; + +/* ============== RTM_NEWQDISC ============== */ +/* RTM_NEWQDISC - do */ +struct tc_newqdisc_req { + __u16 _nlmsg_flags; + + struct tcmsg _hdr; + + struct { + __u32 options:1; + __u32 chain:1; + __u32 ingress_block:1; + __u32 egress_block:1; + } _present; + struct { + __u32 kind; + __u32 rate; + } _len; + + char *kind; + struct tc_options_msg options; + struct gnet_estimator *rate; + __u32 chain; + __u32 ingress_block; + __u32 egress_block; +}; + +static inline struct tc_newqdisc_req *tc_newqdisc_req_alloc(void) +{ + return calloc(1, sizeof(struct tc_newqdisc_req)); +} +void tc_newqdisc_req_free(struct tc_newqdisc_req *req); + +static inline void +tc_newqdisc_req_set_nlflags(struct tc_newqdisc_req *req, __u16 nl_flags) +{ + req->_nlmsg_flags = nl_flags; +} + +static inline void +tc_newqdisc_req_set_kind(struct tc_newqdisc_req *req, const char *kind) +{ + free(req->kind); + req->_len.kind = strlen(kind); + req->kind = malloc(req->_len.kind + 1); + memcpy(req->kind, kind, req->_len.kind); + req->kind[req->_len.kind] = 0; +} +static inline void +tc_newqdisc_req_set_options_basic_classid(struct tc_newqdisc_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.classid = 1; + req->options.basic.classid = classid; +} +static inline void +tc_newqdisc_req_set_options_basic_ematches_tree_hdr(struct tc_newqdisc_req *req, + const void *tree_hdr, + size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.ematches = 1; + free(req->options.basic.ematches.tree_hdr); + req->options.basic.ematches._len.tree_hdr = len; + req->options.basic.ematches.tree_hdr = malloc(req->options.basic.ematches._len.tree_hdr); + memcpy(req->options.basic.ematches.tree_hdr, tree_hdr, req->options.basic.ematches._len.tree_hdr); +} +static inline void +tc_newqdisc_req_set_options_basic_ematches_tree_list(struct tc_newqdisc_req *req, + const void *tree_list, + size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.ematches = 1; + free(req->options.basic.ematches.tree_list); + req->options.basic.ematches._len.tree_list = len; + req->options.basic.ematches.tree_list = malloc(req->options.basic.ematches._len.tree_list); + memcpy(req->options.basic.ematches.tree_list, tree_list, req->options.basic.ematches._len.tree_list); +} +static inline void +__tc_newqdisc_req_set_options_basic_act(struct tc_newqdisc_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.basic = 1; + free(req->options.basic.act); + req->options.basic.act = act; + req->options.basic._count.act = n_act; +} +static inline void +tc_newqdisc_req_set_options_basic_police_tbf(struct tc_newqdisc_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.tbf); + req->options.basic.police._len.tbf = len; + req->options.basic.police.tbf = malloc(req->options.basic.police._len.tbf); + memcpy(req->options.basic.police.tbf, tbf, req->options.basic.police._len.tbf); +} +static inline void +tc_newqdisc_req_set_options_basic_police_rate(struct tc_newqdisc_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.rate); + req->options.basic.police._len.rate = len; + req->options.basic.police.rate = malloc(req->options.basic.police._len.rate); + memcpy(req->options.basic.police.rate, rate, req->options.basic.police._len.rate); +} +static inline void +tc_newqdisc_req_set_options_basic_police_peakrate(struct tc_newqdisc_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.peakrate); + req->options.basic.police._len.peakrate = len; + req->options.basic.police.peakrate = malloc(req->options.basic.police._len.peakrate); + memcpy(req->options.basic.police.peakrate, peakrate, req->options.basic.police._len.peakrate); +} +static inline void +tc_newqdisc_req_set_options_basic_police_avrate(struct tc_newqdisc_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.avrate = 1; + req->options.basic.police.avrate = avrate; +} +static inline void +tc_newqdisc_req_set_options_basic_police_result(struct tc_newqdisc_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.result = 1; + req->options.basic.police.result = result; +} +static inline void +tc_newqdisc_req_set_options_basic_police_tm(struct tc_newqdisc_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.tm); + req->options.basic.police._len.tm = len; + req->options.basic.police.tm = malloc(req->options.basic.police._len.tm); + memcpy(req->options.basic.police.tm, tm, req->options.basic.police._len.tm); +} +static inline void +tc_newqdisc_req_set_options_basic_police_rate64(struct tc_newqdisc_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.rate64 = 1; + req->options.basic.police.rate64 = rate64; +} +static inline void +tc_newqdisc_req_set_options_basic_police_peakrate64(struct tc_newqdisc_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.peakrate64 = 1; + req->options.basic.police.peakrate64 = peakrate64; +} +static inline void +tc_newqdisc_req_set_options_basic_police_pktrate64(struct tc_newqdisc_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.pktrate64 = 1; + req->options.basic.police.pktrate64 = pktrate64; +} +static inline void +tc_newqdisc_req_set_options_basic_police_pktburst64(struct tc_newqdisc_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.pktburst64 = 1; + req->options.basic.police.pktburst64 = pktburst64; +} +static inline void +tc_newqdisc_req_set_options_basic_pcnt(struct tc_newqdisc_req *req, + const void *pcnt, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + free(req->options.basic.pcnt); + req->options.basic._len.pcnt = len; + req->options.basic.pcnt = malloc(req->options.basic._len.pcnt); + memcpy(req->options.basic.pcnt, pcnt, req->options.basic._len.pcnt); +} +static inline void +__tc_newqdisc_req_set_options_bpf_act(struct tc_newqdisc_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.act); + req->options.bpf.act = act; + req->options.bpf._count.act = n_act; +} +static inline void +tc_newqdisc_req_set_options_bpf_police_tbf(struct tc_newqdisc_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.tbf); + req->options.bpf.police._len.tbf = len; + req->options.bpf.police.tbf = malloc(req->options.bpf.police._len.tbf); + memcpy(req->options.bpf.police.tbf, tbf, req->options.bpf.police._len.tbf); +} +static inline void +tc_newqdisc_req_set_options_bpf_police_rate(struct tc_newqdisc_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.rate); + req->options.bpf.police._len.rate = len; + req->options.bpf.police.rate = malloc(req->options.bpf.police._len.rate); + memcpy(req->options.bpf.police.rate, rate, req->options.bpf.police._len.rate); +} +static inline void +tc_newqdisc_req_set_options_bpf_police_peakrate(struct tc_newqdisc_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.peakrate); + req->options.bpf.police._len.peakrate = len; + req->options.bpf.police.peakrate = malloc(req->options.bpf.police._len.peakrate); + memcpy(req->options.bpf.police.peakrate, peakrate, req->options.bpf.police._len.peakrate); +} +static inline void +tc_newqdisc_req_set_options_bpf_police_avrate(struct tc_newqdisc_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.avrate = 1; + req->options.bpf.police.avrate = avrate; +} +static inline void +tc_newqdisc_req_set_options_bpf_police_result(struct tc_newqdisc_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.result = 1; + req->options.bpf.police.result = result; +} +static inline void +tc_newqdisc_req_set_options_bpf_police_tm(struct tc_newqdisc_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.tm); + req->options.bpf.police._len.tm = len; + req->options.bpf.police.tm = malloc(req->options.bpf.police._len.tm); + memcpy(req->options.bpf.police.tm, tm, req->options.bpf.police._len.tm); +} +static inline void +tc_newqdisc_req_set_options_bpf_police_rate64(struct tc_newqdisc_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.rate64 = 1; + req->options.bpf.police.rate64 = rate64; +} +static inline void +tc_newqdisc_req_set_options_bpf_police_peakrate64(struct tc_newqdisc_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.peakrate64 = 1; + req->options.bpf.police.peakrate64 = peakrate64; +} +static inline void +tc_newqdisc_req_set_options_bpf_police_pktrate64(struct tc_newqdisc_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.pktrate64 = 1; + req->options.bpf.police.pktrate64 = pktrate64; +} +static inline void +tc_newqdisc_req_set_options_bpf_police_pktburst64(struct tc_newqdisc_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.pktburst64 = 1; + req->options.bpf.police.pktburst64 = pktburst64; +} +static inline void +tc_newqdisc_req_set_options_bpf_classid(struct tc_newqdisc_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.classid = 1; + req->options.bpf.classid = classid; +} +static inline void +tc_newqdisc_req_set_options_bpf_ops_len(struct tc_newqdisc_req *req, + __u16 ops_len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.ops_len = 1; + req->options.bpf.ops_len = ops_len; +} +static inline void +tc_newqdisc_req_set_options_bpf_ops(struct tc_newqdisc_req *req, + const void *ops, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.ops); + req->options.bpf._len.ops = len; + req->options.bpf.ops = malloc(req->options.bpf._len.ops); + memcpy(req->options.bpf.ops, ops, req->options.bpf._len.ops); +} +static inline void +tc_newqdisc_req_set_options_bpf_fd(struct tc_newqdisc_req *req, __u32 fd) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.fd = 1; + req->options.bpf.fd = fd; +} +static inline void +tc_newqdisc_req_set_options_bpf_name(struct tc_newqdisc_req *req, + const char *name) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.name); + req->options.bpf._len.name = strlen(name); + req->options.bpf.name = malloc(req->options.bpf._len.name + 1); + memcpy(req->options.bpf.name, name, req->options.bpf._len.name); + req->options.bpf.name[req->options.bpf._len.name] = 0; +} +static inline void +tc_newqdisc_req_set_options_bpf_flags(struct tc_newqdisc_req *req, __u32 flags) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.flags = 1; + req->options.bpf.flags = flags; +} +static inline void +tc_newqdisc_req_set_options_bpf_flags_gen(struct tc_newqdisc_req *req, + __u32 flags_gen) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.flags_gen = 1; + req->options.bpf.flags_gen = flags_gen; +} +static inline void +tc_newqdisc_req_set_options_bpf_tag(struct tc_newqdisc_req *req, + const void *tag, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.tag); + req->options.bpf._len.tag = len; + req->options.bpf.tag = malloc(req->options.bpf._len.tag); + memcpy(req->options.bpf.tag, tag, req->options.bpf._len.tag); +} +static inline void +tc_newqdisc_req_set_options_bpf_id(struct tc_newqdisc_req *req, __u32 id) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.id = 1; + req->options.bpf.id = id; +} +static inline void +tc_newqdisc_req_set_options_bfifo(struct tc_newqdisc_req *req, + const void *bfifo, size_t len) +{ + req->_present.options = 1; + free(req->options.bfifo); + req->options._len.bfifo = len; + req->options.bfifo = malloc(req->options._len.bfifo); + memcpy(req->options.bfifo, bfifo, req->options._len.bfifo); +} +static inline void +tc_newqdisc_req_set_options_cake_base_rate64(struct tc_newqdisc_req *req, + __u64 base_rate64) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.base_rate64 = 1; + req->options.cake.base_rate64 = base_rate64; +} +static inline void +tc_newqdisc_req_set_options_cake_diffserv_mode(struct tc_newqdisc_req *req, + __u32 diffserv_mode) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.diffserv_mode = 1; + req->options.cake.diffserv_mode = diffserv_mode; +} +static inline void +tc_newqdisc_req_set_options_cake_atm(struct tc_newqdisc_req *req, __u32 atm) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.atm = 1; + req->options.cake.atm = atm; +} +static inline void +tc_newqdisc_req_set_options_cake_flow_mode(struct tc_newqdisc_req *req, + __u32 flow_mode) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.flow_mode = 1; + req->options.cake.flow_mode = flow_mode; +} +static inline void +tc_newqdisc_req_set_options_cake_overhead(struct tc_newqdisc_req *req, + __u32 overhead) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.overhead = 1; + req->options.cake.overhead = overhead; +} +static inline void +tc_newqdisc_req_set_options_cake_rtt(struct tc_newqdisc_req *req, __u32 rtt) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.rtt = 1; + req->options.cake.rtt = rtt; +} +static inline void +tc_newqdisc_req_set_options_cake_target(struct tc_newqdisc_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.target = 1; + req->options.cake.target = target; +} +static inline void +tc_newqdisc_req_set_options_cake_autorate(struct tc_newqdisc_req *req, + __u32 autorate) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.autorate = 1; + req->options.cake.autorate = autorate; +} +static inline void +tc_newqdisc_req_set_options_cake_memory(struct tc_newqdisc_req *req, + __u32 memory) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.memory = 1; + req->options.cake.memory = memory; +} +static inline void +tc_newqdisc_req_set_options_cake_nat(struct tc_newqdisc_req *req, __u32 nat) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.nat = 1; + req->options.cake.nat = nat; +} +static inline void +tc_newqdisc_req_set_options_cake_raw(struct tc_newqdisc_req *req, __u32 raw) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.raw = 1; + req->options.cake.raw = raw; +} +static inline void +tc_newqdisc_req_set_options_cake_wash(struct tc_newqdisc_req *req, __u32 wash) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.wash = 1; + req->options.cake.wash = wash; +} +static inline void +tc_newqdisc_req_set_options_cake_mpu(struct tc_newqdisc_req *req, __u32 mpu) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.mpu = 1; + req->options.cake.mpu = mpu; +} +static inline void +tc_newqdisc_req_set_options_cake_ingress(struct tc_newqdisc_req *req, + __u32 ingress) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.ingress = 1; + req->options.cake.ingress = ingress; +} +static inline void +tc_newqdisc_req_set_options_cake_ack_filter(struct tc_newqdisc_req *req, + __u32 ack_filter) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.ack_filter = 1; + req->options.cake.ack_filter = ack_filter; +} +static inline void +tc_newqdisc_req_set_options_cake_split_gso(struct tc_newqdisc_req *req, + __u32 split_gso) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.split_gso = 1; + req->options.cake.split_gso = split_gso; +} +static inline void +tc_newqdisc_req_set_options_cake_fwmark(struct tc_newqdisc_req *req, + __u32 fwmark) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.fwmark = 1; + req->options.cake.fwmark = fwmark; +} +static inline void +tc_newqdisc_req_set_options_cbs_parms(struct tc_newqdisc_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.cbs = 1; + free(req->options.cbs.parms); + req->options.cbs._len.parms = len; + req->options.cbs.parms = malloc(req->options.cbs._len.parms); + memcpy(req->options.cbs.parms, parms, req->options.cbs._len.parms); +} +static inline void +__tc_newqdisc_req_set_options_cgroup_act(struct tc_newqdisc_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + free(req->options.cgroup.act); + req->options.cgroup.act = act; + req->options.cgroup._count.act = n_act; +} +static inline void +tc_newqdisc_req_set_options_cgroup_police_tbf(struct tc_newqdisc_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.tbf); + req->options.cgroup.police._len.tbf = len; + req->options.cgroup.police.tbf = malloc(req->options.cgroup.police._len.tbf); + memcpy(req->options.cgroup.police.tbf, tbf, req->options.cgroup.police._len.tbf); +} +static inline void +tc_newqdisc_req_set_options_cgroup_police_rate(struct tc_newqdisc_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.rate); + req->options.cgroup.police._len.rate = len; + req->options.cgroup.police.rate = malloc(req->options.cgroup.police._len.rate); + memcpy(req->options.cgroup.police.rate, rate, req->options.cgroup.police._len.rate); +} +static inline void +tc_newqdisc_req_set_options_cgroup_police_peakrate(struct tc_newqdisc_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.peakrate); + req->options.cgroup.police._len.peakrate = len; + req->options.cgroup.police.peakrate = malloc(req->options.cgroup.police._len.peakrate); + memcpy(req->options.cgroup.police.peakrate, peakrate, req->options.cgroup.police._len.peakrate); +} +static inline void +tc_newqdisc_req_set_options_cgroup_police_avrate(struct tc_newqdisc_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.avrate = 1; + req->options.cgroup.police.avrate = avrate; +} +static inline void +tc_newqdisc_req_set_options_cgroup_police_result(struct tc_newqdisc_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.result = 1; + req->options.cgroup.police.result = result; +} +static inline void +tc_newqdisc_req_set_options_cgroup_police_tm(struct tc_newqdisc_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.tm); + req->options.cgroup.police._len.tm = len; + req->options.cgroup.police.tm = malloc(req->options.cgroup.police._len.tm); + memcpy(req->options.cgroup.police.tm, tm, req->options.cgroup.police._len.tm); +} +static inline void +tc_newqdisc_req_set_options_cgroup_police_rate64(struct tc_newqdisc_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.rate64 = 1; + req->options.cgroup.police.rate64 = rate64; +} +static inline void +tc_newqdisc_req_set_options_cgroup_police_peakrate64(struct tc_newqdisc_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.peakrate64 = 1; + req->options.cgroup.police.peakrate64 = peakrate64; +} +static inline void +tc_newqdisc_req_set_options_cgroup_police_pktrate64(struct tc_newqdisc_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.pktrate64 = 1; + req->options.cgroup.police.pktrate64 = pktrate64; +} +static inline void +tc_newqdisc_req_set_options_cgroup_police_pktburst64(struct tc_newqdisc_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.pktburst64 = 1; + req->options.cgroup.police.pktburst64 = pktburst64; +} +static inline void +tc_newqdisc_req_set_options_cgroup_ematches(struct tc_newqdisc_req *req, + const void *ematches, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + free(req->options.cgroup.ematches); + req->options.cgroup._len.ematches = len; + req->options.cgroup.ematches = malloc(req->options.cgroup._len.ematches); + memcpy(req->options.cgroup.ematches, ematches, req->options.cgroup._len.ematches); +} +static inline void +tc_newqdisc_req_set_options_choke_parms(struct tc_newqdisc_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.choke = 1; + free(req->options.choke.parms); + req->options.choke._len.parms = len; + req->options.choke.parms = malloc(req->options.choke._len.parms); + memcpy(req->options.choke.parms, parms, req->options.choke._len.parms); +} +static inline void +tc_newqdisc_req_set_options_choke_stab(struct tc_newqdisc_req *req, + const void *stab, size_t len) +{ + req->_present.options = 1; + req->options._present.choke = 1; + free(req->options.choke.stab); + req->options.choke._len.stab = len; + req->options.choke.stab = malloc(req->options.choke._len.stab); + memcpy(req->options.choke.stab, stab, req->options.choke._len.stab); +} +static inline void +tc_newqdisc_req_set_options_choke_max_p(struct tc_newqdisc_req *req, + __u32 max_p) +{ + req->_present.options = 1; + req->options._present.choke = 1; + req->options.choke._present.max_p = 1; + req->options.choke.max_p = max_p; +} +static inline void +tc_newqdisc_req_set_options_clsact(struct tc_newqdisc_req *req) +{ + req->_present.options = 1; + req->options._present.clsact = 1; +} +static inline void +tc_newqdisc_req_set_options_codel_target(struct tc_newqdisc_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.target = 1; + req->options.codel.target = target; +} +static inline void +tc_newqdisc_req_set_options_codel_limit(struct tc_newqdisc_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.limit = 1; + req->options.codel.limit = limit; +} +static inline void +tc_newqdisc_req_set_options_codel_interval(struct tc_newqdisc_req *req, + __u32 interval) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.interval = 1; + req->options.codel.interval = interval; +} +static inline void +tc_newqdisc_req_set_options_codel_ecn(struct tc_newqdisc_req *req, __u32 ecn) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.ecn = 1; + req->options.codel.ecn = ecn; +} +static inline void +tc_newqdisc_req_set_options_codel_ce_threshold(struct tc_newqdisc_req *req, + __u32 ce_threshold) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.ce_threshold = 1; + req->options.codel.ce_threshold = ce_threshold; +} +static inline void +tc_newqdisc_req_set_options_drr_quantum(struct tc_newqdisc_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.drr = 1; + req->options.drr._present.quantum = 1; + req->options.drr.quantum = quantum; +} +static inline void +tc_newqdisc_req_set_options_etf_parms(struct tc_newqdisc_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.etf = 1; + free(req->options.etf.parms); + req->options.etf._len.parms = len; + req->options.etf.parms = malloc(req->options.etf._len.parms); + memcpy(req->options.etf.parms, parms, req->options.etf._len.parms); +} +static inline void +tc_newqdisc_req_set_options_flow_keys(struct tc_newqdisc_req *req, __u32 keys) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.keys = 1; + req->options.flow.keys = keys; +} +static inline void +tc_newqdisc_req_set_options_flow_mode(struct tc_newqdisc_req *req, __u32 mode) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.mode = 1; + req->options.flow.mode = mode; +} +static inline void +tc_newqdisc_req_set_options_flow_baseclass(struct tc_newqdisc_req *req, + __u32 baseclass) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.baseclass = 1; + req->options.flow.baseclass = baseclass; +} +static inline void +tc_newqdisc_req_set_options_flow_rshift(struct tc_newqdisc_req *req, + __u32 rshift) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.rshift = 1; + req->options.flow.rshift = rshift; +} +static inline void +tc_newqdisc_req_set_options_flow_addend(struct tc_newqdisc_req *req, + __u32 addend) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.addend = 1; + req->options.flow.addend = addend; +} +static inline void +tc_newqdisc_req_set_options_flow_mask(struct tc_newqdisc_req *req, __u32 mask) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.mask = 1; + req->options.flow.mask = mask; +} +static inline void +tc_newqdisc_req_set_options_flow_xor(struct tc_newqdisc_req *req, __u32 xor) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.xor = 1; + req->options.flow.xor = xor; +} +static inline void +tc_newqdisc_req_set_options_flow_divisor(struct tc_newqdisc_req *req, + __u32 divisor) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.divisor = 1; + req->options.flow.divisor = divisor; +} +static inline void +tc_newqdisc_req_set_options_flow_act(struct tc_newqdisc_req *req, + const void *act, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + free(req->options.flow.act); + req->options.flow._len.act = len; + req->options.flow.act = malloc(req->options.flow._len.act); + memcpy(req->options.flow.act, act, req->options.flow._len.act); +} +static inline void +tc_newqdisc_req_set_options_flow_police_tbf(struct tc_newqdisc_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.tbf); + req->options.flow.police._len.tbf = len; + req->options.flow.police.tbf = malloc(req->options.flow.police._len.tbf); + memcpy(req->options.flow.police.tbf, tbf, req->options.flow.police._len.tbf); +} +static inline void +tc_newqdisc_req_set_options_flow_police_rate(struct tc_newqdisc_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.rate); + req->options.flow.police._len.rate = len; + req->options.flow.police.rate = malloc(req->options.flow.police._len.rate); + memcpy(req->options.flow.police.rate, rate, req->options.flow.police._len.rate); +} +static inline void +tc_newqdisc_req_set_options_flow_police_peakrate(struct tc_newqdisc_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.peakrate); + req->options.flow.police._len.peakrate = len; + req->options.flow.police.peakrate = malloc(req->options.flow.police._len.peakrate); + memcpy(req->options.flow.police.peakrate, peakrate, req->options.flow.police._len.peakrate); +} +static inline void +tc_newqdisc_req_set_options_flow_police_avrate(struct tc_newqdisc_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.avrate = 1; + req->options.flow.police.avrate = avrate; +} +static inline void +tc_newqdisc_req_set_options_flow_police_result(struct tc_newqdisc_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.result = 1; + req->options.flow.police.result = result; +} +static inline void +tc_newqdisc_req_set_options_flow_police_tm(struct tc_newqdisc_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.tm); + req->options.flow.police._len.tm = len; + req->options.flow.police.tm = malloc(req->options.flow.police._len.tm); + memcpy(req->options.flow.police.tm, tm, req->options.flow.police._len.tm); +} +static inline void +tc_newqdisc_req_set_options_flow_police_rate64(struct tc_newqdisc_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.rate64 = 1; + req->options.flow.police.rate64 = rate64; +} +static inline void +tc_newqdisc_req_set_options_flow_police_peakrate64(struct tc_newqdisc_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.peakrate64 = 1; + req->options.flow.police.peakrate64 = peakrate64; +} +static inline void +tc_newqdisc_req_set_options_flow_police_pktrate64(struct tc_newqdisc_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.pktrate64 = 1; + req->options.flow.police.pktrate64 = pktrate64; +} +static inline void +tc_newqdisc_req_set_options_flow_police_pktburst64(struct tc_newqdisc_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.pktburst64 = 1; + req->options.flow.police.pktburst64 = pktburst64; +} +static inline void +tc_newqdisc_req_set_options_flow_ematches(struct tc_newqdisc_req *req, + const void *ematches, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + free(req->options.flow.ematches); + req->options.flow._len.ematches = len; + req->options.flow.ematches = malloc(req->options.flow._len.ematches); + memcpy(req->options.flow.ematches, ematches, req->options.flow._len.ematches); +} +static inline void +tc_newqdisc_req_set_options_flow_perturb(struct tc_newqdisc_req *req, + __u32 perturb) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.perturb = 1; + req->options.flow.perturb = perturb; +} +static inline void +tc_newqdisc_req_set_options_flower_classid(struct tc_newqdisc_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.classid = 1; + req->options.flower.classid = classid; +} +static inline void +tc_newqdisc_req_set_options_flower_indev(struct tc_newqdisc_req *req, + const char *indev) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.indev); + req->options.flower._len.indev = strlen(indev); + req->options.flower.indev = malloc(req->options.flower._len.indev + 1); + memcpy(req->options.flower.indev, indev, req->options.flower._len.indev); + req->options.flower.indev[req->options.flower._len.indev] = 0; +} +static inline void +__tc_newqdisc_req_set_options_flower_act(struct tc_newqdisc_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.act); + req->options.flower.act = act; + req->options.flower._count.act = n_act; +} +static inline void +tc_newqdisc_req_set_options_flower_key_eth_dst(struct tc_newqdisc_req *req, + const void *key_eth_dst, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_dst); + req->options.flower._len.key_eth_dst = len; + req->options.flower.key_eth_dst = malloc(req->options.flower._len.key_eth_dst); + memcpy(req->options.flower.key_eth_dst, key_eth_dst, req->options.flower._len.key_eth_dst); +} +static inline void +tc_newqdisc_req_set_options_flower_key_eth_dst_mask(struct tc_newqdisc_req *req, + const void *key_eth_dst_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_dst_mask); + req->options.flower._len.key_eth_dst_mask = len; + req->options.flower.key_eth_dst_mask = malloc(req->options.flower._len.key_eth_dst_mask); + memcpy(req->options.flower.key_eth_dst_mask, key_eth_dst_mask, req->options.flower._len.key_eth_dst_mask); +} +static inline void +tc_newqdisc_req_set_options_flower_key_eth_src(struct tc_newqdisc_req *req, + const void *key_eth_src, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_src); + req->options.flower._len.key_eth_src = len; + req->options.flower.key_eth_src = malloc(req->options.flower._len.key_eth_src); + memcpy(req->options.flower.key_eth_src, key_eth_src, req->options.flower._len.key_eth_src); +} +static inline void +tc_newqdisc_req_set_options_flower_key_eth_src_mask(struct tc_newqdisc_req *req, + const void *key_eth_src_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_src_mask); + req->options.flower._len.key_eth_src_mask = len; + req->options.flower.key_eth_src_mask = malloc(req->options.flower._len.key_eth_src_mask); + memcpy(req->options.flower.key_eth_src_mask, key_eth_src_mask, req->options.flower._len.key_eth_src_mask); +} +static inline void +tc_newqdisc_req_set_options_flower_key_eth_type(struct tc_newqdisc_req *req, + __u16 key_eth_type /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_eth_type = 1; + req->options.flower.key_eth_type = key_eth_type; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ip_proto(struct tc_newqdisc_req *req, + __u8 key_ip_proto) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_proto = 1; + req->options.flower.key_ip_proto = key_ip_proto; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ipv4_src(struct tc_newqdisc_req *req, + __u32 key_ipv4_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_src = 1; + req->options.flower.key_ipv4_src = key_ipv4_src; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ipv4_src_mask(struct tc_newqdisc_req *req, + __u32 key_ipv4_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_src_mask = 1; + req->options.flower.key_ipv4_src_mask = key_ipv4_src_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ipv4_dst(struct tc_newqdisc_req *req, + __u32 key_ipv4_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_dst = 1; + req->options.flower.key_ipv4_dst = key_ipv4_dst; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ipv4_dst_mask(struct tc_newqdisc_req *req, + __u32 key_ipv4_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_dst_mask = 1; + req->options.flower.key_ipv4_dst_mask = key_ipv4_dst_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ipv6_src(struct tc_newqdisc_req *req, + const void *key_ipv6_src, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_src); + req->options.flower._len.key_ipv6_src = len; + req->options.flower.key_ipv6_src = malloc(req->options.flower._len.key_ipv6_src); + memcpy(req->options.flower.key_ipv6_src, key_ipv6_src, req->options.flower._len.key_ipv6_src); +} +static inline void +tc_newqdisc_req_set_options_flower_key_ipv6_src_mask(struct tc_newqdisc_req *req, + const void *key_ipv6_src_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_src_mask); + req->options.flower._len.key_ipv6_src_mask = len; + req->options.flower.key_ipv6_src_mask = malloc(req->options.flower._len.key_ipv6_src_mask); + memcpy(req->options.flower.key_ipv6_src_mask, key_ipv6_src_mask, req->options.flower._len.key_ipv6_src_mask); +} +static inline void +tc_newqdisc_req_set_options_flower_key_ipv6_dst(struct tc_newqdisc_req *req, + const void *key_ipv6_dst, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_dst); + req->options.flower._len.key_ipv6_dst = len; + req->options.flower.key_ipv6_dst = malloc(req->options.flower._len.key_ipv6_dst); + memcpy(req->options.flower.key_ipv6_dst, key_ipv6_dst, req->options.flower._len.key_ipv6_dst); +} +static inline void +tc_newqdisc_req_set_options_flower_key_ipv6_dst_mask(struct tc_newqdisc_req *req, + const void *key_ipv6_dst_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_dst_mask); + req->options.flower._len.key_ipv6_dst_mask = len; + req->options.flower.key_ipv6_dst_mask = malloc(req->options.flower._len.key_ipv6_dst_mask); + memcpy(req->options.flower.key_ipv6_dst_mask, key_ipv6_dst_mask, req->options.flower._len.key_ipv6_dst_mask); +} +static inline void +tc_newqdisc_req_set_options_flower_key_tcp_src(struct tc_newqdisc_req *req, + __u16 key_tcp_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_src = 1; + req->options.flower.key_tcp_src = key_tcp_src; +} +static inline void +tc_newqdisc_req_set_options_flower_key_tcp_dst(struct tc_newqdisc_req *req, + __u16 key_tcp_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_dst = 1; + req->options.flower.key_tcp_dst = key_tcp_dst; +} +static inline void +tc_newqdisc_req_set_options_flower_key_udp_src(struct tc_newqdisc_req *req, + __u16 key_udp_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_src = 1; + req->options.flower.key_udp_src = key_udp_src; +} +static inline void +tc_newqdisc_req_set_options_flower_key_udp_dst(struct tc_newqdisc_req *req, + __u16 key_udp_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_dst = 1; + req->options.flower.key_udp_dst = key_udp_dst; +} +static inline void +tc_newqdisc_req_set_options_flower_flags(struct tc_newqdisc_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.flags = 1; + req->options.flower.flags = flags; +} +static inline void +tc_newqdisc_req_set_options_flower_key_vlan_id(struct tc_newqdisc_req *req, + __u16 key_vlan_id /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_vlan_id = 1; + req->options.flower.key_vlan_id = key_vlan_id; +} +static inline void +tc_newqdisc_req_set_options_flower_key_vlan_prio(struct tc_newqdisc_req *req, + __u8 key_vlan_prio) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_vlan_prio = 1; + req->options.flower.key_vlan_prio = key_vlan_prio; +} +static inline void +tc_newqdisc_req_set_options_flower_key_vlan_eth_type(struct tc_newqdisc_req *req, + __u16 key_vlan_eth_type /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_vlan_eth_type = 1; + req->options.flower.key_vlan_eth_type = key_vlan_eth_type; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_key_id(struct tc_newqdisc_req *req, + __u32 key_enc_key_id /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_key_id = 1; + req->options.flower.key_enc_key_id = key_enc_key_id; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_ipv4_src(struct tc_newqdisc_req *req, + __u32 key_enc_ipv4_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_src = 1; + req->options.flower.key_enc_ipv4_src = key_enc_ipv4_src; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_ipv4_src_mask(struct tc_newqdisc_req *req, + __u32 key_enc_ipv4_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_src_mask = 1; + req->options.flower.key_enc_ipv4_src_mask = key_enc_ipv4_src_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_ipv4_dst(struct tc_newqdisc_req *req, + __u32 key_enc_ipv4_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_dst = 1; + req->options.flower.key_enc_ipv4_dst = key_enc_ipv4_dst; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_ipv4_dst_mask(struct tc_newqdisc_req *req, + __u32 key_enc_ipv4_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_dst_mask = 1; + req->options.flower.key_enc_ipv4_dst_mask = key_enc_ipv4_dst_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_ipv6_src(struct tc_newqdisc_req *req, + const void *key_enc_ipv6_src, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_src); + req->options.flower._len.key_enc_ipv6_src = len; + req->options.flower.key_enc_ipv6_src = malloc(req->options.flower._len.key_enc_ipv6_src); + memcpy(req->options.flower.key_enc_ipv6_src, key_enc_ipv6_src, req->options.flower._len.key_enc_ipv6_src); +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_ipv6_src_mask(struct tc_newqdisc_req *req, + const void *key_enc_ipv6_src_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_src_mask); + req->options.flower._len.key_enc_ipv6_src_mask = len; + req->options.flower.key_enc_ipv6_src_mask = malloc(req->options.flower._len.key_enc_ipv6_src_mask); + memcpy(req->options.flower.key_enc_ipv6_src_mask, key_enc_ipv6_src_mask, req->options.flower._len.key_enc_ipv6_src_mask); +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_ipv6_dst(struct tc_newqdisc_req *req, + const void *key_enc_ipv6_dst, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_dst); + req->options.flower._len.key_enc_ipv6_dst = len; + req->options.flower.key_enc_ipv6_dst = malloc(req->options.flower._len.key_enc_ipv6_dst); + memcpy(req->options.flower.key_enc_ipv6_dst, key_enc_ipv6_dst, req->options.flower._len.key_enc_ipv6_dst); +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_ipv6_dst_mask(struct tc_newqdisc_req *req, + const void *key_enc_ipv6_dst_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_dst_mask); + req->options.flower._len.key_enc_ipv6_dst_mask = len; + req->options.flower.key_enc_ipv6_dst_mask = malloc(req->options.flower._len.key_enc_ipv6_dst_mask); + memcpy(req->options.flower.key_enc_ipv6_dst_mask, key_enc_ipv6_dst_mask, req->options.flower._len.key_enc_ipv6_dst_mask); +} +static inline void +tc_newqdisc_req_set_options_flower_key_tcp_src_mask(struct tc_newqdisc_req *req, + __u16 key_tcp_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_src_mask = 1; + req->options.flower.key_tcp_src_mask = key_tcp_src_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_tcp_dst_mask(struct tc_newqdisc_req *req, + __u16 key_tcp_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_dst_mask = 1; + req->options.flower.key_tcp_dst_mask = key_tcp_dst_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_udp_src_mask(struct tc_newqdisc_req *req, + __u16 key_udp_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_src_mask = 1; + req->options.flower.key_udp_src_mask = key_udp_src_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_udp_dst_mask(struct tc_newqdisc_req *req, + __u16 key_udp_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_dst_mask = 1; + req->options.flower.key_udp_dst_mask = key_udp_dst_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_sctp_src_mask(struct tc_newqdisc_req *req, + __u16 key_sctp_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_src_mask = 1; + req->options.flower.key_sctp_src_mask = key_sctp_src_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_sctp_dst_mask(struct tc_newqdisc_req *req, + __u16 key_sctp_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_dst_mask = 1; + req->options.flower.key_sctp_dst_mask = key_sctp_dst_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_sctp_src(struct tc_newqdisc_req *req, + __u16 key_sctp_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_src = 1; + req->options.flower.key_sctp_src = key_sctp_src; +} +static inline void +tc_newqdisc_req_set_options_flower_key_sctp_dst(struct tc_newqdisc_req *req, + __u16 key_sctp_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_dst = 1; + req->options.flower.key_sctp_dst = key_sctp_dst; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_udp_src_port(struct tc_newqdisc_req *req, + __u16 key_enc_udp_src_port /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_src_port = 1; + req->options.flower.key_enc_udp_src_port = key_enc_udp_src_port; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_udp_src_port_mask(struct tc_newqdisc_req *req, + __u16 key_enc_udp_src_port_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_src_port_mask = 1; + req->options.flower.key_enc_udp_src_port_mask = key_enc_udp_src_port_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_udp_dst_port(struct tc_newqdisc_req *req, + __u16 key_enc_udp_dst_port /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_dst_port = 1; + req->options.flower.key_enc_udp_dst_port = key_enc_udp_dst_port; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_udp_dst_port_mask(struct tc_newqdisc_req *req, + __u16 key_enc_udp_dst_port_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_dst_port_mask = 1; + req->options.flower.key_enc_udp_dst_port_mask = key_enc_udp_dst_port_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_flags(struct tc_newqdisc_req *req, + __u32 key_flags /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_flags = 1; + req->options.flower.key_flags = key_flags; +} +static inline void +tc_newqdisc_req_set_options_flower_key_flags_mask(struct tc_newqdisc_req *req, + __u32 key_flags_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_flags_mask = 1; + req->options.flower.key_flags_mask = key_flags_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_icmpv4_code(struct tc_newqdisc_req *req, + __u8 key_icmpv4_code) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_code = 1; + req->options.flower.key_icmpv4_code = key_icmpv4_code; +} +static inline void +tc_newqdisc_req_set_options_flower_key_icmpv4_code_mask(struct tc_newqdisc_req *req, + __u8 key_icmpv4_code_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_code_mask = 1; + req->options.flower.key_icmpv4_code_mask = key_icmpv4_code_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_icmpv4_type(struct tc_newqdisc_req *req, + __u8 key_icmpv4_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_type = 1; + req->options.flower.key_icmpv4_type = key_icmpv4_type; +} +static inline void +tc_newqdisc_req_set_options_flower_key_icmpv4_type_mask(struct tc_newqdisc_req *req, + __u8 key_icmpv4_type_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_type_mask = 1; + req->options.flower.key_icmpv4_type_mask = key_icmpv4_type_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_icmpv6_code(struct tc_newqdisc_req *req, + __u8 key_icmpv6_code) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_code = 1; + req->options.flower.key_icmpv6_code = key_icmpv6_code; +} +static inline void +tc_newqdisc_req_set_options_flower_key_icmpv6_code_mask(struct tc_newqdisc_req *req, + __u8 key_icmpv6_code_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_code_mask = 1; + req->options.flower.key_icmpv6_code_mask = key_icmpv6_code_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_icmpv6_type(struct tc_newqdisc_req *req, + __u8 key_icmpv6_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_type = 1; + req->options.flower.key_icmpv6_type = key_icmpv6_type; +} +static inline void +tc_newqdisc_req_set_options_flower_key_icmpv6_type_mask(struct tc_newqdisc_req *req, + __u8 key_icmpv6_type_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_type_mask = 1; + req->options.flower.key_icmpv6_type_mask = key_icmpv6_type_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_arp_sip(struct tc_newqdisc_req *req, + __u32 key_arp_sip /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_sip = 1; + req->options.flower.key_arp_sip = key_arp_sip; +} +static inline void +tc_newqdisc_req_set_options_flower_key_arp_sip_mask(struct tc_newqdisc_req *req, + __u32 key_arp_sip_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_sip_mask = 1; + req->options.flower.key_arp_sip_mask = key_arp_sip_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_arp_tip(struct tc_newqdisc_req *req, + __u32 key_arp_tip /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_tip = 1; + req->options.flower.key_arp_tip = key_arp_tip; +} +static inline void +tc_newqdisc_req_set_options_flower_key_arp_tip_mask(struct tc_newqdisc_req *req, + __u32 key_arp_tip_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_tip_mask = 1; + req->options.flower.key_arp_tip_mask = key_arp_tip_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_arp_op(struct tc_newqdisc_req *req, + __u8 key_arp_op) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_op = 1; + req->options.flower.key_arp_op = key_arp_op; +} +static inline void +tc_newqdisc_req_set_options_flower_key_arp_op_mask(struct tc_newqdisc_req *req, + __u8 key_arp_op_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_op_mask = 1; + req->options.flower.key_arp_op_mask = key_arp_op_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_arp_sha(struct tc_newqdisc_req *req, + const void *key_arp_sha, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_sha); + req->options.flower._len.key_arp_sha = len; + req->options.flower.key_arp_sha = malloc(req->options.flower._len.key_arp_sha); + memcpy(req->options.flower.key_arp_sha, key_arp_sha, req->options.flower._len.key_arp_sha); +} +static inline void +tc_newqdisc_req_set_options_flower_key_arp_sha_mask(struct tc_newqdisc_req *req, + const void *key_arp_sha_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_sha_mask); + req->options.flower._len.key_arp_sha_mask = len; + req->options.flower.key_arp_sha_mask = malloc(req->options.flower._len.key_arp_sha_mask); + memcpy(req->options.flower.key_arp_sha_mask, key_arp_sha_mask, req->options.flower._len.key_arp_sha_mask); +} +static inline void +tc_newqdisc_req_set_options_flower_key_arp_tha(struct tc_newqdisc_req *req, + const void *key_arp_tha, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_tha); + req->options.flower._len.key_arp_tha = len; + req->options.flower.key_arp_tha = malloc(req->options.flower._len.key_arp_tha); + memcpy(req->options.flower.key_arp_tha, key_arp_tha, req->options.flower._len.key_arp_tha); +} +static inline void +tc_newqdisc_req_set_options_flower_key_arp_tha_mask(struct tc_newqdisc_req *req, + const void *key_arp_tha_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_tha_mask); + req->options.flower._len.key_arp_tha_mask = len; + req->options.flower.key_arp_tha_mask = malloc(req->options.flower._len.key_arp_tha_mask); + memcpy(req->options.flower.key_arp_tha_mask, key_arp_tha_mask, req->options.flower._len.key_arp_tha_mask); +} +static inline void +tc_newqdisc_req_set_options_flower_key_mpls_ttl(struct tc_newqdisc_req *req, + __u8 key_mpls_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_ttl = 1; + req->options.flower.key_mpls_ttl = key_mpls_ttl; +} +static inline void +tc_newqdisc_req_set_options_flower_key_mpls_bos(struct tc_newqdisc_req *req, + __u8 key_mpls_bos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_bos = 1; + req->options.flower.key_mpls_bos = key_mpls_bos; +} +static inline void +tc_newqdisc_req_set_options_flower_key_mpls_tc(struct tc_newqdisc_req *req, + __u8 key_mpls_tc) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_tc = 1; + req->options.flower.key_mpls_tc = key_mpls_tc; +} +static inline void +tc_newqdisc_req_set_options_flower_key_mpls_label(struct tc_newqdisc_req *req, + __u32 key_mpls_label /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_label = 1; + req->options.flower.key_mpls_label = key_mpls_label; +} +static inline void +tc_newqdisc_req_set_options_flower_key_tcp_flags(struct tc_newqdisc_req *req, + __u16 key_tcp_flags /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_flags = 1; + req->options.flower.key_tcp_flags = key_tcp_flags; +} +static inline void +tc_newqdisc_req_set_options_flower_key_tcp_flags_mask(struct tc_newqdisc_req *req, + __u16 key_tcp_flags_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_flags_mask = 1; + req->options.flower.key_tcp_flags_mask = key_tcp_flags_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ip_tos(struct tc_newqdisc_req *req, + __u8 key_ip_tos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_tos = 1; + req->options.flower.key_ip_tos = key_ip_tos; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ip_tos_mask(struct tc_newqdisc_req *req, + __u8 key_ip_tos_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_tos_mask = 1; + req->options.flower.key_ip_tos_mask = key_ip_tos_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ip_ttl(struct tc_newqdisc_req *req, + __u8 key_ip_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_ttl = 1; + req->options.flower.key_ip_ttl = key_ip_ttl; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ip_ttl_mask(struct tc_newqdisc_req *req, + __u8 key_ip_ttl_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_ttl_mask = 1; + req->options.flower.key_ip_ttl_mask = key_ip_ttl_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_cvlan_id(struct tc_newqdisc_req *req, + __u16 key_cvlan_id /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cvlan_id = 1; + req->options.flower.key_cvlan_id = key_cvlan_id; +} +static inline void +tc_newqdisc_req_set_options_flower_key_cvlan_prio(struct tc_newqdisc_req *req, + __u8 key_cvlan_prio) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cvlan_prio = 1; + req->options.flower.key_cvlan_prio = key_cvlan_prio; +} +static inline void +tc_newqdisc_req_set_options_flower_key_cvlan_eth_type(struct tc_newqdisc_req *req, + __u16 key_cvlan_eth_type /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cvlan_eth_type = 1; + req->options.flower.key_cvlan_eth_type = key_cvlan_eth_type; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_ip_tos(struct tc_newqdisc_req *req, + __u8 key_enc_ip_tos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_tos = 1; + req->options.flower.key_enc_ip_tos = key_enc_ip_tos; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_ip_tos_mask(struct tc_newqdisc_req *req, + __u8 key_enc_ip_tos_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_tos_mask = 1; + req->options.flower.key_enc_ip_tos_mask = key_enc_ip_tos_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_ip_ttl(struct tc_newqdisc_req *req, + __u8 key_enc_ip_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_ttl = 1; + req->options.flower.key_enc_ip_ttl = key_enc_ip_ttl; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_ip_ttl_mask(struct tc_newqdisc_req *req, + __u8 key_enc_ip_ttl_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_ttl_mask = 1; + req->options.flower.key_enc_ip_ttl_mask = key_enc_ip_ttl_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_geneve_class(struct tc_newqdisc_req *req, + __u16 class) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.geneve = 1; + req->options.flower.key_enc_opts.geneve._present.class = 1; + req->options.flower.key_enc_opts.geneve.class = class; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_geneve_type(struct tc_newqdisc_req *req, + __u8 type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.geneve = 1; + req->options.flower.key_enc_opts.geneve._present.type = 1; + req->options.flower.key_enc_opts.geneve.type = type; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_geneve_data(struct tc_newqdisc_req *req, + const void *data, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.geneve = 1; + free(req->options.flower.key_enc_opts.geneve.data); + req->options.flower.key_enc_opts.geneve._len.data = len; + req->options.flower.key_enc_opts.geneve.data = malloc(req->options.flower.key_enc_opts.geneve._len.data); + memcpy(req->options.flower.key_enc_opts.geneve.data, data, req->options.flower.key_enc_opts.geneve._len.data); +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_vxlan_gbp(struct tc_newqdisc_req *req, + __u32 gbp) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.vxlan = 1; + req->options.flower.key_enc_opts.vxlan._present.gbp = 1; + req->options.flower.key_enc_opts.vxlan.gbp = gbp; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_erspan_ver(struct tc_newqdisc_req *req, + __u8 ver) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.ver = 1; + req->options.flower.key_enc_opts.erspan.ver = ver; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_erspan_index(struct tc_newqdisc_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.index = 1; + req->options.flower.key_enc_opts.erspan.index = index; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_erspan_dir(struct tc_newqdisc_req *req, + __u8 dir) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.dir = 1; + req->options.flower.key_enc_opts.erspan.dir = dir; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_erspan_hwid(struct tc_newqdisc_req *req, + __u8 hwid) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.hwid = 1; + req->options.flower.key_enc_opts.erspan.hwid = hwid; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_gtp_pdu_type(struct tc_newqdisc_req *req, + __u8 pdu_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.gtp = 1; + req->options.flower.key_enc_opts.gtp._present.pdu_type = 1; + req->options.flower.key_enc_opts.gtp.pdu_type = pdu_type; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_gtp_qfi(struct tc_newqdisc_req *req, + __u8 qfi) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.gtp = 1; + req->options.flower.key_enc_opts.gtp._present.qfi = 1; + req->options.flower.key_enc_opts.gtp.qfi = qfi; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_mask_geneve_class(struct tc_newqdisc_req *req, + __u16 class) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.geneve = 1; + req->options.flower.key_enc_opts_mask.geneve._present.class = 1; + req->options.flower.key_enc_opts_mask.geneve.class = class; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_mask_geneve_type(struct tc_newqdisc_req *req, + __u8 type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.geneve = 1; + req->options.flower.key_enc_opts_mask.geneve._present.type = 1; + req->options.flower.key_enc_opts_mask.geneve.type = type; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_mask_geneve_data(struct tc_newqdisc_req *req, + const void *data, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.geneve = 1; + free(req->options.flower.key_enc_opts_mask.geneve.data); + req->options.flower.key_enc_opts_mask.geneve._len.data = len; + req->options.flower.key_enc_opts_mask.geneve.data = malloc(req->options.flower.key_enc_opts_mask.geneve._len.data); + memcpy(req->options.flower.key_enc_opts_mask.geneve.data, data, req->options.flower.key_enc_opts_mask.geneve._len.data); +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_mask_vxlan_gbp(struct tc_newqdisc_req *req, + __u32 gbp) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.vxlan = 1; + req->options.flower.key_enc_opts_mask.vxlan._present.gbp = 1; + req->options.flower.key_enc_opts_mask.vxlan.gbp = gbp; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_mask_erspan_ver(struct tc_newqdisc_req *req, + __u8 ver) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.ver = 1; + req->options.flower.key_enc_opts_mask.erspan.ver = ver; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_mask_erspan_index(struct tc_newqdisc_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.index = 1; + req->options.flower.key_enc_opts_mask.erspan.index = index; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_mask_erspan_dir(struct tc_newqdisc_req *req, + __u8 dir) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.dir = 1; + req->options.flower.key_enc_opts_mask.erspan.dir = dir; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_mask_erspan_hwid(struct tc_newqdisc_req *req, + __u8 hwid) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.hwid = 1; + req->options.flower.key_enc_opts_mask.erspan.hwid = hwid; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_mask_gtp_pdu_type(struct tc_newqdisc_req *req, + __u8 pdu_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.gtp = 1; + req->options.flower.key_enc_opts_mask.gtp._present.pdu_type = 1; + req->options.flower.key_enc_opts_mask.gtp.pdu_type = pdu_type; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_opts_mask_gtp_qfi(struct tc_newqdisc_req *req, + __u8 qfi) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.gtp = 1; + req->options.flower.key_enc_opts_mask.gtp._present.qfi = 1; + req->options.flower.key_enc_opts_mask.gtp.qfi = qfi; +} +static inline void +tc_newqdisc_req_set_options_flower_in_hw_count(struct tc_newqdisc_req *req, + __u32 in_hw_count) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.in_hw_count = 1; + req->options.flower.in_hw_count = in_hw_count; +} +static inline void +tc_newqdisc_req_set_options_flower_key_port_src_min(struct tc_newqdisc_req *req, + __u16 key_port_src_min /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_src_min = 1; + req->options.flower.key_port_src_min = key_port_src_min; +} +static inline void +tc_newqdisc_req_set_options_flower_key_port_src_max(struct tc_newqdisc_req *req, + __u16 key_port_src_max /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_src_max = 1; + req->options.flower.key_port_src_max = key_port_src_max; +} +static inline void +tc_newqdisc_req_set_options_flower_key_port_dst_min(struct tc_newqdisc_req *req, + __u16 key_port_dst_min /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_dst_min = 1; + req->options.flower.key_port_dst_min = key_port_dst_min; +} +static inline void +tc_newqdisc_req_set_options_flower_key_port_dst_max(struct tc_newqdisc_req *req, + __u16 key_port_dst_max /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_dst_max = 1; + req->options.flower.key_port_dst_max = key_port_dst_max; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ct_state(struct tc_newqdisc_req *req, + __u16 key_ct_state) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_state = 1; + req->options.flower.key_ct_state = key_ct_state; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ct_state_mask(struct tc_newqdisc_req *req, + __u16 key_ct_state_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_state_mask = 1; + req->options.flower.key_ct_state_mask = key_ct_state_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ct_zone(struct tc_newqdisc_req *req, + __u16 key_ct_zone) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_zone = 1; + req->options.flower.key_ct_zone = key_ct_zone; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ct_zone_mask(struct tc_newqdisc_req *req, + __u16 key_ct_zone_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_zone_mask = 1; + req->options.flower.key_ct_zone_mask = key_ct_zone_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ct_mark(struct tc_newqdisc_req *req, + __u32 key_ct_mark) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_mark = 1; + req->options.flower.key_ct_mark = key_ct_mark; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ct_mark_mask(struct tc_newqdisc_req *req, + __u32 key_ct_mark_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_mark_mask = 1; + req->options.flower.key_ct_mark_mask = key_ct_mark_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ct_labels(struct tc_newqdisc_req *req, + const void *key_ct_labels, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ct_labels); + req->options.flower._len.key_ct_labels = len; + req->options.flower.key_ct_labels = malloc(req->options.flower._len.key_ct_labels); + memcpy(req->options.flower.key_ct_labels, key_ct_labels, req->options.flower._len.key_ct_labels); +} +static inline void +tc_newqdisc_req_set_options_flower_key_ct_labels_mask(struct tc_newqdisc_req *req, + const void *key_ct_labels_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ct_labels_mask); + req->options.flower._len.key_ct_labels_mask = len; + req->options.flower.key_ct_labels_mask = malloc(req->options.flower._len.key_ct_labels_mask); + memcpy(req->options.flower.key_ct_labels_mask, key_ct_labels_mask, req->options.flower._len.key_ct_labels_mask); +} +static inline void +tc_newqdisc_req_set_options_flower_key_mpls_opts_lse_depth(struct tc_newqdisc_req *req, + __u8 lse_depth) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_depth = 1; + req->options.flower.key_mpls_opts.lse_depth = lse_depth; +} +static inline void +tc_newqdisc_req_set_options_flower_key_mpls_opts_lse_ttl(struct tc_newqdisc_req *req, + __u8 lse_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_ttl = 1; + req->options.flower.key_mpls_opts.lse_ttl = lse_ttl; +} +static inline void +tc_newqdisc_req_set_options_flower_key_mpls_opts_lse_bos(struct tc_newqdisc_req *req, + __u8 lse_bos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_bos = 1; + req->options.flower.key_mpls_opts.lse_bos = lse_bos; +} +static inline void +tc_newqdisc_req_set_options_flower_key_mpls_opts_lse_tc(struct tc_newqdisc_req *req, + __u8 lse_tc) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_tc = 1; + req->options.flower.key_mpls_opts.lse_tc = lse_tc; +} +static inline void +tc_newqdisc_req_set_options_flower_key_mpls_opts_lse_label(struct tc_newqdisc_req *req, + __u32 lse_label) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_label = 1; + req->options.flower.key_mpls_opts.lse_label = lse_label; +} +static inline void +tc_newqdisc_req_set_options_flower_key_hash(struct tc_newqdisc_req *req, + __u32 key_hash) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_hash = 1; + req->options.flower.key_hash = key_hash; +} +static inline void +tc_newqdisc_req_set_options_flower_key_hash_mask(struct tc_newqdisc_req *req, + __u32 key_hash_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_hash_mask = 1; + req->options.flower.key_hash_mask = key_hash_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_num_of_vlans(struct tc_newqdisc_req *req, + __u8 key_num_of_vlans) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_num_of_vlans = 1; + req->options.flower.key_num_of_vlans = key_num_of_vlans; +} +static inline void +tc_newqdisc_req_set_options_flower_key_pppoe_sid(struct tc_newqdisc_req *req, + __u16 key_pppoe_sid /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_pppoe_sid = 1; + req->options.flower.key_pppoe_sid = key_pppoe_sid; +} +static inline void +tc_newqdisc_req_set_options_flower_key_ppp_proto(struct tc_newqdisc_req *req, + __u16 key_ppp_proto /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ppp_proto = 1; + req->options.flower.key_ppp_proto = key_ppp_proto; +} +static inline void +tc_newqdisc_req_set_options_flower_key_l2tpv3_sid(struct tc_newqdisc_req *req, + __u32 key_l2tpv3_sid /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_l2tpv3_sid = 1; + req->options.flower.key_l2tpv3_sid = key_l2tpv3_sid; +} +static inline void +tc_newqdisc_req_set_options_flower_l2_miss(struct tc_newqdisc_req *req, + __u8 l2_miss) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.l2_miss = 1; + req->options.flower.l2_miss = l2_miss; +} +static inline void +tc_newqdisc_req_set_options_flower_key_cfm_md_level(struct tc_newqdisc_req *req, + __u8 md_level) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cfm = 1; + req->options.flower.key_cfm._present.md_level = 1; + req->options.flower.key_cfm.md_level = md_level; +} +static inline void +tc_newqdisc_req_set_options_flower_key_cfm_opcode(struct tc_newqdisc_req *req, + __u8 opcode) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cfm = 1; + req->options.flower.key_cfm._present.opcode = 1; + req->options.flower.key_cfm.opcode = opcode; +} +static inline void +tc_newqdisc_req_set_options_flower_key_spi(struct tc_newqdisc_req *req, + __u32 key_spi /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_spi = 1; + req->options.flower.key_spi = key_spi; +} +static inline void +tc_newqdisc_req_set_options_flower_key_spi_mask(struct tc_newqdisc_req *req, + __u32 key_spi_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_spi_mask = 1; + req->options.flower.key_spi_mask = key_spi_mask; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_flags(struct tc_newqdisc_req *req, + __u32 key_enc_flags /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_flags = 1; + req->options.flower.key_enc_flags = key_enc_flags; +} +static inline void +tc_newqdisc_req_set_options_flower_key_enc_flags_mask(struct tc_newqdisc_req *req, + __u32 key_enc_flags_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_flags_mask = 1; + req->options.flower.key_enc_flags_mask = key_enc_flags_mask; +} +static inline void +tc_newqdisc_req_set_options_fq_plimit(struct tc_newqdisc_req *req, + __u32 plimit) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.plimit = 1; + req->options.fq.plimit = plimit; +} +static inline void +tc_newqdisc_req_set_options_fq_flow_plimit(struct tc_newqdisc_req *req, + __u32 flow_plimit) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_plimit = 1; + req->options.fq.flow_plimit = flow_plimit; +} +static inline void +tc_newqdisc_req_set_options_fq_quantum(struct tc_newqdisc_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.quantum = 1; + req->options.fq.quantum = quantum; +} +static inline void +tc_newqdisc_req_set_options_fq_initial_quantum(struct tc_newqdisc_req *req, + __u32 initial_quantum) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.initial_quantum = 1; + req->options.fq.initial_quantum = initial_quantum; +} +static inline void +tc_newqdisc_req_set_options_fq_rate_enable(struct tc_newqdisc_req *req, + __u32 rate_enable) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.rate_enable = 1; + req->options.fq.rate_enable = rate_enable; +} +static inline void +tc_newqdisc_req_set_options_fq_flow_default_rate(struct tc_newqdisc_req *req, + __u32 flow_default_rate) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_default_rate = 1; + req->options.fq.flow_default_rate = flow_default_rate; +} +static inline void +tc_newqdisc_req_set_options_fq_flow_max_rate(struct tc_newqdisc_req *req, + __u32 flow_max_rate) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_max_rate = 1; + req->options.fq.flow_max_rate = flow_max_rate; +} +static inline void +tc_newqdisc_req_set_options_fq_buckets_log(struct tc_newqdisc_req *req, + __u32 buckets_log) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.buckets_log = 1; + req->options.fq.buckets_log = buckets_log; +} +static inline void +tc_newqdisc_req_set_options_fq_flow_refill_delay(struct tc_newqdisc_req *req, + __u32 flow_refill_delay) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_refill_delay = 1; + req->options.fq.flow_refill_delay = flow_refill_delay; +} +static inline void +tc_newqdisc_req_set_options_fq_orphan_mask(struct tc_newqdisc_req *req, + __u32 orphan_mask) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.orphan_mask = 1; + req->options.fq.orphan_mask = orphan_mask; +} +static inline void +tc_newqdisc_req_set_options_fq_low_rate_threshold(struct tc_newqdisc_req *req, + __u32 low_rate_threshold) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.low_rate_threshold = 1; + req->options.fq.low_rate_threshold = low_rate_threshold; +} +static inline void +tc_newqdisc_req_set_options_fq_ce_threshold(struct tc_newqdisc_req *req, + __u32 ce_threshold) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.ce_threshold = 1; + req->options.fq.ce_threshold = ce_threshold; +} +static inline void +tc_newqdisc_req_set_options_fq_timer_slack(struct tc_newqdisc_req *req, + __u32 timer_slack) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.timer_slack = 1; + req->options.fq.timer_slack = timer_slack; +} +static inline void +tc_newqdisc_req_set_options_fq_horizon(struct tc_newqdisc_req *req, + __u32 horizon) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.horizon = 1; + req->options.fq.horizon = horizon; +} +static inline void +tc_newqdisc_req_set_options_fq_horizon_drop(struct tc_newqdisc_req *req, + __u8 horizon_drop) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.horizon_drop = 1; + req->options.fq.horizon_drop = horizon_drop; +} +static inline void +tc_newqdisc_req_set_options_fq_priomap(struct tc_newqdisc_req *req, + const void *priomap, size_t len) +{ + req->_present.options = 1; + req->options._present.fq = 1; + free(req->options.fq.priomap); + req->options.fq._len.priomap = len; + req->options.fq.priomap = malloc(req->options.fq._len.priomap); + memcpy(req->options.fq.priomap, priomap, req->options.fq._len.priomap); +} +static inline void +tc_newqdisc_req_set_options_fq_weights(struct tc_newqdisc_req *req, + __s32 *weights, size_t count) +{ + req->_present.options = 1; + req->options._present.fq = 1; + free(req->options.fq.weights); + req->options.fq._count.weights = count; + count *= sizeof(__s32); + req->options.fq.weights = malloc(count); + memcpy(req->options.fq.weights, weights, count); +} +static inline void +tc_newqdisc_req_set_options_fq_codel_target(struct tc_newqdisc_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.target = 1; + req->options.fq_codel.target = target; +} +static inline void +tc_newqdisc_req_set_options_fq_codel_limit(struct tc_newqdisc_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.limit = 1; + req->options.fq_codel.limit = limit; +} +static inline void +tc_newqdisc_req_set_options_fq_codel_interval(struct tc_newqdisc_req *req, + __u32 interval) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.interval = 1; + req->options.fq_codel.interval = interval; +} +static inline void +tc_newqdisc_req_set_options_fq_codel_ecn(struct tc_newqdisc_req *req, + __u32 ecn) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ecn = 1; + req->options.fq_codel.ecn = ecn; +} +static inline void +tc_newqdisc_req_set_options_fq_codel_flows(struct tc_newqdisc_req *req, + __u32 flows) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.flows = 1; + req->options.fq_codel.flows = flows; +} +static inline void +tc_newqdisc_req_set_options_fq_codel_quantum(struct tc_newqdisc_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.quantum = 1; + req->options.fq_codel.quantum = quantum; +} +static inline void +tc_newqdisc_req_set_options_fq_codel_ce_threshold(struct tc_newqdisc_req *req, + __u32 ce_threshold) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ce_threshold = 1; + req->options.fq_codel.ce_threshold = ce_threshold; +} +static inline void +tc_newqdisc_req_set_options_fq_codel_drop_batch_size(struct tc_newqdisc_req *req, + __u32 drop_batch_size) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.drop_batch_size = 1; + req->options.fq_codel.drop_batch_size = drop_batch_size; +} +static inline void +tc_newqdisc_req_set_options_fq_codel_memory_limit(struct tc_newqdisc_req *req, + __u32 memory_limit) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.memory_limit = 1; + req->options.fq_codel.memory_limit = memory_limit; +} +static inline void +tc_newqdisc_req_set_options_fq_codel_ce_threshold_selector(struct tc_newqdisc_req *req, + __u8 ce_threshold_selector) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ce_threshold_selector = 1; + req->options.fq_codel.ce_threshold_selector = ce_threshold_selector; +} +static inline void +tc_newqdisc_req_set_options_fq_codel_ce_threshold_mask(struct tc_newqdisc_req *req, + __u8 ce_threshold_mask) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ce_threshold_mask = 1; + req->options.fq_codel.ce_threshold_mask = ce_threshold_mask; +} +static inline void +tc_newqdisc_req_set_options_fq_pie_limit(struct tc_newqdisc_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.limit = 1; + req->options.fq_pie.limit = limit; +} +static inline void +tc_newqdisc_req_set_options_fq_pie_flows(struct tc_newqdisc_req *req, + __u32 flows) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.flows = 1; + req->options.fq_pie.flows = flows; +} +static inline void +tc_newqdisc_req_set_options_fq_pie_target(struct tc_newqdisc_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.target = 1; + req->options.fq_pie.target = target; +} +static inline void +tc_newqdisc_req_set_options_fq_pie_tupdate(struct tc_newqdisc_req *req, + __u32 tupdate) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.tupdate = 1; + req->options.fq_pie.tupdate = tupdate; +} +static inline void +tc_newqdisc_req_set_options_fq_pie_alpha(struct tc_newqdisc_req *req, + __u32 alpha) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.alpha = 1; + req->options.fq_pie.alpha = alpha; +} +static inline void +tc_newqdisc_req_set_options_fq_pie_beta(struct tc_newqdisc_req *req, + __u32 beta) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.beta = 1; + req->options.fq_pie.beta = beta; +} +static inline void +tc_newqdisc_req_set_options_fq_pie_quantum(struct tc_newqdisc_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.quantum = 1; + req->options.fq_pie.quantum = quantum; +} +static inline void +tc_newqdisc_req_set_options_fq_pie_memory_limit(struct tc_newqdisc_req *req, + __u32 memory_limit) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.memory_limit = 1; + req->options.fq_pie.memory_limit = memory_limit; +} +static inline void +tc_newqdisc_req_set_options_fq_pie_ecn_prob(struct tc_newqdisc_req *req, + __u32 ecn_prob) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.ecn_prob = 1; + req->options.fq_pie.ecn_prob = ecn_prob; +} +static inline void +tc_newqdisc_req_set_options_fq_pie_ecn(struct tc_newqdisc_req *req, __u32 ecn) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.ecn = 1; + req->options.fq_pie.ecn = ecn; +} +static inline void +tc_newqdisc_req_set_options_fq_pie_bytemode(struct tc_newqdisc_req *req, + __u32 bytemode) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.bytemode = 1; + req->options.fq_pie.bytemode = bytemode; +} +static inline void +tc_newqdisc_req_set_options_fq_pie_dq_rate_estimator(struct tc_newqdisc_req *req, + __u32 dq_rate_estimator) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.dq_rate_estimator = 1; + req->options.fq_pie.dq_rate_estimator = dq_rate_estimator; +} +static inline void +tc_newqdisc_req_set_options_fw_classid(struct tc_newqdisc_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.classid = 1; + req->options.fw.classid = classid; +} +static inline void +tc_newqdisc_req_set_options_fw_police_tbf(struct tc_newqdisc_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.tbf); + req->options.fw.police._len.tbf = len; + req->options.fw.police.tbf = malloc(req->options.fw.police._len.tbf); + memcpy(req->options.fw.police.tbf, tbf, req->options.fw.police._len.tbf); +} +static inline void +tc_newqdisc_req_set_options_fw_police_rate(struct tc_newqdisc_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.rate); + req->options.fw.police._len.rate = len; + req->options.fw.police.rate = malloc(req->options.fw.police._len.rate); + memcpy(req->options.fw.police.rate, rate, req->options.fw.police._len.rate); +} +static inline void +tc_newqdisc_req_set_options_fw_police_peakrate(struct tc_newqdisc_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.peakrate); + req->options.fw.police._len.peakrate = len; + req->options.fw.police.peakrate = malloc(req->options.fw.police._len.peakrate); + memcpy(req->options.fw.police.peakrate, peakrate, req->options.fw.police._len.peakrate); +} +static inline void +tc_newqdisc_req_set_options_fw_police_avrate(struct tc_newqdisc_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.avrate = 1; + req->options.fw.police.avrate = avrate; +} +static inline void +tc_newqdisc_req_set_options_fw_police_result(struct tc_newqdisc_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.result = 1; + req->options.fw.police.result = result; +} +static inline void +tc_newqdisc_req_set_options_fw_police_tm(struct tc_newqdisc_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.tm); + req->options.fw.police._len.tm = len; + req->options.fw.police.tm = malloc(req->options.fw.police._len.tm); + memcpy(req->options.fw.police.tm, tm, req->options.fw.police._len.tm); +} +static inline void +tc_newqdisc_req_set_options_fw_police_rate64(struct tc_newqdisc_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.rate64 = 1; + req->options.fw.police.rate64 = rate64; +} +static inline void +tc_newqdisc_req_set_options_fw_police_peakrate64(struct tc_newqdisc_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.peakrate64 = 1; + req->options.fw.police.peakrate64 = peakrate64; +} +static inline void +tc_newqdisc_req_set_options_fw_police_pktrate64(struct tc_newqdisc_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.pktrate64 = 1; + req->options.fw.police.pktrate64 = pktrate64; +} +static inline void +tc_newqdisc_req_set_options_fw_police_pktburst64(struct tc_newqdisc_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.pktburst64 = 1; + req->options.fw.police.pktburst64 = pktburst64; +} +static inline void +tc_newqdisc_req_set_options_fw_indev(struct tc_newqdisc_req *req, + const char *indev) +{ + req->_present.options = 1; + req->options._present.fw = 1; + free(req->options.fw.indev); + req->options.fw._len.indev = strlen(indev); + req->options.fw.indev = malloc(req->options.fw._len.indev + 1); + memcpy(req->options.fw.indev, indev, req->options.fw._len.indev); + req->options.fw.indev[req->options.fw._len.indev] = 0; +} +static inline void +__tc_newqdisc_req_set_options_fw_act(struct tc_newqdisc_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.fw = 1; + free(req->options.fw.act); + req->options.fw.act = act; + req->options.fw._count.act = n_act; +} +static inline void +tc_newqdisc_req_set_options_fw_mask(struct tc_newqdisc_req *req, __u32 mask) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.mask = 1; + req->options.fw.mask = mask; +} +static inline void +tc_newqdisc_req_set_options_gred_parms(struct tc_newqdisc_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.parms); + req->options.gred._len.parms = len; + req->options.gred.parms = malloc(req->options.gred._len.parms); + memcpy(req->options.gred.parms, parms, req->options.gred._len.parms); +} +static inline void +tc_newqdisc_req_set_options_gred_stab(struct tc_newqdisc_req *req, __u8 *stab, + size_t count) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.stab); + req->options.gred._count.stab = count; + count *= sizeof(__u8); + req->options.gred.stab = malloc(count); + memcpy(req->options.gred.stab, stab, count); +} +static inline void +tc_newqdisc_req_set_options_gred_dps(struct tc_newqdisc_req *req, + const void *dps, size_t len) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.dps); + req->options.gred._len.dps = len; + req->options.gred.dps = malloc(req->options.gred._len.dps); + memcpy(req->options.gred.dps, dps, req->options.gred._len.dps); +} +static inline void +tc_newqdisc_req_set_options_gred_max_p(struct tc_newqdisc_req *req, + __u32 *max_p, size_t count) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.max_p); + req->options.gred._count.max_p = count; + count *= sizeof(__u32); + req->options.gred.max_p = malloc(count); + memcpy(req->options.gred.max_p, max_p, count); +} +static inline void +tc_newqdisc_req_set_options_gred_limit(struct tc_newqdisc_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.gred = 1; + req->options.gred._present.limit = 1; + req->options.gred.limit = limit; +} +static inline void +__tc_newqdisc_req_set_options_gred_vq_list_entry(struct tc_newqdisc_req *req, + struct tc_tca_gred_vq_entry_attrs *entry, + unsigned int n_entry) +{ + unsigned int i; + + req->_present.options = 1; + req->options._present.gred = 1; + req->options.gred._present.vq_list = 1; + for (i = 0; i < req->options.gred.vq_list._count.entry; i++) + tc_tca_gred_vq_entry_attrs_free(&req->options.gred.vq_list.entry[i]); + free(req->options.gred.vq_list.entry); + req->options.gred.vq_list.entry = entry; + req->options.gred.vq_list._count.entry = n_entry; +} +static inline void +tc_newqdisc_req_set_options_hfsc(struct tc_newqdisc_req *req, const void *hfsc, + size_t len) +{ + req->_present.options = 1; + free(req->options.hfsc); + req->options._len.hfsc = len; + req->options.hfsc = malloc(req->options._len.hfsc); + memcpy(req->options.hfsc, hfsc, req->options._len.hfsc); +} +static inline void +tc_newqdisc_req_set_options_hhf_backlog_limit(struct tc_newqdisc_req *req, + __u32 backlog_limit) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.backlog_limit = 1; + req->options.hhf.backlog_limit = backlog_limit; +} +static inline void +tc_newqdisc_req_set_options_hhf_quantum(struct tc_newqdisc_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.quantum = 1; + req->options.hhf.quantum = quantum; +} +static inline void +tc_newqdisc_req_set_options_hhf_hh_flows_limit(struct tc_newqdisc_req *req, + __u32 hh_flows_limit) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.hh_flows_limit = 1; + req->options.hhf.hh_flows_limit = hh_flows_limit; +} +static inline void +tc_newqdisc_req_set_options_hhf_reset_timeout(struct tc_newqdisc_req *req, + __u32 reset_timeout) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.reset_timeout = 1; + req->options.hhf.reset_timeout = reset_timeout; +} +static inline void +tc_newqdisc_req_set_options_hhf_admit_bytes(struct tc_newqdisc_req *req, + __u32 admit_bytes) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.admit_bytes = 1; + req->options.hhf.admit_bytes = admit_bytes; +} +static inline void +tc_newqdisc_req_set_options_hhf_evict_timeout(struct tc_newqdisc_req *req, + __u32 evict_timeout) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.evict_timeout = 1; + req->options.hhf.evict_timeout = evict_timeout; +} +static inline void +tc_newqdisc_req_set_options_hhf_non_hh_weight(struct tc_newqdisc_req *req, + __u32 non_hh_weight) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.non_hh_weight = 1; + req->options.hhf.non_hh_weight = non_hh_weight; +} +static inline void +tc_newqdisc_req_set_options_htb_parms(struct tc_newqdisc_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.parms); + req->options.htb._len.parms = len; + req->options.htb.parms = malloc(req->options.htb._len.parms); + memcpy(req->options.htb.parms, parms, req->options.htb._len.parms); +} +static inline void +tc_newqdisc_req_set_options_htb_init(struct tc_newqdisc_req *req, + const void *init, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.init); + req->options.htb._len.init = len; + req->options.htb.init = malloc(req->options.htb._len.init); + memcpy(req->options.htb.init, init, req->options.htb._len.init); +} +static inline void +tc_newqdisc_req_set_options_htb_ctab(struct tc_newqdisc_req *req, + const void *ctab, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.ctab); + req->options.htb._len.ctab = len; + req->options.htb.ctab = malloc(req->options.htb._len.ctab); + memcpy(req->options.htb.ctab, ctab, req->options.htb._len.ctab); +} +static inline void +tc_newqdisc_req_set_options_htb_rtab(struct tc_newqdisc_req *req, + const void *rtab, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.rtab); + req->options.htb._len.rtab = len; + req->options.htb.rtab = malloc(req->options.htb._len.rtab); + memcpy(req->options.htb.rtab, rtab, req->options.htb._len.rtab); +} +static inline void +tc_newqdisc_req_set_options_htb_direct_qlen(struct tc_newqdisc_req *req, + __u32 direct_qlen) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.direct_qlen = 1; + req->options.htb.direct_qlen = direct_qlen; +} +static inline void +tc_newqdisc_req_set_options_htb_rate64(struct tc_newqdisc_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.rate64 = 1; + req->options.htb.rate64 = rate64; +} +static inline void +tc_newqdisc_req_set_options_htb_ceil64(struct tc_newqdisc_req *req, + __u64 ceil64) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.ceil64 = 1; + req->options.htb.ceil64 = ceil64; +} +static inline void +tc_newqdisc_req_set_options_htb_offload(struct tc_newqdisc_req *req) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.offload = 1; +} +static inline void +tc_newqdisc_req_set_options_ingress(struct tc_newqdisc_req *req) +{ + req->_present.options = 1; + req->options._present.ingress = 1; +} +static inline void +tc_newqdisc_req_set_options_matchall_classid(struct tc_newqdisc_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + req->options.matchall._present.classid = 1; + req->options.matchall.classid = classid; +} +static inline void +__tc_newqdisc_req_set_options_matchall_act(struct tc_newqdisc_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + free(req->options.matchall.act); + req->options.matchall.act = act; + req->options.matchall._count.act = n_act; +} +static inline void +tc_newqdisc_req_set_options_matchall_flags(struct tc_newqdisc_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + req->options.matchall._present.flags = 1; + req->options.matchall.flags = flags; +} +static inline void +tc_newqdisc_req_set_options_matchall_pcnt(struct tc_newqdisc_req *req, + const void *pcnt, size_t len) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + free(req->options.matchall.pcnt); + req->options.matchall._len.pcnt = len; + req->options.matchall.pcnt = malloc(req->options.matchall._len.pcnt); + memcpy(req->options.matchall.pcnt, pcnt, req->options.matchall._len.pcnt); +} +static inline void tc_newqdisc_req_set_options_mq(struct tc_newqdisc_req *req) +{ + req->_present.options = 1; + req->options._present.mq = 1; +} +static inline void +tc_newqdisc_req_set_options_mqprio(struct tc_newqdisc_req *req, + const void *mqprio, size_t len) +{ + req->_present.options = 1; + free(req->options.mqprio); + req->options._len.mqprio = len; + req->options.mqprio = malloc(req->options._len.mqprio); + memcpy(req->options.mqprio, mqprio, req->options._len.mqprio); +} +static inline void +tc_newqdisc_req_set_options_multiq(struct tc_newqdisc_req *req, + const void *multiq, size_t len) +{ + req->_present.options = 1; + free(req->options.multiq); + req->options._len.multiq = len; + req->options.multiq = malloc(req->options._len.multiq); + memcpy(req->options.multiq, multiq, req->options._len.multiq); +} +static inline void +tc_newqdisc_req_set_options_netem_corr(struct tc_newqdisc_req *req, + const void *corr, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.corr); + req->options.netem._len.corr = len; + req->options.netem.corr = malloc(req->options.netem._len.corr); + memcpy(req->options.netem.corr, corr, req->options.netem._len.corr); +} +static inline void +tc_newqdisc_req_set_options_netem_delay_dist(struct tc_newqdisc_req *req, + __s16 *delay_dist, size_t count) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.delay_dist); + req->options.netem._count.delay_dist = count; + count *= sizeof(__s16); + req->options.netem.delay_dist = malloc(count); + memcpy(req->options.netem.delay_dist, delay_dist, count); +} +static inline void +tc_newqdisc_req_set_options_netem_reorder(struct tc_newqdisc_req *req, + const void *reorder, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.reorder); + req->options.netem._len.reorder = len; + req->options.netem.reorder = malloc(req->options.netem._len.reorder); + memcpy(req->options.netem.reorder, reorder, req->options.netem._len.reorder); +} +static inline void +tc_newqdisc_req_set_options_netem_corrupt(struct tc_newqdisc_req *req, + const void *corrupt, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.corrupt); + req->options.netem._len.corrupt = len; + req->options.netem.corrupt = malloc(req->options.netem._len.corrupt); + memcpy(req->options.netem.corrupt, corrupt, req->options.netem._len.corrupt); +} +static inline void +tc_newqdisc_req_set_options_netem_loss_gi(struct tc_newqdisc_req *req, + const void *gi, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.loss = 1; + free(req->options.netem.loss.gi); + req->options.netem.loss._len.gi = len; + req->options.netem.loss.gi = malloc(req->options.netem.loss._len.gi); + memcpy(req->options.netem.loss.gi, gi, req->options.netem.loss._len.gi); +} +static inline void +tc_newqdisc_req_set_options_netem_loss_ge(struct tc_newqdisc_req *req, + const void *ge, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.loss = 1; + free(req->options.netem.loss.ge); + req->options.netem.loss._len.ge = len; + req->options.netem.loss.ge = malloc(req->options.netem.loss._len.ge); + memcpy(req->options.netem.loss.ge, ge, req->options.netem.loss._len.ge); +} +static inline void +tc_newqdisc_req_set_options_netem_rate(struct tc_newqdisc_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.rate); + req->options.netem._len.rate = len; + req->options.netem.rate = malloc(req->options.netem._len.rate); + memcpy(req->options.netem.rate, rate, req->options.netem._len.rate); +} +static inline void +tc_newqdisc_req_set_options_netem_ecn(struct tc_newqdisc_req *req, __u32 ecn) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.ecn = 1; + req->options.netem.ecn = ecn; +} +static inline void +tc_newqdisc_req_set_options_netem_rate64(struct tc_newqdisc_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.rate64 = 1; + req->options.netem.rate64 = rate64; +} +static inline void +tc_newqdisc_req_set_options_netem_pad(struct tc_newqdisc_req *req, __u32 pad) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.pad = 1; + req->options.netem.pad = pad; +} +static inline void +tc_newqdisc_req_set_options_netem_latency64(struct tc_newqdisc_req *req, + __s64 latency64) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.latency64 = 1; + req->options.netem.latency64 = latency64; +} +static inline void +tc_newqdisc_req_set_options_netem_jitter64(struct tc_newqdisc_req *req, + __s64 jitter64) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.jitter64 = 1; + req->options.netem.jitter64 = jitter64; +} +static inline void +tc_newqdisc_req_set_options_netem_slot(struct tc_newqdisc_req *req, + const void *slot, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.slot); + req->options.netem._len.slot = len; + req->options.netem.slot = malloc(req->options.netem._len.slot); + memcpy(req->options.netem.slot, slot, req->options.netem._len.slot); +} +static inline void +tc_newqdisc_req_set_options_netem_slot_dist(struct tc_newqdisc_req *req, + __s16 *slot_dist, size_t count) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.slot_dist); + req->options.netem._count.slot_dist = count; + count *= sizeof(__s16); + req->options.netem.slot_dist = malloc(count); + memcpy(req->options.netem.slot_dist, slot_dist, count); +} +static inline void +tc_newqdisc_req_set_options_netem_prng_seed(struct tc_newqdisc_req *req, + __u64 prng_seed) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.prng_seed = 1; + req->options.netem.prng_seed = prng_seed; +} +static inline void +tc_newqdisc_req_set_options_pfifo(struct tc_newqdisc_req *req, + const void *pfifo, size_t len) +{ + req->_present.options = 1; + free(req->options.pfifo); + req->options._len.pfifo = len; + req->options.pfifo = malloc(req->options._len.pfifo); + memcpy(req->options.pfifo, pfifo, req->options._len.pfifo); +} +static inline void +tc_newqdisc_req_set_options_pfifo_fast(struct tc_newqdisc_req *req, + const void *pfifo_fast, size_t len) +{ + req->_present.options = 1; + free(req->options.pfifo_fast); + req->options._len.pfifo_fast = len; + req->options.pfifo_fast = malloc(req->options._len.pfifo_fast); + memcpy(req->options.pfifo_fast, pfifo_fast, req->options._len.pfifo_fast); +} +static inline void +tc_newqdisc_req_set_options_pfifo_head_drop(struct tc_newqdisc_req *req, + const void *pfifo_head_drop, + size_t len) +{ + req->_present.options = 1; + free(req->options.pfifo_head_drop); + req->options._len.pfifo_head_drop = len; + req->options.pfifo_head_drop = malloc(req->options._len.pfifo_head_drop); + memcpy(req->options.pfifo_head_drop, pfifo_head_drop, req->options._len.pfifo_head_drop); +} +static inline void +tc_newqdisc_req_set_options_pie_target(struct tc_newqdisc_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.target = 1; + req->options.pie.target = target; +} +static inline void +tc_newqdisc_req_set_options_pie_limit(struct tc_newqdisc_req *req, __u32 limit) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.limit = 1; + req->options.pie.limit = limit; +} +static inline void +tc_newqdisc_req_set_options_pie_tupdate(struct tc_newqdisc_req *req, + __u32 tupdate) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.tupdate = 1; + req->options.pie.tupdate = tupdate; +} +static inline void +tc_newqdisc_req_set_options_pie_alpha(struct tc_newqdisc_req *req, __u32 alpha) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.alpha = 1; + req->options.pie.alpha = alpha; +} +static inline void +tc_newqdisc_req_set_options_pie_beta(struct tc_newqdisc_req *req, __u32 beta) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.beta = 1; + req->options.pie.beta = beta; +} +static inline void +tc_newqdisc_req_set_options_pie_ecn(struct tc_newqdisc_req *req, __u32 ecn) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.ecn = 1; + req->options.pie.ecn = ecn; +} +static inline void +tc_newqdisc_req_set_options_pie_bytemode(struct tc_newqdisc_req *req, + __u32 bytemode) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.bytemode = 1; + req->options.pie.bytemode = bytemode; +} +static inline void +tc_newqdisc_req_set_options_pie_dq_rate_estimator(struct tc_newqdisc_req *req, + __u32 dq_rate_estimator) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.dq_rate_estimator = 1; + req->options.pie.dq_rate_estimator = dq_rate_estimator; +} +static inline void +tc_newqdisc_req_set_options_plug(struct tc_newqdisc_req *req, const void *plug, + size_t len) +{ + req->_present.options = 1; + free(req->options.plug); + req->options._len.plug = len; + req->options.plug = malloc(req->options._len.plug); + memcpy(req->options.plug, plug, req->options._len.plug); +} +static inline void +tc_newqdisc_req_set_options_prio(struct tc_newqdisc_req *req, const void *prio, + size_t len) +{ + req->_present.options = 1; + free(req->options.prio); + req->options._len.prio = len; + req->options.prio = malloc(req->options._len.prio); + memcpy(req->options.prio, prio, req->options._len.prio); +} +static inline void +tc_newqdisc_req_set_options_qfq_weight(struct tc_newqdisc_req *req, + __u32 weight) +{ + req->_present.options = 1; + req->options._present.qfq = 1; + req->options.qfq._present.weight = 1; + req->options.qfq.weight = weight; +} +static inline void +tc_newqdisc_req_set_options_qfq_lmax(struct tc_newqdisc_req *req, __u32 lmax) +{ + req->_present.options = 1; + req->options._present.qfq = 1; + req->options.qfq._present.lmax = 1; + req->options.qfq.lmax = lmax; +} +static inline void +tc_newqdisc_req_set_options_red_parms(struct tc_newqdisc_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.red = 1; + free(req->options.red.parms); + req->options.red._len.parms = len; + req->options.red.parms = malloc(req->options.red._len.parms); + memcpy(req->options.red.parms, parms, req->options.red._len.parms); +} +static inline void +tc_newqdisc_req_set_options_red_stab(struct tc_newqdisc_req *req, + const void *stab, size_t len) +{ + req->_present.options = 1; + req->options._present.red = 1; + free(req->options.red.stab); + req->options.red._len.stab = len; + req->options.red.stab = malloc(req->options.red._len.stab); + memcpy(req->options.red.stab, stab, req->options.red._len.stab); +} +static inline void +tc_newqdisc_req_set_options_red_max_p(struct tc_newqdisc_req *req, __u32 max_p) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.max_p = 1; + req->options.red.max_p = max_p; +} +static inline void +tc_newqdisc_req_set_options_red_flags(struct tc_newqdisc_req *req, + struct nla_bitfield32 *flags) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.flags = 1; + memcpy(&req->options.red.flags, flags, sizeof(struct nla_bitfield32)); +} +static inline void +tc_newqdisc_req_set_options_red_early_drop_block(struct tc_newqdisc_req *req, + __u32 early_drop_block) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.early_drop_block = 1; + req->options.red.early_drop_block = early_drop_block; +} +static inline void +tc_newqdisc_req_set_options_red_mark_block(struct tc_newqdisc_req *req, + __u32 mark_block) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.mark_block = 1; + req->options.red.mark_block = mark_block; +} +static inline void +tc_newqdisc_req_set_options_route_classid(struct tc_newqdisc_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.classid = 1; + req->options.route.classid = classid; +} +static inline void +tc_newqdisc_req_set_options_route_to(struct tc_newqdisc_req *req, __u32 to) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.to = 1; + req->options.route.to = to; +} +static inline void +tc_newqdisc_req_set_options_route_from(struct tc_newqdisc_req *req, __u32 from) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.from = 1; + req->options.route.from = from; +} +static inline void +tc_newqdisc_req_set_options_route_iif(struct tc_newqdisc_req *req, __u32 iif) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.iif = 1; + req->options.route.iif = iif; +} +static inline void +tc_newqdisc_req_set_options_route_police_tbf(struct tc_newqdisc_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.tbf); + req->options.route.police._len.tbf = len; + req->options.route.police.tbf = malloc(req->options.route.police._len.tbf); + memcpy(req->options.route.police.tbf, tbf, req->options.route.police._len.tbf); +} +static inline void +tc_newqdisc_req_set_options_route_police_rate(struct tc_newqdisc_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.rate); + req->options.route.police._len.rate = len; + req->options.route.police.rate = malloc(req->options.route.police._len.rate); + memcpy(req->options.route.police.rate, rate, req->options.route.police._len.rate); +} +static inline void +tc_newqdisc_req_set_options_route_police_peakrate(struct tc_newqdisc_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.peakrate); + req->options.route.police._len.peakrate = len; + req->options.route.police.peakrate = malloc(req->options.route.police._len.peakrate); + memcpy(req->options.route.police.peakrate, peakrate, req->options.route.police._len.peakrate); +} +static inline void +tc_newqdisc_req_set_options_route_police_avrate(struct tc_newqdisc_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.avrate = 1; + req->options.route.police.avrate = avrate; +} +static inline void +tc_newqdisc_req_set_options_route_police_result(struct tc_newqdisc_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.result = 1; + req->options.route.police.result = result; +} +static inline void +tc_newqdisc_req_set_options_route_police_tm(struct tc_newqdisc_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.tm); + req->options.route.police._len.tm = len; + req->options.route.police.tm = malloc(req->options.route.police._len.tm); + memcpy(req->options.route.police.tm, tm, req->options.route.police._len.tm); +} +static inline void +tc_newqdisc_req_set_options_route_police_rate64(struct tc_newqdisc_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.rate64 = 1; + req->options.route.police.rate64 = rate64; +} +static inline void +tc_newqdisc_req_set_options_route_police_peakrate64(struct tc_newqdisc_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.peakrate64 = 1; + req->options.route.police.peakrate64 = peakrate64; +} +static inline void +tc_newqdisc_req_set_options_route_police_pktrate64(struct tc_newqdisc_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.pktrate64 = 1; + req->options.route.police.pktrate64 = pktrate64; +} +static inline void +tc_newqdisc_req_set_options_route_police_pktburst64(struct tc_newqdisc_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.pktburst64 = 1; + req->options.route.police.pktburst64 = pktburst64; +} +static inline void +__tc_newqdisc_req_set_options_route_act(struct tc_newqdisc_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.route = 1; + free(req->options.route.act); + req->options.route.act = act; + req->options.route._count.act = n_act; +} +static inline void +tc_newqdisc_req_set_options_sfb(struct tc_newqdisc_req *req, const void *sfb, + size_t len) +{ + req->_present.options = 1; + free(req->options.sfb); + req->options._len.sfb = len; + req->options.sfb = malloc(req->options._len.sfb); + memcpy(req->options.sfb, sfb, req->options._len.sfb); +} +static inline void +tc_newqdisc_req_set_options_sfq(struct tc_newqdisc_req *req, const void *sfq, + size_t len) +{ + req->_present.options = 1; + free(req->options.sfq); + req->options._len.sfq = len; + req->options.sfq = malloc(req->options._len.sfq); + memcpy(req->options.sfq, sfq, req->options._len.sfq); +} +static inline void +tc_newqdisc_req_set_options_taprio_priomap(struct tc_newqdisc_req *req, + const void *priomap, size_t len) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + free(req->options.taprio.priomap); + req->options.taprio._len.priomap = len; + req->options.taprio.priomap = malloc(req->options.taprio._len.priomap); + memcpy(req->options.taprio.priomap, priomap, req->options.taprio._len.priomap); +} +static inline void +__tc_newqdisc_req_set_options_taprio_sched_entry_list_entry(struct tc_newqdisc_req *req, + struct tc_taprio_sched_entry *entry, + unsigned int n_entry) +{ + unsigned int i; + + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_entry_list = 1; + for (i = 0; i < req->options.taprio.sched_entry_list._count.entry; i++) + tc_taprio_sched_entry_free(&req->options.taprio.sched_entry_list.entry[i]); + free(req->options.taprio.sched_entry_list.entry); + req->options.taprio.sched_entry_list.entry = entry; + req->options.taprio.sched_entry_list._count.entry = n_entry; +} +static inline void +tc_newqdisc_req_set_options_taprio_sched_base_time(struct tc_newqdisc_req *req, + __s64 sched_base_time) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_base_time = 1; + req->options.taprio.sched_base_time = sched_base_time; +} +static inline void +tc_newqdisc_req_set_options_taprio_sched_single_entry_index(struct tc_newqdisc_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.index = 1; + req->options.taprio.sched_single_entry.index = index; +} +static inline void +tc_newqdisc_req_set_options_taprio_sched_single_entry_cmd(struct tc_newqdisc_req *req, + __u8 cmd) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.cmd = 1; + req->options.taprio.sched_single_entry.cmd = cmd; +} +static inline void +tc_newqdisc_req_set_options_taprio_sched_single_entry_gate_mask(struct tc_newqdisc_req *req, + __u32 gate_mask) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.gate_mask = 1; + req->options.taprio.sched_single_entry.gate_mask = gate_mask; +} +static inline void +tc_newqdisc_req_set_options_taprio_sched_single_entry_interval(struct tc_newqdisc_req *req, + __u32 interval) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.interval = 1; + req->options.taprio.sched_single_entry.interval = interval; +} +static inline void +tc_newqdisc_req_set_options_taprio_sched_clockid(struct tc_newqdisc_req *req, + __s32 sched_clockid) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_clockid = 1; + req->options.taprio.sched_clockid = sched_clockid; +} +static inline void +tc_newqdisc_req_set_options_taprio_admin_sched(struct tc_newqdisc_req *req, + const void *admin_sched, + size_t len) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + free(req->options.taprio.admin_sched); + req->options.taprio._len.admin_sched = len; + req->options.taprio.admin_sched = malloc(req->options.taprio._len.admin_sched); + memcpy(req->options.taprio.admin_sched, admin_sched, req->options.taprio._len.admin_sched); +} +static inline void +tc_newqdisc_req_set_options_taprio_sched_cycle_time(struct tc_newqdisc_req *req, + __s64 sched_cycle_time) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_cycle_time = 1; + req->options.taprio.sched_cycle_time = sched_cycle_time; +} +static inline void +tc_newqdisc_req_set_options_taprio_sched_cycle_time_extension(struct tc_newqdisc_req *req, + __s64 sched_cycle_time_extension) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_cycle_time_extension = 1; + req->options.taprio.sched_cycle_time_extension = sched_cycle_time_extension; +} +static inline void +tc_newqdisc_req_set_options_taprio_flags(struct tc_newqdisc_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.flags = 1; + req->options.taprio.flags = flags; +} +static inline void +tc_newqdisc_req_set_options_taprio_txtime_delay(struct tc_newqdisc_req *req, + __u32 txtime_delay) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.txtime_delay = 1; + req->options.taprio.txtime_delay = txtime_delay; +} +static inline void +tc_newqdisc_req_set_options_taprio_tc_entry_index(struct tc_newqdisc_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.tc_entry = 1; + req->options.taprio.tc_entry._present.index = 1; + req->options.taprio.tc_entry.index = index; +} +static inline void +tc_newqdisc_req_set_options_taprio_tc_entry_max_sdu(struct tc_newqdisc_req *req, + __u32 max_sdu) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.tc_entry = 1; + req->options.taprio.tc_entry._present.max_sdu = 1; + req->options.taprio.tc_entry.max_sdu = max_sdu; +} +static inline void +tc_newqdisc_req_set_options_taprio_tc_entry_fp(struct tc_newqdisc_req *req, + __u32 fp) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.tc_entry = 1; + req->options.taprio.tc_entry._present.fp = 1; + req->options.taprio.tc_entry.fp = fp; +} +static inline void +tc_newqdisc_req_set_options_tbf_parms(struct tc_newqdisc_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + free(req->options.tbf.parms); + req->options.tbf._len.parms = len; + req->options.tbf.parms = malloc(req->options.tbf._len.parms); + memcpy(req->options.tbf.parms, parms, req->options.tbf._len.parms); +} +static inline void +tc_newqdisc_req_set_options_tbf_rtab(struct tc_newqdisc_req *req, + const void *rtab, size_t len) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + free(req->options.tbf.rtab); + req->options.tbf._len.rtab = len; + req->options.tbf.rtab = malloc(req->options.tbf._len.rtab); + memcpy(req->options.tbf.rtab, rtab, req->options.tbf._len.rtab); +} +static inline void +tc_newqdisc_req_set_options_tbf_ptab(struct tc_newqdisc_req *req, + const void *ptab, size_t len) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + free(req->options.tbf.ptab); + req->options.tbf._len.ptab = len; + req->options.tbf.ptab = malloc(req->options.tbf._len.ptab); + memcpy(req->options.tbf.ptab, ptab, req->options.tbf._len.ptab); +} +static inline void +tc_newqdisc_req_set_options_tbf_rate64(struct tc_newqdisc_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.rate64 = 1; + req->options.tbf.rate64 = rate64; +} +static inline void +tc_newqdisc_req_set_options_tbf_prate64(struct tc_newqdisc_req *req, + __u64 prate64) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.prate64 = 1; + req->options.tbf.prate64 = prate64; +} +static inline void +tc_newqdisc_req_set_options_tbf_burst(struct tc_newqdisc_req *req, __u32 burst) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.burst = 1; + req->options.tbf.burst = burst; +} +static inline void +tc_newqdisc_req_set_options_tbf_pburst(struct tc_newqdisc_req *req, + __u32 pburst) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.pburst = 1; + req->options.tbf.pburst = pburst; +} +static inline void +tc_newqdisc_req_set_options_u32_classid(struct tc_newqdisc_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.classid = 1; + req->options.u32.classid = classid; +} +static inline void +tc_newqdisc_req_set_options_u32_hash(struct tc_newqdisc_req *req, __u32 hash) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.hash = 1; + req->options.u32.hash = hash; +} +static inline void +tc_newqdisc_req_set_options_u32_link(struct tc_newqdisc_req *req, __u32 link) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.link = 1; + req->options.u32.link = link; +} +static inline void +tc_newqdisc_req_set_options_u32_divisor(struct tc_newqdisc_req *req, + __u32 divisor) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.divisor = 1; + req->options.u32.divisor = divisor; +} +static inline void +tc_newqdisc_req_set_options_u32_sel(struct tc_newqdisc_req *req, + const void *sel, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.sel); + req->options.u32._len.sel = len; + req->options.u32.sel = malloc(req->options.u32._len.sel); + memcpy(req->options.u32.sel, sel, req->options.u32._len.sel); +} +static inline void +tc_newqdisc_req_set_options_u32_police_tbf(struct tc_newqdisc_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.tbf); + req->options.u32.police._len.tbf = len; + req->options.u32.police.tbf = malloc(req->options.u32.police._len.tbf); + memcpy(req->options.u32.police.tbf, tbf, req->options.u32.police._len.tbf); +} +static inline void +tc_newqdisc_req_set_options_u32_police_rate(struct tc_newqdisc_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.rate); + req->options.u32.police._len.rate = len; + req->options.u32.police.rate = malloc(req->options.u32.police._len.rate); + memcpy(req->options.u32.police.rate, rate, req->options.u32.police._len.rate); +} +static inline void +tc_newqdisc_req_set_options_u32_police_peakrate(struct tc_newqdisc_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.peakrate); + req->options.u32.police._len.peakrate = len; + req->options.u32.police.peakrate = malloc(req->options.u32.police._len.peakrate); + memcpy(req->options.u32.police.peakrate, peakrate, req->options.u32.police._len.peakrate); +} +static inline void +tc_newqdisc_req_set_options_u32_police_avrate(struct tc_newqdisc_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.avrate = 1; + req->options.u32.police.avrate = avrate; +} +static inline void +tc_newqdisc_req_set_options_u32_police_result(struct tc_newqdisc_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.result = 1; + req->options.u32.police.result = result; +} +static inline void +tc_newqdisc_req_set_options_u32_police_tm(struct tc_newqdisc_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.tm); + req->options.u32.police._len.tm = len; + req->options.u32.police.tm = malloc(req->options.u32.police._len.tm); + memcpy(req->options.u32.police.tm, tm, req->options.u32.police._len.tm); +} +static inline void +tc_newqdisc_req_set_options_u32_police_rate64(struct tc_newqdisc_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.rate64 = 1; + req->options.u32.police.rate64 = rate64; +} +static inline void +tc_newqdisc_req_set_options_u32_police_peakrate64(struct tc_newqdisc_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.peakrate64 = 1; + req->options.u32.police.peakrate64 = peakrate64; +} +static inline void +tc_newqdisc_req_set_options_u32_police_pktrate64(struct tc_newqdisc_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.pktrate64 = 1; + req->options.u32.police.pktrate64 = pktrate64; +} +static inline void +tc_newqdisc_req_set_options_u32_police_pktburst64(struct tc_newqdisc_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.pktburst64 = 1; + req->options.u32.police.pktburst64 = pktburst64; +} +static inline void +__tc_newqdisc_req_set_options_u32_act(struct tc_newqdisc_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.act); + req->options.u32.act = act; + req->options.u32._count.act = n_act; +} +static inline void +tc_newqdisc_req_set_options_u32_indev(struct tc_newqdisc_req *req, + const char *indev) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.indev); + req->options.u32._len.indev = strlen(indev); + req->options.u32.indev = malloc(req->options.u32._len.indev + 1); + memcpy(req->options.u32.indev, indev, req->options.u32._len.indev); + req->options.u32.indev[req->options.u32._len.indev] = 0; +} +static inline void +tc_newqdisc_req_set_options_u32_pcnt(struct tc_newqdisc_req *req, + const void *pcnt, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.pcnt); + req->options.u32._len.pcnt = len; + req->options.u32.pcnt = malloc(req->options.u32._len.pcnt); + memcpy(req->options.u32.pcnt, pcnt, req->options.u32._len.pcnt); +} +static inline void +tc_newqdisc_req_set_options_u32_mark(struct tc_newqdisc_req *req, + const void *mark, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.mark); + req->options.u32._len.mark = len; + req->options.u32.mark = malloc(req->options.u32._len.mark); + memcpy(req->options.u32.mark, mark, req->options.u32._len.mark); +} +static inline void +tc_newqdisc_req_set_options_u32_flags(struct tc_newqdisc_req *req, __u32 flags) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.flags = 1; + req->options.u32.flags = flags; +} +static inline void +tc_newqdisc_req_set_rate(struct tc_newqdisc_req *req, const void *rate, + size_t len) +{ + free(req->rate); + req->_len.rate = len; + req->rate = malloc(req->_len.rate); + memcpy(req->rate, rate, req->_len.rate); +} +static inline void +tc_newqdisc_req_set_chain(struct tc_newqdisc_req *req, __u32 chain) +{ + req->_present.chain = 1; + req->chain = chain; +} +static inline void +tc_newqdisc_req_set_ingress_block(struct tc_newqdisc_req *req, + __u32 ingress_block) +{ + req->_present.ingress_block = 1; + req->ingress_block = ingress_block; +} +static inline void +tc_newqdisc_req_set_egress_block(struct tc_newqdisc_req *req, + __u32 egress_block) +{ + req->_present.egress_block = 1; + req->egress_block = egress_block; +} + +/* + * Create new tc qdisc. + */ +int tc_newqdisc(struct ynl_sock *ys, struct tc_newqdisc_req *req); + +/* ============== RTM_DELQDISC ============== */ +/* RTM_DELQDISC - do */ +struct tc_delqdisc_req { + __u16 _nlmsg_flags; + + struct tcmsg _hdr; +}; + +static inline struct tc_delqdisc_req *tc_delqdisc_req_alloc(void) +{ + return calloc(1, sizeof(struct tc_delqdisc_req)); +} +void tc_delqdisc_req_free(struct tc_delqdisc_req *req); + +static inline void +tc_delqdisc_req_set_nlflags(struct tc_delqdisc_req *req, __u16 nl_flags) +{ + req->_nlmsg_flags = nl_flags; +} + +/* + * Delete existing tc qdisc. + */ +int tc_delqdisc(struct ynl_sock *ys, struct tc_delqdisc_req *req); + +/* ============== RTM_GETQDISC ============== */ +/* RTM_GETQDISC - do */ +struct tc_getqdisc_req { + __u16 _nlmsg_flags; + + struct tcmsg _hdr; + + struct { + __u32 dump_invisible:1; + } _present; +}; + +static inline struct tc_getqdisc_req *tc_getqdisc_req_alloc(void) +{ + return calloc(1, sizeof(struct tc_getqdisc_req)); +} +void tc_getqdisc_req_free(struct tc_getqdisc_req *req); + +static inline void +tc_getqdisc_req_set_nlflags(struct tc_getqdisc_req *req, __u16 nl_flags) +{ + req->_nlmsg_flags = nl_flags; +} + +static inline void +tc_getqdisc_req_set_dump_invisible(struct tc_getqdisc_req *req) +{ + req->_present.dump_invisible = 1; +} + +struct tc_getqdisc_rsp { + struct tcmsg _hdr; + + struct { + __u32 options:1; + __u32 xstats:1; + __u32 fcnt:1; + __u32 stats2:1; + __u32 stab:1; + __u32 chain:1; + __u32 ingress_block:1; + __u32 egress_block:1; + } _present; + struct { + __u32 kind; + __u32 stats; + __u32 rate; + } _len; + + char *kind; + struct tc_options_msg options; + struct tc_stats *stats; + struct tc_tca_stats_app_msg xstats; + struct gnet_estimator *rate; + __u32 fcnt; + struct tc_tca_stats_attrs stats2; + struct tc_tca_stab_attrs stab; + __u32 chain; + __u32 ingress_block; + __u32 egress_block; +}; + +void tc_getqdisc_rsp_free(struct tc_getqdisc_rsp *rsp); + +/* + * Get / dump tc qdisc information. + */ +struct tc_getqdisc_rsp * +tc_getqdisc(struct ynl_sock *ys, struct tc_getqdisc_req *req); + +/* RTM_GETQDISC - dump */ +struct tc_getqdisc_req_dump { + struct tcmsg _hdr; + + struct { + __u32 dump_invisible:1; + } _present; +}; + +static inline struct tc_getqdisc_req_dump *tc_getqdisc_req_dump_alloc(void) +{ + return calloc(1, sizeof(struct tc_getqdisc_req_dump)); +} +void tc_getqdisc_req_dump_free(struct tc_getqdisc_req_dump *req); + +static inline void +tc_getqdisc_req_dump_set_dump_invisible(struct tc_getqdisc_req_dump *req) +{ + req->_present.dump_invisible = 1; +} + +struct tc_getqdisc_list { + struct tc_getqdisc_list *next; + struct tc_getqdisc_rsp obj __attribute__((aligned(8))); +}; + +void tc_getqdisc_list_free(struct tc_getqdisc_list *rsp); + +struct tc_getqdisc_list * +tc_getqdisc_dump(struct ynl_sock *ys, struct tc_getqdisc_req_dump *req); + +/* ============== RTM_NEWTCLASS ============== */ +/* RTM_NEWTCLASS - do */ +struct tc_newtclass_req { + __u16 _nlmsg_flags; + + struct tcmsg _hdr; + + struct { + __u32 options:1; + __u32 chain:1; + __u32 ingress_block:1; + __u32 egress_block:1; + } _present; + struct { + __u32 kind; + __u32 rate; + } _len; + + char *kind; + struct tc_options_msg options; + struct gnet_estimator *rate; + __u32 chain; + __u32 ingress_block; + __u32 egress_block; +}; + +static inline struct tc_newtclass_req *tc_newtclass_req_alloc(void) +{ + return calloc(1, sizeof(struct tc_newtclass_req)); +} +void tc_newtclass_req_free(struct tc_newtclass_req *req); + +static inline void +tc_newtclass_req_set_nlflags(struct tc_newtclass_req *req, __u16 nl_flags) +{ + req->_nlmsg_flags = nl_flags; +} + +static inline void +tc_newtclass_req_set_kind(struct tc_newtclass_req *req, const char *kind) +{ + free(req->kind); + req->_len.kind = strlen(kind); + req->kind = malloc(req->_len.kind + 1); + memcpy(req->kind, kind, req->_len.kind); + req->kind[req->_len.kind] = 0; +} +static inline void +tc_newtclass_req_set_options_basic_classid(struct tc_newtclass_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.classid = 1; + req->options.basic.classid = classid; +} +static inline void +tc_newtclass_req_set_options_basic_ematches_tree_hdr(struct tc_newtclass_req *req, + const void *tree_hdr, + size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.ematches = 1; + free(req->options.basic.ematches.tree_hdr); + req->options.basic.ematches._len.tree_hdr = len; + req->options.basic.ematches.tree_hdr = malloc(req->options.basic.ematches._len.tree_hdr); + memcpy(req->options.basic.ematches.tree_hdr, tree_hdr, req->options.basic.ematches._len.tree_hdr); +} +static inline void +tc_newtclass_req_set_options_basic_ematches_tree_list(struct tc_newtclass_req *req, + const void *tree_list, + size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.ematches = 1; + free(req->options.basic.ematches.tree_list); + req->options.basic.ematches._len.tree_list = len; + req->options.basic.ematches.tree_list = malloc(req->options.basic.ematches._len.tree_list); + memcpy(req->options.basic.ematches.tree_list, tree_list, req->options.basic.ematches._len.tree_list); +} +static inline void +__tc_newtclass_req_set_options_basic_act(struct tc_newtclass_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.basic = 1; + free(req->options.basic.act); + req->options.basic.act = act; + req->options.basic._count.act = n_act; +} +static inline void +tc_newtclass_req_set_options_basic_police_tbf(struct tc_newtclass_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.tbf); + req->options.basic.police._len.tbf = len; + req->options.basic.police.tbf = malloc(req->options.basic.police._len.tbf); + memcpy(req->options.basic.police.tbf, tbf, req->options.basic.police._len.tbf); +} +static inline void +tc_newtclass_req_set_options_basic_police_rate(struct tc_newtclass_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.rate); + req->options.basic.police._len.rate = len; + req->options.basic.police.rate = malloc(req->options.basic.police._len.rate); + memcpy(req->options.basic.police.rate, rate, req->options.basic.police._len.rate); +} +static inline void +tc_newtclass_req_set_options_basic_police_peakrate(struct tc_newtclass_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.peakrate); + req->options.basic.police._len.peakrate = len; + req->options.basic.police.peakrate = malloc(req->options.basic.police._len.peakrate); + memcpy(req->options.basic.police.peakrate, peakrate, req->options.basic.police._len.peakrate); +} +static inline void +tc_newtclass_req_set_options_basic_police_avrate(struct tc_newtclass_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.avrate = 1; + req->options.basic.police.avrate = avrate; +} +static inline void +tc_newtclass_req_set_options_basic_police_result(struct tc_newtclass_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.result = 1; + req->options.basic.police.result = result; +} +static inline void +tc_newtclass_req_set_options_basic_police_tm(struct tc_newtclass_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.tm); + req->options.basic.police._len.tm = len; + req->options.basic.police.tm = malloc(req->options.basic.police._len.tm); + memcpy(req->options.basic.police.tm, tm, req->options.basic.police._len.tm); +} +static inline void +tc_newtclass_req_set_options_basic_police_rate64(struct tc_newtclass_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.rate64 = 1; + req->options.basic.police.rate64 = rate64; +} +static inline void +tc_newtclass_req_set_options_basic_police_peakrate64(struct tc_newtclass_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.peakrate64 = 1; + req->options.basic.police.peakrate64 = peakrate64; +} +static inline void +tc_newtclass_req_set_options_basic_police_pktrate64(struct tc_newtclass_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.pktrate64 = 1; + req->options.basic.police.pktrate64 = pktrate64; +} +static inline void +tc_newtclass_req_set_options_basic_police_pktburst64(struct tc_newtclass_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.pktburst64 = 1; + req->options.basic.police.pktburst64 = pktburst64; +} +static inline void +tc_newtclass_req_set_options_basic_pcnt(struct tc_newtclass_req *req, + const void *pcnt, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + free(req->options.basic.pcnt); + req->options.basic._len.pcnt = len; + req->options.basic.pcnt = malloc(req->options.basic._len.pcnt); + memcpy(req->options.basic.pcnt, pcnt, req->options.basic._len.pcnt); +} +static inline void +__tc_newtclass_req_set_options_bpf_act(struct tc_newtclass_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.act); + req->options.bpf.act = act; + req->options.bpf._count.act = n_act; +} +static inline void +tc_newtclass_req_set_options_bpf_police_tbf(struct tc_newtclass_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.tbf); + req->options.bpf.police._len.tbf = len; + req->options.bpf.police.tbf = malloc(req->options.bpf.police._len.tbf); + memcpy(req->options.bpf.police.tbf, tbf, req->options.bpf.police._len.tbf); +} +static inline void +tc_newtclass_req_set_options_bpf_police_rate(struct tc_newtclass_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.rate); + req->options.bpf.police._len.rate = len; + req->options.bpf.police.rate = malloc(req->options.bpf.police._len.rate); + memcpy(req->options.bpf.police.rate, rate, req->options.bpf.police._len.rate); +} +static inline void +tc_newtclass_req_set_options_bpf_police_peakrate(struct tc_newtclass_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.peakrate); + req->options.bpf.police._len.peakrate = len; + req->options.bpf.police.peakrate = malloc(req->options.bpf.police._len.peakrate); + memcpy(req->options.bpf.police.peakrate, peakrate, req->options.bpf.police._len.peakrate); +} +static inline void +tc_newtclass_req_set_options_bpf_police_avrate(struct tc_newtclass_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.avrate = 1; + req->options.bpf.police.avrate = avrate; +} +static inline void +tc_newtclass_req_set_options_bpf_police_result(struct tc_newtclass_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.result = 1; + req->options.bpf.police.result = result; +} +static inline void +tc_newtclass_req_set_options_bpf_police_tm(struct tc_newtclass_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.tm); + req->options.bpf.police._len.tm = len; + req->options.bpf.police.tm = malloc(req->options.bpf.police._len.tm); + memcpy(req->options.bpf.police.tm, tm, req->options.bpf.police._len.tm); +} +static inline void +tc_newtclass_req_set_options_bpf_police_rate64(struct tc_newtclass_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.rate64 = 1; + req->options.bpf.police.rate64 = rate64; +} +static inline void +tc_newtclass_req_set_options_bpf_police_peakrate64(struct tc_newtclass_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.peakrate64 = 1; + req->options.bpf.police.peakrate64 = peakrate64; +} +static inline void +tc_newtclass_req_set_options_bpf_police_pktrate64(struct tc_newtclass_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.pktrate64 = 1; + req->options.bpf.police.pktrate64 = pktrate64; +} +static inline void +tc_newtclass_req_set_options_bpf_police_pktburst64(struct tc_newtclass_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.pktburst64 = 1; + req->options.bpf.police.pktburst64 = pktburst64; +} +static inline void +tc_newtclass_req_set_options_bpf_classid(struct tc_newtclass_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.classid = 1; + req->options.bpf.classid = classid; +} +static inline void +tc_newtclass_req_set_options_bpf_ops_len(struct tc_newtclass_req *req, + __u16 ops_len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.ops_len = 1; + req->options.bpf.ops_len = ops_len; +} +static inline void +tc_newtclass_req_set_options_bpf_ops(struct tc_newtclass_req *req, + const void *ops, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.ops); + req->options.bpf._len.ops = len; + req->options.bpf.ops = malloc(req->options.bpf._len.ops); + memcpy(req->options.bpf.ops, ops, req->options.bpf._len.ops); +} +static inline void +tc_newtclass_req_set_options_bpf_fd(struct tc_newtclass_req *req, __u32 fd) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.fd = 1; + req->options.bpf.fd = fd; +} +static inline void +tc_newtclass_req_set_options_bpf_name(struct tc_newtclass_req *req, + const char *name) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.name); + req->options.bpf._len.name = strlen(name); + req->options.bpf.name = malloc(req->options.bpf._len.name + 1); + memcpy(req->options.bpf.name, name, req->options.bpf._len.name); + req->options.bpf.name[req->options.bpf._len.name] = 0; +} +static inline void +tc_newtclass_req_set_options_bpf_flags(struct tc_newtclass_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.flags = 1; + req->options.bpf.flags = flags; +} +static inline void +tc_newtclass_req_set_options_bpf_flags_gen(struct tc_newtclass_req *req, + __u32 flags_gen) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.flags_gen = 1; + req->options.bpf.flags_gen = flags_gen; +} +static inline void +tc_newtclass_req_set_options_bpf_tag(struct tc_newtclass_req *req, + const void *tag, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.tag); + req->options.bpf._len.tag = len; + req->options.bpf.tag = malloc(req->options.bpf._len.tag); + memcpy(req->options.bpf.tag, tag, req->options.bpf._len.tag); +} +static inline void +tc_newtclass_req_set_options_bpf_id(struct tc_newtclass_req *req, __u32 id) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.id = 1; + req->options.bpf.id = id; +} +static inline void +tc_newtclass_req_set_options_bfifo(struct tc_newtclass_req *req, + const void *bfifo, size_t len) +{ + req->_present.options = 1; + free(req->options.bfifo); + req->options._len.bfifo = len; + req->options.bfifo = malloc(req->options._len.bfifo); + memcpy(req->options.bfifo, bfifo, req->options._len.bfifo); +} +static inline void +tc_newtclass_req_set_options_cake_base_rate64(struct tc_newtclass_req *req, + __u64 base_rate64) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.base_rate64 = 1; + req->options.cake.base_rate64 = base_rate64; +} +static inline void +tc_newtclass_req_set_options_cake_diffserv_mode(struct tc_newtclass_req *req, + __u32 diffserv_mode) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.diffserv_mode = 1; + req->options.cake.diffserv_mode = diffserv_mode; +} +static inline void +tc_newtclass_req_set_options_cake_atm(struct tc_newtclass_req *req, __u32 atm) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.atm = 1; + req->options.cake.atm = atm; +} +static inline void +tc_newtclass_req_set_options_cake_flow_mode(struct tc_newtclass_req *req, + __u32 flow_mode) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.flow_mode = 1; + req->options.cake.flow_mode = flow_mode; +} +static inline void +tc_newtclass_req_set_options_cake_overhead(struct tc_newtclass_req *req, + __u32 overhead) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.overhead = 1; + req->options.cake.overhead = overhead; +} +static inline void +tc_newtclass_req_set_options_cake_rtt(struct tc_newtclass_req *req, __u32 rtt) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.rtt = 1; + req->options.cake.rtt = rtt; +} +static inline void +tc_newtclass_req_set_options_cake_target(struct tc_newtclass_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.target = 1; + req->options.cake.target = target; +} +static inline void +tc_newtclass_req_set_options_cake_autorate(struct tc_newtclass_req *req, + __u32 autorate) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.autorate = 1; + req->options.cake.autorate = autorate; +} +static inline void +tc_newtclass_req_set_options_cake_memory(struct tc_newtclass_req *req, + __u32 memory) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.memory = 1; + req->options.cake.memory = memory; +} +static inline void +tc_newtclass_req_set_options_cake_nat(struct tc_newtclass_req *req, __u32 nat) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.nat = 1; + req->options.cake.nat = nat; +} +static inline void +tc_newtclass_req_set_options_cake_raw(struct tc_newtclass_req *req, __u32 raw) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.raw = 1; + req->options.cake.raw = raw; +} +static inline void +tc_newtclass_req_set_options_cake_wash(struct tc_newtclass_req *req, + __u32 wash) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.wash = 1; + req->options.cake.wash = wash; +} +static inline void +tc_newtclass_req_set_options_cake_mpu(struct tc_newtclass_req *req, __u32 mpu) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.mpu = 1; + req->options.cake.mpu = mpu; +} +static inline void +tc_newtclass_req_set_options_cake_ingress(struct tc_newtclass_req *req, + __u32 ingress) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.ingress = 1; + req->options.cake.ingress = ingress; +} +static inline void +tc_newtclass_req_set_options_cake_ack_filter(struct tc_newtclass_req *req, + __u32 ack_filter) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.ack_filter = 1; + req->options.cake.ack_filter = ack_filter; +} +static inline void +tc_newtclass_req_set_options_cake_split_gso(struct tc_newtclass_req *req, + __u32 split_gso) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.split_gso = 1; + req->options.cake.split_gso = split_gso; +} +static inline void +tc_newtclass_req_set_options_cake_fwmark(struct tc_newtclass_req *req, + __u32 fwmark) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.fwmark = 1; + req->options.cake.fwmark = fwmark; +} +static inline void +tc_newtclass_req_set_options_cbs_parms(struct tc_newtclass_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.cbs = 1; + free(req->options.cbs.parms); + req->options.cbs._len.parms = len; + req->options.cbs.parms = malloc(req->options.cbs._len.parms); + memcpy(req->options.cbs.parms, parms, req->options.cbs._len.parms); +} +static inline void +__tc_newtclass_req_set_options_cgroup_act(struct tc_newtclass_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + free(req->options.cgroup.act); + req->options.cgroup.act = act; + req->options.cgroup._count.act = n_act; +} +static inline void +tc_newtclass_req_set_options_cgroup_police_tbf(struct tc_newtclass_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.tbf); + req->options.cgroup.police._len.tbf = len; + req->options.cgroup.police.tbf = malloc(req->options.cgroup.police._len.tbf); + memcpy(req->options.cgroup.police.tbf, tbf, req->options.cgroup.police._len.tbf); +} +static inline void +tc_newtclass_req_set_options_cgroup_police_rate(struct tc_newtclass_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.rate); + req->options.cgroup.police._len.rate = len; + req->options.cgroup.police.rate = malloc(req->options.cgroup.police._len.rate); + memcpy(req->options.cgroup.police.rate, rate, req->options.cgroup.police._len.rate); +} +static inline void +tc_newtclass_req_set_options_cgroup_police_peakrate(struct tc_newtclass_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.peakrate); + req->options.cgroup.police._len.peakrate = len; + req->options.cgroup.police.peakrate = malloc(req->options.cgroup.police._len.peakrate); + memcpy(req->options.cgroup.police.peakrate, peakrate, req->options.cgroup.police._len.peakrate); +} +static inline void +tc_newtclass_req_set_options_cgroup_police_avrate(struct tc_newtclass_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.avrate = 1; + req->options.cgroup.police.avrate = avrate; +} +static inline void +tc_newtclass_req_set_options_cgroup_police_result(struct tc_newtclass_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.result = 1; + req->options.cgroup.police.result = result; +} +static inline void +tc_newtclass_req_set_options_cgroup_police_tm(struct tc_newtclass_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.tm); + req->options.cgroup.police._len.tm = len; + req->options.cgroup.police.tm = malloc(req->options.cgroup.police._len.tm); + memcpy(req->options.cgroup.police.tm, tm, req->options.cgroup.police._len.tm); +} +static inline void +tc_newtclass_req_set_options_cgroup_police_rate64(struct tc_newtclass_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.rate64 = 1; + req->options.cgroup.police.rate64 = rate64; +} +static inline void +tc_newtclass_req_set_options_cgroup_police_peakrate64(struct tc_newtclass_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.peakrate64 = 1; + req->options.cgroup.police.peakrate64 = peakrate64; +} +static inline void +tc_newtclass_req_set_options_cgroup_police_pktrate64(struct tc_newtclass_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.pktrate64 = 1; + req->options.cgroup.police.pktrate64 = pktrate64; +} +static inline void +tc_newtclass_req_set_options_cgroup_police_pktburst64(struct tc_newtclass_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.pktburst64 = 1; + req->options.cgroup.police.pktburst64 = pktburst64; +} +static inline void +tc_newtclass_req_set_options_cgroup_ematches(struct tc_newtclass_req *req, + const void *ematches, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + free(req->options.cgroup.ematches); + req->options.cgroup._len.ematches = len; + req->options.cgroup.ematches = malloc(req->options.cgroup._len.ematches); + memcpy(req->options.cgroup.ematches, ematches, req->options.cgroup._len.ematches); +} +static inline void +tc_newtclass_req_set_options_choke_parms(struct tc_newtclass_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.choke = 1; + free(req->options.choke.parms); + req->options.choke._len.parms = len; + req->options.choke.parms = malloc(req->options.choke._len.parms); + memcpy(req->options.choke.parms, parms, req->options.choke._len.parms); +} +static inline void +tc_newtclass_req_set_options_choke_stab(struct tc_newtclass_req *req, + const void *stab, size_t len) +{ + req->_present.options = 1; + req->options._present.choke = 1; + free(req->options.choke.stab); + req->options.choke._len.stab = len; + req->options.choke.stab = malloc(req->options.choke._len.stab); + memcpy(req->options.choke.stab, stab, req->options.choke._len.stab); +} +static inline void +tc_newtclass_req_set_options_choke_max_p(struct tc_newtclass_req *req, + __u32 max_p) +{ + req->_present.options = 1; + req->options._present.choke = 1; + req->options.choke._present.max_p = 1; + req->options.choke.max_p = max_p; +} +static inline void +tc_newtclass_req_set_options_clsact(struct tc_newtclass_req *req) +{ + req->_present.options = 1; + req->options._present.clsact = 1; +} +static inline void +tc_newtclass_req_set_options_codel_target(struct tc_newtclass_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.target = 1; + req->options.codel.target = target; +} +static inline void +tc_newtclass_req_set_options_codel_limit(struct tc_newtclass_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.limit = 1; + req->options.codel.limit = limit; +} +static inline void +tc_newtclass_req_set_options_codel_interval(struct tc_newtclass_req *req, + __u32 interval) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.interval = 1; + req->options.codel.interval = interval; +} +static inline void +tc_newtclass_req_set_options_codel_ecn(struct tc_newtclass_req *req, __u32 ecn) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.ecn = 1; + req->options.codel.ecn = ecn; +} +static inline void +tc_newtclass_req_set_options_codel_ce_threshold(struct tc_newtclass_req *req, + __u32 ce_threshold) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.ce_threshold = 1; + req->options.codel.ce_threshold = ce_threshold; +} +static inline void +tc_newtclass_req_set_options_drr_quantum(struct tc_newtclass_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.drr = 1; + req->options.drr._present.quantum = 1; + req->options.drr.quantum = quantum; +} +static inline void +tc_newtclass_req_set_options_etf_parms(struct tc_newtclass_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.etf = 1; + free(req->options.etf.parms); + req->options.etf._len.parms = len; + req->options.etf.parms = malloc(req->options.etf._len.parms); + memcpy(req->options.etf.parms, parms, req->options.etf._len.parms); +} +static inline void +tc_newtclass_req_set_options_flow_keys(struct tc_newtclass_req *req, + __u32 keys) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.keys = 1; + req->options.flow.keys = keys; +} +static inline void +tc_newtclass_req_set_options_flow_mode(struct tc_newtclass_req *req, + __u32 mode) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.mode = 1; + req->options.flow.mode = mode; +} +static inline void +tc_newtclass_req_set_options_flow_baseclass(struct tc_newtclass_req *req, + __u32 baseclass) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.baseclass = 1; + req->options.flow.baseclass = baseclass; +} +static inline void +tc_newtclass_req_set_options_flow_rshift(struct tc_newtclass_req *req, + __u32 rshift) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.rshift = 1; + req->options.flow.rshift = rshift; +} +static inline void +tc_newtclass_req_set_options_flow_addend(struct tc_newtclass_req *req, + __u32 addend) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.addend = 1; + req->options.flow.addend = addend; +} +static inline void +tc_newtclass_req_set_options_flow_mask(struct tc_newtclass_req *req, + __u32 mask) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.mask = 1; + req->options.flow.mask = mask; +} +static inline void +tc_newtclass_req_set_options_flow_xor(struct tc_newtclass_req *req, __u32 xor) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.xor = 1; + req->options.flow.xor = xor; +} +static inline void +tc_newtclass_req_set_options_flow_divisor(struct tc_newtclass_req *req, + __u32 divisor) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.divisor = 1; + req->options.flow.divisor = divisor; +} +static inline void +tc_newtclass_req_set_options_flow_act(struct tc_newtclass_req *req, + const void *act, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + free(req->options.flow.act); + req->options.flow._len.act = len; + req->options.flow.act = malloc(req->options.flow._len.act); + memcpy(req->options.flow.act, act, req->options.flow._len.act); +} +static inline void +tc_newtclass_req_set_options_flow_police_tbf(struct tc_newtclass_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.tbf); + req->options.flow.police._len.tbf = len; + req->options.flow.police.tbf = malloc(req->options.flow.police._len.tbf); + memcpy(req->options.flow.police.tbf, tbf, req->options.flow.police._len.tbf); +} +static inline void +tc_newtclass_req_set_options_flow_police_rate(struct tc_newtclass_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.rate); + req->options.flow.police._len.rate = len; + req->options.flow.police.rate = malloc(req->options.flow.police._len.rate); + memcpy(req->options.flow.police.rate, rate, req->options.flow.police._len.rate); +} +static inline void +tc_newtclass_req_set_options_flow_police_peakrate(struct tc_newtclass_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.peakrate); + req->options.flow.police._len.peakrate = len; + req->options.flow.police.peakrate = malloc(req->options.flow.police._len.peakrate); + memcpy(req->options.flow.police.peakrate, peakrate, req->options.flow.police._len.peakrate); +} +static inline void +tc_newtclass_req_set_options_flow_police_avrate(struct tc_newtclass_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.avrate = 1; + req->options.flow.police.avrate = avrate; +} +static inline void +tc_newtclass_req_set_options_flow_police_result(struct tc_newtclass_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.result = 1; + req->options.flow.police.result = result; +} +static inline void +tc_newtclass_req_set_options_flow_police_tm(struct tc_newtclass_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.tm); + req->options.flow.police._len.tm = len; + req->options.flow.police.tm = malloc(req->options.flow.police._len.tm); + memcpy(req->options.flow.police.tm, tm, req->options.flow.police._len.tm); +} +static inline void +tc_newtclass_req_set_options_flow_police_rate64(struct tc_newtclass_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.rate64 = 1; + req->options.flow.police.rate64 = rate64; +} +static inline void +tc_newtclass_req_set_options_flow_police_peakrate64(struct tc_newtclass_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.peakrate64 = 1; + req->options.flow.police.peakrate64 = peakrate64; +} +static inline void +tc_newtclass_req_set_options_flow_police_pktrate64(struct tc_newtclass_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.pktrate64 = 1; + req->options.flow.police.pktrate64 = pktrate64; +} +static inline void +tc_newtclass_req_set_options_flow_police_pktburst64(struct tc_newtclass_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.pktburst64 = 1; + req->options.flow.police.pktburst64 = pktburst64; +} +static inline void +tc_newtclass_req_set_options_flow_ematches(struct tc_newtclass_req *req, + const void *ematches, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + free(req->options.flow.ematches); + req->options.flow._len.ematches = len; + req->options.flow.ematches = malloc(req->options.flow._len.ematches); + memcpy(req->options.flow.ematches, ematches, req->options.flow._len.ematches); +} +static inline void +tc_newtclass_req_set_options_flow_perturb(struct tc_newtclass_req *req, + __u32 perturb) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.perturb = 1; + req->options.flow.perturb = perturb; +} +static inline void +tc_newtclass_req_set_options_flower_classid(struct tc_newtclass_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.classid = 1; + req->options.flower.classid = classid; +} +static inline void +tc_newtclass_req_set_options_flower_indev(struct tc_newtclass_req *req, + const char *indev) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.indev); + req->options.flower._len.indev = strlen(indev); + req->options.flower.indev = malloc(req->options.flower._len.indev + 1); + memcpy(req->options.flower.indev, indev, req->options.flower._len.indev); + req->options.flower.indev[req->options.flower._len.indev] = 0; +} +static inline void +__tc_newtclass_req_set_options_flower_act(struct tc_newtclass_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.act); + req->options.flower.act = act; + req->options.flower._count.act = n_act; +} +static inline void +tc_newtclass_req_set_options_flower_key_eth_dst(struct tc_newtclass_req *req, + const void *key_eth_dst, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_dst); + req->options.flower._len.key_eth_dst = len; + req->options.flower.key_eth_dst = malloc(req->options.flower._len.key_eth_dst); + memcpy(req->options.flower.key_eth_dst, key_eth_dst, req->options.flower._len.key_eth_dst); +} +static inline void +tc_newtclass_req_set_options_flower_key_eth_dst_mask(struct tc_newtclass_req *req, + const void *key_eth_dst_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_dst_mask); + req->options.flower._len.key_eth_dst_mask = len; + req->options.flower.key_eth_dst_mask = malloc(req->options.flower._len.key_eth_dst_mask); + memcpy(req->options.flower.key_eth_dst_mask, key_eth_dst_mask, req->options.flower._len.key_eth_dst_mask); +} +static inline void +tc_newtclass_req_set_options_flower_key_eth_src(struct tc_newtclass_req *req, + const void *key_eth_src, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_src); + req->options.flower._len.key_eth_src = len; + req->options.flower.key_eth_src = malloc(req->options.flower._len.key_eth_src); + memcpy(req->options.flower.key_eth_src, key_eth_src, req->options.flower._len.key_eth_src); +} +static inline void +tc_newtclass_req_set_options_flower_key_eth_src_mask(struct tc_newtclass_req *req, + const void *key_eth_src_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_src_mask); + req->options.flower._len.key_eth_src_mask = len; + req->options.flower.key_eth_src_mask = malloc(req->options.flower._len.key_eth_src_mask); + memcpy(req->options.flower.key_eth_src_mask, key_eth_src_mask, req->options.flower._len.key_eth_src_mask); +} +static inline void +tc_newtclass_req_set_options_flower_key_eth_type(struct tc_newtclass_req *req, + __u16 key_eth_type /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_eth_type = 1; + req->options.flower.key_eth_type = key_eth_type; +} +static inline void +tc_newtclass_req_set_options_flower_key_ip_proto(struct tc_newtclass_req *req, + __u8 key_ip_proto) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_proto = 1; + req->options.flower.key_ip_proto = key_ip_proto; +} +static inline void +tc_newtclass_req_set_options_flower_key_ipv4_src(struct tc_newtclass_req *req, + __u32 key_ipv4_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_src = 1; + req->options.flower.key_ipv4_src = key_ipv4_src; +} +static inline void +tc_newtclass_req_set_options_flower_key_ipv4_src_mask(struct tc_newtclass_req *req, + __u32 key_ipv4_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_src_mask = 1; + req->options.flower.key_ipv4_src_mask = key_ipv4_src_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_ipv4_dst(struct tc_newtclass_req *req, + __u32 key_ipv4_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_dst = 1; + req->options.flower.key_ipv4_dst = key_ipv4_dst; +} +static inline void +tc_newtclass_req_set_options_flower_key_ipv4_dst_mask(struct tc_newtclass_req *req, + __u32 key_ipv4_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_dst_mask = 1; + req->options.flower.key_ipv4_dst_mask = key_ipv4_dst_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_ipv6_src(struct tc_newtclass_req *req, + const void *key_ipv6_src, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_src); + req->options.flower._len.key_ipv6_src = len; + req->options.flower.key_ipv6_src = malloc(req->options.flower._len.key_ipv6_src); + memcpy(req->options.flower.key_ipv6_src, key_ipv6_src, req->options.flower._len.key_ipv6_src); +} +static inline void +tc_newtclass_req_set_options_flower_key_ipv6_src_mask(struct tc_newtclass_req *req, + const void *key_ipv6_src_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_src_mask); + req->options.flower._len.key_ipv6_src_mask = len; + req->options.flower.key_ipv6_src_mask = malloc(req->options.flower._len.key_ipv6_src_mask); + memcpy(req->options.flower.key_ipv6_src_mask, key_ipv6_src_mask, req->options.flower._len.key_ipv6_src_mask); +} +static inline void +tc_newtclass_req_set_options_flower_key_ipv6_dst(struct tc_newtclass_req *req, + const void *key_ipv6_dst, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_dst); + req->options.flower._len.key_ipv6_dst = len; + req->options.flower.key_ipv6_dst = malloc(req->options.flower._len.key_ipv6_dst); + memcpy(req->options.flower.key_ipv6_dst, key_ipv6_dst, req->options.flower._len.key_ipv6_dst); +} +static inline void +tc_newtclass_req_set_options_flower_key_ipv6_dst_mask(struct tc_newtclass_req *req, + const void *key_ipv6_dst_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_dst_mask); + req->options.flower._len.key_ipv6_dst_mask = len; + req->options.flower.key_ipv6_dst_mask = malloc(req->options.flower._len.key_ipv6_dst_mask); + memcpy(req->options.flower.key_ipv6_dst_mask, key_ipv6_dst_mask, req->options.flower._len.key_ipv6_dst_mask); +} +static inline void +tc_newtclass_req_set_options_flower_key_tcp_src(struct tc_newtclass_req *req, + __u16 key_tcp_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_src = 1; + req->options.flower.key_tcp_src = key_tcp_src; +} +static inline void +tc_newtclass_req_set_options_flower_key_tcp_dst(struct tc_newtclass_req *req, + __u16 key_tcp_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_dst = 1; + req->options.flower.key_tcp_dst = key_tcp_dst; +} +static inline void +tc_newtclass_req_set_options_flower_key_udp_src(struct tc_newtclass_req *req, + __u16 key_udp_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_src = 1; + req->options.flower.key_udp_src = key_udp_src; +} +static inline void +tc_newtclass_req_set_options_flower_key_udp_dst(struct tc_newtclass_req *req, + __u16 key_udp_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_dst = 1; + req->options.flower.key_udp_dst = key_udp_dst; +} +static inline void +tc_newtclass_req_set_options_flower_flags(struct tc_newtclass_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.flags = 1; + req->options.flower.flags = flags; +} +static inline void +tc_newtclass_req_set_options_flower_key_vlan_id(struct tc_newtclass_req *req, + __u16 key_vlan_id /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_vlan_id = 1; + req->options.flower.key_vlan_id = key_vlan_id; +} +static inline void +tc_newtclass_req_set_options_flower_key_vlan_prio(struct tc_newtclass_req *req, + __u8 key_vlan_prio) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_vlan_prio = 1; + req->options.flower.key_vlan_prio = key_vlan_prio; +} +static inline void +tc_newtclass_req_set_options_flower_key_vlan_eth_type(struct tc_newtclass_req *req, + __u16 key_vlan_eth_type /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_vlan_eth_type = 1; + req->options.flower.key_vlan_eth_type = key_vlan_eth_type; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_key_id(struct tc_newtclass_req *req, + __u32 key_enc_key_id /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_key_id = 1; + req->options.flower.key_enc_key_id = key_enc_key_id; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_ipv4_src(struct tc_newtclass_req *req, + __u32 key_enc_ipv4_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_src = 1; + req->options.flower.key_enc_ipv4_src = key_enc_ipv4_src; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_ipv4_src_mask(struct tc_newtclass_req *req, + __u32 key_enc_ipv4_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_src_mask = 1; + req->options.flower.key_enc_ipv4_src_mask = key_enc_ipv4_src_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_ipv4_dst(struct tc_newtclass_req *req, + __u32 key_enc_ipv4_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_dst = 1; + req->options.flower.key_enc_ipv4_dst = key_enc_ipv4_dst; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_ipv4_dst_mask(struct tc_newtclass_req *req, + __u32 key_enc_ipv4_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_dst_mask = 1; + req->options.flower.key_enc_ipv4_dst_mask = key_enc_ipv4_dst_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_ipv6_src(struct tc_newtclass_req *req, + const void *key_enc_ipv6_src, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_src); + req->options.flower._len.key_enc_ipv6_src = len; + req->options.flower.key_enc_ipv6_src = malloc(req->options.flower._len.key_enc_ipv6_src); + memcpy(req->options.flower.key_enc_ipv6_src, key_enc_ipv6_src, req->options.flower._len.key_enc_ipv6_src); +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_ipv6_src_mask(struct tc_newtclass_req *req, + const void *key_enc_ipv6_src_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_src_mask); + req->options.flower._len.key_enc_ipv6_src_mask = len; + req->options.flower.key_enc_ipv6_src_mask = malloc(req->options.flower._len.key_enc_ipv6_src_mask); + memcpy(req->options.flower.key_enc_ipv6_src_mask, key_enc_ipv6_src_mask, req->options.flower._len.key_enc_ipv6_src_mask); +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_ipv6_dst(struct tc_newtclass_req *req, + const void *key_enc_ipv6_dst, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_dst); + req->options.flower._len.key_enc_ipv6_dst = len; + req->options.flower.key_enc_ipv6_dst = malloc(req->options.flower._len.key_enc_ipv6_dst); + memcpy(req->options.flower.key_enc_ipv6_dst, key_enc_ipv6_dst, req->options.flower._len.key_enc_ipv6_dst); +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_ipv6_dst_mask(struct tc_newtclass_req *req, + const void *key_enc_ipv6_dst_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_dst_mask); + req->options.flower._len.key_enc_ipv6_dst_mask = len; + req->options.flower.key_enc_ipv6_dst_mask = malloc(req->options.flower._len.key_enc_ipv6_dst_mask); + memcpy(req->options.flower.key_enc_ipv6_dst_mask, key_enc_ipv6_dst_mask, req->options.flower._len.key_enc_ipv6_dst_mask); +} +static inline void +tc_newtclass_req_set_options_flower_key_tcp_src_mask(struct tc_newtclass_req *req, + __u16 key_tcp_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_src_mask = 1; + req->options.flower.key_tcp_src_mask = key_tcp_src_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_tcp_dst_mask(struct tc_newtclass_req *req, + __u16 key_tcp_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_dst_mask = 1; + req->options.flower.key_tcp_dst_mask = key_tcp_dst_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_udp_src_mask(struct tc_newtclass_req *req, + __u16 key_udp_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_src_mask = 1; + req->options.flower.key_udp_src_mask = key_udp_src_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_udp_dst_mask(struct tc_newtclass_req *req, + __u16 key_udp_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_dst_mask = 1; + req->options.flower.key_udp_dst_mask = key_udp_dst_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_sctp_src_mask(struct tc_newtclass_req *req, + __u16 key_sctp_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_src_mask = 1; + req->options.flower.key_sctp_src_mask = key_sctp_src_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_sctp_dst_mask(struct tc_newtclass_req *req, + __u16 key_sctp_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_dst_mask = 1; + req->options.flower.key_sctp_dst_mask = key_sctp_dst_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_sctp_src(struct tc_newtclass_req *req, + __u16 key_sctp_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_src = 1; + req->options.flower.key_sctp_src = key_sctp_src; +} +static inline void +tc_newtclass_req_set_options_flower_key_sctp_dst(struct tc_newtclass_req *req, + __u16 key_sctp_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_dst = 1; + req->options.flower.key_sctp_dst = key_sctp_dst; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_udp_src_port(struct tc_newtclass_req *req, + __u16 key_enc_udp_src_port /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_src_port = 1; + req->options.flower.key_enc_udp_src_port = key_enc_udp_src_port; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_udp_src_port_mask(struct tc_newtclass_req *req, + __u16 key_enc_udp_src_port_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_src_port_mask = 1; + req->options.flower.key_enc_udp_src_port_mask = key_enc_udp_src_port_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_udp_dst_port(struct tc_newtclass_req *req, + __u16 key_enc_udp_dst_port /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_dst_port = 1; + req->options.flower.key_enc_udp_dst_port = key_enc_udp_dst_port; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_udp_dst_port_mask(struct tc_newtclass_req *req, + __u16 key_enc_udp_dst_port_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_dst_port_mask = 1; + req->options.flower.key_enc_udp_dst_port_mask = key_enc_udp_dst_port_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_flags(struct tc_newtclass_req *req, + __u32 key_flags /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_flags = 1; + req->options.flower.key_flags = key_flags; +} +static inline void +tc_newtclass_req_set_options_flower_key_flags_mask(struct tc_newtclass_req *req, + __u32 key_flags_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_flags_mask = 1; + req->options.flower.key_flags_mask = key_flags_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_icmpv4_code(struct tc_newtclass_req *req, + __u8 key_icmpv4_code) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_code = 1; + req->options.flower.key_icmpv4_code = key_icmpv4_code; +} +static inline void +tc_newtclass_req_set_options_flower_key_icmpv4_code_mask(struct tc_newtclass_req *req, + __u8 key_icmpv4_code_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_code_mask = 1; + req->options.flower.key_icmpv4_code_mask = key_icmpv4_code_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_icmpv4_type(struct tc_newtclass_req *req, + __u8 key_icmpv4_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_type = 1; + req->options.flower.key_icmpv4_type = key_icmpv4_type; +} +static inline void +tc_newtclass_req_set_options_flower_key_icmpv4_type_mask(struct tc_newtclass_req *req, + __u8 key_icmpv4_type_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_type_mask = 1; + req->options.flower.key_icmpv4_type_mask = key_icmpv4_type_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_icmpv6_code(struct tc_newtclass_req *req, + __u8 key_icmpv6_code) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_code = 1; + req->options.flower.key_icmpv6_code = key_icmpv6_code; +} +static inline void +tc_newtclass_req_set_options_flower_key_icmpv6_code_mask(struct tc_newtclass_req *req, + __u8 key_icmpv6_code_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_code_mask = 1; + req->options.flower.key_icmpv6_code_mask = key_icmpv6_code_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_icmpv6_type(struct tc_newtclass_req *req, + __u8 key_icmpv6_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_type = 1; + req->options.flower.key_icmpv6_type = key_icmpv6_type; +} +static inline void +tc_newtclass_req_set_options_flower_key_icmpv6_type_mask(struct tc_newtclass_req *req, + __u8 key_icmpv6_type_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_type_mask = 1; + req->options.flower.key_icmpv6_type_mask = key_icmpv6_type_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_arp_sip(struct tc_newtclass_req *req, + __u32 key_arp_sip /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_sip = 1; + req->options.flower.key_arp_sip = key_arp_sip; +} +static inline void +tc_newtclass_req_set_options_flower_key_arp_sip_mask(struct tc_newtclass_req *req, + __u32 key_arp_sip_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_sip_mask = 1; + req->options.flower.key_arp_sip_mask = key_arp_sip_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_arp_tip(struct tc_newtclass_req *req, + __u32 key_arp_tip /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_tip = 1; + req->options.flower.key_arp_tip = key_arp_tip; +} +static inline void +tc_newtclass_req_set_options_flower_key_arp_tip_mask(struct tc_newtclass_req *req, + __u32 key_arp_tip_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_tip_mask = 1; + req->options.flower.key_arp_tip_mask = key_arp_tip_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_arp_op(struct tc_newtclass_req *req, + __u8 key_arp_op) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_op = 1; + req->options.flower.key_arp_op = key_arp_op; +} +static inline void +tc_newtclass_req_set_options_flower_key_arp_op_mask(struct tc_newtclass_req *req, + __u8 key_arp_op_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_op_mask = 1; + req->options.flower.key_arp_op_mask = key_arp_op_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_arp_sha(struct tc_newtclass_req *req, + const void *key_arp_sha, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_sha); + req->options.flower._len.key_arp_sha = len; + req->options.flower.key_arp_sha = malloc(req->options.flower._len.key_arp_sha); + memcpy(req->options.flower.key_arp_sha, key_arp_sha, req->options.flower._len.key_arp_sha); +} +static inline void +tc_newtclass_req_set_options_flower_key_arp_sha_mask(struct tc_newtclass_req *req, + const void *key_arp_sha_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_sha_mask); + req->options.flower._len.key_arp_sha_mask = len; + req->options.flower.key_arp_sha_mask = malloc(req->options.flower._len.key_arp_sha_mask); + memcpy(req->options.flower.key_arp_sha_mask, key_arp_sha_mask, req->options.flower._len.key_arp_sha_mask); +} +static inline void +tc_newtclass_req_set_options_flower_key_arp_tha(struct tc_newtclass_req *req, + const void *key_arp_tha, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_tha); + req->options.flower._len.key_arp_tha = len; + req->options.flower.key_arp_tha = malloc(req->options.flower._len.key_arp_tha); + memcpy(req->options.flower.key_arp_tha, key_arp_tha, req->options.flower._len.key_arp_tha); +} +static inline void +tc_newtclass_req_set_options_flower_key_arp_tha_mask(struct tc_newtclass_req *req, + const void *key_arp_tha_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_tha_mask); + req->options.flower._len.key_arp_tha_mask = len; + req->options.flower.key_arp_tha_mask = malloc(req->options.flower._len.key_arp_tha_mask); + memcpy(req->options.flower.key_arp_tha_mask, key_arp_tha_mask, req->options.flower._len.key_arp_tha_mask); +} +static inline void +tc_newtclass_req_set_options_flower_key_mpls_ttl(struct tc_newtclass_req *req, + __u8 key_mpls_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_ttl = 1; + req->options.flower.key_mpls_ttl = key_mpls_ttl; +} +static inline void +tc_newtclass_req_set_options_flower_key_mpls_bos(struct tc_newtclass_req *req, + __u8 key_mpls_bos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_bos = 1; + req->options.flower.key_mpls_bos = key_mpls_bos; +} +static inline void +tc_newtclass_req_set_options_flower_key_mpls_tc(struct tc_newtclass_req *req, + __u8 key_mpls_tc) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_tc = 1; + req->options.flower.key_mpls_tc = key_mpls_tc; +} +static inline void +tc_newtclass_req_set_options_flower_key_mpls_label(struct tc_newtclass_req *req, + __u32 key_mpls_label /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_label = 1; + req->options.flower.key_mpls_label = key_mpls_label; +} +static inline void +tc_newtclass_req_set_options_flower_key_tcp_flags(struct tc_newtclass_req *req, + __u16 key_tcp_flags /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_flags = 1; + req->options.flower.key_tcp_flags = key_tcp_flags; +} +static inline void +tc_newtclass_req_set_options_flower_key_tcp_flags_mask(struct tc_newtclass_req *req, + __u16 key_tcp_flags_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_flags_mask = 1; + req->options.flower.key_tcp_flags_mask = key_tcp_flags_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_ip_tos(struct tc_newtclass_req *req, + __u8 key_ip_tos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_tos = 1; + req->options.flower.key_ip_tos = key_ip_tos; +} +static inline void +tc_newtclass_req_set_options_flower_key_ip_tos_mask(struct tc_newtclass_req *req, + __u8 key_ip_tos_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_tos_mask = 1; + req->options.flower.key_ip_tos_mask = key_ip_tos_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_ip_ttl(struct tc_newtclass_req *req, + __u8 key_ip_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_ttl = 1; + req->options.flower.key_ip_ttl = key_ip_ttl; +} +static inline void +tc_newtclass_req_set_options_flower_key_ip_ttl_mask(struct tc_newtclass_req *req, + __u8 key_ip_ttl_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_ttl_mask = 1; + req->options.flower.key_ip_ttl_mask = key_ip_ttl_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_cvlan_id(struct tc_newtclass_req *req, + __u16 key_cvlan_id /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cvlan_id = 1; + req->options.flower.key_cvlan_id = key_cvlan_id; +} +static inline void +tc_newtclass_req_set_options_flower_key_cvlan_prio(struct tc_newtclass_req *req, + __u8 key_cvlan_prio) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cvlan_prio = 1; + req->options.flower.key_cvlan_prio = key_cvlan_prio; +} +static inline void +tc_newtclass_req_set_options_flower_key_cvlan_eth_type(struct tc_newtclass_req *req, + __u16 key_cvlan_eth_type /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cvlan_eth_type = 1; + req->options.flower.key_cvlan_eth_type = key_cvlan_eth_type; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_ip_tos(struct tc_newtclass_req *req, + __u8 key_enc_ip_tos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_tos = 1; + req->options.flower.key_enc_ip_tos = key_enc_ip_tos; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_ip_tos_mask(struct tc_newtclass_req *req, + __u8 key_enc_ip_tos_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_tos_mask = 1; + req->options.flower.key_enc_ip_tos_mask = key_enc_ip_tos_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_ip_ttl(struct tc_newtclass_req *req, + __u8 key_enc_ip_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_ttl = 1; + req->options.flower.key_enc_ip_ttl = key_enc_ip_ttl; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_ip_ttl_mask(struct tc_newtclass_req *req, + __u8 key_enc_ip_ttl_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_ttl_mask = 1; + req->options.flower.key_enc_ip_ttl_mask = key_enc_ip_ttl_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_geneve_class(struct tc_newtclass_req *req, + __u16 class) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.geneve = 1; + req->options.flower.key_enc_opts.geneve._present.class = 1; + req->options.flower.key_enc_opts.geneve.class = class; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_geneve_type(struct tc_newtclass_req *req, + __u8 type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.geneve = 1; + req->options.flower.key_enc_opts.geneve._present.type = 1; + req->options.flower.key_enc_opts.geneve.type = type; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_geneve_data(struct tc_newtclass_req *req, + const void *data, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.geneve = 1; + free(req->options.flower.key_enc_opts.geneve.data); + req->options.flower.key_enc_opts.geneve._len.data = len; + req->options.flower.key_enc_opts.geneve.data = malloc(req->options.flower.key_enc_opts.geneve._len.data); + memcpy(req->options.flower.key_enc_opts.geneve.data, data, req->options.flower.key_enc_opts.geneve._len.data); +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_vxlan_gbp(struct tc_newtclass_req *req, + __u32 gbp) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.vxlan = 1; + req->options.flower.key_enc_opts.vxlan._present.gbp = 1; + req->options.flower.key_enc_opts.vxlan.gbp = gbp; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_erspan_ver(struct tc_newtclass_req *req, + __u8 ver) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.ver = 1; + req->options.flower.key_enc_opts.erspan.ver = ver; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_erspan_index(struct tc_newtclass_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.index = 1; + req->options.flower.key_enc_opts.erspan.index = index; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_erspan_dir(struct tc_newtclass_req *req, + __u8 dir) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.dir = 1; + req->options.flower.key_enc_opts.erspan.dir = dir; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_erspan_hwid(struct tc_newtclass_req *req, + __u8 hwid) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.hwid = 1; + req->options.flower.key_enc_opts.erspan.hwid = hwid; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_gtp_pdu_type(struct tc_newtclass_req *req, + __u8 pdu_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.gtp = 1; + req->options.flower.key_enc_opts.gtp._present.pdu_type = 1; + req->options.flower.key_enc_opts.gtp.pdu_type = pdu_type; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_gtp_qfi(struct tc_newtclass_req *req, + __u8 qfi) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.gtp = 1; + req->options.flower.key_enc_opts.gtp._present.qfi = 1; + req->options.flower.key_enc_opts.gtp.qfi = qfi; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_mask_geneve_class(struct tc_newtclass_req *req, + __u16 class) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.geneve = 1; + req->options.flower.key_enc_opts_mask.geneve._present.class = 1; + req->options.flower.key_enc_opts_mask.geneve.class = class; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_mask_geneve_type(struct tc_newtclass_req *req, + __u8 type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.geneve = 1; + req->options.flower.key_enc_opts_mask.geneve._present.type = 1; + req->options.flower.key_enc_opts_mask.geneve.type = type; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_mask_geneve_data(struct tc_newtclass_req *req, + const void *data, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.geneve = 1; + free(req->options.flower.key_enc_opts_mask.geneve.data); + req->options.flower.key_enc_opts_mask.geneve._len.data = len; + req->options.flower.key_enc_opts_mask.geneve.data = malloc(req->options.flower.key_enc_opts_mask.geneve._len.data); + memcpy(req->options.flower.key_enc_opts_mask.geneve.data, data, req->options.flower.key_enc_opts_mask.geneve._len.data); +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_mask_vxlan_gbp(struct tc_newtclass_req *req, + __u32 gbp) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.vxlan = 1; + req->options.flower.key_enc_opts_mask.vxlan._present.gbp = 1; + req->options.flower.key_enc_opts_mask.vxlan.gbp = gbp; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_mask_erspan_ver(struct tc_newtclass_req *req, + __u8 ver) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.ver = 1; + req->options.flower.key_enc_opts_mask.erspan.ver = ver; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_mask_erspan_index(struct tc_newtclass_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.index = 1; + req->options.flower.key_enc_opts_mask.erspan.index = index; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_mask_erspan_dir(struct tc_newtclass_req *req, + __u8 dir) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.dir = 1; + req->options.flower.key_enc_opts_mask.erspan.dir = dir; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_mask_erspan_hwid(struct tc_newtclass_req *req, + __u8 hwid) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.hwid = 1; + req->options.flower.key_enc_opts_mask.erspan.hwid = hwid; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_mask_gtp_pdu_type(struct tc_newtclass_req *req, + __u8 pdu_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.gtp = 1; + req->options.flower.key_enc_opts_mask.gtp._present.pdu_type = 1; + req->options.flower.key_enc_opts_mask.gtp.pdu_type = pdu_type; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_opts_mask_gtp_qfi(struct tc_newtclass_req *req, + __u8 qfi) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.gtp = 1; + req->options.flower.key_enc_opts_mask.gtp._present.qfi = 1; + req->options.flower.key_enc_opts_mask.gtp.qfi = qfi; +} +static inline void +tc_newtclass_req_set_options_flower_in_hw_count(struct tc_newtclass_req *req, + __u32 in_hw_count) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.in_hw_count = 1; + req->options.flower.in_hw_count = in_hw_count; +} +static inline void +tc_newtclass_req_set_options_flower_key_port_src_min(struct tc_newtclass_req *req, + __u16 key_port_src_min /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_src_min = 1; + req->options.flower.key_port_src_min = key_port_src_min; +} +static inline void +tc_newtclass_req_set_options_flower_key_port_src_max(struct tc_newtclass_req *req, + __u16 key_port_src_max /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_src_max = 1; + req->options.flower.key_port_src_max = key_port_src_max; +} +static inline void +tc_newtclass_req_set_options_flower_key_port_dst_min(struct tc_newtclass_req *req, + __u16 key_port_dst_min /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_dst_min = 1; + req->options.flower.key_port_dst_min = key_port_dst_min; +} +static inline void +tc_newtclass_req_set_options_flower_key_port_dst_max(struct tc_newtclass_req *req, + __u16 key_port_dst_max /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_dst_max = 1; + req->options.flower.key_port_dst_max = key_port_dst_max; +} +static inline void +tc_newtclass_req_set_options_flower_key_ct_state(struct tc_newtclass_req *req, + __u16 key_ct_state) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_state = 1; + req->options.flower.key_ct_state = key_ct_state; +} +static inline void +tc_newtclass_req_set_options_flower_key_ct_state_mask(struct tc_newtclass_req *req, + __u16 key_ct_state_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_state_mask = 1; + req->options.flower.key_ct_state_mask = key_ct_state_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_ct_zone(struct tc_newtclass_req *req, + __u16 key_ct_zone) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_zone = 1; + req->options.flower.key_ct_zone = key_ct_zone; +} +static inline void +tc_newtclass_req_set_options_flower_key_ct_zone_mask(struct tc_newtclass_req *req, + __u16 key_ct_zone_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_zone_mask = 1; + req->options.flower.key_ct_zone_mask = key_ct_zone_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_ct_mark(struct tc_newtclass_req *req, + __u32 key_ct_mark) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_mark = 1; + req->options.flower.key_ct_mark = key_ct_mark; +} +static inline void +tc_newtclass_req_set_options_flower_key_ct_mark_mask(struct tc_newtclass_req *req, + __u32 key_ct_mark_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_mark_mask = 1; + req->options.flower.key_ct_mark_mask = key_ct_mark_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_ct_labels(struct tc_newtclass_req *req, + const void *key_ct_labels, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ct_labels); + req->options.flower._len.key_ct_labels = len; + req->options.flower.key_ct_labels = malloc(req->options.flower._len.key_ct_labels); + memcpy(req->options.flower.key_ct_labels, key_ct_labels, req->options.flower._len.key_ct_labels); +} +static inline void +tc_newtclass_req_set_options_flower_key_ct_labels_mask(struct tc_newtclass_req *req, + const void *key_ct_labels_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ct_labels_mask); + req->options.flower._len.key_ct_labels_mask = len; + req->options.flower.key_ct_labels_mask = malloc(req->options.flower._len.key_ct_labels_mask); + memcpy(req->options.flower.key_ct_labels_mask, key_ct_labels_mask, req->options.flower._len.key_ct_labels_mask); +} +static inline void +tc_newtclass_req_set_options_flower_key_mpls_opts_lse_depth(struct tc_newtclass_req *req, + __u8 lse_depth) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_depth = 1; + req->options.flower.key_mpls_opts.lse_depth = lse_depth; +} +static inline void +tc_newtclass_req_set_options_flower_key_mpls_opts_lse_ttl(struct tc_newtclass_req *req, + __u8 lse_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_ttl = 1; + req->options.flower.key_mpls_opts.lse_ttl = lse_ttl; +} +static inline void +tc_newtclass_req_set_options_flower_key_mpls_opts_lse_bos(struct tc_newtclass_req *req, + __u8 lse_bos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_bos = 1; + req->options.flower.key_mpls_opts.lse_bos = lse_bos; +} +static inline void +tc_newtclass_req_set_options_flower_key_mpls_opts_lse_tc(struct tc_newtclass_req *req, + __u8 lse_tc) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_tc = 1; + req->options.flower.key_mpls_opts.lse_tc = lse_tc; +} +static inline void +tc_newtclass_req_set_options_flower_key_mpls_opts_lse_label(struct tc_newtclass_req *req, + __u32 lse_label) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_label = 1; + req->options.flower.key_mpls_opts.lse_label = lse_label; +} +static inline void +tc_newtclass_req_set_options_flower_key_hash(struct tc_newtclass_req *req, + __u32 key_hash) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_hash = 1; + req->options.flower.key_hash = key_hash; +} +static inline void +tc_newtclass_req_set_options_flower_key_hash_mask(struct tc_newtclass_req *req, + __u32 key_hash_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_hash_mask = 1; + req->options.flower.key_hash_mask = key_hash_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_num_of_vlans(struct tc_newtclass_req *req, + __u8 key_num_of_vlans) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_num_of_vlans = 1; + req->options.flower.key_num_of_vlans = key_num_of_vlans; +} +static inline void +tc_newtclass_req_set_options_flower_key_pppoe_sid(struct tc_newtclass_req *req, + __u16 key_pppoe_sid /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_pppoe_sid = 1; + req->options.flower.key_pppoe_sid = key_pppoe_sid; +} +static inline void +tc_newtclass_req_set_options_flower_key_ppp_proto(struct tc_newtclass_req *req, + __u16 key_ppp_proto /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ppp_proto = 1; + req->options.flower.key_ppp_proto = key_ppp_proto; +} +static inline void +tc_newtclass_req_set_options_flower_key_l2tpv3_sid(struct tc_newtclass_req *req, + __u32 key_l2tpv3_sid /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_l2tpv3_sid = 1; + req->options.flower.key_l2tpv3_sid = key_l2tpv3_sid; +} +static inline void +tc_newtclass_req_set_options_flower_l2_miss(struct tc_newtclass_req *req, + __u8 l2_miss) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.l2_miss = 1; + req->options.flower.l2_miss = l2_miss; +} +static inline void +tc_newtclass_req_set_options_flower_key_cfm_md_level(struct tc_newtclass_req *req, + __u8 md_level) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cfm = 1; + req->options.flower.key_cfm._present.md_level = 1; + req->options.flower.key_cfm.md_level = md_level; +} +static inline void +tc_newtclass_req_set_options_flower_key_cfm_opcode(struct tc_newtclass_req *req, + __u8 opcode) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cfm = 1; + req->options.flower.key_cfm._present.opcode = 1; + req->options.flower.key_cfm.opcode = opcode; +} +static inline void +tc_newtclass_req_set_options_flower_key_spi(struct tc_newtclass_req *req, + __u32 key_spi /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_spi = 1; + req->options.flower.key_spi = key_spi; +} +static inline void +tc_newtclass_req_set_options_flower_key_spi_mask(struct tc_newtclass_req *req, + __u32 key_spi_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_spi_mask = 1; + req->options.flower.key_spi_mask = key_spi_mask; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_flags(struct tc_newtclass_req *req, + __u32 key_enc_flags /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_flags = 1; + req->options.flower.key_enc_flags = key_enc_flags; +} +static inline void +tc_newtclass_req_set_options_flower_key_enc_flags_mask(struct tc_newtclass_req *req, + __u32 key_enc_flags_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_flags_mask = 1; + req->options.flower.key_enc_flags_mask = key_enc_flags_mask; +} +static inline void +tc_newtclass_req_set_options_fq_plimit(struct tc_newtclass_req *req, + __u32 plimit) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.plimit = 1; + req->options.fq.plimit = plimit; +} +static inline void +tc_newtclass_req_set_options_fq_flow_plimit(struct tc_newtclass_req *req, + __u32 flow_plimit) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_plimit = 1; + req->options.fq.flow_plimit = flow_plimit; +} +static inline void +tc_newtclass_req_set_options_fq_quantum(struct tc_newtclass_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.quantum = 1; + req->options.fq.quantum = quantum; +} +static inline void +tc_newtclass_req_set_options_fq_initial_quantum(struct tc_newtclass_req *req, + __u32 initial_quantum) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.initial_quantum = 1; + req->options.fq.initial_quantum = initial_quantum; +} +static inline void +tc_newtclass_req_set_options_fq_rate_enable(struct tc_newtclass_req *req, + __u32 rate_enable) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.rate_enable = 1; + req->options.fq.rate_enable = rate_enable; +} +static inline void +tc_newtclass_req_set_options_fq_flow_default_rate(struct tc_newtclass_req *req, + __u32 flow_default_rate) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_default_rate = 1; + req->options.fq.flow_default_rate = flow_default_rate; +} +static inline void +tc_newtclass_req_set_options_fq_flow_max_rate(struct tc_newtclass_req *req, + __u32 flow_max_rate) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_max_rate = 1; + req->options.fq.flow_max_rate = flow_max_rate; +} +static inline void +tc_newtclass_req_set_options_fq_buckets_log(struct tc_newtclass_req *req, + __u32 buckets_log) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.buckets_log = 1; + req->options.fq.buckets_log = buckets_log; +} +static inline void +tc_newtclass_req_set_options_fq_flow_refill_delay(struct tc_newtclass_req *req, + __u32 flow_refill_delay) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_refill_delay = 1; + req->options.fq.flow_refill_delay = flow_refill_delay; +} +static inline void +tc_newtclass_req_set_options_fq_orphan_mask(struct tc_newtclass_req *req, + __u32 orphan_mask) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.orphan_mask = 1; + req->options.fq.orphan_mask = orphan_mask; +} +static inline void +tc_newtclass_req_set_options_fq_low_rate_threshold(struct tc_newtclass_req *req, + __u32 low_rate_threshold) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.low_rate_threshold = 1; + req->options.fq.low_rate_threshold = low_rate_threshold; +} +static inline void +tc_newtclass_req_set_options_fq_ce_threshold(struct tc_newtclass_req *req, + __u32 ce_threshold) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.ce_threshold = 1; + req->options.fq.ce_threshold = ce_threshold; +} +static inline void +tc_newtclass_req_set_options_fq_timer_slack(struct tc_newtclass_req *req, + __u32 timer_slack) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.timer_slack = 1; + req->options.fq.timer_slack = timer_slack; +} +static inline void +tc_newtclass_req_set_options_fq_horizon(struct tc_newtclass_req *req, + __u32 horizon) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.horizon = 1; + req->options.fq.horizon = horizon; +} +static inline void +tc_newtclass_req_set_options_fq_horizon_drop(struct tc_newtclass_req *req, + __u8 horizon_drop) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.horizon_drop = 1; + req->options.fq.horizon_drop = horizon_drop; +} +static inline void +tc_newtclass_req_set_options_fq_priomap(struct tc_newtclass_req *req, + const void *priomap, size_t len) +{ + req->_present.options = 1; + req->options._present.fq = 1; + free(req->options.fq.priomap); + req->options.fq._len.priomap = len; + req->options.fq.priomap = malloc(req->options.fq._len.priomap); + memcpy(req->options.fq.priomap, priomap, req->options.fq._len.priomap); +} +static inline void +tc_newtclass_req_set_options_fq_weights(struct tc_newtclass_req *req, + __s32 *weights, size_t count) +{ + req->_present.options = 1; + req->options._present.fq = 1; + free(req->options.fq.weights); + req->options.fq._count.weights = count; + count *= sizeof(__s32); + req->options.fq.weights = malloc(count); + memcpy(req->options.fq.weights, weights, count); +} +static inline void +tc_newtclass_req_set_options_fq_codel_target(struct tc_newtclass_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.target = 1; + req->options.fq_codel.target = target; +} +static inline void +tc_newtclass_req_set_options_fq_codel_limit(struct tc_newtclass_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.limit = 1; + req->options.fq_codel.limit = limit; +} +static inline void +tc_newtclass_req_set_options_fq_codel_interval(struct tc_newtclass_req *req, + __u32 interval) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.interval = 1; + req->options.fq_codel.interval = interval; +} +static inline void +tc_newtclass_req_set_options_fq_codel_ecn(struct tc_newtclass_req *req, + __u32 ecn) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ecn = 1; + req->options.fq_codel.ecn = ecn; +} +static inline void +tc_newtclass_req_set_options_fq_codel_flows(struct tc_newtclass_req *req, + __u32 flows) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.flows = 1; + req->options.fq_codel.flows = flows; +} +static inline void +tc_newtclass_req_set_options_fq_codel_quantum(struct tc_newtclass_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.quantum = 1; + req->options.fq_codel.quantum = quantum; +} +static inline void +tc_newtclass_req_set_options_fq_codel_ce_threshold(struct tc_newtclass_req *req, + __u32 ce_threshold) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ce_threshold = 1; + req->options.fq_codel.ce_threshold = ce_threshold; +} +static inline void +tc_newtclass_req_set_options_fq_codel_drop_batch_size(struct tc_newtclass_req *req, + __u32 drop_batch_size) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.drop_batch_size = 1; + req->options.fq_codel.drop_batch_size = drop_batch_size; +} +static inline void +tc_newtclass_req_set_options_fq_codel_memory_limit(struct tc_newtclass_req *req, + __u32 memory_limit) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.memory_limit = 1; + req->options.fq_codel.memory_limit = memory_limit; +} +static inline void +tc_newtclass_req_set_options_fq_codel_ce_threshold_selector(struct tc_newtclass_req *req, + __u8 ce_threshold_selector) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ce_threshold_selector = 1; + req->options.fq_codel.ce_threshold_selector = ce_threshold_selector; +} +static inline void +tc_newtclass_req_set_options_fq_codel_ce_threshold_mask(struct tc_newtclass_req *req, + __u8 ce_threshold_mask) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ce_threshold_mask = 1; + req->options.fq_codel.ce_threshold_mask = ce_threshold_mask; +} +static inline void +tc_newtclass_req_set_options_fq_pie_limit(struct tc_newtclass_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.limit = 1; + req->options.fq_pie.limit = limit; +} +static inline void +tc_newtclass_req_set_options_fq_pie_flows(struct tc_newtclass_req *req, + __u32 flows) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.flows = 1; + req->options.fq_pie.flows = flows; +} +static inline void +tc_newtclass_req_set_options_fq_pie_target(struct tc_newtclass_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.target = 1; + req->options.fq_pie.target = target; +} +static inline void +tc_newtclass_req_set_options_fq_pie_tupdate(struct tc_newtclass_req *req, + __u32 tupdate) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.tupdate = 1; + req->options.fq_pie.tupdate = tupdate; +} +static inline void +tc_newtclass_req_set_options_fq_pie_alpha(struct tc_newtclass_req *req, + __u32 alpha) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.alpha = 1; + req->options.fq_pie.alpha = alpha; +} +static inline void +tc_newtclass_req_set_options_fq_pie_beta(struct tc_newtclass_req *req, + __u32 beta) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.beta = 1; + req->options.fq_pie.beta = beta; +} +static inline void +tc_newtclass_req_set_options_fq_pie_quantum(struct tc_newtclass_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.quantum = 1; + req->options.fq_pie.quantum = quantum; +} +static inline void +tc_newtclass_req_set_options_fq_pie_memory_limit(struct tc_newtclass_req *req, + __u32 memory_limit) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.memory_limit = 1; + req->options.fq_pie.memory_limit = memory_limit; +} +static inline void +tc_newtclass_req_set_options_fq_pie_ecn_prob(struct tc_newtclass_req *req, + __u32 ecn_prob) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.ecn_prob = 1; + req->options.fq_pie.ecn_prob = ecn_prob; +} +static inline void +tc_newtclass_req_set_options_fq_pie_ecn(struct tc_newtclass_req *req, + __u32 ecn) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.ecn = 1; + req->options.fq_pie.ecn = ecn; +} +static inline void +tc_newtclass_req_set_options_fq_pie_bytemode(struct tc_newtclass_req *req, + __u32 bytemode) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.bytemode = 1; + req->options.fq_pie.bytemode = bytemode; +} +static inline void +tc_newtclass_req_set_options_fq_pie_dq_rate_estimator(struct tc_newtclass_req *req, + __u32 dq_rate_estimator) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.dq_rate_estimator = 1; + req->options.fq_pie.dq_rate_estimator = dq_rate_estimator; +} +static inline void +tc_newtclass_req_set_options_fw_classid(struct tc_newtclass_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.classid = 1; + req->options.fw.classid = classid; +} +static inline void +tc_newtclass_req_set_options_fw_police_tbf(struct tc_newtclass_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.tbf); + req->options.fw.police._len.tbf = len; + req->options.fw.police.tbf = malloc(req->options.fw.police._len.tbf); + memcpy(req->options.fw.police.tbf, tbf, req->options.fw.police._len.tbf); +} +static inline void +tc_newtclass_req_set_options_fw_police_rate(struct tc_newtclass_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.rate); + req->options.fw.police._len.rate = len; + req->options.fw.police.rate = malloc(req->options.fw.police._len.rate); + memcpy(req->options.fw.police.rate, rate, req->options.fw.police._len.rate); +} +static inline void +tc_newtclass_req_set_options_fw_police_peakrate(struct tc_newtclass_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.peakrate); + req->options.fw.police._len.peakrate = len; + req->options.fw.police.peakrate = malloc(req->options.fw.police._len.peakrate); + memcpy(req->options.fw.police.peakrate, peakrate, req->options.fw.police._len.peakrate); +} +static inline void +tc_newtclass_req_set_options_fw_police_avrate(struct tc_newtclass_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.avrate = 1; + req->options.fw.police.avrate = avrate; +} +static inline void +tc_newtclass_req_set_options_fw_police_result(struct tc_newtclass_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.result = 1; + req->options.fw.police.result = result; +} +static inline void +tc_newtclass_req_set_options_fw_police_tm(struct tc_newtclass_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.tm); + req->options.fw.police._len.tm = len; + req->options.fw.police.tm = malloc(req->options.fw.police._len.tm); + memcpy(req->options.fw.police.tm, tm, req->options.fw.police._len.tm); +} +static inline void +tc_newtclass_req_set_options_fw_police_rate64(struct tc_newtclass_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.rate64 = 1; + req->options.fw.police.rate64 = rate64; +} +static inline void +tc_newtclass_req_set_options_fw_police_peakrate64(struct tc_newtclass_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.peakrate64 = 1; + req->options.fw.police.peakrate64 = peakrate64; +} +static inline void +tc_newtclass_req_set_options_fw_police_pktrate64(struct tc_newtclass_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.pktrate64 = 1; + req->options.fw.police.pktrate64 = pktrate64; +} +static inline void +tc_newtclass_req_set_options_fw_police_pktburst64(struct tc_newtclass_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.pktburst64 = 1; + req->options.fw.police.pktburst64 = pktburst64; +} +static inline void +tc_newtclass_req_set_options_fw_indev(struct tc_newtclass_req *req, + const char *indev) +{ + req->_present.options = 1; + req->options._present.fw = 1; + free(req->options.fw.indev); + req->options.fw._len.indev = strlen(indev); + req->options.fw.indev = malloc(req->options.fw._len.indev + 1); + memcpy(req->options.fw.indev, indev, req->options.fw._len.indev); + req->options.fw.indev[req->options.fw._len.indev] = 0; +} +static inline void +__tc_newtclass_req_set_options_fw_act(struct tc_newtclass_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.fw = 1; + free(req->options.fw.act); + req->options.fw.act = act; + req->options.fw._count.act = n_act; +} +static inline void +tc_newtclass_req_set_options_fw_mask(struct tc_newtclass_req *req, __u32 mask) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.mask = 1; + req->options.fw.mask = mask; +} +static inline void +tc_newtclass_req_set_options_gred_parms(struct tc_newtclass_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.parms); + req->options.gred._len.parms = len; + req->options.gred.parms = malloc(req->options.gred._len.parms); + memcpy(req->options.gred.parms, parms, req->options.gred._len.parms); +} +static inline void +tc_newtclass_req_set_options_gred_stab(struct tc_newtclass_req *req, + __u8 *stab, size_t count) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.stab); + req->options.gred._count.stab = count; + count *= sizeof(__u8); + req->options.gred.stab = malloc(count); + memcpy(req->options.gred.stab, stab, count); +} +static inline void +tc_newtclass_req_set_options_gred_dps(struct tc_newtclass_req *req, + const void *dps, size_t len) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.dps); + req->options.gred._len.dps = len; + req->options.gred.dps = malloc(req->options.gred._len.dps); + memcpy(req->options.gred.dps, dps, req->options.gred._len.dps); +} +static inline void +tc_newtclass_req_set_options_gred_max_p(struct tc_newtclass_req *req, + __u32 *max_p, size_t count) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.max_p); + req->options.gred._count.max_p = count; + count *= sizeof(__u32); + req->options.gred.max_p = malloc(count); + memcpy(req->options.gred.max_p, max_p, count); +} +static inline void +tc_newtclass_req_set_options_gred_limit(struct tc_newtclass_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.gred = 1; + req->options.gred._present.limit = 1; + req->options.gred.limit = limit; +} +static inline void +__tc_newtclass_req_set_options_gred_vq_list_entry(struct tc_newtclass_req *req, + struct tc_tca_gred_vq_entry_attrs *entry, + unsigned int n_entry) +{ + unsigned int i; + + req->_present.options = 1; + req->options._present.gred = 1; + req->options.gred._present.vq_list = 1; + for (i = 0; i < req->options.gred.vq_list._count.entry; i++) + tc_tca_gred_vq_entry_attrs_free(&req->options.gred.vq_list.entry[i]); + free(req->options.gred.vq_list.entry); + req->options.gred.vq_list.entry = entry; + req->options.gred.vq_list._count.entry = n_entry; +} +static inline void +tc_newtclass_req_set_options_hfsc(struct tc_newtclass_req *req, + const void *hfsc, size_t len) +{ + req->_present.options = 1; + free(req->options.hfsc); + req->options._len.hfsc = len; + req->options.hfsc = malloc(req->options._len.hfsc); + memcpy(req->options.hfsc, hfsc, req->options._len.hfsc); +} +static inline void +tc_newtclass_req_set_options_hhf_backlog_limit(struct tc_newtclass_req *req, + __u32 backlog_limit) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.backlog_limit = 1; + req->options.hhf.backlog_limit = backlog_limit; +} +static inline void +tc_newtclass_req_set_options_hhf_quantum(struct tc_newtclass_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.quantum = 1; + req->options.hhf.quantum = quantum; +} +static inline void +tc_newtclass_req_set_options_hhf_hh_flows_limit(struct tc_newtclass_req *req, + __u32 hh_flows_limit) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.hh_flows_limit = 1; + req->options.hhf.hh_flows_limit = hh_flows_limit; +} +static inline void +tc_newtclass_req_set_options_hhf_reset_timeout(struct tc_newtclass_req *req, + __u32 reset_timeout) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.reset_timeout = 1; + req->options.hhf.reset_timeout = reset_timeout; +} +static inline void +tc_newtclass_req_set_options_hhf_admit_bytes(struct tc_newtclass_req *req, + __u32 admit_bytes) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.admit_bytes = 1; + req->options.hhf.admit_bytes = admit_bytes; +} +static inline void +tc_newtclass_req_set_options_hhf_evict_timeout(struct tc_newtclass_req *req, + __u32 evict_timeout) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.evict_timeout = 1; + req->options.hhf.evict_timeout = evict_timeout; +} +static inline void +tc_newtclass_req_set_options_hhf_non_hh_weight(struct tc_newtclass_req *req, + __u32 non_hh_weight) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.non_hh_weight = 1; + req->options.hhf.non_hh_weight = non_hh_weight; +} +static inline void +tc_newtclass_req_set_options_htb_parms(struct tc_newtclass_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.parms); + req->options.htb._len.parms = len; + req->options.htb.parms = malloc(req->options.htb._len.parms); + memcpy(req->options.htb.parms, parms, req->options.htb._len.parms); +} +static inline void +tc_newtclass_req_set_options_htb_init(struct tc_newtclass_req *req, + const void *init, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.init); + req->options.htb._len.init = len; + req->options.htb.init = malloc(req->options.htb._len.init); + memcpy(req->options.htb.init, init, req->options.htb._len.init); +} +static inline void +tc_newtclass_req_set_options_htb_ctab(struct tc_newtclass_req *req, + const void *ctab, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.ctab); + req->options.htb._len.ctab = len; + req->options.htb.ctab = malloc(req->options.htb._len.ctab); + memcpy(req->options.htb.ctab, ctab, req->options.htb._len.ctab); +} +static inline void +tc_newtclass_req_set_options_htb_rtab(struct tc_newtclass_req *req, + const void *rtab, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.rtab); + req->options.htb._len.rtab = len; + req->options.htb.rtab = malloc(req->options.htb._len.rtab); + memcpy(req->options.htb.rtab, rtab, req->options.htb._len.rtab); +} +static inline void +tc_newtclass_req_set_options_htb_direct_qlen(struct tc_newtclass_req *req, + __u32 direct_qlen) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.direct_qlen = 1; + req->options.htb.direct_qlen = direct_qlen; +} +static inline void +tc_newtclass_req_set_options_htb_rate64(struct tc_newtclass_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.rate64 = 1; + req->options.htb.rate64 = rate64; +} +static inline void +tc_newtclass_req_set_options_htb_ceil64(struct tc_newtclass_req *req, + __u64 ceil64) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.ceil64 = 1; + req->options.htb.ceil64 = ceil64; +} +static inline void +tc_newtclass_req_set_options_htb_offload(struct tc_newtclass_req *req) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.offload = 1; +} +static inline void +tc_newtclass_req_set_options_ingress(struct tc_newtclass_req *req) +{ + req->_present.options = 1; + req->options._present.ingress = 1; +} +static inline void +tc_newtclass_req_set_options_matchall_classid(struct tc_newtclass_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + req->options.matchall._present.classid = 1; + req->options.matchall.classid = classid; +} +static inline void +__tc_newtclass_req_set_options_matchall_act(struct tc_newtclass_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + free(req->options.matchall.act); + req->options.matchall.act = act; + req->options.matchall._count.act = n_act; +} +static inline void +tc_newtclass_req_set_options_matchall_flags(struct tc_newtclass_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + req->options.matchall._present.flags = 1; + req->options.matchall.flags = flags; +} +static inline void +tc_newtclass_req_set_options_matchall_pcnt(struct tc_newtclass_req *req, + const void *pcnt, size_t len) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + free(req->options.matchall.pcnt); + req->options.matchall._len.pcnt = len; + req->options.matchall.pcnt = malloc(req->options.matchall._len.pcnt); + memcpy(req->options.matchall.pcnt, pcnt, req->options.matchall._len.pcnt); +} +static inline void +tc_newtclass_req_set_options_mq(struct tc_newtclass_req *req) +{ + req->_present.options = 1; + req->options._present.mq = 1; +} +static inline void +tc_newtclass_req_set_options_mqprio(struct tc_newtclass_req *req, + const void *mqprio, size_t len) +{ + req->_present.options = 1; + free(req->options.mqprio); + req->options._len.mqprio = len; + req->options.mqprio = malloc(req->options._len.mqprio); + memcpy(req->options.mqprio, mqprio, req->options._len.mqprio); +} +static inline void +tc_newtclass_req_set_options_multiq(struct tc_newtclass_req *req, + const void *multiq, size_t len) +{ + req->_present.options = 1; + free(req->options.multiq); + req->options._len.multiq = len; + req->options.multiq = malloc(req->options._len.multiq); + memcpy(req->options.multiq, multiq, req->options._len.multiq); +} +static inline void +tc_newtclass_req_set_options_netem_corr(struct tc_newtclass_req *req, + const void *corr, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.corr); + req->options.netem._len.corr = len; + req->options.netem.corr = malloc(req->options.netem._len.corr); + memcpy(req->options.netem.corr, corr, req->options.netem._len.corr); +} +static inline void +tc_newtclass_req_set_options_netem_delay_dist(struct tc_newtclass_req *req, + __s16 *delay_dist, size_t count) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.delay_dist); + req->options.netem._count.delay_dist = count; + count *= sizeof(__s16); + req->options.netem.delay_dist = malloc(count); + memcpy(req->options.netem.delay_dist, delay_dist, count); +} +static inline void +tc_newtclass_req_set_options_netem_reorder(struct tc_newtclass_req *req, + const void *reorder, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.reorder); + req->options.netem._len.reorder = len; + req->options.netem.reorder = malloc(req->options.netem._len.reorder); + memcpy(req->options.netem.reorder, reorder, req->options.netem._len.reorder); +} +static inline void +tc_newtclass_req_set_options_netem_corrupt(struct tc_newtclass_req *req, + const void *corrupt, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.corrupt); + req->options.netem._len.corrupt = len; + req->options.netem.corrupt = malloc(req->options.netem._len.corrupt); + memcpy(req->options.netem.corrupt, corrupt, req->options.netem._len.corrupt); +} +static inline void +tc_newtclass_req_set_options_netem_loss_gi(struct tc_newtclass_req *req, + const void *gi, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.loss = 1; + free(req->options.netem.loss.gi); + req->options.netem.loss._len.gi = len; + req->options.netem.loss.gi = malloc(req->options.netem.loss._len.gi); + memcpy(req->options.netem.loss.gi, gi, req->options.netem.loss._len.gi); +} +static inline void +tc_newtclass_req_set_options_netem_loss_ge(struct tc_newtclass_req *req, + const void *ge, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.loss = 1; + free(req->options.netem.loss.ge); + req->options.netem.loss._len.ge = len; + req->options.netem.loss.ge = malloc(req->options.netem.loss._len.ge); + memcpy(req->options.netem.loss.ge, ge, req->options.netem.loss._len.ge); +} +static inline void +tc_newtclass_req_set_options_netem_rate(struct tc_newtclass_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.rate); + req->options.netem._len.rate = len; + req->options.netem.rate = malloc(req->options.netem._len.rate); + memcpy(req->options.netem.rate, rate, req->options.netem._len.rate); +} +static inline void +tc_newtclass_req_set_options_netem_ecn(struct tc_newtclass_req *req, __u32 ecn) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.ecn = 1; + req->options.netem.ecn = ecn; +} +static inline void +tc_newtclass_req_set_options_netem_rate64(struct tc_newtclass_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.rate64 = 1; + req->options.netem.rate64 = rate64; +} +static inline void +tc_newtclass_req_set_options_netem_pad(struct tc_newtclass_req *req, __u32 pad) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.pad = 1; + req->options.netem.pad = pad; +} +static inline void +tc_newtclass_req_set_options_netem_latency64(struct tc_newtclass_req *req, + __s64 latency64) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.latency64 = 1; + req->options.netem.latency64 = latency64; +} +static inline void +tc_newtclass_req_set_options_netem_jitter64(struct tc_newtclass_req *req, + __s64 jitter64) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.jitter64 = 1; + req->options.netem.jitter64 = jitter64; +} +static inline void +tc_newtclass_req_set_options_netem_slot(struct tc_newtclass_req *req, + const void *slot, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.slot); + req->options.netem._len.slot = len; + req->options.netem.slot = malloc(req->options.netem._len.slot); + memcpy(req->options.netem.slot, slot, req->options.netem._len.slot); +} +static inline void +tc_newtclass_req_set_options_netem_slot_dist(struct tc_newtclass_req *req, + __s16 *slot_dist, size_t count) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.slot_dist); + req->options.netem._count.slot_dist = count; + count *= sizeof(__s16); + req->options.netem.slot_dist = malloc(count); + memcpy(req->options.netem.slot_dist, slot_dist, count); +} +static inline void +tc_newtclass_req_set_options_netem_prng_seed(struct tc_newtclass_req *req, + __u64 prng_seed) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.prng_seed = 1; + req->options.netem.prng_seed = prng_seed; +} +static inline void +tc_newtclass_req_set_options_pfifo(struct tc_newtclass_req *req, + const void *pfifo, size_t len) +{ + req->_present.options = 1; + free(req->options.pfifo); + req->options._len.pfifo = len; + req->options.pfifo = malloc(req->options._len.pfifo); + memcpy(req->options.pfifo, pfifo, req->options._len.pfifo); +} +static inline void +tc_newtclass_req_set_options_pfifo_fast(struct tc_newtclass_req *req, + const void *pfifo_fast, size_t len) +{ + req->_present.options = 1; + free(req->options.pfifo_fast); + req->options._len.pfifo_fast = len; + req->options.pfifo_fast = malloc(req->options._len.pfifo_fast); + memcpy(req->options.pfifo_fast, pfifo_fast, req->options._len.pfifo_fast); +} +static inline void +tc_newtclass_req_set_options_pfifo_head_drop(struct tc_newtclass_req *req, + const void *pfifo_head_drop, + size_t len) +{ + req->_present.options = 1; + free(req->options.pfifo_head_drop); + req->options._len.pfifo_head_drop = len; + req->options.pfifo_head_drop = malloc(req->options._len.pfifo_head_drop); + memcpy(req->options.pfifo_head_drop, pfifo_head_drop, req->options._len.pfifo_head_drop); +} +static inline void +tc_newtclass_req_set_options_pie_target(struct tc_newtclass_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.target = 1; + req->options.pie.target = target; +} +static inline void +tc_newtclass_req_set_options_pie_limit(struct tc_newtclass_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.limit = 1; + req->options.pie.limit = limit; +} +static inline void +tc_newtclass_req_set_options_pie_tupdate(struct tc_newtclass_req *req, + __u32 tupdate) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.tupdate = 1; + req->options.pie.tupdate = tupdate; +} +static inline void +tc_newtclass_req_set_options_pie_alpha(struct tc_newtclass_req *req, + __u32 alpha) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.alpha = 1; + req->options.pie.alpha = alpha; +} +static inline void +tc_newtclass_req_set_options_pie_beta(struct tc_newtclass_req *req, __u32 beta) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.beta = 1; + req->options.pie.beta = beta; +} +static inline void +tc_newtclass_req_set_options_pie_ecn(struct tc_newtclass_req *req, __u32 ecn) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.ecn = 1; + req->options.pie.ecn = ecn; +} +static inline void +tc_newtclass_req_set_options_pie_bytemode(struct tc_newtclass_req *req, + __u32 bytemode) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.bytemode = 1; + req->options.pie.bytemode = bytemode; +} +static inline void +tc_newtclass_req_set_options_pie_dq_rate_estimator(struct tc_newtclass_req *req, + __u32 dq_rate_estimator) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.dq_rate_estimator = 1; + req->options.pie.dq_rate_estimator = dq_rate_estimator; +} +static inline void +tc_newtclass_req_set_options_plug(struct tc_newtclass_req *req, + const void *plug, size_t len) +{ + req->_present.options = 1; + free(req->options.plug); + req->options._len.plug = len; + req->options.plug = malloc(req->options._len.plug); + memcpy(req->options.plug, plug, req->options._len.plug); +} +static inline void +tc_newtclass_req_set_options_prio(struct tc_newtclass_req *req, + const void *prio, size_t len) +{ + req->_present.options = 1; + free(req->options.prio); + req->options._len.prio = len; + req->options.prio = malloc(req->options._len.prio); + memcpy(req->options.prio, prio, req->options._len.prio); +} +static inline void +tc_newtclass_req_set_options_qfq_weight(struct tc_newtclass_req *req, + __u32 weight) +{ + req->_present.options = 1; + req->options._present.qfq = 1; + req->options.qfq._present.weight = 1; + req->options.qfq.weight = weight; +} +static inline void +tc_newtclass_req_set_options_qfq_lmax(struct tc_newtclass_req *req, __u32 lmax) +{ + req->_present.options = 1; + req->options._present.qfq = 1; + req->options.qfq._present.lmax = 1; + req->options.qfq.lmax = lmax; +} +static inline void +tc_newtclass_req_set_options_red_parms(struct tc_newtclass_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.red = 1; + free(req->options.red.parms); + req->options.red._len.parms = len; + req->options.red.parms = malloc(req->options.red._len.parms); + memcpy(req->options.red.parms, parms, req->options.red._len.parms); +} +static inline void +tc_newtclass_req_set_options_red_stab(struct tc_newtclass_req *req, + const void *stab, size_t len) +{ + req->_present.options = 1; + req->options._present.red = 1; + free(req->options.red.stab); + req->options.red._len.stab = len; + req->options.red.stab = malloc(req->options.red._len.stab); + memcpy(req->options.red.stab, stab, req->options.red._len.stab); +} +static inline void +tc_newtclass_req_set_options_red_max_p(struct tc_newtclass_req *req, + __u32 max_p) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.max_p = 1; + req->options.red.max_p = max_p; +} +static inline void +tc_newtclass_req_set_options_red_flags(struct tc_newtclass_req *req, + struct nla_bitfield32 *flags) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.flags = 1; + memcpy(&req->options.red.flags, flags, sizeof(struct nla_bitfield32)); +} +static inline void +tc_newtclass_req_set_options_red_early_drop_block(struct tc_newtclass_req *req, + __u32 early_drop_block) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.early_drop_block = 1; + req->options.red.early_drop_block = early_drop_block; +} +static inline void +tc_newtclass_req_set_options_red_mark_block(struct tc_newtclass_req *req, + __u32 mark_block) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.mark_block = 1; + req->options.red.mark_block = mark_block; +} +static inline void +tc_newtclass_req_set_options_route_classid(struct tc_newtclass_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.classid = 1; + req->options.route.classid = classid; +} +static inline void +tc_newtclass_req_set_options_route_to(struct tc_newtclass_req *req, __u32 to) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.to = 1; + req->options.route.to = to; +} +static inline void +tc_newtclass_req_set_options_route_from(struct tc_newtclass_req *req, + __u32 from) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.from = 1; + req->options.route.from = from; +} +static inline void +tc_newtclass_req_set_options_route_iif(struct tc_newtclass_req *req, __u32 iif) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.iif = 1; + req->options.route.iif = iif; +} +static inline void +tc_newtclass_req_set_options_route_police_tbf(struct tc_newtclass_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.tbf); + req->options.route.police._len.tbf = len; + req->options.route.police.tbf = malloc(req->options.route.police._len.tbf); + memcpy(req->options.route.police.tbf, tbf, req->options.route.police._len.tbf); +} +static inline void +tc_newtclass_req_set_options_route_police_rate(struct tc_newtclass_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.rate); + req->options.route.police._len.rate = len; + req->options.route.police.rate = malloc(req->options.route.police._len.rate); + memcpy(req->options.route.police.rate, rate, req->options.route.police._len.rate); +} +static inline void +tc_newtclass_req_set_options_route_police_peakrate(struct tc_newtclass_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.peakrate); + req->options.route.police._len.peakrate = len; + req->options.route.police.peakrate = malloc(req->options.route.police._len.peakrate); + memcpy(req->options.route.police.peakrate, peakrate, req->options.route.police._len.peakrate); +} +static inline void +tc_newtclass_req_set_options_route_police_avrate(struct tc_newtclass_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.avrate = 1; + req->options.route.police.avrate = avrate; +} +static inline void +tc_newtclass_req_set_options_route_police_result(struct tc_newtclass_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.result = 1; + req->options.route.police.result = result; +} +static inline void +tc_newtclass_req_set_options_route_police_tm(struct tc_newtclass_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.tm); + req->options.route.police._len.tm = len; + req->options.route.police.tm = malloc(req->options.route.police._len.tm); + memcpy(req->options.route.police.tm, tm, req->options.route.police._len.tm); +} +static inline void +tc_newtclass_req_set_options_route_police_rate64(struct tc_newtclass_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.rate64 = 1; + req->options.route.police.rate64 = rate64; +} +static inline void +tc_newtclass_req_set_options_route_police_peakrate64(struct tc_newtclass_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.peakrate64 = 1; + req->options.route.police.peakrate64 = peakrate64; +} +static inline void +tc_newtclass_req_set_options_route_police_pktrate64(struct tc_newtclass_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.pktrate64 = 1; + req->options.route.police.pktrate64 = pktrate64; +} +static inline void +tc_newtclass_req_set_options_route_police_pktburst64(struct tc_newtclass_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.pktburst64 = 1; + req->options.route.police.pktburst64 = pktburst64; +} +static inline void +__tc_newtclass_req_set_options_route_act(struct tc_newtclass_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.route = 1; + free(req->options.route.act); + req->options.route.act = act; + req->options.route._count.act = n_act; +} +static inline void +tc_newtclass_req_set_options_sfb(struct tc_newtclass_req *req, const void *sfb, + size_t len) +{ + req->_present.options = 1; + free(req->options.sfb); + req->options._len.sfb = len; + req->options.sfb = malloc(req->options._len.sfb); + memcpy(req->options.sfb, sfb, req->options._len.sfb); +} +static inline void +tc_newtclass_req_set_options_sfq(struct tc_newtclass_req *req, const void *sfq, + size_t len) +{ + req->_present.options = 1; + free(req->options.sfq); + req->options._len.sfq = len; + req->options.sfq = malloc(req->options._len.sfq); + memcpy(req->options.sfq, sfq, req->options._len.sfq); +} +static inline void +tc_newtclass_req_set_options_taprio_priomap(struct tc_newtclass_req *req, + const void *priomap, size_t len) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + free(req->options.taprio.priomap); + req->options.taprio._len.priomap = len; + req->options.taprio.priomap = malloc(req->options.taprio._len.priomap); + memcpy(req->options.taprio.priomap, priomap, req->options.taprio._len.priomap); +} +static inline void +__tc_newtclass_req_set_options_taprio_sched_entry_list_entry(struct tc_newtclass_req *req, + struct tc_taprio_sched_entry *entry, + unsigned int n_entry) +{ + unsigned int i; + + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_entry_list = 1; + for (i = 0; i < req->options.taprio.sched_entry_list._count.entry; i++) + tc_taprio_sched_entry_free(&req->options.taprio.sched_entry_list.entry[i]); + free(req->options.taprio.sched_entry_list.entry); + req->options.taprio.sched_entry_list.entry = entry; + req->options.taprio.sched_entry_list._count.entry = n_entry; +} +static inline void +tc_newtclass_req_set_options_taprio_sched_base_time(struct tc_newtclass_req *req, + __s64 sched_base_time) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_base_time = 1; + req->options.taprio.sched_base_time = sched_base_time; +} +static inline void +tc_newtclass_req_set_options_taprio_sched_single_entry_index(struct tc_newtclass_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.index = 1; + req->options.taprio.sched_single_entry.index = index; +} +static inline void +tc_newtclass_req_set_options_taprio_sched_single_entry_cmd(struct tc_newtclass_req *req, + __u8 cmd) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.cmd = 1; + req->options.taprio.sched_single_entry.cmd = cmd; +} +static inline void +tc_newtclass_req_set_options_taprio_sched_single_entry_gate_mask(struct tc_newtclass_req *req, + __u32 gate_mask) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.gate_mask = 1; + req->options.taprio.sched_single_entry.gate_mask = gate_mask; +} +static inline void +tc_newtclass_req_set_options_taprio_sched_single_entry_interval(struct tc_newtclass_req *req, + __u32 interval) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.interval = 1; + req->options.taprio.sched_single_entry.interval = interval; +} +static inline void +tc_newtclass_req_set_options_taprio_sched_clockid(struct tc_newtclass_req *req, + __s32 sched_clockid) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_clockid = 1; + req->options.taprio.sched_clockid = sched_clockid; +} +static inline void +tc_newtclass_req_set_options_taprio_admin_sched(struct tc_newtclass_req *req, + const void *admin_sched, + size_t len) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + free(req->options.taprio.admin_sched); + req->options.taprio._len.admin_sched = len; + req->options.taprio.admin_sched = malloc(req->options.taprio._len.admin_sched); + memcpy(req->options.taprio.admin_sched, admin_sched, req->options.taprio._len.admin_sched); +} +static inline void +tc_newtclass_req_set_options_taprio_sched_cycle_time(struct tc_newtclass_req *req, + __s64 sched_cycle_time) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_cycle_time = 1; + req->options.taprio.sched_cycle_time = sched_cycle_time; +} +static inline void +tc_newtclass_req_set_options_taprio_sched_cycle_time_extension(struct tc_newtclass_req *req, + __s64 sched_cycle_time_extension) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_cycle_time_extension = 1; + req->options.taprio.sched_cycle_time_extension = sched_cycle_time_extension; +} +static inline void +tc_newtclass_req_set_options_taprio_flags(struct tc_newtclass_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.flags = 1; + req->options.taprio.flags = flags; +} +static inline void +tc_newtclass_req_set_options_taprio_txtime_delay(struct tc_newtclass_req *req, + __u32 txtime_delay) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.txtime_delay = 1; + req->options.taprio.txtime_delay = txtime_delay; +} +static inline void +tc_newtclass_req_set_options_taprio_tc_entry_index(struct tc_newtclass_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.tc_entry = 1; + req->options.taprio.tc_entry._present.index = 1; + req->options.taprio.tc_entry.index = index; +} +static inline void +tc_newtclass_req_set_options_taprio_tc_entry_max_sdu(struct tc_newtclass_req *req, + __u32 max_sdu) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.tc_entry = 1; + req->options.taprio.tc_entry._present.max_sdu = 1; + req->options.taprio.tc_entry.max_sdu = max_sdu; +} +static inline void +tc_newtclass_req_set_options_taprio_tc_entry_fp(struct tc_newtclass_req *req, + __u32 fp) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.tc_entry = 1; + req->options.taprio.tc_entry._present.fp = 1; + req->options.taprio.tc_entry.fp = fp; +} +static inline void +tc_newtclass_req_set_options_tbf_parms(struct tc_newtclass_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + free(req->options.tbf.parms); + req->options.tbf._len.parms = len; + req->options.tbf.parms = malloc(req->options.tbf._len.parms); + memcpy(req->options.tbf.parms, parms, req->options.tbf._len.parms); +} +static inline void +tc_newtclass_req_set_options_tbf_rtab(struct tc_newtclass_req *req, + const void *rtab, size_t len) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + free(req->options.tbf.rtab); + req->options.tbf._len.rtab = len; + req->options.tbf.rtab = malloc(req->options.tbf._len.rtab); + memcpy(req->options.tbf.rtab, rtab, req->options.tbf._len.rtab); +} +static inline void +tc_newtclass_req_set_options_tbf_ptab(struct tc_newtclass_req *req, + const void *ptab, size_t len) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + free(req->options.tbf.ptab); + req->options.tbf._len.ptab = len; + req->options.tbf.ptab = malloc(req->options.tbf._len.ptab); + memcpy(req->options.tbf.ptab, ptab, req->options.tbf._len.ptab); +} +static inline void +tc_newtclass_req_set_options_tbf_rate64(struct tc_newtclass_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.rate64 = 1; + req->options.tbf.rate64 = rate64; +} +static inline void +tc_newtclass_req_set_options_tbf_prate64(struct tc_newtclass_req *req, + __u64 prate64) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.prate64 = 1; + req->options.tbf.prate64 = prate64; +} +static inline void +tc_newtclass_req_set_options_tbf_burst(struct tc_newtclass_req *req, + __u32 burst) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.burst = 1; + req->options.tbf.burst = burst; +} +static inline void +tc_newtclass_req_set_options_tbf_pburst(struct tc_newtclass_req *req, + __u32 pburst) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.pburst = 1; + req->options.tbf.pburst = pburst; +} +static inline void +tc_newtclass_req_set_options_u32_classid(struct tc_newtclass_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.classid = 1; + req->options.u32.classid = classid; +} +static inline void +tc_newtclass_req_set_options_u32_hash(struct tc_newtclass_req *req, __u32 hash) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.hash = 1; + req->options.u32.hash = hash; +} +static inline void +tc_newtclass_req_set_options_u32_link(struct tc_newtclass_req *req, __u32 link) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.link = 1; + req->options.u32.link = link; +} +static inline void +tc_newtclass_req_set_options_u32_divisor(struct tc_newtclass_req *req, + __u32 divisor) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.divisor = 1; + req->options.u32.divisor = divisor; +} +static inline void +tc_newtclass_req_set_options_u32_sel(struct tc_newtclass_req *req, + const void *sel, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.sel); + req->options.u32._len.sel = len; + req->options.u32.sel = malloc(req->options.u32._len.sel); + memcpy(req->options.u32.sel, sel, req->options.u32._len.sel); +} +static inline void +tc_newtclass_req_set_options_u32_police_tbf(struct tc_newtclass_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.tbf); + req->options.u32.police._len.tbf = len; + req->options.u32.police.tbf = malloc(req->options.u32.police._len.tbf); + memcpy(req->options.u32.police.tbf, tbf, req->options.u32.police._len.tbf); +} +static inline void +tc_newtclass_req_set_options_u32_police_rate(struct tc_newtclass_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.rate); + req->options.u32.police._len.rate = len; + req->options.u32.police.rate = malloc(req->options.u32.police._len.rate); + memcpy(req->options.u32.police.rate, rate, req->options.u32.police._len.rate); +} +static inline void +tc_newtclass_req_set_options_u32_police_peakrate(struct tc_newtclass_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.peakrate); + req->options.u32.police._len.peakrate = len; + req->options.u32.police.peakrate = malloc(req->options.u32.police._len.peakrate); + memcpy(req->options.u32.police.peakrate, peakrate, req->options.u32.police._len.peakrate); +} +static inline void +tc_newtclass_req_set_options_u32_police_avrate(struct tc_newtclass_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.avrate = 1; + req->options.u32.police.avrate = avrate; +} +static inline void +tc_newtclass_req_set_options_u32_police_result(struct tc_newtclass_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.result = 1; + req->options.u32.police.result = result; +} +static inline void +tc_newtclass_req_set_options_u32_police_tm(struct tc_newtclass_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.tm); + req->options.u32.police._len.tm = len; + req->options.u32.police.tm = malloc(req->options.u32.police._len.tm); + memcpy(req->options.u32.police.tm, tm, req->options.u32.police._len.tm); +} +static inline void +tc_newtclass_req_set_options_u32_police_rate64(struct tc_newtclass_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.rate64 = 1; + req->options.u32.police.rate64 = rate64; +} +static inline void +tc_newtclass_req_set_options_u32_police_peakrate64(struct tc_newtclass_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.peakrate64 = 1; + req->options.u32.police.peakrate64 = peakrate64; +} +static inline void +tc_newtclass_req_set_options_u32_police_pktrate64(struct tc_newtclass_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.pktrate64 = 1; + req->options.u32.police.pktrate64 = pktrate64; +} +static inline void +tc_newtclass_req_set_options_u32_police_pktburst64(struct tc_newtclass_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.pktburst64 = 1; + req->options.u32.police.pktburst64 = pktburst64; +} +static inline void +__tc_newtclass_req_set_options_u32_act(struct tc_newtclass_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.act); + req->options.u32.act = act; + req->options.u32._count.act = n_act; +} +static inline void +tc_newtclass_req_set_options_u32_indev(struct tc_newtclass_req *req, + const char *indev) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.indev); + req->options.u32._len.indev = strlen(indev); + req->options.u32.indev = malloc(req->options.u32._len.indev + 1); + memcpy(req->options.u32.indev, indev, req->options.u32._len.indev); + req->options.u32.indev[req->options.u32._len.indev] = 0; +} +static inline void +tc_newtclass_req_set_options_u32_pcnt(struct tc_newtclass_req *req, + const void *pcnt, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.pcnt); + req->options.u32._len.pcnt = len; + req->options.u32.pcnt = malloc(req->options.u32._len.pcnt); + memcpy(req->options.u32.pcnt, pcnt, req->options.u32._len.pcnt); +} +static inline void +tc_newtclass_req_set_options_u32_mark(struct tc_newtclass_req *req, + const void *mark, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.mark); + req->options.u32._len.mark = len; + req->options.u32.mark = malloc(req->options.u32._len.mark); + memcpy(req->options.u32.mark, mark, req->options.u32._len.mark); +} +static inline void +tc_newtclass_req_set_options_u32_flags(struct tc_newtclass_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.flags = 1; + req->options.u32.flags = flags; +} +static inline void +tc_newtclass_req_set_rate(struct tc_newtclass_req *req, const void *rate, + size_t len) +{ + free(req->rate); + req->_len.rate = len; + req->rate = malloc(req->_len.rate); + memcpy(req->rate, rate, req->_len.rate); +} +static inline void +tc_newtclass_req_set_chain(struct tc_newtclass_req *req, __u32 chain) +{ + req->_present.chain = 1; + req->chain = chain; +} +static inline void +tc_newtclass_req_set_ingress_block(struct tc_newtclass_req *req, + __u32 ingress_block) +{ + req->_present.ingress_block = 1; + req->ingress_block = ingress_block; +} +static inline void +tc_newtclass_req_set_egress_block(struct tc_newtclass_req *req, + __u32 egress_block) +{ + req->_present.egress_block = 1; + req->egress_block = egress_block; +} + +/* + * Get / dump tc traffic class information. + */ +int tc_newtclass(struct ynl_sock *ys, struct tc_newtclass_req *req); + +/* ============== RTM_DELTCLASS ============== */ +/* RTM_DELTCLASS - do */ +struct tc_deltclass_req { + __u16 _nlmsg_flags; + + struct tcmsg _hdr; +}; + +static inline struct tc_deltclass_req *tc_deltclass_req_alloc(void) +{ + return calloc(1, sizeof(struct tc_deltclass_req)); +} +void tc_deltclass_req_free(struct tc_deltclass_req *req); + +static inline void +tc_deltclass_req_set_nlflags(struct tc_deltclass_req *req, __u16 nl_flags) +{ + req->_nlmsg_flags = nl_flags; +} + +/* + * Get / dump tc traffic class information. + */ +int tc_deltclass(struct ynl_sock *ys, struct tc_deltclass_req *req); + +/* ============== RTM_GETTCLASS ============== */ +/* RTM_GETTCLASS - do */ +struct tc_gettclass_req { + __u16 _nlmsg_flags; + + struct tcmsg _hdr; +}; + +static inline struct tc_gettclass_req *tc_gettclass_req_alloc(void) +{ + return calloc(1, sizeof(struct tc_gettclass_req)); +} +void tc_gettclass_req_free(struct tc_gettclass_req *req); + +static inline void +tc_gettclass_req_set_nlflags(struct tc_gettclass_req *req, __u16 nl_flags) +{ + req->_nlmsg_flags = nl_flags; +} + +struct tc_gettclass_rsp { + struct tcmsg _hdr; + + struct { + __u32 options:1; + __u32 xstats:1; + __u32 fcnt:1; + __u32 stats2:1; + __u32 stab:1; + __u32 chain:1; + __u32 ingress_block:1; + __u32 egress_block:1; + } _present; + struct { + __u32 kind; + __u32 stats; + __u32 rate; + } _len; + + char *kind; + struct tc_options_msg options; + struct tc_stats *stats; + struct tc_tca_stats_app_msg xstats; + struct gnet_estimator *rate; + __u32 fcnt; + struct tc_tca_stats_attrs stats2; + struct tc_tca_stab_attrs stab; + __u32 chain; + __u32 ingress_block; + __u32 egress_block; +}; + +void tc_gettclass_rsp_free(struct tc_gettclass_rsp *rsp); + +/* + * Get / dump tc traffic class information. + */ +struct tc_gettclass_rsp * +tc_gettclass(struct ynl_sock *ys, struct tc_gettclass_req *req); + +/* ============== RTM_NEWTFILTER ============== */ +/* RTM_NEWTFILTER - do */ +struct tc_newtfilter_req { + __u16 _nlmsg_flags; + + struct tcmsg _hdr; + + struct { + __u32 options:1; + __u32 chain:1; + __u32 ingress_block:1; + __u32 egress_block:1; + } _present; + struct { + __u32 kind; + __u32 rate; + } _len; + + char *kind; + struct tc_options_msg options; + struct gnet_estimator *rate; + __u32 chain; + __u32 ingress_block; + __u32 egress_block; +}; + +static inline struct tc_newtfilter_req *tc_newtfilter_req_alloc(void) +{ + return calloc(1, sizeof(struct tc_newtfilter_req)); +} +void tc_newtfilter_req_free(struct tc_newtfilter_req *req); + +static inline void +tc_newtfilter_req_set_nlflags(struct tc_newtfilter_req *req, __u16 nl_flags) +{ + req->_nlmsg_flags = nl_flags; +} + +static inline void +tc_newtfilter_req_set_kind(struct tc_newtfilter_req *req, const char *kind) +{ + free(req->kind); + req->_len.kind = strlen(kind); + req->kind = malloc(req->_len.kind + 1); + memcpy(req->kind, kind, req->_len.kind); + req->kind[req->_len.kind] = 0; +} +static inline void +tc_newtfilter_req_set_options_basic_classid(struct tc_newtfilter_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.classid = 1; + req->options.basic.classid = classid; +} +static inline void +tc_newtfilter_req_set_options_basic_ematches_tree_hdr(struct tc_newtfilter_req *req, + const void *tree_hdr, + size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.ematches = 1; + free(req->options.basic.ematches.tree_hdr); + req->options.basic.ematches._len.tree_hdr = len; + req->options.basic.ematches.tree_hdr = malloc(req->options.basic.ematches._len.tree_hdr); + memcpy(req->options.basic.ematches.tree_hdr, tree_hdr, req->options.basic.ematches._len.tree_hdr); +} +static inline void +tc_newtfilter_req_set_options_basic_ematches_tree_list(struct tc_newtfilter_req *req, + const void *tree_list, + size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.ematches = 1; + free(req->options.basic.ematches.tree_list); + req->options.basic.ematches._len.tree_list = len; + req->options.basic.ematches.tree_list = malloc(req->options.basic.ematches._len.tree_list); + memcpy(req->options.basic.ematches.tree_list, tree_list, req->options.basic.ematches._len.tree_list); +} +static inline void +__tc_newtfilter_req_set_options_basic_act(struct tc_newtfilter_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.basic = 1; + free(req->options.basic.act); + req->options.basic.act = act; + req->options.basic._count.act = n_act; +} +static inline void +tc_newtfilter_req_set_options_basic_police_tbf(struct tc_newtfilter_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.tbf); + req->options.basic.police._len.tbf = len; + req->options.basic.police.tbf = malloc(req->options.basic.police._len.tbf); + memcpy(req->options.basic.police.tbf, tbf, req->options.basic.police._len.tbf); +} +static inline void +tc_newtfilter_req_set_options_basic_police_rate(struct tc_newtfilter_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.rate); + req->options.basic.police._len.rate = len; + req->options.basic.police.rate = malloc(req->options.basic.police._len.rate); + memcpy(req->options.basic.police.rate, rate, req->options.basic.police._len.rate); +} +static inline void +tc_newtfilter_req_set_options_basic_police_peakrate(struct tc_newtfilter_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.peakrate); + req->options.basic.police._len.peakrate = len; + req->options.basic.police.peakrate = malloc(req->options.basic.police._len.peakrate); + memcpy(req->options.basic.police.peakrate, peakrate, req->options.basic.police._len.peakrate); +} +static inline void +tc_newtfilter_req_set_options_basic_police_avrate(struct tc_newtfilter_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.avrate = 1; + req->options.basic.police.avrate = avrate; +} +static inline void +tc_newtfilter_req_set_options_basic_police_result(struct tc_newtfilter_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.result = 1; + req->options.basic.police.result = result; +} +static inline void +tc_newtfilter_req_set_options_basic_police_tm(struct tc_newtfilter_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.tm); + req->options.basic.police._len.tm = len; + req->options.basic.police.tm = malloc(req->options.basic.police._len.tm); + memcpy(req->options.basic.police.tm, tm, req->options.basic.police._len.tm); +} +static inline void +tc_newtfilter_req_set_options_basic_police_rate64(struct tc_newtfilter_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.rate64 = 1; + req->options.basic.police.rate64 = rate64; +} +static inline void +tc_newtfilter_req_set_options_basic_police_peakrate64(struct tc_newtfilter_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.peakrate64 = 1; + req->options.basic.police.peakrate64 = peakrate64; +} +static inline void +tc_newtfilter_req_set_options_basic_police_pktrate64(struct tc_newtfilter_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.pktrate64 = 1; + req->options.basic.police.pktrate64 = pktrate64; +} +static inline void +tc_newtfilter_req_set_options_basic_police_pktburst64(struct tc_newtfilter_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.pktburst64 = 1; + req->options.basic.police.pktburst64 = pktburst64; +} +static inline void +tc_newtfilter_req_set_options_basic_pcnt(struct tc_newtfilter_req *req, + const void *pcnt, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + free(req->options.basic.pcnt); + req->options.basic._len.pcnt = len; + req->options.basic.pcnt = malloc(req->options.basic._len.pcnt); + memcpy(req->options.basic.pcnt, pcnt, req->options.basic._len.pcnt); +} +static inline void +__tc_newtfilter_req_set_options_bpf_act(struct tc_newtfilter_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.act); + req->options.bpf.act = act; + req->options.bpf._count.act = n_act; +} +static inline void +tc_newtfilter_req_set_options_bpf_police_tbf(struct tc_newtfilter_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.tbf); + req->options.bpf.police._len.tbf = len; + req->options.bpf.police.tbf = malloc(req->options.bpf.police._len.tbf); + memcpy(req->options.bpf.police.tbf, tbf, req->options.bpf.police._len.tbf); +} +static inline void +tc_newtfilter_req_set_options_bpf_police_rate(struct tc_newtfilter_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.rate); + req->options.bpf.police._len.rate = len; + req->options.bpf.police.rate = malloc(req->options.bpf.police._len.rate); + memcpy(req->options.bpf.police.rate, rate, req->options.bpf.police._len.rate); +} +static inline void +tc_newtfilter_req_set_options_bpf_police_peakrate(struct tc_newtfilter_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.peakrate); + req->options.bpf.police._len.peakrate = len; + req->options.bpf.police.peakrate = malloc(req->options.bpf.police._len.peakrate); + memcpy(req->options.bpf.police.peakrate, peakrate, req->options.bpf.police._len.peakrate); +} +static inline void +tc_newtfilter_req_set_options_bpf_police_avrate(struct tc_newtfilter_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.avrate = 1; + req->options.bpf.police.avrate = avrate; +} +static inline void +tc_newtfilter_req_set_options_bpf_police_result(struct tc_newtfilter_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.result = 1; + req->options.bpf.police.result = result; +} +static inline void +tc_newtfilter_req_set_options_bpf_police_tm(struct tc_newtfilter_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.tm); + req->options.bpf.police._len.tm = len; + req->options.bpf.police.tm = malloc(req->options.bpf.police._len.tm); + memcpy(req->options.bpf.police.tm, tm, req->options.bpf.police._len.tm); +} +static inline void +tc_newtfilter_req_set_options_bpf_police_rate64(struct tc_newtfilter_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.rate64 = 1; + req->options.bpf.police.rate64 = rate64; +} +static inline void +tc_newtfilter_req_set_options_bpf_police_peakrate64(struct tc_newtfilter_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.peakrate64 = 1; + req->options.bpf.police.peakrate64 = peakrate64; +} +static inline void +tc_newtfilter_req_set_options_bpf_police_pktrate64(struct tc_newtfilter_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.pktrate64 = 1; + req->options.bpf.police.pktrate64 = pktrate64; +} +static inline void +tc_newtfilter_req_set_options_bpf_police_pktburst64(struct tc_newtfilter_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.pktburst64 = 1; + req->options.bpf.police.pktburst64 = pktburst64; +} +static inline void +tc_newtfilter_req_set_options_bpf_classid(struct tc_newtfilter_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.classid = 1; + req->options.bpf.classid = classid; +} +static inline void +tc_newtfilter_req_set_options_bpf_ops_len(struct tc_newtfilter_req *req, + __u16 ops_len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.ops_len = 1; + req->options.bpf.ops_len = ops_len; +} +static inline void +tc_newtfilter_req_set_options_bpf_ops(struct tc_newtfilter_req *req, + const void *ops, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.ops); + req->options.bpf._len.ops = len; + req->options.bpf.ops = malloc(req->options.bpf._len.ops); + memcpy(req->options.bpf.ops, ops, req->options.bpf._len.ops); +} +static inline void +tc_newtfilter_req_set_options_bpf_fd(struct tc_newtfilter_req *req, __u32 fd) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.fd = 1; + req->options.bpf.fd = fd; +} +static inline void +tc_newtfilter_req_set_options_bpf_name(struct tc_newtfilter_req *req, + const char *name) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.name); + req->options.bpf._len.name = strlen(name); + req->options.bpf.name = malloc(req->options.bpf._len.name + 1); + memcpy(req->options.bpf.name, name, req->options.bpf._len.name); + req->options.bpf.name[req->options.bpf._len.name] = 0; +} +static inline void +tc_newtfilter_req_set_options_bpf_flags(struct tc_newtfilter_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.flags = 1; + req->options.bpf.flags = flags; +} +static inline void +tc_newtfilter_req_set_options_bpf_flags_gen(struct tc_newtfilter_req *req, + __u32 flags_gen) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.flags_gen = 1; + req->options.bpf.flags_gen = flags_gen; +} +static inline void +tc_newtfilter_req_set_options_bpf_tag(struct tc_newtfilter_req *req, + const void *tag, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.tag); + req->options.bpf._len.tag = len; + req->options.bpf.tag = malloc(req->options.bpf._len.tag); + memcpy(req->options.bpf.tag, tag, req->options.bpf._len.tag); +} +static inline void +tc_newtfilter_req_set_options_bpf_id(struct tc_newtfilter_req *req, __u32 id) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.id = 1; + req->options.bpf.id = id; +} +static inline void +tc_newtfilter_req_set_options_bfifo(struct tc_newtfilter_req *req, + const void *bfifo, size_t len) +{ + req->_present.options = 1; + free(req->options.bfifo); + req->options._len.bfifo = len; + req->options.bfifo = malloc(req->options._len.bfifo); + memcpy(req->options.bfifo, bfifo, req->options._len.bfifo); +} +static inline void +tc_newtfilter_req_set_options_cake_base_rate64(struct tc_newtfilter_req *req, + __u64 base_rate64) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.base_rate64 = 1; + req->options.cake.base_rate64 = base_rate64; +} +static inline void +tc_newtfilter_req_set_options_cake_diffserv_mode(struct tc_newtfilter_req *req, + __u32 diffserv_mode) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.diffserv_mode = 1; + req->options.cake.diffserv_mode = diffserv_mode; +} +static inline void +tc_newtfilter_req_set_options_cake_atm(struct tc_newtfilter_req *req, + __u32 atm) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.atm = 1; + req->options.cake.atm = atm; +} +static inline void +tc_newtfilter_req_set_options_cake_flow_mode(struct tc_newtfilter_req *req, + __u32 flow_mode) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.flow_mode = 1; + req->options.cake.flow_mode = flow_mode; +} +static inline void +tc_newtfilter_req_set_options_cake_overhead(struct tc_newtfilter_req *req, + __u32 overhead) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.overhead = 1; + req->options.cake.overhead = overhead; +} +static inline void +tc_newtfilter_req_set_options_cake_rtt(struct tc_newtfilter_req *req, + __u32 rtt) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.rtt = 1; + req->options.cake.rtt = rtt; +} +static inline void +tc_newtfilter_req_set_options_cake_target(struct tc_newtfilter_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.target = 1; + req->options.cake.target = target; +} +static inline void +tc_newtfilter_req_set_options_cake_autorate(struct tc_newtfilter_req *req, + __u32 autorate) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.autorate = 1; + req->options.cake.autorate = autorate; +} +static inline void +tc_newtfilter_req_set_options_cake_memory(struct tc_newtfilter_req *req, + __u32 memory) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.memory = 1; + req->options.cake.memory = memory; +} +static inline void +tc_newtfilter_req_set_options_cake_nat(struct tc_newtfilter_req *req, + __u32 nat) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.nat = 1; + req->options.cake.nat = nat; +} +static inline void +tc_newtfilter_req_set_options_cake_raw(struct tc_newtfilter_req *req, + __u32 raw) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.raw = 1; + req->options.cake.raw = raw; +} +static inline void +tc_newtfilter_req_set_options_cake_wash(struct tc_newtfilter_req *req, + __u32 wash) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.wash = 1; + req->options.cake.wash = wash; +} +static inline void +tc_newtfilter_req_set_options_cake_mpu(struct tc_newtfilter_req *req, + __u32 mpu) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.mpu = 1; + req->options.cake.mpu = mpu; +} +static inline void +tc_newtfilter_req_set_options_cake_ingress(struct tc_newtfilter_req *req, + __u32 ingress) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.ingress = 1; + req->options.cake.ingress = ingress; +} +static inline void +tc_newtfilter_req_set_options_cake_ack_filter(struct tc_newtfilter_req *req, + __u32 ack_filter) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.ack_filter = 1; + req->options.cake.ack_filter = ack_filter; +} +static inline void +tc_newtfilter_req_set_options_cake_split_gso(struct tc_newtfilter_req *req, + __u32 split_gso) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.split_gso = 1; + req->options.cake.split_gso = split_gso; +} +static inline void +tc_newtfilter_req_set_options_cake_fwmark(struct tc_newtfilter_req *req, + __u32 fwmark) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.fwmark = 1; + req->options.cake.fwmark = fwmark; +} +static inline void +tc_newtfilter_req_set_options_cbs_parms(struct tc_newtfilter_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.cbs = 1; + free(req->options.cbs.parms); + req->options.cbs._len.parms = len; + req->options.cbs.parms = malloc(req->options.cbs._len.parms); + memcpy(req->options.cbs.parms, parms, req->options.cbs._len.parms); +} +static inline void +__tc_newtfilter_req_set_options_cgroup_act(struct tc_newtfilter_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + free(req->options.cgroup.act); + req->options.cgroup.act = act; + req->options.cgroup._count.act = n_act; +} +static inline void +tc_newtfilter_req_set_options_cgroup_police_tbf(struct tc_newtfilter_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.tbf); + req->options.cgroup.police._len.tbf = len; + req->options.cgroup.police.tbf = malloc(req->options.cgroup.police._len.tbf); + memcpy(req->options.cgroup.police.tbf, tbf, req->options.cgroup.police._len.tbf); +} +static inline void +tc_newtfilter_req_set_options_cgroup_police_rate(struct tc_newtfilter_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.rate); + req->options.cgroup.police._len.rate = len; + req->options.cgroup.police.rate = malloc(req->options.cgroup.police._len.rate); + memcpy(req->options.cgroup.police.rate, rate, req->options.cgroup.police._len.rate); +} +static inline void +tc_newtfilter_req_set_options_cgroup_police_peakrate(struct tc_newtfilter_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.peakrate); + req->options.cgroup.police._len.peakrate = len; + req->options.cgroup.police.peakrate = malloc(req->options.cgroup.police._len.peakrate); + memcpy(req->options.cgroup.police.peakrate, peakrate, req->options.cgroup.police._len.peakrate); +} +static inline void +tc_newtfilter_req_set_options_cgroup_police_avrate(struct tc_newtfilter_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.avrate = 1; + req->options.cgroup.police.avrate = avrate; +} +static inline void +tc_newtfilter_req_set_options_cgroup_police_result(struct tc_newtfilter_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.result = 1; + req->options.cgroup.police.result = result; +} +static inline void +tc_newtfilter_req_set_options_cgroup_police_tm(struct tc_newtfilter_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.tm); + req->options.cgroup.police._len.tm = len; + req->options.cgroup.police.tm = malloc(req->options.cgroup.police._len.tm); + memcpy(req->options.cgroup.police.tm, tm, req->options.cgroup.police._len.tm); +} +static inline void +tc_newtfilter_req_set_options_cgroup_police_rate64(struct tc_newtfilter_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.rate64 = 1; + req->options.cgroup.police.rate64 = rate64; +} +static inline void +tc_newtfilter_req_set_options_cgroup_police_peakrate64(struct tc_newtfilter_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.peakrate64 = 1; + req->options.cgroup.police.peakrate64 = peakrate64; +} +static inline void +tc_newtfilter_req_set_options_cgroup_police_pktrate64(struct tc_newtfilter_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.pktrate64 = 1; + req->options.cgroup.police.pktrate64 = pktrate64; +} +static inline void +tc_newtfilter_req_set_options_cgroup_police_pktburst64(struct tc_newtfilter_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.pktburst64 = 1; + req->options.cgroup.police.pktburst64 = pktburst64; +} +static inline void +tc_newtfilter_req_set_options_cgroup_ematches(struct tc_newtfilter_req *req, + const void *ematches, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + free(req->options.cgroup.ematches); + req->options.cgroup._len.ematches = len; + req->options.cgroup.ematches = malloc(req->options.cgroup._len.ematches); + memcpy(req->options.cgroup.ematches, ematches, req->options.cgroup._len.ematches); +} +static inline void +tc_newtfilter_req_set_options_choke_parms(struct tc_newtfilter_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.choke = 1; + free(req->options.choke.parms); + req->options.choke._len.parms = len; + req->options.choke.parms = malloc(req->options.choke._len.parms); + memcpy(req->options.choke.parms, parms, req->options.choke._len.parms); +} +static inline void +tc_newtfilter_req_set_options_choke_stab(struct tc_newtfilter_req *req, + const void *stab, size_t len) +{ + req->_present.options = 1; + req->options._present.choke = 1; + free(req->options.choke.stab); + req->options.choke._len.stab = len; + req->options.choke.stab = malloc(req->options.choke._len.stab); + memcpy(req->options.choke.stab, stab, req->options.choke._len.stab); +} +static inline void +tc_newtfilter_req_set_options_choke_max_p(struct tc_newtfilter_req *req, + __u32 max_p) +{ + req->_present.options = 1; + req->options._present.choke = 1; + req->options.choke._present.max_p = 1; + req->options.choke.max_p = max_p; +} +static inline void +tc_newtfilter_req_set_options_clsact(struct tc_newtfilter_req *req) +{ + req->_present.options = 1; + req->options._present.clsact = 1; +} +static inline void +tc_newtfilter_req_set_options_codel_target(struct tc_newtfilter_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.target = 1; + req->options.codel.target = target; +} +static inline void +tc_newtfilter_req_set_options_codel_limit(struct tc_newtfilter_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.limit = 1; + req->options.codel.limit = limit; +} +static inline void +tc_newtfilter_req_set_options_codel_interval(struct tc_newtfilter_req *req, + __u32 interval) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.interval = 1; + req->options.codel.interval = interval; +} +static inline void +tc_newtfilter_req_set_options_codel_ecn(struct tc_newtfilter_req *req, + __u32 ecn) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.ecn = 1; + req->options.codel.ecn = ecn; +} +static inline void +tc_newtfilter_req_set_options_codel_ce_threshold(struct tc_newtfilter_req *req, + __u32 ce_threshold) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.ce_threshold = 1; + req->options.codel.ce_threshold = ce_threshold; +} +static inline void +tc_newtfilter_req_set_options_drr_quantum(struct tc_newtfilter_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.drr = 1; + req->options.drr._present.quantum = 1; + req->options.drr.quantum = quantum; +} +static inline void +tc_newtfilter_req_set_options_etf_parms(struct tc_newtfilter_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.etf = 1; + free(req->options.etf.parms); + req->options.etf._len.parms = len; + req->options.etf.parms = malloc(req->options.etf._len.parms); + memcpy(req->options.etf.parms, parms, req->options.etf._len.parms); +} +static inline void +tc_newtfilter_req_set_options_flow_keys(struct tc_newtfilter_req *req, + __u32 keys) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.keys = 1; + req->options.flow.keys = keys; +} +static inline void +tc_newtfilter_req_set_options_flow_mode(struct tc_newtfilter_req *req, + __u32 mode) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.mode = 1; + req->options.flow.mode = mode; +} +static inline void +tc_newtfilter_req_set_options_flow_baseclass(struct tc_newtfilter_req *req, + __u32 baseclass) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.baseclass = 1; + req->options.flow.baseclass = baseclass; +} +static inline void +tc_newtfilter_req_set_options_flow_rshift(struct tc_newtfilter_req *req, + __u32 rshift) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.rshift = 1; + req->options.flow.rshift = rshift; +} +static inline void +tc_newtfilter_req_set_options_flow_addend(struct tc_newtfilter_req *req, + __u32 addend) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.addend = 1; + req->options.flow.addend = addend; +} +static inline void +tc_newtfilter_req_set_options_flow_mask(struct tc_newtfilter_req *req, + __u32 mask) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.mask = 1; + req->options.flow.mask = mask; +} +static inline void +tc_newtfilter_req_set_options_flow_xor(struct tc_newtfilter_req *req, + __u32 xor) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.xor = 1; + req->options.flow.xor = xor; +} +static inline void +tc_newtfilter_req_set_options_flow_divisor(struct tc_newtfilter_req *req, + __u32 divisor) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.divisor = 1; + req->options.flow.divisor = divisor; +} +static inline void +tc_newtfilter_req_set_options_flow_act(struct tc_newtfilter_req *req, + const void *act, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + free(req->options.flow.act); + req->options.flow._len.act = len; + req->options.flow.act = malloc(req->options.flow._len.act); + memcpy(req->options.flow.act, act, req->options.flow._len.act); +} +static inline void +tc_newtfilter_req_set_options_flow_police_tbf(struct tc_newtfilter_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.tbf); + req->options.flow.police._len.tbf = len; + req->options.flow.police.tbf = malloc(req->options.flow.police._len.tbf); + memcpy(req->options.flow.police.tbf, tbf, req->options.flow.police._len.tbf); +} +static inline void +tc_newtfilter_req_set_options_flow_police_rate(struct tc_newtfilter_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.rate); + req->options.flow.police._len.rate = len; + req->options.flow.police.rate = malloc(req->options.flow.police._len.rate); + memcpy(req->options.flow.police.rate, rate, req->options.flow.police._len.rate); +} +static inline void +tc_newtfilter_req_set_options_flow_police_peakrate(struct tc_newtfilter_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.peakrate); + req->options.flow.police._len.peakrate = len; + req->options.flow.police.peakrate = malloc(req->options.flow.police._len.peakrate); + memcpy(req->options.flow.police.peakrate, peakrate, req->options.flow.police._len.peakrate); +} +static inline void +tc_newtfilter_req_set_options_flow_police_avrate(struct tc_newtfilter_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.avrate = 1; + req->options.flow.police.avrate = avrate; +} +static inline void +tc_newtfilter_req_set_options_flow_police_result(struct tc_newtfilter_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.result = 1; + req->options.flow.police.result = result; +} +static inline void +tc_newtfilter_req_set_options_flow_police_tm(struct tc_newtfilter_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.tm); + req->options.flow.police._len.tm = len; + req->options.flow.police.tm = malloc(req->options.flow.police._len.tm); + memcpy(req->options.flow.police.tm, tm, req->options.flow.police._len.tm); +} +static inline void +tc_newtfilter_req_set_options_flow_police_rate64(struct tc_newtfilter_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.rate64 = 1; + req->options.flow.police.rate64 = rate64; +} +static inline void +tc_newtfilter_req_set_options_flow_police_peakrate64(struct tc_newtfilter_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.peakrate64 = 1; + req->options.flow.police.peakrate64 = peakrate64; +} +static inline void +tc_newtfilter_req_set_options_flow_police_pktrate64(struct tc_newtfilter_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.pktrate64 = 1; + req->options.flow.police.pktrate64 = pktrate64; +} +static inline void +tc_newtfilter_req_set_options_flow_police_pktburst64(struct tc_newtfilter_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.pktburst64 = 1; + req->options.flow.police.pktburst64 = pktburst64; +} +static inline void +tc_newtfilter_req_set_options_flow_ematches(struct tc_newtfilter_req *req, + const void *ematches, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + free(req->options.flow.ematches); + req->options.flow._len.ematches = len; + req->options.flow.ematches = malloc(req->options.flow._len.ematches); + memcpy(req->options.flow.ematches, ematches, req->options.flow._len.ematches); +} +static inline void +tc_newtfilter_req_set_options_flow_perturb(struct tc_newtfilter_req *req, + __u32 perturb) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.perturb = 1; + req->options.flow.perturb = perturb; +} +static inline void +tc_newtfilter_req_set_options_flower_classid(struct tc_newtfilter_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.classid = 1; + req->options.flower.classid = classid; +} +static inline void +tc_newtfilter_req_set_options_flower_indev(struct tc_newtfilter_req *req, + const char *indev) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.indev); + req->options.flower._len.indev = strlen(indev); + req->options.flower.indev = malloc(req->options.flower._len.indev + 1); + memcpy(req->options.flower.indev, indev, req->options.flower._len.indev); + req->options.flower.indev[req->options.flower._len.indev] = 0; +} +static inline void +__tc_newtfilter_req_set_options_flower_act(struct tc_newtfilter_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.act); + req->options.flower.act = act; + req->options.flower._count.act = n_act; +} +static inline void +tc_newtfilter_req_set_options_flower_key_eth_dst(struct tc_newtfilter_req *req, + const void *key_eth_dst, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_dst); + req->options.flower._len.key_eth_dst = len; + req->options.flower.key_eth_dst = malloc(req->options.flower._len.key_eth_dst); + memcpy(req->options.flower.key_eth_dst, key_eth_dst, req->options.flower._len.key_eth_dst); +} +static inline void +tc_newtfilter_req_set_options_flower_key_eth_dst_mask(struct tc_newtfilter_req *req, + const void *key_eth_dst_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_dst_mask); + req->options.flower._len.key_eth_dst_mask = len; + req->options.flower.key_eth_dst_mask = malloc(req->options.flower._len.key_eth_dst_mask); + memcpy(req->options.flower.key_eth_dst_mask, key_eth_dst_mask, req->options.flower._len.key_eth_dst_mask); +} +static inline void +tc_newtfilter_req_set_options_flower_key_eth_src(struct tc_newtfilter_req *req, + const void *key_eth_src, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_src); + req->options.flower._len.key_eth_src = len; + req->options.flower.key_eth_src = malloc(req->options.flower._len.key_eth_src); + memcpy(req->options.flower.key_eth_src, key_eth_src, req->options.flower._len.key_eth_src); +} +static inline void +tc_newtfilter_req_set_options_flower_key_eth_src_mask(struct tc_newtfilter_req *req, + const void *key_eth_src_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_src_mask); + req->options.flower._len.key_eth_src_mask = len; + req->options.flower.key_eth_src_mask = malloc(req->options.flower._len.key_eth_src_mask); + memcpy(req->options.flower.key_eth_src_mask, key_eth_src_mask, req->options.flower._len.key_eth_src_mask); +} +static inline void +tc_newtfilter_req_set_options_flower_key_eth_type(struct tc_newtfilter_req *req, + __u16 key_eth_type /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_eth_type = 1; + req->options.flower.key_eth_type = key_eth_type; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ip_proto(struct tc_newtfilter_req *req, + __u8 key_ip_proto) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_proto = 1; + req->options.flower.key_ip_proto = key_ip_proto; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ipv4_src(struct tc_newtfilter_req *req, + __u32 key_ipv4_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_src = 1; + req->options.flower.key_ipv4_src = key_ipv4_src; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ipv4_src_mask(struct tc_newtfilter_req *req, + __u32 key_ipv4_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_src_mask = 1; + req->options.flower.key_ipv4_src_mask = key_ipv4_src_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ipv4_dst(struct tc_newtfilter_req *req, + __u32 key_ipv4_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_dst = 1; + req->options.flower.key_ipv4_dst = key_ipv4_dst; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ipv4_dst_mask(struct tc_newtfilter_req *req, + __u32 key_ipv4_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_dst_mask = 1; + req->options.flower.key_ipv4_dst_mask = key_ipv4_dst_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ipv6_src(struct tc_newtfilter_req *req, + const void *key_ipv6_src, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_src); + req->options.flower._len.key_ipv6_src = len; + req->options.flower.key_ipv6_src = malloc(req->options.flower._len.key_ipv6_src); + memcpy(req->options.flower.key_ipv6_src, key_ipv6_src, req->options.flower._len.key_ipv6_src); +} +static inline void +tc_newtfilter_req_set_options_flower_key_ipv6_src_mask(struct tc_newtfilter_req *req, + const void *key_ipv6_src_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_src_mask); + req->options.flower._len.key_ipv6_src_mask = len; + req->options.flower.key_ipv6_src_mask = malloc(req->options.flower._len.key_ipv6_src_mask); + memcpy(req->options.flower.key_ipv6_src_mask, key_ipv6_src_mask, req->options.flower._len.key_ipv6_src_mask); +} +static inline void +tc_newtfilter_req_set_options_flower_key_ipv6_dst(struct tc_newtfilter_req *req, + const void *key_ipv6_dst, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_dst); + req->options.flower._len.key_ipv6_dst = len; + req->options.flower.key_ipv6_dst = malloc(req->options.flower._len.key_ipv6_dst); + memcpy(req->options.flower.key_ipv6_dst, key_ipv6_dst, req->options.flower._len.key_ipv6_dst); +} +static inline void +tc_newtfilter_req_set_options_flower_key_ipv6_dst_mask(struct tc_newtfilter_req *req, + const void *key_ipv6_dst_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_dst_mask); + req->options.flower._len.key_ipv6_dst_mask = len; + req->options.flower.key_ipv6_dst_mask = malloc(req->options.flower._len.key_ipv6_dst_mask); + memcpy(req->options.flower.key_ipv6_dst_mask, key_ipv6_dst_mask, req->options.flower._len.key_ipv6_dst_mask); +} +static inline void +tc_newtfilter_req_set_options_flower_key_tcp_src(struct tc_newtfilter_req *req, + __u16 key_tcp_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_src = 1; + req->options.flower.key_tcp_src = key_tcp_src; +} +static inline void +tc_newtfilter_req_set_options_flower_key_tcp_dst(struct tc_newtfilter_req *req, + __u16 key_tcp_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_dst = 1; + req->options.flower.key_tcp_dst = key_tcp_dst; +} +static inline void +tc_newtfilter_req_set_options_flower_key_udp_src(struct tc_newtfilter_req *req, + __u16 key_udp_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_src = 1; + req->options.flower.key_udp_src = key_udp_src; +} +static inline void +tc_newtfilter_req_set_options_flower_key_udp_dst(struct tc_newtfilter_req *req, + __u16 key_udp_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_dst = 1; + req->options.flower.key_udp_dst = key_udp_dst; +} +static inline void +tc_newtfilter_req_set_options_flower_flags(struct tc_newtfilter_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.flags = 1; + req->options.flower.flags = flags; +} +static inline void +tc_newtfilter_req_set_options_flower_key_vlan_id(struct tc_newtfilter_req *req, + __u16 key_vlan_id /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_vlan_id = 1; + req->options.flower.key_vlan_id = key_vlan_id; +} +static inline void +tc_newtfilter_req_set_options_flower_key_vlan_prio(struct tc_newtfilter_req *req, + __u8 key_vlan_prio) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_vlan_prio = 1; + req->options.flower.key_vlan_prio = key_vlan_prio; +} +static inline void +tc_newtfilter_req_set_options_flower_key_vlan_eth_type(struct tc_newtfilter_req *req, + __u16 key_vlan_eth_type /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_vlan_eth_type = 1; + req->options.flower.key_vlan_eth_type = key_vlan_eth_type; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_key_id(struct tc_newtfilter_req *req, + __u32 key_enc_key_id /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_key_id = 1; + req->options.flower.key_enc_key_id = key_enc_key_id; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_ipv4_src(struct tc_newtfilter_req *req, + __u32 key_enc_ipv4_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_src = 1; + req->options.flower.key_enc_ipv4_src = key_enc_ipv4_src; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_ipv4_src_mask(struct tc_newtfilter_req *req, + __u32 key_enc_ipv4_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_src_mask = 1; + req->options.flower.key_enc_ipv4_src_mask = key_enc_ipv4_src_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_ipv4_dst(struct tc_newtfilter_req *req, + __u32 key_enc_ipv4_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_dst = 1; + req->options.flower.key_enc_ipv4_dst = key_enc_ipv4_dst; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_ipv4_dst_mask(struct tc_newtfilter_req *req, + __u32 key_enc_ipv4_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_dst_mask = 1; + req->options.flower.key_enc_ipv4_dst_mask = key_enc_ipv4_dst_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_ipv6_src(struct tc_newtfilter_req *req, + const void *key_enc_ipv6_src, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_src); + req->options.flower._len.key_enc_ipv6_src = len; + req->options.flower.key_enc_ipv6_src = malloc(req->options.flower._len.key_enc_ipv6_src); + memcpy(req->options.flower.key_enc_ipv6_src, key_enc_ipv6_src, req->options.flower._len.key_enc_ipv6_src); +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_ipv6_src_mask(struct tc_newtfilter_req *req, + const void *key_enc_ipv6_src_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_src_mask); + req->options.flower._len.key_enc_ipv6_src_mask = len; + req->options.flower.key_enc_ipv6_src_mask = malloc(req->options.flower._len.key_enc_ipv6_src_mask); + memcpy(req->options.flower.key_enc_ipv6_src_mask, key_enc_ipv6_src_mask, req->options.flower._len.key_enc_ipv6_src_mask); +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_ipv6_dst(struct tc_newtfilter_req *req, + const void *key_enc_ipv6_dst, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_dst); + req->options.flower._len.key_enc_ipv6_dst = len; + req->options.flower.key_enc_ipv6_dst = malloc(req->options.flower._len.key_enc_ipv6_dst); + memcpy(req->options.flower.key_enc_ipv6_dst, key_enc_ipv6_dst, req->options.flower._len.key_enc_ipv6_dst); +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_ipv6_dst_mask(struct tc_newtfilter_req *req, + const void *key_enc_ipv6_dst_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_dst_mask); + req->options.flower._len.key_enc_ipv6_dst_mask = len; + req->options.flower.key_enc_ipv6_dst_mask = malloc(req->options.flower._len.key_enc_ipv6_dst_mask); + memcpy(req->options.flower.key_enc_ipv6_dst_mask, key_enc_ipv6_dst_mask, req->options.flower._len.key_enc_ipv6_dst_mask); +} +static inline void +tc_newtfilter_req_set_options_flower_key_tcp_src_mask(struct tc_newtfilter_req *req, + __u16 key_tcp_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_src_mask = 1; + req->options.flower.key_tcp_src_mask = key_tcp_src_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_tcp_dst_mask(struct tc_newtfilter_req *req, + __u16 key_tcp_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_dst_mask = 1; + req->options.flower.key_tcp_dst_mask = key_tcp_dst_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_udp_src_mask(struct tc_newtfilter_req *req, + __u16 key_udp_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_src_mask = 1; + req->options.flower.key_udp_src_mask = key_udp_src_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_udp_dst_mask(struct tc_newtfilter_req *req, + __u16 key_udp_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_dst_mask = 1; + req->options.flower.key_udp_dst_mask = key_udp_dst_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_sctp_src_mask(struct tc_newtfilter_req *req, + __u16 key_sctp_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_src_mask = 1; + req->options.flower.key_sctp_src_mask = key_sctp_src_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_sctp_dst_mask(struct tc_newtfilter_req *req, + __u16 key_sctp_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_dst_mask = 1; + req->options.flower.key_sctp_dst_mask = key_sctp_dst_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_sctp_src(struct tc_newtfilter_req *req, + __u16 key_sctp_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_src = 1; + req->options.flower.key_sctp_src = key_sctp_src; +} +static inline void +tc_newtfilter_req_set_options_flower_key_sctp_dst(struct tc_newtfilter_req *req, + __u16 key_sctp_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_dst = 1; + req->options.flower.key_sctp_dst = key_sctp_dst; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_udp_src_port(struct tc_newtfilter_req *req, + __u16 key_enc_udp_src_port /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_src_port = 1; + req->options.flower.key_enc_udp_src_port = key_enc_udp_src_port; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_udp_src_port_mask(struct tc_newtfilter_req *req, + __u16 key_enc_udp_src_port_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_src_port_mask = 1; + req->options.flower.key_enc_udp_src_port_mask = key_enc_udp_src_port_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_udp_dst_port(struct tc_newtfilter_req *req, + __u16 key_enc_udp_dst_port /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_dst_port = 1; + req->options.flower.key_enc_udp_dst_port = key_enc_udp_dst_port; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_udp_dst_port_mask(struct tc_newtfilter_req *req, + __u16 key_enc_udp_dst_port_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_dst_port_mask = 1; + req->options.flower.key_enc_udp_dst_port_mask = key_enc_udp_dst_port_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_flags(struct tc_newtfilter_req *req, + __u32 key_flags /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_flags = 1; + req->options.flower.key_flags = key_flags; +} +static inline void +tc_newtfilter_req_set_options_flower_key_flags_mask(struct tc_newtfilter_req *req, + __u32 key_flags_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_flags_mask = 1; + req->options.flower.key_flags_mask = key_flags_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_icmpv4_code(struct tc_newtfilter_req *req, + __u8 key_icmpv4_code) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_code = 1; + req->options.flower.key_icmpv4_code = key_icmpv4_code; +} +static inline void +tc_newtfilter_req_set_options_flower_key_icmpv4_code_mask(struct tc_newtfilter_req *req, + __u8 key_icmpv4_code_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_code_mask = 1; + req->options.flower.key_icmpv4_code_mask = key_icmpv4_code_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_icmpv4_type(struct tc_newtfilter_req *req, + __u8 key_icmpv4_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_type = 1; + req->options.flower.key_icmpv4_type = key_icmpv4_type; +} +static inline void +tc_newtfilter_req_set_options_flower_key_icmpv4_type_mask(struct tc_newtfilter_req *req, + __u8 key_icmpv4_type_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_type_mask = 1; + req->options.flower.key_icmpv4_type_mask = key_icmpv4_type_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_icmpv6_code(struct tc_newtfilter_req *req, + __u8 key_icmpv6_code) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_code = 1; + req->options.flower.key_icmpv6_code = key_icmpv6_code; +} +static inline void +tc_newtfilter_req_set_options_flower_key_icmpv6_code_mask(struct tc_newtfilter_req *req, + __u8 key_icmpv6_code_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_code_mask = 1; + req->options.flower.key_icmpv6_code_mask = key_icmpv6_code_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_icmpv6_type(struct tc_newtfilter_req *req, + __u8 key_icmpv6_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_type = 1; + req->options.flower.key_icmpv6_type = key_icmpv6_type; +} +static inline void +tc_newtfilter_req_set_options_flower_key_icmpv6_type_mask(struct tc_newtfilter_req *req, + __u8 key_icmpv6_type_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_type_mask = 1; + req->options.flower.key_icmpv6_type_mask = key_icmpv6_type_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_arp_sip(struct tc_newtfilter_req *req, + __u32 key_arp_sip /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_sip = 1; + req->options.flower.key_arp_sip = key_arp_sip; +} +static inline void +tc_newtfilter_req_set_options_flower_key_arp_sip_mask(struct tc_newtfilter_req *req, + __u32 key_arp_sip_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_sip_mask = 1; + req->options.flower.key_arp_sip_mask = key_arp_sip_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_arp_tip(struct tc_newtfilter_req *req, + __u32 key_arp_tip /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_tip = 1; + req->options.flower.key_arp_tip = key_arp_tip; +} +static inline void +tc_newtfilter_req_set_options_flower_key_arp_tip_mask(struct tc_newtfilter_req *req, + __u32 key_arp_tip_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_tip_mask = 1; + req->options.flower.key_arp_tip_mask = key_arp_tip_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_arp_op(struct tc_newtfilter_req *req, + __u8 key_arp_op) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_op = 1; + req->options.flower.key_arp_op = key_arp_op; +} +static inline void +tc_newtfilter_req_set_options_flower_key_arp_op_mask(struct tc_newtfilter_req *req, + __u8 key_arp_op_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_op_mask = 1; + req->options.flower.key_arp_op_mask = key_arp_op_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_arp_sha(struct tc_newtfilter_req *req, + const void *key_arp_sha, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_sha); + req->options.flower._len.key_arp_sha = len; + req->options.flower.key_arp_sha = malloc(req->options.flower._len.key_arp_sha); + memcpy(req->options.flower.key_arp_sha, key_arp_sha, req->options.flower._len.key_arp_sha); +} +static inline void +tc_newtfilter_req_set_options_flower_key_arp_sha_mask(struct tc_newtfilter_req *req, + const void *key_arp_sha_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_sha_mask); + req->options.flower._len.key_arp_sha_mask = len; + req->options.flower.key_arp_sha_mask = malloc(req->options.flower._len.key_arp_sha_mask); + memcpy(req->options.flower.key_arp_sha_mask, key_arp_sha_mask, req->options.flower._len.key_arp_sha_mask); +} +static inline void +tc_newtfilter_req_set_options_flower_key_arp_tha(struct tc_newtfilter_req *req, + const void *key_arp_tha, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_tha); + req->options.flower._len.key_arp_tha = len; + req->options.flower.key_arp_tha = malloc(req->options.flower._len.key_arp_tha); + memcpy(req->options.flower.key_arp_tha, key_arp_tha, req->options.flower._len.key_arp_tha); +} +static inline void +tc_newtfilter_req_set_options_flower_key_arp_tha_mask(struct tc_newtfilter_req *req, + const void *key_arp_tha_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_tha_mask); + req->options.flower._len.key_arp_tha_mask = len; + req->options.flower.key_arp_tha_mask = malloc(req->options.flower._len.key_arp_tha_mask); + memcpy(req->options.flower.key_arp_tha_mask, key_arp_tha_mask, req->options.flower._len.key_arp_tha_mask); +} +static inline void +tc_newtfilter_req_set_options_flower_key_mpls_ttl(struct tc_newtfilter_req *req, + __u8 key_mpls_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_ttl = 1; + req->options.flower.key_mpls_ttl = key_mpls_ttl; +} +static inline void +tc_newtfilter_req_set_options_flower_key_mpls_bos(struct tc_newtfilter_req *req, + __u8 key_mpls_bos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_bos = 1; + req->options.flower.key_mpls_bos = key_mpls_bos; +} +static inline void +tc_newtfilter_req_set_options_flower_key_mpls_tc(struct tc_newtfilter_req *req, + __u8 key_mpls_tc) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_tc = 1; + req->options.flower.key_mpls_tc = key_mpls_tc; +} +static inline void +tc_newtfilter_req_set_options_flower_key_mpls_label(struct tc_newtfilter_req *req, + __u32 key_mpls_label /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_label = 1; + req->options.flower.key_mpls_label = key_mpls_label; +} +static inline void +tc_newtfilter_req_set_options_flower_key_tcp_flags(struct tc_newtfilter_req *req, + __u16 key_tcp_flags /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_flags = 1; + req->options.flower.key_tcp_flags = key_tcp_flags; +} +static inline void +tc_newtfilter_req_set_options_flower_key_tcp_flags_mask(struct tc_newtfilter_req *req, + __u16 key_tcp_flags_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_flags_mask = 1; + req->options.flower.key_tcp_flags_mask = key_tcp_flags_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ip_tos(struct tc_newtfilter_req *req, + __u8 key_ip_tos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_tos = 1; + req->options.flower.key_ip_tos = key_ip_tos; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ip_tos_mask(struct tc_newtfilter_req *req, + __u8 key_ip_tos_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_tos_mask = 1; + req->options.flower.key_ip_tos_mask = key_ip_tos_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ip_ttl(struct tc_newtfilter_req *req, + __u8 key_ip_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_ttl = 1; + req->options.flower.key_ip_ttl = key_ip_ttl; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ip_ttl_mask(struct tc_newtfilter_req *req, + __u8 key_ip_ttl_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_ttl_mask = 1; + req->options.flower.key_ip_ttl_mask = key_ip_ttl_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_cvlan_id(struct tc_newtfilter_req *req, + __u16 key_cvlan_id /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cvlan_id = 1; + req->options.flower.key_cvlan_id = key_cvlan_id; +} +static inline void +tc_newtfilter_req_set_options_flower_key_cvlan_prio(struct tc_newtfilter_req *req, + __u8 key_cvlan_prio) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cvlan_prio = 1; + req->options.flower.key_cvlan_prio = key_cvlan_prio; +} +static inline void +tc_newtfilter_req_set_options_flower_key_cvlan_eth_type(struct tc_newtfilter_req *req, + __u16 key_cvlan_eth_type /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cvlan_eth_type = 1; + req->options.flower.key_cvlan_eth_type = key_cvlan_eth_type; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_ip_tos(struct tc_newtfilter_req *req, + __u8 key_enc_ip_tos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_tos = 1; + req->options.flower.key_enc_ip_tos = key_enc_ip_tos; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_ip_tos_mask(struct tc_newtfilter_req *req, + __u8 key_enc_ip_tos_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_tos_mask = 1; + req->options.flower.key_enc_ip_tos_mask = key_enc_ip_tos_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_ip_ttl(struct tc_newtfilter_req *req, + __u8 key_enc_ip_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_ttl = 1; + req->options.flower.key_enc_ip_ttl = key_enc_ip_ttl; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_ip_ttl_mask(struct tc_newtfilter_req *req, + __u8 key_enc_ip_ttl_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_ttl_mask = 1; + req->options.flower.key_enc_ip_ttl_mask = key_enc_ip_ttl_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_geneve_class(struct tc_newtfilter_req *req, + __u16 class) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.geneve = 1; + req->options.flower.key_enc_opts.geneve._present.class = 1; + req->options.flower.key_enc_opts.geneve.class = class; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_geneve_type(struct tc_newtfilter_req *req, + __u8 type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.geneve = 1; + req->options.flower.key_enc_opts.geneve._present.type = 1; + req->options.flower.key_enc_opts.geneve.type = type; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_geneve_data(struct tc_newtfilter_req *req, + const void *data, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.geneve = 1; + free(req->options.flower.key_enc_opts.geneve.data); + req->options.flower.key_enc_opts.geneve._len.data = len; + req->options.flower.key_enc_opts.geneve.data = malloc(req->options.flower.key_enc_opts.geneve._len.data); + memcpy(req->options.flower.key_enc_opts.geneve.data, data, req->options.flower.key_enc_opts.geneve._len.data); +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_vxlan_gbp(struct tc_newtfilter_req *req, + __u32 gbp) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.vxlan = 1; + req->options.flower.key_enc_opts.vxlan._present.gbp = 1; + req->options.flower.key_enc_opts.vxlan.gbp = gbp; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_erspan_ver(struct tc_newtfilter_req *req, + __u8 ver) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.ver = 1; + req->options.flower.key_enc_opts.erspan.ver = ver; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_erspan_index(struct tc_newtfilter_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.index = 1; + req->options.flower.key_enc_opts.erspan.index = index; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_erspan_dir(struct tc_newtfilter_req *req, + __u8 dir) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.dir = 1; + req->options.flower.key_enc_opts.erspan.dir = dir; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_erspan_hwid(struct tc_newtfilter_req *req, + __u8 hwid) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.hwid = 1; + req->options.flower.key_enc_opts.erspan.hwid = hwid; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_gtp_pdu_type(struct tc_newtfilter_req *req, + __u8 pdu_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.gtp = 1; + req->options.flower.key_enc_opts.gtp._present.pdu_type = 1; + req->options.flower.key_enc_opts.gtp.pdu_type = pdu_type; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_gtp_qfi(struct tc_newtfilter_req *req, + __u8 qfi) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.gtp = 1; + req->options.flower.key_enc_opts.gtp._present.qfi = 1; + req->options.flower.key_enc_opts.gtp.qfi = qfi; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_mask_geneve_class(struct tc_newtfilter_req *req, + __u16 class) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.geneve = 1; + req->options.flower.key_enc_opts_mask.geneve._present.class = 1; + req->options.flower.key_enc_opts_mask.geneve.class = class; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_mask_geneve_type(struct tc_newtfilter_req *req, + __u8 type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.geneve = 1; + req->options.flower.key_enc_opts_mask.geneve._present.type = 1; + req->options.flower.key_enc_opts_mask.geneve.type = type; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_mask_geneve_data(struct tc_newtfilter_req *req, + const void *data, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.geneve = 1; + free(req->options.flower.key_enc_opts_mask.geneve.data); + req->options.flower.key_enc_opts_mask.geneve._len.data = len; + req->options.flower.key_enc_opts_mask.geneve.data = malloc(req->options.flower.key_enc_opts_mask.geneve._len.data); + memcpy(req->options.flower.key_enc_opts_mask.geneve.data, data, req->options.flower.key_enc_opts_mask.geneve._len.data); +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_mask_vxlan_gbp(struct tc_newtfilter_req *req, + __u32 gbp) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.vxlan = 1; + req->options.flower.key_enc_opts_mask.vxlan._present.gbp = 1; + req->options.flower.key_enc_opts_mask.vxlan.gbp = gbp; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_mask_erspan_ver(struct tc_newtfilter_req *req, + __u8 ver) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.ver = 1; + req->options.flower.key_enc_opts_mask.erspan.ver = ver; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_mask_erspan_index(struct tc_newtfilter_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.index = 1; + req->options.flower.key_enc_opts_mask.erspan.index = index; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_mask_erspan_dir(struct tc_newtfilter_req *req, + __u8 dir) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.dir = 1; + req->options.flower.key_enc_opts_mask.erspan.dir = dir; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_mask_erspan_hwid(struct tc_newtfilter_req *req, + __u8 hwid) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.hwid = 1; + req->options.flower.key_enc_opts_mask.erspan.hwid = hwid; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_mask_gtp_pdu_type(struct tc_newtfilter_req *req, + __u8 pdu_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.gtp = 1; + req->options.flower.key_enc_opts_mask.gtp._present.pdu_type = 1; + req->options.flower.key_enc_opts_mask.gtp.pdu_type = pdu_type; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_opts_mask_gtp_qfi(struct tc_newtfilter_req *req, + __u8 qfi) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.gtp = 1; + req->options.flower.key_enc_opts_mask.gtp._present.qfi = 1; + req->options.flower.key_enc_opts_mask.gtp.qfi = qfi; +} +static inline void +tc_newtfilter_req_set_options_flower_in_hw_count(struct tc_newtfilter_req *req, + __u32 in_hw_count) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.in_hw_count = 1; + req->options.flower.in_hw_count = in_hw_count; +} +static inline void +tc_newtfilter_req_set_options_flower_key_port_src_min(struct tc_newtfilter_req *req, + __u16 key_port_src_min /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_src_min = 1; + req->options.flower.key_port_src_min = key_port_src_min; +} +static inline void +tc_newtfilter_req_set_options_flower_key_port_src_max(struct tc_newtfilter_req *req, + __u16 key_port_src_max /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_src_max = 1; + req->options.flower.key_port_src_max = key_port_src_max; +} +static inline void +tc_newtfilter_req_set_options_flower_key_port_dst_min(struct tc_newtfilter_req *req, + __u16 key_port_dst_min /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_dst_min = 1; + req->options.flower.key_port_dst_min = key_port_dst_min; +} +static inline void +tc_newtfilter_req_set_options_flower_key_port_dst_max(struct tc_newtfilter_req *req, + __u16 key_port_dst_max /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_dst_max = 1; + req->options.flower.key_port_dst_max = key_port_dst_max; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ct_state(struct tc_newtfilter_req *req, + __u16 key_ct_state) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_state = 1; + req->options.flower.key_ct_state = key_ct_state; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ct_state_mask(struct tc_newtfilter_req *req, + __u16 key_ct_state_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_state_mask = 1; + req->options.flower.key_ct_state_mask = key_ct_state_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ct_zone(struct tc_newtfilter_req *req, + __u16 key_ct_zone) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_zone = 1; + req->options.flower.key_ct_zone = key_ct_zone; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ct_zone_mask(struct tc_newtfilter_req *req, + __u16 key_ct_zone_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_zone_mask = 1; + req->options.flower.key_ct_zone_mask = key_ct_zone_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ct_mark(struct tc_newtfilter_req *req, + __u32 key_ct_mark) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_mark = 1; + req->options.flower.key_ct_mark = key_ct_mark; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ct_mark_mask(struct tc_newtfilter_req *req, + __u32 key_ct_mark_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_mark_mask = 1; + req->options.flower.key_ct_mark_mask = key_ct_mark_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ct_labels(struct tc_newtfilter_req *req, + const void *key_ct_labels, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ct_labels); + req->options.flower._len.key_ct_labels = len; + req->options.flower.key_ct_labels = malloc(req->options.flower._len.key_ct_labels); + memcpy(req->options.flower.key_ct_labels, key_ct_labels, req->options.flower._len.key_ct_labels); +} +static inline void +tc_newtfilter_req_set_options_flower_key_ct_labels_mask(struct tc_newtfilter_req *req, + const void *key_ct_labels_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ct_labels_mask); + req->options.flower._len.key_ct_labels_mask = len; + req->options.flower.key_ct_labels_mask = malloc(req->options.flower._len.key_ct_labels_mask); + memcpy(req->options.flower.key_ct_labels_mask, key_ct_labels_mask, req->options.flower._len.key_ct_labels_mask); +} +static inline void +tc_newtfilter_req_set_options_flower_key_mpls_opts_lse_depth(struct tc_newtfilter_req *req, + __u8 lse_depth) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_depth = 1; + req->options.flower.key_mpls_opts.lse_depth = lse_depth; +} +static inline void +tc_newtfilter_req_set_options_flower_key_mpls_opts_lse_ttl(struct tc_newtfilter_req *req, + __u8 lse_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_ttl = 1; + req->options.flower.key_mpls_opts.lse_ttl = lse_ttl; +} +static inline void +tc_newtfilter_req_set_options_flower_key_mpls_opts_lse_bos(struct tc_newtfilter_req *req, + __u8 lse_bos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_bos = 1; + req->options.flower.key_mpls_opts.lse_bos = lse_bos; +} +static inline void +tc_newtfilter_req_set_options_flower_key_mpls_opts_lse_tc(struct tc_newtfilter_req *req, + __u8 lse_tc) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_tc = 1; + req->options.flower.key_mpls_opts.lse_tc = lse_tc; +} +static inline void +tc_newtfilter_req_set_options_flower_key_mpls_opts_lse_label(struct tc_newtfilter_req *req, + __u32 lse_label) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_label = 1; + req->options.flower.key_mpls_opts.lse_label = lse_label; +} +static inline void +tc_newtfilter_req_set_options_flower_key_hash(struct tc_newtfilter_req *req, + __u32 key_hash) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_hash = 1; + req->options.flower.key_hash = key_hash; +} +static inline void +tc_newtfilter_req_set_options_flower_key_hash_mask(struct tc_newtfilter_req *req, + __u32 key_hash_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_hash_mask = 1; + req->options.flower.key_hash_mask = key_hash_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_num_of_vlans(struct tc_newtfilter_req *req, + __u8 key_num_of_vlans) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_num_of_vlans = 1; + req->options.flower.key_num_of_vlans = key_num_of_vlans; +} +static inline void +tc_newtfilter_req_set_options_flower_key_pppoe_sid(struct tc_newtfilter_req *req, + __u16 key_pppoe_sid /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_pppoe_sid = 1; + req->options.flower.key_pppoe_sid = key_pppoe_sid; +} +static inline void +tc_newtfilter_req_set_options_flower_key_ppp_proto(struct tc_newtfilter_req *req, + __u16 key_ppp_proto /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ppp_proto = 1; + req->options.flower.key_ppp_proto = key_ppp_proto; +} +static inline void +tc_newtfilter_req_set_options_flower_key_l2tpv3_sid(struct tc_newtfilter_req *req, + __u32 key_l2tpv3_sid /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_l2tpv3_sid = 1; + req->options.flower.key_l2tpv3_sid = key_l2tpv3_sid; +} +static inline void +tc_newtfilter_req_set_options_flower_l2_miss(struct tc_newtfilter_req *req, + __u8 l2_miss) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.l2_miss = 1; + req->options.flower.l2_miss = l2_miss; +} +static inline void +tc_newtfilter_req_set_options_flower_key_cfm_md_level(struct tc_newtfilter_req *req, + __u8 md_level) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cfm = 1; + req->options.flower.key_cfm._present.md_level = 1; + req->options.flower.key_cfm.md_level = md_level; +} +static inline void +tc_newtfilter_req_set_options_flower_key_cfm_opcode(struct tc_newtfilter_req *req, + __u8 opcode) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cfm = 1; + req->options.flower.key_cfm._present.opcode = 1; + req->options.flower.key_cfm.opcode = opcode; +} +static inline void +tc_newtfilter_req_set_options_flower_key_spi(struct tc_newtfilter_req *req, + __u32 key_spi /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_spi = 1; + req->options.flower.key_spi = key_spi; +} +static inline void +tc_newtfilter_req_set_options_flower_key_spi_mask(struct tc_newtfilter_req *req, + __u32 key_spi_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_spi_mask = 1; + req->options.flower.key_spi_mask = key_spi_mask; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_flags(struct tc_newtfilter_req *req, + __u32 key_enc_flags /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_flags = 1; + req->options.flower.key_enc_flags = key_enc_flags; +} +static inline void +tc_newtfilter_req_set_options_flower_key_enc_flags_mask(struct tc_newtfilter_req *req, + __u32 key_enc_flags_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_flags_mask = 1; + req->options.flower.key_enc_flags_mask = key_enc_flags_mask; +} +static inline void +tc_newtfilter_req_set_options_fq_plimit(struct tc_newtfilter_req *req, + __u32 plimit) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.plimit = 1; + req->options.fq.plimit = plimit; +} +static inline void +tc_newtfilter_req_set_options_fq_flow_plimit(struct tc_newtfilter_req *req, + __u32 flow_plimit) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_plimit = 1; + req->options.fq.flow_plimit = flow_plimit; +} +static inline void +tc_newtfilter_req_set_options_fq_quantum(struct tc_newtfilter_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.quantum = 1; + req->options.fq.quantum = quantum; +} +static inline void +tc_newtfilter_req_set_options_fq_initial_quantum(struct tc_newtfilter_req *req, + __u32 initial_quantum) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.initial_quantum = 1; + req->options.fq.initial_quantum = initial_quantum; +} +static inline void +tc_newtfilter_req_set_options_fq_rate_enable(struct tc_newtfilter_req *req, + __u32 rate_enable) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.rate_enable = 1; + req->options.fq.rate_enable = rate_enable; +} +static inline void +tc_newtfilter_req_set_options_fq_flow_default_rate(struct tc_newtfilter_req *req, + __u32 flow_default_rate) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_default_rate = 1; + req->options.fq.flow_default_rate = flow_default_rate; +} +static inline void +tc_newtfilter_req_set_options_fq_flow_max_rate(struct tc_newtfilter_req *req, + __u32 flow_max_rate) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_max_rate = 1; + req->options.fq.flow_max_rate = flow_max_rate; +} +static inline void +tc_newtfilter_req_set_options_fq_buckets_log(struct tc_newtfilter_req *req, + __u32 buckets_log) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.buckets_log = 1; + req->options.fq.buckets_log = buckets_log; +} +static inline void +tc_newtfilter_req_set_options_fq_flow_refill_delay(struct tc_newtfilter_req *req, + __u32 flow_refill_delay) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_refill_delay = 1; + req->options.fq.flow_refill_delay = flow_refill_delay; +} +static inline void +tc_newtfilter_req_set_options_fq_orphan_mask(struct tc_newtfilter_req *req, + __u32 orphan_mask) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.orphan_mask = 1; + req->options.fq.orphan_mask = orphan_mask; +} +static inline void +tc_newtfilter_req_set_options_fq_low_rate_threshold(struct tc_newtfilter_req *req, + __u32 low_rate_threshold) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.low_rate_threshold = 1; + req->options.fq.low_rate_threshold = low_rate_threshold; +} +static inline void +tc_newtfilter_req_set_options_fq_ce_threshold(struct tc_newtfilter_req *req, + __u32 ce_threshold) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.ce_threshold = 1; + req->options.fq.ce_threshold = ce_threshold; +} +static inline void +tc_newtfilter_req_set_options_fq_timer_slack(struct tc_newtfilter_req *req, + __u32 timer_slack) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.timer_slack = 1; + req->options.fq.timer_slack = timer_slack; +} +static inline void +tc_newtfilter_req_set_options_fq_horizon(struct tc_newtfilter_req *req, + __u32 horizon) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.horizon = 1; + req->options.fq.horizon = horizon; +} +static inline void +tc_newtfilter_req_set_options_fq_horizon_drop(struct tc_newtfilter_req *req, + __u8 horizon_drop) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.horizon_drop = 1; + req->options.fq.horizon_drop = horizon_drop; +} +static inline void +tc_newtfilter_req_set_options_fq_priomap(struct tc_newtfilter_req *req, + const void *priomap, size_t len) +{ + req->_present.options = 1; + req->options._present.fq = 1; + free(req->options.fq.priomap); + req->options.fq._len.priomap = len; + req->options.fq.priomap = malloc(req->options.fq._len.priomap); + memcpy(req->options.fq.priomap, priomap, req->options.fq._len.priomap); +} +static inline void +tc_newtfilter_req_set_options_fq_weights(struct tc_newtfilter_req *req, + __s32 *weights, size_t count) +{ + req->_present.options = 1; + req->options._present.fq = 1; + free(req->options.fq.weights); + req->options.fq._count.weights = count; + count *= sizeof(__s32); + req->options.fq.weights = malloc(count); + memcpy(req->options.fq.weights, weights, count); +} +static inline void +tc_newtfilter_req_set_options_fq_codel_target(struct tc_newtfilter_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.target = 1; + req->options.fq_codel.target = target; +} +static inline void +tc_newtfilter_req_set_options_fq_codel_limit(struct tc_newtfilter_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.limit = 1; + req->options.fq_codel.limit = limit; +} +static inline void +tc_newtfilter_req_set_options_fq_codel_interval(struct tc_newtfilter_req *req, + __u32 interval) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.interval = 1; + req->options.fq_codel.interval = interval; +} +static inline void +tc_newtfilter_req_set_options_fq_codel_ecn(struct tc_newtfilter_req *req, + __u32 ecn) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ecn = 1; + req->options.fq_codel.ecn = ecn; +} +static inline void +tc_newtfilter_req_set_options_fq_codel_flows(struct tc_newtfilter_req *req, + __u32 flows) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.flows = 1; + req->options.fq_codel.flows = flows; +} +static inline void +tc_newtfilter_req_set_options_fq_codel_quantum(struct tc_newtfilter_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.quantum = 1; + req->options.fq_codel.quantum = quantum; +} +static inline void +tc_newtfilter_req_set_options_fq_codel_ce_threshold(struct tc_newtfilter_req *req, + __u32 ce_threshold) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ce_threshold = 1; + req->options.fq_codel.ce_threshold = ce_threshold; +} +static inline void +tc_newtfilter_req_set_options_fq_codel_drop_batch_size(struct tc_newtfilter_req *req, + __u32 drop_batch_size) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.drop_batch_size = 1; + req->options.fq_codel.drop_batch_size = drop_batch_size; +} +static inline void +tc_newtfilter_req_set_options_fq_codel_memory_limit(struct tc_newtfilter_req *req, + __u32 memory_limit) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.memory_limit = 1; + req->options.fq_codel.memory_limit = memory_limit; +} +static inline void +tc_newtfilter_req_set_options_fq_codel_ce_threshold_selector(struct tc_newtfilter_req *req, + __u8 ce_threshold_selector) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ce_threshold_selector = 1; + req->options.fq_codel.ce_threshold_selector = ce_threshold_selector; +} +static inline void +tc_newtfilter_req_set_options_fq_codel_ce_threshold_mask(struct tc_newtfilter_req *req, + __u8 ce_threshold_mask) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ce_threshold_mask = 1; + req->options.fq_codel.ce_threshold_mask = ce_threshold_mask; +} +static inline void +tc_newtfilter_req_set_options_fq_pie_limit(struct tc_newtfilter_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.limit = 1; + req->options.fq_pie.limit = limit; +} +static inline void +tc_newtfilter_req_set_options_fq_pie_flows(struct tc_newtfilter_req *req, + __u32 flows) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.flows = 1; + req->options.fq_pie.flows = flows; +} +static inline void +tc_newtfilter_req_set_options_fq_pie_target(struct tc_newtfilter_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.target = 1; + req->options.fq_pie.target = target; +} +static inline void +tc_newtfilter_req_set_options_fq_pie_tupdate(struct tc_newtfilter_req *req, + __u32 tupdate) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.tupdate = 1; + req->options.fq_pie.tupdate = tupdate; +} +static inline void +tc_newtfilter_req_set_options_fq_pie_alpha(struct tc_newtfilter_req *req, + __u32 alpha) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.alpha = 1; + req->options.fq_pie.alpha = alpha; +} +static inline void +tc_newtfilter_req_set_options_fq_pie_beta(struct tc_newtfilter_req *req, + __u32 beta) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.beta = 1; + req->options.fq_pie.beta = beta; +} +static inline void +tc_newtfilter_req_set_options_fq_pie_quantum(struct tc_newtfilter_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.quantum = 1; + req->options.fq_pie.quantum = quantum; +} +static inline void +tc_newtfilter_req_set_options_fq_pie_memory_limit(struct tc_newtfilter_req *req, + __u32 memory_limit) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.memory_limit = 1; + req->options.fq_pie.memory_limit = memory_limit; +} +static inline void +tc_newtfilter_req_set_options_fq_pie_ecn_prob(struct tc_newtfilter_req *req, + __u32 ecn_prob) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.ecn_prob = 1; + req->options.fq_pie.ecn_prob = ecn_prob; +} +static inline void +tc_newtfilter_req_set_options_fq_pie_ecn(struct tc_newtfilter_req *req, + __u32 ecn) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.ecn = 1; + req->options.fq_pie.ecn = ecn; +} +static inline void +tc_newtfilter_req_set_options_fq_pie_bytemode(struct tc_newtfilter_req *req, + __u32 bytemode) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.bytemode = 1; + req->options.fq_pie.bytemode = bytemode; +} +static inline void +tc_newtfilter_req_set_options_fq_pie_dq_rate_estimator(struct tc_newtfilter_req *req, + __u32 dq_rate_estimator) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.dq_rate_estimator = 1; + req->options.fq_pie.dq_rate_estimator = dq_rate_estimator; +} +static inline void +tc_newtfilter_req_set_options_fw_classid(struct tc_newtfilter_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.classid = 1; + req->options.fw.classid = classid; +} +static inline void +tc_newtfilter_req_set_options_fw_police_tbf(struct tc_newtfilter_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.tbf); + req->options.fw.police._len.tbf = len; + req->options.fw.police.tbf = malloc(req->options.fw.police._len.tbf); + memcpy(req->options.fw.police.tbf, tbf, req->options.fw.police._len.tbf); +} +static inline void +tc_newtfilter_req_set_options_fw_police_rate(struct tc_newtfilter_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.rate); + req->options.fw.police._len.rate = len; + req->options.fw.police.rate = malloc(req->options.fw.police._len.rate); + memcpy(req->options.fw.police.rate, rate, req->options.fw.police._len.rate); +} +static inline void +tc_newtfilter_req_set_options_fw_police_peakrate(struct tc_newtfilter_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.peakrate); + req->options.fw.police._len.peakrate = len; + req->options.fw.police.peakrate = malloc(req->options.fw.police._len.peakrate); + memcpy(req->options.fw.police.peakrate, peakrate, req->options.fw.police._len.peakrate); +} +static inline void +tc_newtfilter_req_set_options_fw_police_avrate(struct tc_newtfilter_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.avrate = 1; + req->options.fw.police.avrate = avrate; +} +static inline void +tc_newtfilter_req_set_options_fw_police_result(struct tc_newtfilter_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.result = 1; + req->options.fw.police.result = result; +} +static inline void +tc_newtfilter_req_set_options_fw_police_tm(struct tc_newtfilter_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.tm); + req->options.fw.police._len.tm = len; + req->options.fw.police.tm = malloc(req->options.fw.police._len.tm); + memcpy(req->options.fw.police.tm, tm, req->options.fw.police._len.tm); +} +static inline void +tc_newtfilter_req_set_options_fw_police_rate64(struct tc_newtfilter_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.rate64 = 1; + req->options.fw.police.rate64 = rate64; +} +static inline void +tc_newtfilter_req_set_options_fw_police_peakrate64(struct tc_newtfilter_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.peakrate64 = 1; + req->options.fw.police.peakrate64 = peakrate64; +} +static inline void +tc_newtfilter_req_set_options_fw_police_pktrate64(struct tc_newtfilter_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.pktrate64 = 1; + req->options.fw.police.pktrate64 = pktrate64; +} +static inline void +tc_newtfilter_req_set_options_fw_police_pktburst64(struct tc_newtfilter_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.pktburst64 = 1; + req->options.fw.police.pktburst64 = pktburst64; +} +static inline void +tc_newtfilter_req_set_options_fw_indev(struct tc_newtfilter_req *req, + const char *indev) +{ + req->_present.options = 1; + req->options._present.fw = 1; + free(req->options.fw.indev); + req->options.fw._len.indev = strlen(indev); + req->options.fw.indev = malloc(req->options.fw._len.indev + 1); + memcpy(req->options.fw.indev, indev, req->options.fw._len.indev); + req->options.fw.indev[req->options.fw._len.indev] = 0; +} +static inline void +__tc_newtfilter_req_set_options_fw_act(struct tc_newtfilter_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.fw = 1; + free(req->options.fw.act); + req->options.fw.act = act; + req->options.fw._count.act = n_act; +} +static inline void +tc_newtfilter_req_set_options_fw_mask(struct tc_newtfilter_req *req, + __u32 mask) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.mask = 1; + req->options.fw.mask = mask; +} +static inline void +tc_newtfilter_req_set_options_gred_parms(struct tc_newtfilter_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.parms); + req->options.gred._len.parms = len; + req->options.gred.parms = malloc(req->options.gred._len.parms); + memcpy(req->options.gred.parms, parms, req->options.gred._len.parms); +} +static inline void +tc_newtfilter_req_set_options_gred_stab(struct tc_newtfilter_req *req, + __u8 *stab, size_t count) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.stab); + req->options.gred._count.stab = count; + count *= sizeof(__u8); + req->options.gred.stab = malloc(count); + memcpy(req->options.gred.stab, stab, count); +} +static inline void +tc_newtfilter_req_set_options_gred_dps(struct tc_newtfilter_req *req, + const void *dps, size_t len) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.dps); + req->options.gred._len.dps = len; + req->options.gred.dps = malloc(req->options.gred._len.dps); + memcpy(req->options.gred.dps, dps, req->options.gred._len.dps); +} +static inline void +tc_newtfilter_req_set_options_gred_max_p(struct tc_newtfilter_req *req, + __u32 *max_p, size_t count) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.max_p); + req->options.gred._count.max_p = count; + count *= sizeof(__u32); + req->options.gred.max_p = malloc(count); + memcpy(req->options.gred.max_p, max_p, count); +} +static inline void +tc_newtfilter_req_set_options_gred_limit(struct tc_newtfilter_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.gred = 1; + req->options.gred._present.limit = 1; + req->options.gred.limit = limit; +} +static inline void +__tc_newtfilter_req_set_options_gred_vq_list_entry(struct tc_newtfilter_req *req, + struct tc_tca_gred_vq_entry_attrs *entry, + unsigned int n_entry) +{ + unsigned int i; + + req->_present.options = 1; + req->options._present.gred = 1; + req->options.gred._present.vq_list = 1; + for (i = 0; i < req->options.gred.vq_list._count.entry; i++) + tc_tca_gred_vq_entry_attrs_free(&req->options.gred.vq_list.entry[i]); + free(req->options.gred.vq_list.entry); + req->options.gred.vq_list.entry = entry; + req->options.gred.vq_list._count.entry = n_entry; +} +static inline void +tc_newtfilter_req_set_options_hfsc(struct tc_newtfilter_req *req, + const void *hfsc, size_t len) +{ + req->_present.options = 1; + free(req->options.hfsc); + req->options._len.hfsc = len; + req->options.hfsc = malloc(req->options._len.hfsc); + memcpy(req->options.hfsc, hfsc, req->options._len.hfsc); +} +static inline void +tc_newtfilter_req_set_options_hhf_backlog_limit(struct tc_newtfilter_req *req, + __u32 backlog_limit) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.backlog_limit = 1; + req->options.hhf.backlog_limit = backlog_limit; +} +static inline void +tc_newtfilter_req_set_options_hhf_quantum(struct tc_newtfilter_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.quantum = 1; + req->options.hhf.quantum = quantum; +} +static inline void +tc_newtfilter_req_set_options_hhf_hh_flows_limit(struct tc_newtfilter_req *req, + __u32 hh_flows_limit) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.hh_flows_limit = 1; + req->options.hhf.hh_flows_limit = hh_flows_limit; +} +static inline void +tc_newtfilter_req_set_options_hhf_reset_timeout(struct tc_newtfilter_req *req, + __u32 reset_timeout) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.reset_timeout = 1; + req->options.hhf.reset_timeout = reset_timeout; +} +static inline void +tc_newtfilter_req_set_options_hhf_admit_bytes(struct tc_newtfilter_req *req, + __u32 admit_bytes) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.admit_bytes = 1; + req->options.hhf.admit_bytes = admit_bytes; +} +static inline void +tc_newtfilter_req_set_options_hhf_evict_timeout(struct tc_newtfilter_req *req, + __u32 evict_timeout) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.evict_timeout = 1; + req->options.hhf.evict_timeout = evict_timeout; +} +static inline void +tc_newtfilter_req_set_options_hhf_non_hh_weight(struct tc_newtfilter_req *req, + __u32 non_hh_weight) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.non_hh_weight = 1; + req->options.hhf.non_hh_weight = non_hh_weight; +} +static inline void +tc_newtfilter_req_set_options_htb_parms(struct tc_newtfilter_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.parms); + req->options.htb._len.parms = len; + req->options.htb.parms = malloc(req->options.htb._len.parms); + memcpy(req->options.htb.parms, parms, req->options.htb._len.parms); +} +static inline void +tc_newtfilter_req_set_options_htb_init(struct tc_newtfilter_req *req, + const void *init, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.init); + req->options.htb._len.init = len; + req->options.htb.init = malloc(req->options.htb._len.init); + memcpy(req->options.htb.init, init, req->options.htb._len.init); +} +static inline void +tc_newtfilter_req_set_options_htb_ctab(struct tc_newtfilter_req *req, + const void *ctab, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.ctab); + req->options.htb._len.ctab = len; + req->options.htb.ctab = malloc(req->options.htb._len.ctab); + memcpy(req->options.htb.ctab, ctab, req->options.htb._len.ctab); +} +static inline void +tc_newtfilter_req_set_options_htb_rtab(struct tc_newtfilter_req *req, + const void *rtab, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.rtab); + req->options.htb._len.rtab = len; + req->options.htb.rtab = malloc(req->options.htb._len.rtab); + memcpy(req->options.htb.rtab, rtab, req->options.htb._len.rtab); +} +static inline void +tc_newtfilter_req_set_options_htb_direct_qlen(struct tc_newtfilter_req *req, + __u32 direct_qlen) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.direct_qlen = 1; + req->options.htb.direct_qlen = direct_qlen; +} +static inline void +tc_newtfilter_req_set_options_htb_rate64(struct tc_newtfilter_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.rate64 = 1; + req->options.htb.rate64 = rate64; +} +static inline void +tc_newtfilter_req_set_options_htb_ceil64(struct tc_newtfilter_req *req, + __u64 ceil64) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.ceil64 = 1; + req->options.htb.ceil64 = ceil64; +} +static inline void +tc_newtfilter_req_set_options_htb_offload(struct tc_newtfilter_req *req) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.offload = 1; +} +static inline void +tc_newtfilter_req_set_options_ingress(struct tc_newtfilter_req *req) +{ + req->_present.options = 1; + req->options._present.ingress = 1; +} +static inline void +tc_newtfilter_req_set_options_matchall_classid(struct tc_newtfilter_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + req->options.matchall._present.classid = 1; + req->options.matchall.classid = classid; +} +static inline void +__tc_newtfilter_req_set_options_matchall_act(struct tc_newtfilter_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + free(req->options.matchall.act); + req->options.matchall.act = act; + req->options.matchall._count.act = n_act; +} +static inline void +tc_newtfilter_req_set_options_matchall_flags(struct tc_newtfilter_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + req->options.matchall._present.flags = 1; + req->options.matchall.flags = flags; +} +static inline void +tc_newtfilter_req_set_options_matchall_pcnt(struct tc_newtfilter_req *req, + const void *pcnt, size_t len) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + free(req->options.matchall.pcnt); + req->options.matchall._len.pcnt = len; + req->options.matchall.pcnt = malloc(req->options.matchall._len.pcnt); + memcpy(req->options.matchall.pcnt, pcnt, req->options.matchall._len.pcnt); +} +static inline void +tc_newtfilter_req_set_options_mq(struct tc_newtfilter_req *req) +{ + req->_present.options = 1; + req->options._present.mq = 1; +} +static inline void +tc_newtfilter_req_set_options_mqprio(struct tc_newtfilter_req *req, + const void *mqprio, size_t len) +{ + req->_present.options = 1; + free(req->options.mqprio); + req->options._len.mqprio = len; + req->options.mqprio = malloc(req->options._len.mqprio); + memcpy(req->options.mqprio, mqprio, req->options._len.mqprio); +} +static inline void +tc_newtfilter_req_set_options_multiq(struct tc_newtfilter_req *req, + const void *multiq, size_t len) +{ + req->_present.options = 1; + free(req->options.multiq); + req->options._len.multiq = len; + req->options.multiq = malloc(req->options._len.multiq); + memcpy(req->options.multiq, multiq, req->options._len.multiq); +} +static inline void +tc_newtfilter_req_set_options_netem_corr(struct tc_newtfilter_req *req, + const void *corr, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.corr); + req->options.netem._len.corr = len; + req->options.netem.corr = malloc(req->options.netem._len.corr); + memcpy(req->options.netem.corr, corr, req->options.netem._len.corr); +} +static inline void +tc_newtfilter_req_set_options_netem_delay_dist(struct tc_newtfilter_req *req, + __s16 *delay_dist, size_t count) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.delay_dist); + req->options.netem._count.delay_dist = count; + count *= sizeof(__s16); + req->options.netem.delay_dist = malloc(count); + memcpy(req->options.netem.delay_dist, delay_dist, count); +} +static inline void +tc_newtfilter_req_set_options_netem_reorder(struct tc_newtfilter_req *req, + const void *reorder, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.reorder); + req->options.netem._len.reorder = len; + req->options.netem.reorder = malloc(req->options.netem._len.reorder); + memcpy(req->options.netem.reorder, reorder, req->options.netem._len.reorder); +} +static inline void +tc_newtfilter_req_set_options_netem_corrupt(struct tc_newtfilter_req *req, + const void *corrupt, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.corrupt); + req->options.netem._len.corrupt = len; + req->options.netem.corrupt = malloc(req->options.netem._len.corrupt); + memcpy(req->options.netem.corrupt, corrupt, req->options.netem._len.corrupt); +} +static inline void +tc_newtfilter_req_set_options_netem_loss_gi(struct tc_newtfilter_req *req, + const void *gi, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.loss = 1; + free(req->options.netem.loss.gi); + req->options.netem.loss._len.gi = len; + req->options.netem.loss.gi = malloc(req->options.netem.loss._len.gi); + memcpy(req->options.netem.loss.gi, gi, req->options.netem.loss._len.gi); +} +static inline void +tc_newtfilter_req_set_options_netem_loss_ge(struct tc_newtfilter_req *req, + const void *ge, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.loss = 1; + free(req->options.netem.loss.ge); + req->options.netem.loss._len.ge = len; + req->options.netem.loss.ge = malloc(req->options.netem.loss._len.ge); + memcpy(req->options.netem.loss.ge, ge, req->options.netem.loss._len.ge); +} +static inline void +tc_newtfilter_req_set_options_netem_rate(struct tc_newtfilter_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.rate); + req->options.netem._len.rate = len; + req->options.netem.rate = malloc(req->options.netem._len.rate); + memcpy(req->options.netem.rate, rate, req->options.netem._len.rate); +} +static inline void +tc_newtfilter_req_set_options_netem_ecn(struct tc_newtfilter_req *req, + __u32 ecn) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.ecn = 1; + req->options.netem.ecn = ecn; +} +static inline void +tc_newtfilter_req_set_options_netem_rate64(struct tc_newtfilter_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.rate64 = 1; + req->options.netem.rate64 = rate64; +} +static inline void +tc_newtfilter_req_set_options_netem_pad(struct tc_newtfilter_req *req, + __u32 pad) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.pad = 1; + req->options.netem.pad = pad; +} +static inline void +tc_newtfilter_req_set_options_netem_latency64(struct tc_newtfilter_req *req, + __s64 latency64) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.latency64 = 1; + req->options.netem.latency64 = latency64; +} +static inline void +tc_newtfilter_req_set_options_netem_jitter64(struct tc_newtfilter_req *req, + __s64 jitter64) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.jitter64 = 1; + req->options.netem.jitter64 = jitter64; +} +static inline void +tc_newtfilter_req_set_options_netem_slot(struct tc_newtfilter_req *req, + const void *slot, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.slot); + req->options.netem._len.slot = len; + req->options.netem.slot = malloc(req->options.netem._len.slot); + memcpy(req->options.netem.slot, slot, req->options.netem._len.slot); +} +static inline void +tc_newtfilter_req_set_options_netem_slot_dist(struct tc_newtfilter_req *req, + __s16 *slot_dist, size_t count) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.slot_dist); + req->options.netem._count.slot_dist = count; + count *= sizeof(__s16); + req->options.netem.slot_dist = malloc(count); + memcpy(req->options.netem.slot_dist, slot_dist, count); +} +static inline void +tc_newtfilter_req_set_options_netem_prng_seed(struct tc_newtfilter_req *req, + __u64 prng_seed) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.prng_seed = 1; + req->options.netem.prng_seed = prng_seed; +} +static inline void +tc_newtfilter_req_set_options_pfifo(struct tc_newtfilter_req *req, + const void *pfifo, size_t len) +{ + req->_present.options = 1; + free(req->options.pfifo); + req->options._len.pfifo = len; + req->options.pfifo = malloc(req->options._len.pfifo); + memcpy(req->options.pfifo, pfifo, req->options._len.pfifo); +} +static inline void +tc_newtfilter_req_set_options_pfifo_fast(struct tc_newtfilter_req *req, + const void *pfifo_fast, size_t len) +{ + req->_present.options = 1; + free(req->options.pfifo_fast); + req->options._len.pfifo_fast = len; + req->options.pfifo_fast = malloc(req->options._len.pfifo_fast); + memcpy(req->options.pfifo_fast, pfifo_fast, req->options._len.pfifo_fast); +} +static inline void +tc_newtfilter_req_set_options_pfifo_head_drop(struct tc_newtfilter_req *req, + const void *pfifo_head_drop, + size_t len) +{ + req->_present.options = 1; + free(req->options.pfifo_head_drop); + req->options._len.pfifo_head_drop = len; + req->options.pfifo_head_drop = malloc(req->options._len.pfifo_head_drop); + memcpy(req->options.pfifo_head_drop, pfifo_head_drop, req->options._len.pfifo_head_drop); +} +static inline void +tc_newtfilter_req_set_options_pie_target(struct tc_newtfilter_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.target = 1; + req->options.pie.target = target; +} +static inline void +tc_newtfilter_req_set_options_pie_limit(struct tc_newtfilter_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.limit = 1; + req->options.pie.limit = limit; +} +static inline void +tc_newtfilter_req_set_options_pie_tupdate(struct tc_newtfilter_req *req, + __u32 tupdate) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.tupdate = 1; + req->options.pie.tupdate = tupdate; +} +static inline void +tc_newtfilter_req_set_options_pie_alpha(struct tc_newtfilter_req *req, + __u32 alpha) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.alpha = 1; + req->options.pie.alpha = alpha; +} +static inline void +tc_newtfilter_req_set_options_pie_beta(struct tc_newtfilter_req *req, + __u32 beta) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.beta = 1; + req->options.pie.beta = beta; +} +static inline void +tc_newtfilter_req_set_options_pie_ecn(struct tc_newtfilter_req *req, __u32 ecn) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.ecn = 1; + req->options.pie.ecn = ecn; +} +static inline void +tc_newtfilter_req_set_options_pie_bytemode(struct tc_newtfilter_req *req, + __u32 bytemode) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.bytemode = 1; + req->options.pie.bytemode = bytemode; +} +static inline void +tc_newtfilter_req_set_options_pie_dq_rate_estimator(struct tc_newtfilter_req *req, + __u32 dq_rate_estimator) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.dq_rate_estimator = 1; + req->options.pie.dq_rate_estimator = dq_rate_estimator; +} +static inline void +tc_newtfilter_req_set_options_plug(struct tc_newtfilter_req *req, + const void *plug, size_t len) +{ + req->_present.options = 1; + free(req->options.plug); + req->options._len.plug = len; + req->options.plug = malloc(req->options._len.plug); + memcpy(req->options.plug, plug, req->options._len.plug); +} +static inline void +tc_newtfilter_req_set_options_prio(struct tc_newtfilter_req *req, + const void *prio, size_t len) +{ + req->_present.options = 1; + free(req->options.prio); + req->options._len.prio = len; + req->options.prio = malloc(req->options._len.prio); + memcpy(req->options.prio, prio, req->options._len.prio); +} +static inline void +tc_newtfilter_req_set_options_qfq_weight(struct tc_newtfilter_req *req, + __u32 weight) +{ + req->_present.options = 1; + req->options._present.qfq = 1; + req->options.qfq._present.weight = 1; + req->options.qfq.weight = weight; +} +static inline void +tc_newtfilter_req_set_options_qfq_lmax(struct tc_newtfilter_req *req, + __u32 lmax) +{ + req->_present.options = 1; + req->options._present.qfq = 1; + req->options.qfq._present.lmax = 1; + req->options.qfq.lmax = lmax; +} +static inline void +tc_newtfilter_req_set_options_red_parms(struct tc_newtfilter_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.red = 1; + free(req->options.red.parms); + req->options.red._len.parms = len; + req->options.red.parms = malloc(req->options.red._len.parms); + memcpy(req->options.red.parms, parms, req->options.red._len.parms); +} +static inline void +tc_newtfilter_req_set_options_red_stab(struct tc_newtfilter_req *req, + const void *stab, size_t len) +{ + req->_present.options = 1; + req->options._present.red = 1; + free(req->options.red.stab); + req->options.red._len.stab = len; + req->options.red.stab = malloc(req->options.red._len.stab); + memcpy(req->options.red.stab, stab, req->options.red._len.stab); +} +static inline void +tc_newtfilter_req_set_options_red_max_p(struct tc_newtfilter_req *req, + __u32 max_p) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.max_p = 1; + req->options.red.max_p = max_p; +} +static inline void +tc_newtfilter_req_set_options_red_flags(struct tc_newtfilter_req *req, + struct nla_bitfield32 *flags) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.flags = 1; + memcpy(&req->options.red.flags, flags, sizeof(struct nla_bitfield32)); +} +static inline void +tc_newtfilter_req_set_options_red_early_drop_block(struct tc_newtfilter_req *req, + __u32 early_drop_block) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.early_drop_block = 1; + req->options.red.early_drop_block = early_drop_block; +} +static inline void +tc_newtfilter_req_set_options_red_mark_block(struct tc_newtfilter_req *req, + __u32 mark_block) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.mark_block = 1; + req->options.red.mark_block = mark_block; +} +static inline void +tc_newtfilter_req_set_options_route_classid(struct tc_newtfilter_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.classid = 1; + req->options.route.classid = classid; +} +static inline void +tc_newtfilter_req_set_options_route_to(struct tc_newtfilter_req *req, __u32 to) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.to = 1; + req->options.route.to = to; +} +static inline void +tc_newtfilter_req_set_options_route_from(struct tc_newtfilter_req *req, + __u32 from) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.from = 1; + req->options.route.from = from; +} +static inline void +tc_newtfilter_req_set_options_route_iif(struct tc_newtfilter_req *req, + __u32 iif) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.iif = 1; + req->options.route.iif = iif; +} +static inline void +tc_newtfilter_req_set_options_route_police_tbf(struct tc_newtfilter_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.tbf); + req->options.route.police._len.tbf = len; + req->options.route.police.tbf = malloc(req->options.route.police._len.tbf); + memcpy(req->options.route.police.tbf, tbf, req->options.route.police._len.tbf); +} +static inline void +tc_newtfilter_req_set_options_route_police_rate(struct tc_newtfilter_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.rate); + req->options.route.police._len.rate = len; + req->options.route.police.rate = malloc(req->options.route.police._len.rate); + memcpy(req->options.route.police.rate, rate, req->options.route.police._len.rate); +} +static inline void +tc_newtfilter_req_set_options_route_police_peakrate(struct tc_newtfilter_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.peakrate); + req->options.route.police._len.peakrate = len; + req->options.route.police.peakrate = malloc(req->options.route.police._len.peakrate); + memcpy(req->options.route.police.peakrate, peakrate, req->options.route.police._len.peakrate); +} +static inline void +tc_newtfilter_req_set_options_route_police_avrate(struct tc_newtfilter_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.avrate = 1; + req->options.route.police.avrate = avrate; +} +static inline void +tc_newtfilter_req_set_options_route_police_result(struct tc_newtfilter_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.result = 1; + req->options.route.police.result = result; +} +static inline void +tc_newtfilter_req_set_options_route_police_tm(struct tc_newtfilter_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.tm); + req->options.route.police._len.tm = len; + req->options.route.police.tm = malloc(req->options.route.police._len.tm); + memcpy(req->options.route.police.tm, tm, req->options.route.police._len.tm); +} +static inline void +tc_newtfilter_req_set_options_route_police_rate64(struct tc_newtfilter_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.rate64 = 1; + req->options.route.police.rate64 = rate64; +} +static inline void +tc_newtfilter_req_set_options_route_police_peakrate64(struct tc_newtfilter_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.peakrate64 = 1; + req->options.route.police.peakrate64 = peakrate64; +} +static inline void +tc_newtfilter_req_set_options_route_police_pktrate64(struct tc_newtfilter_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.pktrate64 = 1; + req->options.route.police.pktrate64 = pktrate64; +} +static inline void +tc_newtfilter_req_set_options_route_police_pktburst64(struct tc_newtfilter_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.pktburst64 = 1; + req->options.route.police.pktburst64 = pktburst64; +} +static inline void +__tc_newtfilter_req_set_options_route_act(struct tc_newtfilter_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.route = 1; + free(req->options.route.act); + req->options.route.act = act; + req->options.route._count.act = n_act; +} +static inline void +tc_newtfilter_req_set_options_sfb(struct tc_newtfilter_req *req, + const void *sfb, size_t len) +{ + req->_present.options = 1; + free(req->options.sfb); + req->options._len.sfb = len; + req->options.sfb = malloc(req->options._len.sfb); + memcpy(req->options.sfb, sfb, req->options._len.sfb); +} +static inline void +tc_newtfilter_req_set_options_sfq(struct tc_newtfilter_req *req, + const void *sfq, size_t len) +{ + req->_present.options = 1; + free(req->options.sfq); + req->options._len.sfq = len; + req->options.sfq = malloc(req->options._len.sfq); + memcpy(req->options.sfq, sfq, req->options._len.sfq); +} +static inline void +tc_newtfilter_req_set_options_taprio_priomap(struct tc_newtfilter_req *req, + const void *priomap, size_t len) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + free(req->options.taprio.priomap); + req->options.taprio._len.priomap = len; + req->options.taprio.priomap = malloc(req->options.taprio._len.priomap); + memcpy(req->options.taprio.priomap, priomap, req->options.taprio._len.priomap); +} +static inline void +__tc_newtfilter_req_set_options_taprio_sched_entry_list_entry(struct tc_newtfilter_req *req, + struct tc_taprio_sched_entry *entry, + unsigned int n_entry) +{ + unsigned int i; + + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_entry_list = 1; + for (i = 0; i < req->options.taprio.sched_entry_list._count.entry; i++) + tc_taprio_sched_entry_free(&req->options.taprio.sched_entry_list.entry[i]); + free(req->options.taprio.sched_entry_list.entry); + req->options.taprio.sched_entry_list.entry = entry; + req->options.taprio.sched_entry_list._count.entry = n_entry; +} +static inline void +tc_newtfilter_req_set_options_taprio_sched_base_time(struct tc_newtfilter_req *req, + __s64 sched_base_time) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_base_time = 1; + req->options.taprio.sched_base_time = sched_base_time; +} +static inline void +tc_newtfilter_req_set_options_taprio_sched_single_entry_index(struct tc_newtfilter_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.index = 1; + req->options.taprio.sched_single_entry.index = index; +} +static inline void +tc_newtfilter_req_set_options_taprio_sched_single_entry_cmd(struct tc_newtfilter_req *req, + __u8 cmd) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.cmd = 1; + req->options.taprio.sched_single_entry.cmd = cmd; +} +static inline void +tc_newtfilter_req_set_options_taprio_sched_single_entry_gate_mask(struct tc_newtfilter_req *req, + __u32 gate_mask) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.gate_mask = 1; + req->options.taprio.sched_single_entry.gate_mask = gate_mask; +} +static inline void +tc_newtfilter_req_set_options_taprio_sched_single_entry_interval(struct tc_newtfilter_req *req, + __u32 interval) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.interval = 1; + req->options.taprio.sched_single_entry.interval = interval; +} +static inline void +tc_newtfilter_req_set_options_taprio_sched_clockid(struct tc_newtfilter_req *req, + __s32 sched_clockid) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_clockid = 1; + req->options.taprio.sched_clockid = sched_clockid; +} +static inline void +tc_newtfilter_req_set_options_taprio_admin_sched(struct tc_newtfilter_req *req, + const void *admin_sched, + size_t len) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + free(req->options.taprio.admin_sched); + req->options.taprio._len.admin_sched = len; + req->options.taprio.admin_sched = malloc(req->options.taprio._len.admin_sched); + memcpy(req->options.taprio.admin_sched, admin_sched, req->options.taprio._len.admin_sched); +} +static inline void +tc_newtfilter_req_set_options_taprio_sched_cycle_time(struct tc_newtfilter_req *req, + __s64 sched_cycle_time) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_cycle_time = 1; + req->options.taprio.sched_cycle_time = sched_cycle_time; +} +static inline void +tc_newtfilter_req_set_options_taprio_sched_cycle_time_extension(struct tc_newtfilter_req *req, + __s64 sched_cycle_time_extension) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_cycle_time_extension = 1; + req->options.taprio.sched_cycle_time_extension = sched_cycle_time_extension; +} +static inline void +tc_newtfilter_req_set_options_taprio_flags(struct tc_newtfilter_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.flags = 1; + req->options.taprio.flags = flags; +} +static inline void +tc_newtfilter_req_set_options_taprio_txtime_delay(struct tc_newtfilter_req *req, + __u32 txtime_delay) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.txtime_delay = 1; + req->options.taprio.txtime_delay = txtime_delay; +} +static inline void +tc_newtfilter_req_set_options_taprio_tc_entry_index(struct tc_newtfilter_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.tc_entry = 1; + req->options.taprio.tc_entry._present.index = 1; + req->options.taprio.tc_entry.index = index; +} +static inline void +tc_newtfilter_req_set_options_taprio_tc_entry_max_sdu(struct tc_newtfilter_req *req, + __u32 max_sdu) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.tc_entry = 1; + req->options.taprio.tc_entry._present.max_sdu = 1; + req->options.taprio.tc_entry.max_sdu = max_sdu; +} +static inline void +tc_newtfilter_req_set_options_taprio_tc_entry_fp(struct tc_newtfilter_req *req, + __u32 fp) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.tc_entry = 1; + req->options.taprio.tc_entry._present.fp = 1; + req->options.taprio.tc_entry.fp = fp; +} +static inline void +tc_newtfilter_req_set_options_tbf_parms(struct tc_newtfilter_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + free(req->options.tbf.parms); + req->options.tbf._len.parms = len; + req->options.tbf.parms = malloc(req->options.tbf._len.parms); + memcpy(req->options.tbf.parms, parms, req->options.tbf._len.parms); +} +static inline void +tc_newtfilter_req_set_options_tbf_rtab(struct tc_newtfilter_req *req, + const void *rtab, size_t len) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + free(req->options.tbf.rtab); + req->options.tbf._len.rtab = len; + req->options.tbf.rtab = malloc(req->options.tbf._len.rtab); + memcpy(req->options.tbf.rtab, rtab, req->options.tbf._len.rtab); +} +static inline void +tc_newtfilter_req_set_options_tbf_ptab(struct tc_newtfilter_req *req, + const void *ptab, size_t len) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + free(req->options.tbf.ptab); + req->options.tbf._len.ptab = len; + req->options.tbf.ptab = malloc(req->options.tbf._len.ptab); + memcpy(req->options.tbf.ptab, ptab, req->options.tbf._len.ptab); +} +static inline void +tc_newtfilter_req_set_options_tbf_rate64(struct tc_newtfilter_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.rate64 = 1; + req->options.tbf.rate64 = rate64; +} +static inline void +tc_newtfilter_req_set_options_tbf_prate64(struct tc_newtfilter_req *req, + __u64 prate64) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.prate64 = 1; + req->options.tbf.prate64 = prate64; +} +static inline void +tc_newtfilter_req_set_options_tbf_burst(struct tc_newtfilter_req *req, + __u32 burst) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.burst = 1; + req->options.tbf.burst = burst; +} +static inline void +tc_newtfilter_req_set_options_tbf_pburst(struct tc_newtfilter_req *req, + __u32 pburst) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.pburst = 1; + req->options.tbf.pburst = pburst; +} +static inline void +tc_newtfilter_req_set_options_u32_classid(struct tc_newtfilter_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.classid = 1; + req->options.u32.classid = classid; +} +static inline void +tc_newtfilter_req_set_options_u32_hash(struct tc_newtfilter_req *req, + __u32 hash) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.hash = 1; + req->options.u32.hash = hash; +} +static inline void +tc_newtfilter_req_set_options_u32_link(struct tc_newtfilter_req *req, + __u32 link) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.link = 1; + req->options.u32.link = link; +} +static inline void +tc_newtfilter_req_set_options_u32_divisor(struct tc_newtfilter_req *req, + __u32 divisor) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.divisor = 1; + req->options.u32.divisor = divisor; +} +static inline void +tc_newtfilter_req_set_options_u32_sel(struct tc_newtfilter_req *req, + const void *sel, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.sel); + req->options.u32._len.sel = len; + req->options.u32.sel = malloc(req->options.u32._len.sel); + memcpy(req->options.u32.sel, sel, req->options.u32._len.sel); +} +static inline void +tc_newtfilter_req_set_options_u32_police_tbf(struct tc_newtfilter_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.tbf); + req->options.u32.police._len.tbf = len; + req->options.u32.police.tbf = malloc(req->options.u32.police._len.tbf); + memcpy(req->options.u32.police.tbf, tbf, req->options.u32.police._len.tbf); +} +static inline void +tc_newtfilter_req_set_options_u32_police_rate(struct tc_newtfilter_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.rate); + req->options.u32.police._len.rate = len; + req->options.u32.police.rate = malloc(req->options.u32.police._len.rate); + memcpy(req->options.u32.police.rate, rate, req->options.u32.police._len.rate); +} +static inline void +tc_newtfilter_req_set_options_u32_police_peakrate(struct tc_newtfilter_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.peakrate); + req->options.u32.police._len.peakrate = len; + req->options.u32.police.peakrate = malloc(req->options.u32.police._len.peakrate); + memcpy(req->options.u32.police.peakrate, peakrate, req->options.u32.police._len.peakrate); +} +static inline void +tc_newtfilter_req_set_options_u32_police_avrate(struct tc_newtfilter_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.avrate = 1; + req->options.u32.police.avrate = avrate; +} +static inline void +tc_newtfilter_req_set_options_u32_police_result(struct tc_newtfilter_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.result = 1; + req->options.u32.police.result = result; +} +static inline void +tc_newtfilter_req_set_options_u32_police_tm(struct tc_newtfilter_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.tm); + req->options.u32.police._len.tm = len; + req->options.u32.police.tm = malloc(req->options.u32.police._len.tm); + memcpy(req->options.u32.police.tm, tm, req->options.u32.police._len.tm); +} +static inline void +tc_newtfilter_req_set_options_u32_police_rate64(struct tc_newtfilter_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.rate64 = 1; + req->options.u32.police.rate64 = rate64; +} +static inline void +tc_newtfilter_req_set_options_u32_police_peakrate64(struct tc_newtfilter_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.peakrate64 = 1; + req->options.u32.police.peakrate64 = peakrate64; +} +static inline void +tc_newtfilter_req_set_options_u32_police_pktrate64(struct tc_newtfilter_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.pktrate64 = 1; + req->options.u32.police.pktrate64 = pktrate64; +} +static inline void +tc_newtfilter_req_set_options_u32_police_pktburst64(struct tc_newtfilter_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.pktburst64 = 1; + req->options.u32.police.pktburst64 = pktburst64; +} +static inline void +__tc_newtfilter_req_set_options_u32_act(struct tc_newtfilter_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.act); + req->options.u32.act = act; + req->options.u32._count.act = n_act; +} +static inline void +tc_newtfilter_req_set_options_u32_indev(struct tc_newtfilter_req *req, + const char *indev) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.indev); + req->options.u32._len.indev = strlen(indev); + req->options.u32.indev = malloc(req->options.u32._len.indev + 1); + memcpy(req->options.u32.indev, indev, req->options.u32._len.indev); + req->options.u32.indev[req->options.u32._len.indev] = 0; +} +static inline void +tc_newtfilter_req_set_options_u32_pcnt(struct tc_newtfilter_req *req, + const void *pcnt, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.pcnt); + req->options.u32._len.pcnt = len; + req->options.u32.pcnt = malloc(req->options.u32._len.pcnt); + memcpy(req->options.u32.pcnt, pcnt, req->options.u32._len.pcnt); +} +static inline void +tc_newtfilter_req_set_options_u32_mark(struct tc_newtfilter_req *req, + const void *mark, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.mark); + req->options.u32._len.mark = len; + req->options.u32.mark = malloc(req->options.u32._len.mark); + memcpy(req->options.u32.mark, mark, req->options.u32._len.mark); +} +static inline void +tc_newtfilter_req_set_options_u32_flags(struct tc_newtfilter_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.flags = 1; + req->options.u32.flags = flags; +} +static inline void +tc_newtfilter_req_set_rate(struct tc_newtfilter_req *req, const void *rate, + size_t len) +{ + free(req->rate); + req->_len.rate = len; + req->rate = malloc(req->_len.rate); + memcpy(req->rate, rate, req->_len.rate); +} +static inline void +tc_newtfilter_req_set_chain(struct tc_newtfilter_req *req, __u32 chain) +{ + req->_present.chain = 1; + req->chain = chain; +} +static inline void +tc_newtfilter_req_set_ingress_block(struct tc_newtfilter_req *req, + __u32 ingress_block) +{ + req->_present.ingress_block = 1; + req->ingress_block = ingress_block; +} +static inline void +tc_newtfilter_req_set_egress_block(struct tc_newtfilter_req *req, + __u32 egress_block) +{ + req->_present.egress_block = 1; + req->egress_block = egress_block; +} + +/* + * Get / dump tc filter information. + */ +int tc_newtfilter(struct ynl_sock *ys, struct tc_newtfilter_req *req); + +/* ============== RTM_DELTFILTER ============== */ +/* RTM_DELTFILTER - do */ +struct tc_deltfilter_req { + __u16 _nlmsg_flags; + + struct tcmsg _hdr; + + struct { + __u32 chain:1; + } _present; + struct { + __u32 kind; + } _len; + + __u32 chain; + char *kind; +}; + +static inline struct tc_deltfilter_req *tc_deltfilter_req_alloc(void) +{ + return calloc(1, sizeof(struct tc_deltfilter_req)); +} +void tc_deltfilter_req_free(struct tc_deltfilter_req *req); + +static inline void +tc_deltfilter_req_set_nlflags(struct tc_deltfilter_req *req, __u16 nl_flags) +{ + req->_nlmsg_flags = nl_flags; +} + +static inline void +tc_deltfilter_req_set_chain(struct tc_deltfilter_req *req, __u32 chain) +{ + req->_present.chain = 1; + req->chain = chain; +} +static inline void +tc_deltfilter_req_set_kind(struct tc_deltfilter_req *req, const char *kind) +{ + free(req->kind); + req->_len.kind = strlen(kind); + req->kind = malloc(req->_len.kind + 1); + memcpy(req->kind, kind, req->_len.kind); + req->kind[req->_len.kind] = 0; +} + +/* + * Get / dump tc filter information. + */ +int tc_deltfilter(struct ynl_sock *ys, struct tc_deltfilter_req *req); + +/* ============== RTM_GETTFILTER ============== */ +/* RTM_GETTFILTER - do */ +struct tc_gettfilter_req { + __u16 _nlmsg_flags; + + struct tcmsg _hdr; + + struct { + __u32 chain:1; + } _present; + struct { + __u32 kind; + } _len; + + __u32 chain; + char *kind; +}; + +static inline struct tc_gettfilter_req *tc_gettfilter_req_alloc(void) +{ + return calloc(1, sizeof(struct tc_gettfilter_req)); +} +void tc_gettfilter_req_free(struct tc_gettfilter_req *req); + +static inline void +tc_gettfilter_req_set_nlflags(struct tc_gettfilter_req *req, __u16 nl_flags) +{ + req->_nlmsg_flags = nl_flags; +} + +static inline void +tc_gettfilter_req_set_chain(struct tc_gettfilter_req *req, __u32 chain) +{ + req->_present.chain = 1; + req->chain = chain; +} +static inline void +tc_gettfilter_req_set_kind(struct tc_gettfilter_req *req, const char *kind) +{ + free(req->kind); + req->_len.kind = strlen(kind); + req->kind = malloc(req->_len.kind + 1); + memcpy(req->kind, kind, req->_len.kind); + req->kind[req->_len.kind] = 0; +} + +struct tc_gettfilter_rsp { + struct tcmsg _hdr; + + struct { + __u32 options:1; + __u32 xstats:1; + __u32 fcnt:1; + __u32 stats2:1; + __u32 stab:1; + __u32 chain:1; + __u32 ingress_block:1; + __u32 egress_block:1; + } _present; + struct { + __u32 kind; + __u32 stats; + __u32 rate; + } _len; + + char *kind; + struct tc_options_msg options; + struct tc_stats *stats; + struct tc_tca_stats_app_msg xstats; + struct gnet_estimator *rate; + __u32 fcnt; + struct tc_tca_stats_attrs stats2; + struct tc_tca_stab_attrs stab; + __u32 chain; + __u32 ingress_block; + __u32 egress_block; +}; + +void tc_gettfilter_rsp_free(struct tc_gettfilter_rsp *rsp); + +/* + * Get / dump tc filter information. + */ +struct tc_gettfilter_rsp * +tc_gettfilter(struct ynl_sock *ys, struct tc_gettfilter_req *req); + +/* RTM_GETTFILTER - dump */ +struct tc_gettfilter_req_dump { + struct tcmsg _hdr; + + struct { + __u32 chain:1; + __u32 dump_flags:1; + } _present; + + __u32 chain; + struct nla_bitfield32 dump_flags; +}; + +static inline struct tc_gettfilter_req_dump *tc_gettfilter_req_dump_alloc(void) +{ + return calloc(1, sizeof(struct tc_gettfilter_req_dump)); +} +void tc_gettfilter_req_dump_free(struct tc_gettfilter_req_dump *req); + +static inline void +tc_gettfilter_req_dump_set_chain(struct tc_gettfilter_req_dump *req, + __u32 chain) +{ + req->_present.chain = 1; + req->chain = chain; +} +static inline void +tc_gettfilter_req_dump_set_dump_flags(struct tc_gettfilter_req_dump *req, + struct nla_bitfield32 *dump_flags) +{ + req->_present.dump_flags = 1; + memcpy(&req->dump_flags, dump_flags, sizeof(struct nla_bitfield32)); +} + +struct tc_gettfilter_list { + struct tc_gettfilter_list *next; + struct tc_gettfilter_rsp obj __attribute__((aligned(8))); +}; + +void tc_gettfilter_list_free(struct tc_gettfilter_list *rsp); + +struct tc_gettfilter_list * +tc_gettfilter_dump(struct ynl_sock *ys, struct tc_gettfilter_req_dump *req); + +/* ============== RTM_NEWCHAIN ============== */ +/* RTM_NEWCHAIN - do */ +struct tc_newchain_req { + __u16 _nlmsg_flags; + + struct tcmsg _hdr; + + struct { + __u32 options:1; + __u32 chain:1; + __u32 ingress_block:1; + __u32 egress_block:1; + } _present; + struct { + __u32 kind; + __u32 rate; + } _len; + + char *kind; + struct tc_options_msg options; + struct gnet_estimator *rate; + __u32 chain; + __u32 ingress_block; + __u32 egress_block; +}; + +static inline struct tc_newchain_req *tc_newchain_req_alloc(void) +{ + return calloc(1, sizeof(struct tc_newchain_req)); +} +void tc_newchain_req_free(struct tc_newchain_req *req); + +static inline void +tc_newchain_req_set_nlflags(struct tc_newchain_req *req, __u16 nl_flags) +{ + req->_nlmsg_flags = nl_flags; +} + +static inline void +tc_newchain_req_set_kind(struct tc_newchain_req *req, const char *kind) +{ + free(req->kind); + req->_len.kind = strlen(kind); + req->kind = malloc(req->_len.kind + 1); + memcpy(req->kind, kind, req->_len.kind); + req->kind[req->_len.kind] = 0; +} +static inline void +tc_newchain_req_set_options_basic_classid(struct tc_newchain_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.classid = 1; + req->options.basic.classid = classid; +} +static inline void +tc_newchain_req_set_options_basic_ematches_tree_hdr(struct tc_newchain_req *req, + const void *tree_hdr, + size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.ematches = 1; + free(req->options.basic.ematches.tree_hdr); + req->options.basic.ematches._len.tree_hdr = len; + req->options.basic.ematches.tree_hdr = malloc(req->options.basic.ematches._len.tree_hdr); + memcpy(req->options.basic.ematches.tree_hdr, tree_hdr, req->options.basic.ematches._len.tree_hdr); +} +static inline void +tc_newchain_req_set_options_basic_ematches_tree_list(struct tc_newchain_req *req, + const void *tree_list, + size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.ematches = 1; + free(req->options.basic.ematches.tree_list); + req->options.basic.ematches._len.tree_list = len; + req->options.basic.ematches.tree_list = malloc(req->options.basic.ematches._len.tree_list); + memcpy(req->options.basic.ematches.tree_list, tree_list, req->options.basic.ematches._len.tree_list); +} +static inline void +__tc_newchain_req_set_options_basic_act(struct tc_newchain_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.basic = 1; + free(req->options.basic.act); + req->options.basic.act = act; + req->options.basic._count.act = n_act; +} +static inline void +tc_newchain_req_set_options_basic_police_tbf(struct tc_newchain_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.tbf); + req->options.basic.police._len.tbf = len; + req->options.basic.police.tbf = malloc(req->options.basic.police._len.tbf); + memcpy(req->options.basic.police.tbf, tbf, req->options.basic.police._len.tbf); +} +static inline void +tc_newchain_req_set_options_basic_police_rate(struct tc_newchain_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.rate); + req->options.basic.police._len.rate = len; + req->options.basic.police.rate = malloc(req->options.basic.police._len.rate); + memcpy(req->options.basic.police.rate, rate, req->options.basic.police._len.rate); +} +static inline void +tc_newchain_req_set_options_basic_police_peakrate(struct tc_newchain_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.peakrate); + req->options.basic.police._len.peakrate = len; + req->options.basic.police.peakrate = malloc(req->options.basic.police._len.peakrate); + memcpy(req->options.basic.police.peakrate, peakrate, req->options.basic.police._len.peakrate); +} +static inline void +tc_newchain_req_set_options_basic_police_avrate(struct tc_newchain_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.avrate = 1; + req->options.basic.police.avrate = avrate; +} +static inline void +tc_newchain_req_set_options_basic_police_result(struct tc_newchain_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.result = 1; + req->options.basic.police.result = result; +} +static inline void +tc_newchain_req_set_options_basic_police_tm(struct tc_newchain_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + free(req->options.basic.police.tm); + req->options.basic.police._len.tm = len; + req->options.basic.police.tm = malloc(req->options.basic.police._len.tm); + memcpy(req->options.basic.police.tm, tm, req->options.basic.police._len.tm); +} +static inline void +tc_newchain_req_set_options_basic_police_rate64(struct tc_newchain_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.rate64 = 1; + req->options.basic.police.rate64 = rate64; +} +static inline void +tc_newchain_req_set_options_basic_police_peakrate64(struct tc_newchain_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.peakrate64 = 1; + req->options.basic.police.peakrate64 = peakrate64; +} +static inline void +tc_newchain_req_set_options_basic_police_pktrate64(struct tc_newchain_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.pktrate64 = 1; + req->options.basic.police.pktrate64 = pktrate64; +} +static inline void +tc_newchain_req_set_options_basic_police_pktburst64(struct tc_newchain_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.basic = 1; + req->options.basic._present.police = 1; + req->options.basic.police._present.pktburst64 = 1; + req->options.basic.police.pktburst64 = pktburst64; +} +static inline void +tc_newchain_req_set_options_basic_pcnt(struct tc_newchain_req *req, + const void *pcnt, size_t len) +{ + req->_present.options = 1; + req->options._present.basic = 1; + free(req->options.basic.pcnt); + req->options.basic._len.pcnt = len; + req->options.basic.pcnt = malloc(req->options.basic._len.pcnt); + memcpy(req->options.basic.pcnt, pcnt, req->options.basic._len.pcnt); +} +static inline void +__tc_newchain_req_set_options_bpf_act(struct tc_newchain_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.act); + req->options.bpf.act = act; + req->options.bpf._count.act = n_act; +} +static inline void +tc_newchain_req_set_options_bpf_police_tbf(struct tc_newchain_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.tbf); + req->options.bpf.police._len.tbf = len; + req->options.bpf.police.tbf = malloc(req->options.bpf.police._len.tbf); + memcpy(req->options.bpf.police.tbf, tbf, req->options.bpf.police._len.tbf); +} +static inline void +tc_newchain_req_set_options_bpf_police_rate(struct tc_newchain_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.rate); + req->options.bpf.police._len.rate = len; + req->options.bpf.police.rate = malloc(req->options.bpf.police._len.rate); + memcpy(req->options.bpf.police.rate, rate, req->options.bpf.police._len.rate); +} +static inline void +tc_newchain_req_set_options_bpf_police_peakrate(struct tc_newchain_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.peakrate); + req->options.bpf.police._len.peakrate = len; + req->options.bpf.police.peakrate = malloc(req->options.bpf.police._len.peakrate); + memcpy(req->options.bpf.police.peakrate, peakrate, req->options.bpf.police._len.peakrate); +} +static inline void +tc_newchain_req_set_options_bpf_police_avrate(struct tc_newchain_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.avrate = 1; + req->options.bpf.police.avrate = avrate; +} +static inline void +tc_newchain_req_set_options_bpf_police_result(struct tc_newchain_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.result = 1; + req->options.bpf.police.result = result; +} +static inline void +tc_newchain_req_set_options_bpf_police_tm(struct tc_newchain_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + free(req->options.bpf.police.tm); + req->options.bpf.police._len.tm = len; + req->options.bpf.police.tm = malloc(req->options.bpf.police._len.tm); + memcpy(req->options.bpf.police.tm, tm, req->options.bpf.police._len.tm); +} +static inline void +tc_newchain_req_set_options_bpf_police_rate64(struct tc_newchain_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.rate64 = 1; + req->options.bpf.police.rate64 = rate64; +} +static inline void +tc_newchain_req_set_options_bpf_police_peakrate64(struct tc_newchain_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.peakrate64 = 1; + req->options.bpf.police.peakrate64 = peakrate64; +} +static inline void +tc_newchain_req_set_options_bpf_police_pktrate64(struct tc_newchain_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.pktrate64 = 1; + req->options.bpf.police.pktrate64 = pktrate64; +} +static inline void +tc_newchain_req_set_options_bpf_police_pktburst64(struct tc_newchain_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.police = 1; + req->options.bpf.police._present.pktburst64 = 1; + req->options.bpf.police.pktburst64 = pktburst64; +} +static inline void +tc_newchain_req_set_options_bpf_classid(struct tc_newchain_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.classid = 1; + req->options.bpf.classid = classid; +} +static inline void +tc_newchain_req_set_options_bpf_ops_len(struct tc_newchain_req *req, + __u16 ops_len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.ops_len = 1; + req->options.bpf.ops_len = ops_len; +} +static inline void +tc_newchain_req_set_options_bpf_ops(struct tc_newchain_req *req, + const void *ops, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.ops); + req->options.bpf._len.ops = len; + req->options.bpf.ops = malloc(req->options.bpf._len.ops); + memcpy(req->options.bpf.ops, ops, req->options.bpf._len.ops); +} +static inline void +tc_newchain_req_set_options_bpf_fd(struct tc_newchain_req *req, __u32 fd) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.fd = 1; + req->options.bpf.fd = fd; +} +static inline void +tc_newchain_req_set_options_bpf_name(struct tc_newchain_req *req, + const char *name) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.name); + req->options.bpf._len.name = strlen(name); + req->options.bpf.name = malloc(req->options.bpf._len.name + 1); + memcpy(req->options.bpf.name, name, req->options.bpf._len.name); + req->options.bpf.name[req->options.bpf._len.name] = 0; +} +static inline void +tc_newchain_req_set_options_bpf_flags(struct tc_newchain_req *req, __u32 flags) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.flags = 1; + req->options.bpf.flags = flags; +} +static inline void +tc_newchain_req_set_options_bpf_flags_gen(struct tc_newchain_req *req, + __u32 flags_gen) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.flags_gen = 1; + req->options.bpf.flags_gen = flags_gen; +} +static inline void +tc_newchain_req_set_options_bpf_tag(struct tc_newchain_req *req, + const void *tag, size_t len) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + free(req->options.bpf.tag); + req->options.bpf._len.tag = len; + req->options.bpf.tag = malloc(req->options.bpf._len.tag); + memcpy(req->options.bpf.tag, tag, req->options.bpf._len.tag); +} +static inline void +tc_newchain_req_set_options_bpf_id(struct tc_newchain_req *req, __u32 id) +{ + req->_present.options = 1; + req->options._present.bpf = 1; + req->options.bpf._present.id = 1; + req->options.bpf.id = id; +} +static inline void +tc_newchain_req_set_options_bfifo(struct tc_newchain_req *req, + const void *bfifo, size_t len) +{ + req->_present.options = 1; + free(req->options.bfifo); + req->options._len.bfifo = len; + req->options.bfifo = malloc(req->options._len.bfifo); + memcpy(req->options.bfifo, bfifo, req->options._len.bfifo); +} +static inline void +tc_newchain_req_set_options_cake_base_rate64(struct tc_newchain_req *req, + __u64 base_rate64) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.base_rate64 = 1; + req->options.cake.base_rate64 = base_rate64; +} +static inline void +tc_newchain_req_set_options_cake_diffserv_mode(struct tc_newchain_req *req, + __u32 diffserv_mode) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.diffserv_mode = 1; + req->options.cake.diffserv_mode = diffserv_mode; +} +static inline void +tc_newchain_req_set_options_cake_atm(struct tc_newchain_req *req, __u32 atm) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.atm = 1; + req->options.cake.atm = atm; +} +static inline void +tc_newchain_req_set_options_cake_flow_mode(struct tc_newchain_req *req, + __u32 flow_mode) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.flow_mode = 1; + req->options.cake.flow_mode = flow_mode; +} +static inline void +tc_newchain_req_set_options_cake_overhead(struct tc_newchain_req *req, + __u32 overhead) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.overhead = 1; + req->options.cake.overhead = overhead; +} +static inline void +tc_newchain_req_set_options_cake_rtt(struct tc_newchain_req *req, __u32 rtt) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.rtt = 1; + req->options.cake.rtt = rtt; +} +static inline void +tc_newchain_req_set_options_cake_target(struct tc_newchain_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.target = 1; + req->options.cake.target = target; +} +static inline void +tc_newchain_req_set_options_cake_autorate(struct tc_newchain_req *req, + __u32 autorate) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.autorate = 1; + req->options.cake.autorate = autorate; +} +static inline void +tc_newchain_req_set_options_cake_memory(struct tc_newchain_req *req, + __u32 memory) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.memory = 1; + req->options.cake.memory = memory; +} +static inline void +tc_newchain_req_set_options_cake_nat(struct tc_newchain_req *req, __u32 nat) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.nat = 1; + req->options.cake.nat = nat; +} +static inline void +tc_newchain_req_set_options_cake_raw(struct tc_newchain_req *req, __u32 raw) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.raw = 1; + req->options.cake.raw = raw; +} +static inline void +tc_newchain_req_set_options_cake_wash(struct tc_newchain_req *req, __u32 wash) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.wash = 1; + req->options.cake.wash = wash; +} +static inline void +tc_newchain_req_set_options_cake_mpu(struct tc_newchain_req *req, __u32 mpu) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.mpu = 1; + req->options.cake.mpu = mpu; +} +static inline void +tc_newchain_req_set_options_cake_ingress(struct tc_newchain_req *req, + __u32 ingress) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.ingress = 1; + req->options.cake.ingress = ingress; +} +static inline void +tc_newchain_req_set_options_cake_ack_filter(struct tc_newchain_req *req, + __u32 ack_filter) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.ack_filter = 1; + req->options.cake.ack_filter = ack_filter; +} +static inline void +tc_newchain_req_set_options_cake_split_gso(struct tc_newchain_req *req, + __u32 split_gso) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.split_gso = 1; + req->options.cake.split_gso = split_gso; +} +static inline void +tc_newchain_req_set_options_cake_fwmark(struct tc_newchain_req *req, + __u32 fwmark) +{ + req->_present.options = 1; + req->options._present.cake = 1; + req->options.cake._present.fwmark = 1; + req->options.cake.fwmark = fwmark; +} +static inline void +tc_newchain_req_set_options_cbs_parms(struct tc_newchain_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.cbs = 1; + free(req->options.cbs.parms); + req->options.cbs._len.parms = len; + req->options.cbs.parms = malloc(req->options.cbs._len.parms); + memcpy(req->options.cbs.parms, parms, req->options.cbs._len.parms); +} +static inline void +__tc_newchain_req_set_options_cgroup_act(struct tc_newchain_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + free(req->options.cgroup.act); + req->options.cgroup.act = act; + req->options.cgroup._count.act = n_act; +} +static inline void +tc_newchain_req_set_options_cgroup_police_tbf(struct tc_newchain_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.tbf); + req->options.cgroup.police._len.tbf = len; + req->options.cgroup.police.tbf = malloc(req->options.cgroup.police._len.tbf); + memcpy(req->options.cgroup.police.tbf, tbf, req->options.cgroup.police._len.tbf); +} +static inline void +tc_newchain_req_set_options_cgroup_police_rate(struct tc_newchain_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.rate); + req->options.cgroup.police._len.rate = len; + req->options.cgroup.police.rate = malloc(req->options.cgroup.police._len.rate); + memcpy(req->options.cgroup.police.rate, rate, req->options.cgroup.police._len.rate); +} +static inline void +tc_newchain_req_set_options_cgroup_police_peakrate(struct tc_newchain_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.peakrate); + req->options.cgroup.police._len.peakrate = len; + req->options.cgroup.police.peakrate = malloc(req->options.cgroup.police._len.peakrate); + memcpy(req->options.cgroup.police.peakrate, peakrate, req->options.cgroup.police._len.peakrate); +} +static inline void +tc_newchain_req_set_options_cgroup_police_avrate(struct tc_newchain_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.avrate = 1; + req->options.cgroup.police.avrate = avrate; +} +static inline void +tc_newchain_req_set_options_cgroup_police_result(struct tc_newchain_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.result = 1; + req->options.cgroup.police.result = result; +} +static inline void +tc_newchain_req_set_options_cgroup_police_tm(struct tc_newchain_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + free(req->options.cgroup.police.tm); + req->options.cgroup.police._len.tm = len; + req->options.cgroup.police.tm = malloc(req->options.cgroup.police._len.tm); + memcpy(req->options.cgroup.police.tm, tm, req->options.cgroup.police._len.tm); +} +static inline void +tc_newchain_req_set_options_cgroup_police_rate64(struct tc_newchain_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.rate64 = 1; + req->options.cgroup.police.rate64 = rate64; +} +static inline void +tc_newchain_req_set_options_cgroup_police_peakrate64(struct tc_newchain_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.peakrate64 = 1; + req->options.cgroup.police.peakrate64 = peakrate64; +} +static inline void +tc_newchain_req_set_options_cgroup_police_pktrate64(struct tc_newchain_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.pktrate64 = 1; + req->options.cgroup.police.pktrate64 = pktrate64; +} +static inline void +tc_newchain_req_set_options_cgroup_police_pktburst64(struct tc_newchain_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + req->options.cgroup._present.police = 1; + req->options.cgroup.police._present.pktburst64 = 1; + req->options.cgroup.police.pktburst64 = pktburst64; +} +static inline void +tc_newchain_req_set_options_cgroup_ematches(struct tc_newchain_req *req, + const void *ematches, size_t len) +{ + req->_present.options = 1; + req->options._present.cgroup = 1; + free(req->options.cgroup.ematches); + req->options.cgroup._len.ematches = len; + req->options.cgroup.ematches = malloc(req->options.cgroup._len.ematches); + memcpy(req->options.cgroup.ematches, ematches, req->options.cgroup._len.ematches); +} +static inline void +tc_newchain_req_set_options_choke_parms(struct tc_newchain_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.choke = 1; + free(req->options.choke.parms); + req->options.choke._len.parms = len; + req->options.choke.parms = malloc(req->options.choke._len.parms); + memcpy(req->options.choke.parms, parms, req->options.choke._len.parms); +} +static inline void +tc_newchain_req_set_options_choke_stab(struct tc_newchain_req *req, + const void *stab, size_t len) +{ + req->_present.options = 1; + req->options._present.choke = 1; + free(req->options.choke.stab); + req->options.choke._len.stab = len; + req->options.choke.stab = malloc(req->options.choke._len.stab); + memcpy(req->options.choke.stab, stab, req->options.choke._len.stab); +} +static inline void +tc_newchain_req_set_options_choke_max_p(struct tc_newchain_req *req, + __u32 max_p) +{ + req->_present.options = 1; + req->options._present.choke = 1; + req->options.choke._present.max_p = 1; + req->options.choke.max_p = max_p; +} +static inline void +tc_newchain_req_set_options_clsact(struct tc_newchain_req *req) +{ + req->_present.options = 1; + req->options._present.clsact = 1; +} +static inline void +tc_newchain_req_set_options_codel_target(struct tc_newchain_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.target = 1; + req->options.codel.target = target; +} +static inline void +tc_newchain_req_set_options_codel_limit(struct tc_newchain_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.limit = 1; + req->options.codel.limit = limit; +} +static inline void +tc_newchain_req_set_options_codel_interval(struct tc_newchain_req *req, + __u32 interval) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.interval = 1; + req->options.codel.interval = interval; +} +static inline void +tc_newchain_req_set_options_codel_ecn(struct tc_newchain_req *req, __u32 ecn) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.ecn = 1; + req->options.codel.ecn = ecn; +} +static inline void +tc_newchain_req_set_options_codel_ce_threshold(struct tc_newchain_req *req, + __u32 ce_threshold) +{ + req->_present.options = 1; + req->options._present.codel = 1; + req->options.codel._present.ce_threshold = 1; + req->options.codel.ce_threshold = ce_threshold; +} +static inline void +tc_newchain_req_set_options_drr_quantum(struct tc_newchain_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.drr = 1; + req->options.drr._present.quantum = 1; + req->options.drr.quantum = quantum; +} +static inline void +tc_newchain_req_set_options_etf_parms(struct tc_newchain_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.etf = 1; + free(req->options.etf.parms); + req->options.etf._len.parms = len; + req->options.etf.parms = malloc(req->options.etf._len.parms); + memcpy(req->options.etf.parms, parms, req->options.etf._len.parms); +} +static inline void +tc_newchain_req_set_options_flow_keys(struct tc_newchain_req *req, __u32 keys) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.keys = 1; + req->options.flow.keys = keys; +} +static inline void +tc_newchain_req_set_options_flow_mode(struct tc_newchain_req *req, __u32 mode) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.mode = 1; + req->options.flow.mode = mode; +} +static inline void +tc_newchain_req_set_options_flow_baseclass(struct tc_newchain_req *req, + __u32 baseclass) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.baseclass = 1; + req->options.flow.baseclass = baseclass; +} +static inline void +tc_newchain_req_set_options_flow_rshift(struct tc_newchain_req *req, + __u32 rshift) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.rshift = 1; + req->options.flow.rshift = rshift; +} +static inline void +tc_newchain_req_set_options_flow_addend(struct tc_newchain_req *req, + __u32 addend) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.addend = 1; + req->options.flow.addend = addend; +} +static inline void +tc_newchain_req_set_options_flow_mask(struct tc_newchain_req *req, __u32 mask) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.mask = 1; + req->options.flow.mask = mask; +} +static inline void +tc_newchain_req_set_options_flow_xor(struct tc_newchain_req *req, __u32 xor) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.xor = 1; + req->options.flow.xor = xor; +} +static inline void +tc_newchain_req_set_options_flow_divisor(struct tc_newchain_req *req, + __u32 divisor) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.divisor = 1; + req->options.flow.divisor = divisor; +} +static inline void +tc_newchain_req_set_options_flow_act(struct tc_newchain_req *req, + const void *act, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + free(req->options.flow.act); + req->options.flow._len.act = len; + req->options.flow.act = malloc(req->options.flow._len.act); + memcpy(req->options.flow.act, act, req->options.flow._len.act); +} +static inline void +tc_newchain_req_set_options_flow_police_tbf(struct tc_newchain_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.tbf); + req->options.flow.police._len.tbf = len; + req->options.flow.police.tbf = malloc(req->options.flow.police._len.tbf); + memcpy(req->options.flow.police.tbf, tbf, req->options.flow.police._len.tbf); +} +static inline void +tc_newchain_req_set_options_flow_police_rate(struct tc_newchain_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.rate); + req->options.flow.police._len.rate = len; + req->options.flow.police.rate = malloc(req->options.flow.police._len.rate); + memcpy(req->options.flow.police.rate, rate, req->options.flow.police._len.rate); +} +static inline void +tc_newchain_req_set_options_flow_police_peakrate(struct tc_newchain_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.peakrate); + req->options.flow.police._len.peakrate = len; + req->options.flow.police.peakrate = malloc(req->options.flow.police._len.peakrate); + memcpy(req->options.flow.police.peakrate, peakrate, req->options.flow.police._len.peakrate); +} +static inline void +tc_newchain_req_set_options_flow_police_avrate(struct tc_newchain_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.avrate = 1; + req->options.flow.police.avrate = avrate; +} +static inline void +tc_newchain_req_set_options_flow_police_result(struct tc_newchain_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.result = 1; + req->options.flow.police.result = result; +} +static inline void +tc_newchain_req_set_options_flow_police_tm(struct tc_newchain_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + free(req->options.flow.police.tm); + req->options.flow.police._len.tm = len; + req->options.flow.police.tm = malloc(req->options.flow.police._len.tm); + memcpy(req->options.flow.police.tm, tm, req->options.flow.police._len.tm); +} +static inline void +tc_newchain_req_set_options_flow_police_rate64(struct tc_newchain_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.rate64 = 1; + req->options.flow.police.rate64 = rate64; +} +static inline void +tc_newchain_req_set_options_flow_police_peakrate64(struct tc_newchain_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.peakrate64 = 1; + req->options.flow.police.peakrate64 = peakrate64; +} +static inline void +tc_newchain_req_set_options_flow_police_pktrate64(struct tc_newchain_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.pktrate64 = 1; + req->options.flow.police.pktrate64 = pktrate64; +} +static inline void +tc_newchain_req_set_options_flow_police_pktburst64(struct tc_newchain_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.police = 1; + req->options.flow.police._present.pktburst64 = 1; + req->options.flow.police.pktburst64 = pktburst64; +} +static inline void +tc_newchain_req_set_options_flow_ematches(struct tc_newchain_req *req, + const void *ematches, size_t len) +{ + req->_present.options = 1; + req->options._present.flow = 1; + free(req->options.flow.ematches); + req->options.flow._len.ematches = len; + req->options.flow.ematches = malloc(req->options.flow._len.ematches); + memcpy(req->options.flow.ematches, ematches, req->options.flow._len.ematches); +} +static inline void +tc_newchain_req_set_options_flow_perturb(struct tc_newchain_req *req, + __u32 perturb) +{ + req->_present.options = 1; + req->options._present.flow = 1; + req->options.flow._present.perturb = 1; + req->options.flow.perturb = perturb; +} +static inline void +tc_newchain_req_set_options_flower_classid(struct tc_newchain_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.classid = 1; + req->options.flower.classid = classid; +} +static inline void +tc_newchain_req_set_options_flower_indev(struct tc_newchain_req *req, + const char *indev) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.indev); + req->options.flower._len.indev = strlen(indev); + req->options.flower.indev = malloc(req->options.flower._len.indev + 1); + memcpy(req->options.flower.indev, indev, req->options.flower._len.indev); + req->options.flower.indev[req->options.flower._len.indev] = 0; +} +static inline void +__tc_newchain_req_set_options_flower_act(struct tc_newchain_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.act); + req->options.flower.act = act; + req->options.flower._count.act = n_act; +} +static inline void +tc_newchain_req_set_options_flower_key_eth_dst(struct tc_newchain_req *req, + const void *key_eth_dst, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_dst); + req->options.flower._len.key_eth_dst = len; + req->options.flower.key_eth_dst = malloc(req->options.flower._len.key_eth_dst); + memcpy(req->options.flower.key_eth_dst, key_eth_dst, req->options.flower._len.key_eth_dst); +} +static inline void +tc_newchain_req_set_options_flower_key_eth_dst_mask(struct tc_newchain_req *req, + const void *key_eth_dst_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_dst_mask); + req->options.flower._len.key_eth_dst_mask = len; + req->options.flower.key_eth_dst_mask = malloc(req->options.flower._len.key_eth_dst_mask); + memcpy(req->options.flower.key_eth_dst_mask, key_eth_dst_mask, req->options.flower._len.key_eth_dst_mask); +} +static inline void +tc_newchain_req_set_options_flower_key_eth_src(struct tc_newchain_req *req, + const void *key_eth_src, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_src); + req->options.flower._len.key_eth_src = len; + req->options.flower.key_eth_src = malloc(req->options.flower._len.key_eth_src); + memcpy(req->options.flower.key_eth_src, key_eth_src, req->options.flower._len.key_eth_src); +} +static inline void +tc_newchain_req_set_options_flower_key_eth_src_mask(struct tc_newchain_req *req, + const void *key_eth_src_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_eth_src_mask); + req->options.flower._len.key_eth_src_mask = len; + req->options.flower.key_eth_src_mask = malloc(req->options.flower._len.key_eth_src_mask); + memcpy(req->options.flower.key_eth_src_mask, key_eth_src_mask, req->options.flower._len.key_eth_src_mask); +} +static inline void +tc_newchain_req_set_options_flower_key_eth_type(struct tc_newchain_req *req, + __u16 key_eth_type /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_eth_type = 1; + req->options.flower.key_eth_type = key_eth_type; +} +static inline void +tc_newchain_req_set_options_flower_key_ip_proto(struct tc_newchain_req *req, + __u8 key_ip_proto) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_proto = 1; + req->options.flower.key_ip_proto = key_ip_proto; +} +static inline void +tc_newchain_req_set_options_flower_key_ipv4_src(struct tc_newchain_req *req, + __u32 key_ipv4_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_src = 1; + req->options.flower.key_ipv4_src = key_ipv4_src; +} +static inline void +tc_newchain_req_set_options_flower_key_ipv4_src_mask(struct tc_newchain_req *req, + __u32 key_ipv4_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_src_mask = 1; + req->options.flower.key_ipv4_src_mask = key_ipv4_src_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_ipv4_dst(struct tc_newchain_req *req, + __u32 key_ipv4_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_dst = 1; + req->options.flower.key_ipv4_dst = key_ipv4_dst; +} +static inline void +tc_newchain_req_set_options_flower_key_ipv4_dst_mask(struct tc_newchain_req *req, + __u32 key_ipv4_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ipv4_dst_mask = 1; + req->options.flower.key_ipv4_dst_mask = key_ipv4_dst_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_ipv6_src(struct tc_newchain_req *req, + const void *key_ipv6_src, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_src); + req->options.flower._len.key_ipv6_src = len; + req->options.flower.key_ipv6_src = malloc(req->options.flower._len.key_ipv6_src); + memcpy(req->options.flower.key_ipv6_src, key_ipv6_src, req->options.flower._len.key_ipv6_src); +} +static inline void +tc_newchain_req_set_options_flower_key_ipv6_src_mask(struct tc_newchain_req *req, + const void *key_ipv6_src_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_src_mask); + req->options.flower._len.key_ipv6_src_mask = len; + req->options.flower.key_ipv6_src_mask = malloc(req->options.flower._len.key_ipv6_src_mask); + memcpy(req->options.flower.key_ipv6_src_mask, key_ipv6_src_mask, req->options.flower._len.key_ipv6_src_mask); +} +static inline void +tc_newchain_req_set_options_flower_key_ipv6_dst(struct tc_newchain_req *req, + const void *key_ipv6_dst, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_dst); + req->options.flower._len.key_ipv6_dst = len; + req->options.flower.key_ipv6_dst = malloc(req->options.flower._len.key_ipv6_dst); + memcpy(req->options.flower.key_ipv6_dst, key_ipv6_dst, req->options.flower._len.key_ipv6_dst); +} +static inline void +tc_newchain_req_set_options_flower_key_ipv6_dst_mask(struct tc_newchain_req *req, + const void *key_ipv6_dst_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ipv6_dst_mask); + req->options.flower._len.key_ipv6_dst_mask = len; + req->options.flower.key_ipv6_dst_mask = malloc(req->options.flower._len.key_ipv6_dst_mask); + memcpy(req->options.flower.key_ipv6_dst_mask, key_ipv6_dst_mask, req->options.flower._len.key_ipv6_dst_mask); +} +static inline void +tc_newchain_req_set_options_flower_key_tcp_src(struct tc_newchain_req *req, + __u16 key_tcp_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_src = 1; + req->options.flower.key_tcp_src = key_tcp_src; +} +static inline void +tc_newchain_req_set_options_flower_key_tcp_dst(struct tc_newchain_req *req, + __u16 key_tcp_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_dst = 1; + req->options.flower.key_tcp_dst = key_tcp_dst; +} +static inline void +tc_newchain_req_set_options_flower_key_udp_src(struct tc_newchain_req *req, + __u16 key_udp_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_src = 1; + req->options.flower.key_udp_src = key_udp_src; +} +static inline void +tc_newchain_req_set_options_flower_key_udp_dst(struct tc_newchain_req *req, + __u16 key_udp_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_dst = 1; + req->options.flower.key_udp_dst = key_udp_dst; +} +static inline void +tc_newchain_req_set_options_flower_flags(struct tc_newchain_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.flags = 1; + req->options.flower.flags = flags; +} +static inline void +tc_newchain_req_set_options_flower_key_vlan_id(struct tc_newchain_req *req, + __u16 key_vlan_id /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_vlan_id = 1; + req->options.flower.key_vlan_id = key_vlan_id; +} +static inline void +tc_newchain_req_set_options_flower_key_vlan_prio(struct tc_newchain_req *req, + __u8 key_vlan_prio) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_vlan_prio = 1; + req->options.flower.key_vlan_prio = key_vlan_prio; +} +static inline void +tc_newchain_req_set_options_flower_key_vlan_eth_type(struct tc_newchain_req *req, + __u16 key_vlan_eth_type /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_vlan_eth_type = 1; + req->options.flower.key_vlan_eth_type = key_vlan_eth_type; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_key_id(struct tc_newchain_req *req, + __u32 key_enc_key_id /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_key_id = 1; + req->options.flower.key_enc_key_id = key_enc_key_id; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_ipv4_src(struct tc_newchain_req *req, + __u32 key_enc_ipv4_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_src = 1; + req->options.flower.key_enc_ipv4_src = key_enc_ipv4_src; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_ipv4_src_mask(struct tc_newchain_req *req, + __u32 key_enc_ipv4_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_src_mask = 1; + req->options.flower.key_enc_ipv4_src_mask = key_enc_ipv4_src_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_ipv4_dst(struct tc_newchain_req *req, + __u32 key_enc_ipv4_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_dst = 1; + req->options.flower.key_enc_ipv4_dst = key_enc_ipv4_dst; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_ipv4_dst_mask(struct tc_newchain_req *req, + __u32 key_enc_ipv4_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ipv4_dst_mask = 1; + req->options.flower.key_enc_ipv4_dst_mask = key_enc_ipv4_dst_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_ipv6_src(struct tc_newchain_req *req, + const void *key_enc_ipv6_src, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_src); + req->options.flower._len.key_enc_ipv6_src = len; + req->options.flower.key_enc_ipv6_src = malloc(req->options.flower._len.key_enc_ipv6_src); + memcpy(req->options.flower.key_enc_ipv6_src, key_enc_ipv6_src, req->options.flower._len.key_enc_ipv6_src); +} +static inline void +tc_newchain_req_set_options_flower_key_enc_ipv6_src_mask(struct tc_newchain_req *req, + const void *key_enc_ipv6_src_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_src_mask); + req->options.flower._len.key_enc_ipv6_src_mask = len; + req->options.flower.key_enc_ipv6_src_mask = malloc(req->options.flower._len.key_enc_ipv6_src_mask); + memcpy(req->options.flower.key_enc_ipv6_src_mask, key_enc_ipv6_src_mask, req->options.flower._len.key_enc_ipv6_src_mask); +} +static inline void +tc_newchain_req_set_options_flower_key_enc_ipv6_dst(struct tc_newchain_req *req, + const void *key_enc_ipv6_dst, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_dst); + req->options.flower._len.key_enc_ipv6_dst = len; + req->options.flower.key_enc_ipv6_dst = malloc(req->options.flower._len.key_enc_ipv6_dst); + memcpy(req->options.flower.key_enc_ipv6_dst, key_enc_ipv6_dst, req->options.flower._len.key_enc_ipv6_dst); +} +static inline void +tc_newchain_req_set_options_flower_key_enc_ipv6_dst_mask(struct tc_newchain_req *req, + const void *key_enc_ipv6_dst_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_enc_ipv6_dst_mask); + req->options.flower._len.key_enc_ipv6_dst_mask = len; + req->options.flower.key_enc_ipv6_dst_mask = malloc(req->options.flower._len.key_enc_ipv6_dst_mask); + memcpy(req->options.flower.key_enc_ipv6_dst_mask, key_enc_ipv6_dst_mask, req->options.flower._len.key_enc_ipv6_dst_mask); +} +static inline void +tc_newchain_req_set_options_flower_key_tcp_src_mask(struct tc_newchain_req *req, + __u16 key_tcp_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_src_mask = 1; + req->options.flower.key_tcp_src_mask = key_tcp_src_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_tcp_dst_mask(struct tc_newchain_req *req, + __u16 key_tcp_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_dst_mask = 1; + req->options.flower.key_tcp_dst_mask = key_tcp_dst_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_udp_src_mask(struct tc_newchain_req *req, + __u16 key_udp_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_src_mask = 1; + req->options.flower.key_udp_src_mask = key_udp_src_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_udp_dst_mask(struct tc_newchain_req *req, + __u16 key_udp_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_udp_dst_mask = 1; + req->options.flower.key_udp_dst_mask = key_udp_dst_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_sctp_src_mask(struct tc_newchain_req *req, + __u16 key_sctp_src_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_src_mask = 1; + req->options.flower.key_sctp_src_mask = key_sctp_src_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_sctp_dst_mask(struct tc_newchain_req *req, + __u16 key_sctp_dst_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_dst_mask = 1; + req->options.flower.key_sctp_dst_mask = key_sctp_dst_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_sctp_src(struct tc_newchain_req *req, + __u16 key_sctp_src /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_src = 1; + req->options.flower.key_sctp_src = key_sctp_src; +} +static inline void +tc_newchain_req_set_options_flower_key_sctp_dst(struct tc_newchain_req *req, + __u16 key_sctp_dst /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_sctp_dst = 1; + req->options.flower.key_sctp_dst = key_sctp_dst; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_udp_src_port(struct tc_newchain_req *req, + __u16 key_enc_udp_src_port /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_src_port = 1; + req->options.flower.key_enc_udp_src_port = key_enc_udp_src_port; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_udp_src_port_mask(struct tc_newchain_req *req, + __u16 key_enc_udp_src_port_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_src_port_mask = 1; + req->options.flower.key_enc_udp_src_port_mask = key_enc_udp_src_port_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_udp_dst_port(struct tc_newchain_req *req, + __u16 key_enc_udp_dst_port /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_dst_port = 1; + req->options.flower.key_enc_udp_dst_port = key_enc_udp_dst_port; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_udp_dst_port_mask(struct tc_newchain_req *req, + __u16 key_enc_udp_dst_port_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_udp_dst_port_mask = 1; + req->options.flower.key_enc_udp_dst_port_mask = key_enc_udp_dst_port_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_flags(struct tc_newchain_req *req, + __u32 key_flags /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_flags = 1; + req->options.flower.key_flags = key_flags; +} +static inline void +tc_newchain_req_set_options_flower_key_flags_mask(struct tc_newchain_req *req, + __u32 key_flags_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_flags_mask = 1; + req->options.flower.key_flags_mask = key_flags_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_icmpv4_code(struct tc_newchain_req *req, + __u8 key_icmpv4_code) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_code = 1; + req->options.flower.key_icmpv4_code = key_icmpv4_code; +} +static inline void +tc_newchain_req_set_options_flower_key_icmpv4_code_mask(struct tc_newchain_req *req, + __u8 key_icmpv4_code_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_code_mask = 1; + req->options.flower.key_icmpv4_code_mask = key_icmpv4_code_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_icmpv4_type(struct tc_newchain_req *req, + __u8 key_icmpv4_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_type = 1; + req->options.flower.key_icmpv4_type = key_icmpv4_type; +} +static inline void +tc_newchain_req_set_options_flower_key_icmpv4_type_mask(struct tc_newchain_req *req, + __u8 key_icmpv4_type_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv4_type_mask = 1; + req->options.flower.key_icmpv4_type_mask = key_icmpv4_type_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_icmpv6_code(struct tc_newchain_req *req, + __u8 key_icmpv6_code) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_code = 1; + req->options.flower.key_icmpv6_code = key_icmpv6_code; +} +static inline void +tc_newchain_req_set_options_flower_key_icmpv6_code_mask(struct tc_newchain_req *req, + __u8 key_icmpv6_code_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_code_mask = 1; + req->options.flower.key_icmpv6_code_mask = key_icmpv6_code_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_icmpv6_type(struct tc_newchain_req *req, + __u8 key_icmpv6_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_type = 1; + req->options.flower.key_icmpv6_type = key_icmpv6_type; +} +static inline void +tc_newchain_req_set_options_flower_key_icmpv6_type_mask(struct tc_newchain_req *req, + __u8 key_icmpv6_type_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_icmpv6_type_mask = 1; + req->options.flower.key_icmpv6_type_mask = key_icmpv6_type_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_arp_sip(struct tc_newchain_req *req, + __u32 key_arp_sip /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_sip = 1; + req->options.flower.key_arp_sip = key_arp_sip; +} +static inline void +tc_newchain_req_set_options_flower_key_arp_sip_mask(struct tc_newchain_req *req, + __u32 key_arp_sip_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_sip_mask = 1; + req->options.flower.key_arp_sip_mask = key_arp_sip_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_arp_tip(struct tc_newchain_req *req, + __u32 key_arp_tip /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_tip = 1; + req->options.flower.key_arp_tip = key_arp_tip; +} +static inline void +tc_newchain_req_set_options_flower_key_arp_tip_mask(struct tc_newchain_req *req, + __u32 key_arp_tip_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_tip_mask = 1; + req->options.flower.key_arp_tip_mask = key_arp_tip_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_arp_op(struct tc_newchain_req *req, + __u8 key_arp_op) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_op = 1; + req->options.flower.key_arp_op = key_arp_op; +} +static inline void +tc_newchain_req_set_options_flower_key_arp_op_mask(struct tc_newchain_req *req, + __u8 key_arp_op_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_arp_op_mask = 1; + req->options.flower.key_arp_op_mask = key_arp_op_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_arp_sha(struct tc_newchain_req *req, + const void *key_arp_sha, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_sha); + req->options.flower._len.key_arp_sha = len; + req->options.flower.key_arp_sha = malloc(req->options.flower._len.key_arp_sha); + memcpy(req->options.flower.key_arp_sha, key_arp_sha, req->options.flower._len.key_arp_sha); +} +static inline void +tc_newchain_req_set_options_flower_key_arp_sha_mask(struct tc_newchain_req *req, + const void *key_arp_sha_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_sha_mask); + req->options.flower._len.key_arp_sha_mask = len; + req->options.flower.key_arp_sha_mask = malloc(req->options.flower._len.key_arp_sha_mask); + memcpy(req->options.flower.key_arp_sha_mask, key_arp_sha_mask, req->options.flower._len.key_arp_sha_mask); +} +static inline void +tc_newchain_req_set_options_flower_key_arp_tha(struct tc_newchain_req *req, + const void *key_arp_tha, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_tha); + req->options.flower._len.key_arp_tha = len; + req->options.flower.key_arp_tha = malloc(req->options.flower._len.key_arp_tha); + memcpy(req->options.flower.key_arp_tha, key_arp_tha, req->options.flower._len.key_arp_tha); +} +static inline void +tc_newchain_req_set_options_flower_key_arp_tha_mask(struct tc_newchain_req *req, + const void *key_arp_tha_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_arp_tha_mask); + req->options.flower._len.key_arp_tha_mask = len; + req->options.flower.key_arp_tha_mask = malloc(req->options.flower._len.key_arp_tha_mask); + memcpy(req->options.flower.key_arp_tha_mask, key_arp_tha_mask, req->options.flower._len.key_arp_tha_mask); +} +static inline void +tc_newchain_req_set_options_flower_key_mpls_ttl(struct tc_newchain_req *req, + __u8 key_mpls_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_ttl = 1; + req->options.flower.key_mpls_ttl = key_mpls_ttl; +} +static inline void +tc_newchain_req_set_options_flower_key_mpls_bos(struct tc_newchain_req *req, + __u8 key_mpls_bos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_bos = 1; + req->options.flower.key_mpls_bos = key_mpls_bos; +} +static inline void +tc_newchain_req_set_options_flower_key_mpls_tc(struct tc_newchain_req *req, + __u8 key_mpls_tc) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_tc = 1; + req->options.flower.key_mpls_tc = key_mpls_tc; +} +static inline void +tc_newchain_req_set_options_flower_key_mpls_label(struct tc_newchain_req *req, + __u32 key_mpls_label /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_label = 1; + req->options.flower.key_mpls_label = key_mpls_label; +} +static inline void +tc_newchain_req_set_options_flower_key_tcp_flags(struct tc_newchain_req *req, + __u16 key_tcp_flags /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_flags = 1; + req->options.flower.key_tcp_flags = key_tcp_flags; +} +static inline void +tc_newchain_req_set_options_flower_key_tcp_flags_mask(struct tc_newchain_req *req, + __u16 key_tcp_flags_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_tcp_flags_mask = 1; + req->options.flower.key_tcp_flags_mask = key_tcp_flags_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_ip_tos(struct tc_newchain_req *req, + __u8 key_ip_tos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_tos = 1; + req->options.flower.key_ip_tos = key_ip_tos; +} +static inline void +tc_newchain_req_set_options_flower_key_ip_tos_mask(struct tc_newchain_req *req, + __u8 key_ip_tos_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_tos_mask = 1; + req->options.flower.key_ip_tos_mask = key_ip_tos_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_ip_ttl(struct tc_newchain_req *req, + __u8 key_ip_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_ttl = 1; + req->options.flower.key_ip_ttl = key_ip_ttl; +} +static inline void +tc_newchain_req_set_options_flower_key_ip_ttl_mask(struct tc_newchain_req *req, + __u8 key_ip_ttl_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ip_ttl_mask = 1; + req->options.flower.key_ip_ttl_mask = key_ip_ttl_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_cvlan_id(struct tc_newchain_req *req, + __u16 key_cvlan_id /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cvlan_id = 1; + req->options.flower.key_cvlan_id = key_cvlan_id; +} +static inline void +tc_newchain_req_set_options_flower_key_cvlan_prio(struct tc_newchain_req *req, + __u8 key_cvlan_prio) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cvlan_prio = 1; + req->options.flower.key_cvlan_prio = key_cvlan_prio; +} +static inline void +tc_newchain_req_set_options_flower_key_cvlan_eth_type(struct tc_newchain_req *req, + __u16 key_cvlan_eth_type /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cvlan_eth_type = 1; + req->options.flower.key_cvlan_eth_type = key_cvlan_eth_type; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_ip_tos(struct tc_newchain_req *req, + __u8 key_enc_ip_tos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_tos = 1; + req->options.flower.key_enc_ip_tos = key_enc_ip_tos; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_ip_tos_mask(struct tc_newchain_req *req, + __u8 key_enc_ip_tos_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_tos_mask = 1; + req->options.flower.key_enc_ip_tos_mask = key_enc_ip_tos_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_ip_ttl(struct tc_newchain_req *req, + __u8 key_enc_ip_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_ttl = 1; + req->options.flower.key_enc_ip_ttl = key_enc_ip_ttl; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_ip_ttl_mask(struct tc_newchain_req *req, + __u8 key_enc_ip_ttl_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_ip_ttl_mask = 1; + req->options.flower.key_enc_ip_ttl_mask = key_enc_ip_ttl_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_geneve_class(struct tc_newchain_req *req, + __u16 class) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.geneve = 1; + req->options.flower.key_enc_opts.geneve._present.class = 1; + req->options.flower.key_enc_opts.geneve.class = class; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_geneve_type(struct tc_newchain_req *req, + __u8 type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.geneve = 1; + req->options.flower.key_enc_opts.geneve._present.type = 1; + req->options.flower.key_enc_opts.geneve.type = type; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_geneve_data(struct tc_newchain_req *req, + const void *data, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.geneve = 1; + free(req->options.flower.key_enc_opts.geneve.data); + req->options.flower.key_enc_opts.geneve._len.data = len; + req->options.flower.key_enc_opts.geneve.data = malloc(req->options.flower.key_enc_opts.geneve._len.data); + memcpy(req->options.flower.key_enc_opts.geneve.data, data, req->options.flower.key_enc_opts.geneve._len.data); +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_vxlan_gbp(struct tc_newchain_req *req, + __u32 gbp) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.vxlan = 1; + req->options.flower.key_enc_opts.vxlan._present.gbp = 1; + req->options.flower.key_enc_opts.vxlan.gbp = gbp; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_erspan_ver(struct tc_newchain_req *req, + __u8 ver) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.ver = 1; + req->options.flower.key_enc_opts.erspan.ver = ver; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_erspan_index(struct tc_newchain_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.index = 1; + req->options.flower.key_enc_opts.erspan.index = index; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_erspan_dir(struct tc_newchain_req *req, + __u8 dir) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.dir = 1; + req->options.flower.key_enc_opts.erspan.dir = dir; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_erspan_hwid(struct tc_newchain_req *req, + __u8 hwid) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.erspan = 1; + req->options.flower.key_enc_opts.erspan._present.hwid = 1; + req->options.flower.key_enc_opts.erspan.hwid = hwid; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_gtp_pdu_type(struct tc_newchain_req *req, + __u8 pdu_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.gtp = 1; + req->options.flower.key_enc_opts.gtp._present.pdu_type = 1; + req->options.flower.key_enc_opts.gtp.pdu_type = pdu_type; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_gtp_qfi(struct tc_newchain_req *req, + __u8 qfi) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts = 1; + req->options.flower.key_enc_opts._present.gtp = 1; + req->options.flower.key_enc_opts.gtp._present.qfi = 1; + req->options.flower.key_enc_opts.gtp.qfi = qfi; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_mask_geneve_class(struct tc_newchain_req *req, + __u16 class) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.geneve = 1; + req->options.flower.key_enc_opts_mask.geneve._present.class = 1; + req->options.flower.key_enc_opts_mask.geneve.class = class; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_mask_geneve_type(struct tc_newchain_req *req, + __u8 type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.geneve = 1; + req->options.flower.key_enc_opts_mask.geneve._present.type = 1; + req->options.flower.key_enc_opts_mask.geneve.type = type; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_mask_geneve_data(struct tc_newchain_req *req, + const void *data, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.geneve = 1; + free(req->options.flower.key_enc_opts_mask.geneve.data); + req->options.flower.key_enc_opts_mask.geneve._len.data = len; + req->options.flower.key_enc_opts_mask.geneve.data = malloc(req->options.flower.key_enc_opts_mask.geneve._len.data); + memcpy(req->options.flower.key_enc_opts_mask.geneve.data, data, req->options.flower.key_enc_opts_mask.geneve._len.data); +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_mask_vxlan_gbp(struct tc_newchain_req *req, + __u32 gbp) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.vxlan = 1; + req->options.flower.key_enc_opts_mask.vxlan._present.gbp = 1; + req->options.flower.key_enc_opts_mask.vxlan.gbp = gbp; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_mask_erspan_ver(struct tc_newchain_req *req, + __u8 ver) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.ver = 1; + req->options.flower.key_enc_opts_mask.erspan.ver = ver; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_mask_erspan_index(struct tc_newchain_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.index = 1; + req->options.flower.key_enc_opts_mask.erspan.index = index; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_mask_erspan_dir(struct tc_newchain_req *req, + __u8 dir) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.dir = 1; + req->options.flower.key_enc_opts_mask.erspan.dir = dir; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_mask_erspan_hwid(struct tc_newchain_req *req, + __u8 hwid) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.erspan = 1; + req->options.flower.key_enc_opts_mask.erspan._present.hwid = 1; + req->options.flower.key_enc_opts_mask.erspan.hwid = hwid; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_mask_gtp_pdu_type(struct tc_newchain_req *req, + __u8 pdu_type) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.gtp = 1; + req->options.flower.key_enc_opts_mask.gtp._present.pdu_type = 1; + req->options.flower.key_enc_opts_mask.gtp.pdu_type = pdu_type; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_opts_mask_gtp_qfi(struct tc_newchain_req *req, + __u8 qfi) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_opts_mask = 1; + req->options.flower.key_enc_opts_mask._present.gtp = 1; + req->options.flower.key_enc_opts_mask.gtp._present.qfi = 1; + req->options.flower.key_enc_opts_mask.gtp.qfi = qfi; +} +static inline void +tc_newchain_req_set_options_flower_in_hw_count(struct tc_newchain_req *req, + __u32 in_hw_count) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.in_hw_count = 1; + req->options.flower.in_hw_count = in_hw_count; +} +static inline void +tc_newchain_req_set_options_flower_key_port_src_min(struct tc_newchain_req *req, + __u16 key_port_src_min /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_src_min = 1; + req->options.flower.key_port_src_min = key_port_src_min; +} +static inline void +tc_newchain_req_set_options_flower_key_port_src_max(struct tc_newchain_req *req, + __u16 key_port_src_max /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_src_max = 1; + req->options.flower.key_port_src_max = key_port_src_max; +} +static inline void +tc_newchain_req_set_options_flower_key_port_dst_min(struct tc_newchain_req *req, + __u16 key_port_dst_min /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_dst_min = 1; + req->options.flower.key_port_dst_min = key_port_dst_min; +} +static inline void +tc_newchain_req_set_options_flower_key_port_dst_max(struct tc_newchain_req *req, + __u16 key_port_dst_max /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_port_dst_max = 1; + req->options.flower.key_port_dst_max = key_port_dst_max; +} +static inline void +tc_newchain_req_set_options_flower_key_ct_state(struct tc_newchain_req *req, + __u16 key_ct_state) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_state = 1; + req->options.flower.key_ct_state = key_ct_state; +} +static inline void +tc_newchain_req_set_options_flower_key_ct_state_mask(struct tc_newchain_req *req, + __u16 key_ct_state_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_state_mask = 1; + req->options.flower.key_ct_state_mask = key_ct_state_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_ct_zone(struct tc_newchain_req *req, + __u16 key_ct_zone) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_zone = 1; + req->options.flower.key_ct_zone = key_ct_zone; +} +static inline void +tc_newchain_req_set_options_flower_key_ct_zone_mask(struct tc_newchain_req *req, + __u16 key_ct_zone_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_zone_mask = 1; + req->options.flower.key_ct_zone_mask = key_ct_zone_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_ct_mark(struct tc_newchain_req *req, + __u32 key_ct_mark) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_mark = 1; + req->options.flower.key_ct_mark = key_ct_mark; +} +static inline void +tc_newchain_req_set_options_flower_key_ct_mark_mask(struct tc_newchain_req *req, + __u32 key_ct_mark_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ct_mark_mask = 1; + req->options.flower.key_ct_mark_mask = key_ct_mark_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_ct_labels(struct tc_newchain_req *req, + const void *key_ct_labels, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ct_labels); + req->options.flower._len.key_ct_labels = len; + req->options.flower.key_ct_labels = malloc(req->options.flower._len.key_ct_labels); + memcpy(req->options.flower.key_ct_labels, key_ct_labels, req->options.flower._len.key_ct_labels); +} +static inline void +tc_newchain_req_set_options_flower_key_ct_labels_mask(struct tc_newchain_req *req, + const void *key_ct_labels_mask, + size_t len) +{ + req->_present.options = 1; + req->options._present.flower = 1; + free(req->options.flower.key_ct_labels_mask); + req->options.flower._len.key_ct_labels_mask = len; + req->options.flower.key_ct_labels_mask = malloc(req->options.flower._len.key_ct_labels_mask); + memcpy(req->options.flower.key_ct_labels_mask, key_ct_labels_mask, req->options.flower._len.key_ct_labels_mask); +} +static inline void +tc_newchain_req_set_options_flower_key_mpls_opts_lse_depth(struct tc_newchain_req *req, + __u8 lse_depth) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_depth = 1; + req->options.flower.key_mpls_opts.lse_depth = lse_depth; +} +static inline void +tc_newchain_req_set_options_flower_key_mpls_opts_lse_ttl(struct tc_newchain_req *req, + __u8 lse_ttl) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_ttl = 1; + req->options.flower.key_mpls_opts.lse_ttl = lse_ttl; +} +static inline void +tc_newchain_req_set_options_flower_key_mpls_opts_lse_bos(struct tc_newchain_req *req, + __u8 lse_bos) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_bos = 1; + req->options.flower.key_mpls_opts.lse_bos = lse_bos; +} +static inline void +tc_newchain_req_set_options_flower_key_mpls_opts_lse_tc(struct tc_newchain_req *req, + __u8 lse_tc) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_tc = 1; + req->options.flower.key_mpls_opts.lse_tc = lse_tc; +} +static inline void +tc_newchain_req_set_options_flower_key_mpls_opts_lse_label(struct tc_newchain_req *req, + __u32 lse_label) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_mpls_opts = 1; + req->options.flower.key_mpls_opts._present.lse_label = 1; + req->options.flower.key_mpls_opts.lse_label = lse_label; +} +static inline void +tc_newchain_req_set_options_flower_key_hash(struct tc_newchain_req *req, + __u32 key_hash) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_hash = 1; + req->options.flower.key_hash = key_hash; +} +static inline void +tc_newchain_req_set_options_flower_key_hash_mask(struct tc_newchain_req *req, + __u32 key_hash_mask) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_hash_mask = 1; + req->options.flower.key_hash_mask = key_hash_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_num_of_vlans(struct tc_newchain_req *req, + __u8 key_num_of_vlans) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_num_of_vlans = 1; + req->options.flower.key_num_of_vlans = key_num_of_vlans; +} +static inline void +tc_newchain_req_set_options_flower_key_pppoe_sid(struct tc_newchain_req *req, + __u16 key_pppoe_sid /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_pppoe_sid = 1; + req->options.flower.key_pppoe_sid = key_pppoe_sid; +} +static inline void +tc_newchain_req_set_options_flower_key_ppp_proto(struct tc_newchain_req *req, + __u16 key_ppp_proto /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_ppp_proto = 1; + req->options.flower.key_ppp_proto = key_ppp_proto; +} +static inline void +tc_newchain_req_set_options_flower_key_l2tpv3_sid(struct tc_newchain_req *req, + __u32 key_l2tpv3_sid /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_l2tpv3_sid = 1; + req->options.flower.key_l2tpv3_sid = key_l2tpv3_sid; +} +static inline void +tc_newchain_req_set_options_flower_l2_miss(struct tc_newchain_req *req, + __u8 l2_miss) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.l2_miss = 1; + req->options.flower.l2_miss = l2_miss; +} +static inline void +tc_newchain_req_set_options_flower_key_cfm_md_level(struct tc_newchain_req *req, + __u8 md_level) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cfm = 1; + req->options.flower.key_cfm._present.md_level = 1; + req->options.flower.key_cfm.md_level = md_level; +} +static inline void +tc_newchain_req_set_options_flower_key_cfm_opcode(struct tc_newchain_req *req, + __u8 opcode) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_cfm = 1; + req->options.flower.key_cfm._present.opcode = 1; + req->options.flower.key_cfm.opcode = opcode; +} +static inline void +tc_newchain_req_set_options_flower_key_spi(struct tc_newchain_req *req, + __u32 key_spi /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_spi = 1; + req->options.flower.key_spi = key_spi; +} +static inline void +tc_newchain_req_set_options_flower_key_spi_mask(struct tc_newchain_req *req, + __u32 key_spi_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_spi_mask = 1; + req->options.flower.key_spi_mask = key_spi_mask; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_flags(struct tc_newchain_req *req, + __u32 key_enc_flags /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_flags = 1; + req->options.flower.key_enc_flags = key_enc_flags; +} +static inline void +tc_newchain_req_set_options_flower_key_enc_flags_mask(struct tc_newchain_req *req, + __u32 key_enc_flags_mask /* big-endian */) +{ + req->_present.options = 1; + req->options._present.flower = 1; + req->options.flower._present.key_enc_flags_mask = 1; + req->options.flower.key_enc_flags_mask = key_enc_flags_mask; +} +static inline void +tc_newchain_req_set_options_fq_plimit(struct tc_newchain_req *req, + __u32 plimit) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.plimit = 1; + req->options.fq.plimit = plimit; +} +static inline void +tc_newchain_req_set_options_fq_flow_plimit(struct tc_newchain_req *req, + __u32 flow_plimit) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_plimit = 1; + req->options.fq.flow_plimit = flow_plimit; +} +static inline void +tc_newchain_req_set_options_fq_quantum(struct tc_newchain_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.quantum = 1; + req->options.fq.quantum = quantum; +} +static inline void +tc_newchain_req_set_options_fq_initial_quantum(struct tc_newchain_req *req, + __u32 initial_quantum) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.initial_quantum = 1; + req->options.fq.initial_quantum = initial_quantum; +} +static inline void +tc_newchain_req_set_options_fq_rate_enable(struct tc_newchain_req *req, + __u32 rate_enable) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.rate_enable = 1; + req->options.fq.rate_enable = rate_enable; +} +static inline void +tc_newchain_req_set_options_fq_flow_default_rate(struct tc_newchain_req *req, + __u32 flow_default_rate) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_default_rate = 1; + req->options.fq.flow_default_rate = flow_default_rate; +} +static inline void +tc_newchain_req_set_options_fq_flow_max_rate(struct tc_newchain_req *req, + __u32 flow_max_rate) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_max_rate = 1; + req->options.fq.flow_max_rate = flow_max_rate; +} +static inline void +tc_newchain_req_set_options_fq_buckets_log(struct tc_newchain_req *req, + __u32 buckets_log) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.buckets_log = 1; + req->options.fq.buckets_log = buckets_log; +} +static inline void +tc_newchain_req_set_options_fq_flow_refill_delay(struct tc_newchain_req *req, + __u32 flow_refill_delay) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.flow_refill_delay = 1; + req->options.fq.flow_refill_delay = flow_refill_delay; +} +static inline void +tc_newchain_req_set_options_fq_orphan_mask(struct tc_newchain_req *req, + __u32 orphan_mask) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.orphan_mask = 1; + req->options.fq.orphan_mask = orphan_mask; +} +static inline void +tc_newchain_req_set_options_fq_low_rate_threshold(struct tc_newchain_req *req, + __u32 low_rate_threshold) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.low_rate_threshold = 1; + req->options.fq.low_rate_threshold = low_rate_threshold; +} +static inline void +tc_newchain_req_set_options_fq_ce_threshold(struct tc_newchain_req *req, + __u32 ce_threshold) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.ce_threshold = 1; + req->options.fq.ce_threshold = ce_threshold; +} +static inline void +tc_newchain_req_set_options_fq_timer_slack(struct tc_newchain_req *req, + __u32 timer_slack) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.timer_slack = 1; + req->options.fq.timer_slack = timer_slack; +} +static inline void +tc_newchain_req_set_options_fq_horizon(struct tc_newchain_req *req, + __u32 horizon) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.horizon = 1; + req->options.fq.horizon = horizon; +} +static inline void +tc_newchain_req_set_options_fq_horizon_drop(struct tc_newchain_req *req, + __u8 horizon_drop) +{ + req->_present.options = 1; + req->options._present.fq = 1; + req->options.fq._present.horizon_drop = 1; + req->options.fq.horizon_drop = horizon_drop; +} +static inline void +tc_newchain_req_set_options_fq_priomap(struct tc_newchain_req *req, + const void *priomap, size_t len) +{ + req->_present.options = 1; + req->options._present.fq = 1; + free(req->options.fq.priomap); + req->options.fq._len.priomap = len; + req->options.fq.priomap = malloc(req->options.fq._len.priomap); + memcpy(req->options.fq.priomap, priomap, req->options.fq._len.priomap); +} +static inline void +tc_newchain_req_set_options_fq_weights(struct tc_newchain_req *req, + __s32 *weights, size_t count) +{ + req->_present.options = 1; + req->options._present.fq = 1; + free(req->options.fq.weights); + req->options.fq._count.weights = count; + count *= sizeof(__s32); + req->options.fq.weights = malloc(count); + memcpy(req->options.fq.weights, weights, count); +} +static inline void +tc_newchain_req_set_options_fq_codel_target(struct tc_newchain_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.target = 1; + req->options.fq_codel.target = target; +} +static inline void +tc_newchain_req_set_options_fq_codel_limit(struct tc_newchain_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.limit = 1; + req->options.fq_codel.limit = limit; +} +static inline void +tc_newchain_req_set_options_fq_codel_interval(struct tc_newchain_req *req, + __u32 interval) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.interval = 1; + req->options.fq_codel.interval = interval; +} +static inline void +tc_newchain_req_set_options_fq_codel_ecn(struct tc_newchain_req *req, + __u32 ecn) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ecn = 1; + req->options.fq_codel.ecn = ecn; +} +static inline void +tc_newchain_req_set_options_fq_codel_flows(struct tc_newchain_req *req, + __u32 flows) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.flows = 1; + req->options.fq_codel.flows = flows; +} +static inline void +tc_newchain_req_set_options_fq_codel_quantum(struct tc_newchain_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.quantum = 1; + req->options.fq_codel.quantum = quantum; +} +static inline void +tc_newchain_req_set_options_fq_codel_ce_threshold(struct tc_newchain_req *req, + __u32 ce_threshold) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ce_threshold = 1; + req->options.fq_codel.ce_threshold = ce_threshold; +} +static inline void +tc_newchain_req_set_options_fq_codel_drop_batch_size(struct tc_newchain_req *req, + __u32 drop_batch_size) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.drop_batch_size = 1; + req->options.fq_codel.drop_batch_size = drop_batch_size; +} +static inline void +tc_newchain_req_set_options_fq_codel_memory_limit(struct tc_newchain_req *req, + __u32 memory_limit) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.memory_limit = 1; + req->options.fq_codel.memory_limit = memory_limit; +} +static inline void +tc_newchain_req_set_options_fq_codel_ce_threshold_selector(struct tc_newchain_req *req, + __u8 ce_threshold_selector) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ce_threshold_selector = 1; + req->options.fq_codel.ce_threshold_selector = ce_threshold_selector; +} +static inline void +tc_newchain_req_set_options_fq_codel_ce_threshold_mask(struct tc_newchain_req *req, + __u8 ce_threshold_mask) +{ + req->_present.options = 1; + req->options._present.fq_codel = 1; + req->options.fq_codel._present.ce_threshold_mask = 1; + req->options.fq_codel.ce_threshold_mask = ce_threshold_mask; +} +static inline void +tc_newchain_req_set_options_fq_pie_limit(struct tc_newchain_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.limit = 1; + req->options.fq_pie.limit = limit; +} +static inline void +tc_newchain_req_set_options_fq_pie_flows(struct tc_newchain_req *req, + __u32 flows) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.flows = 1; + req->options.fq_pie.flows = flows; +} +static inline void +tc_newchain_req_set_options_fq_pie_target(struct tc_newchain_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.target = 1; + req->options.fq_pie.target = target; +} +static inline void +tc_newchain_req_set_options_fq_pie_tupdate(struct tc_newchain_req *req, + __u32 tupdate) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.tupdate = 1; + req->options.fq_pie.tupdate = tupdate; +} +static inline void +tc_newchain_req_set_options_fq_pie_alpha(struct tc_newchain_req *req, + __u32 alpha) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.alpha = 1; + req->options.fq_pie.alpha = alpha; +} +static inline void +tc_newchain_req_set_options_fq_pie_beta(struct tc_newchain_req *req, + __u32 beta) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.beta = 1; + req->options.fq_pie.beta = beta; +} +static inline void +tc_newchain_req_set_options_fq_pie_quantum(struct tc_newchain_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.quantum = 1; + req->options.fq_pie.quantum = quantum; +} +static inline void +tc_newchain_req_set_options_fq_pie_memory_limit(struct tc_newchain_req *req, + __u32 memory_limit) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.memory_limit = 1; + req->options.fq_pie.memory_limit = memory_limit; +} +static inline void +tc_newchain_req_set_options_fq_pie_ecn_prob(struct tc_newchain_req *req, + __u32 ecn_prob) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.ecn_prob = 1; + req->options.fq_pie.ecn_prob = ecn_prob; +} +static inline void +tc_newchain_req_set_options_fq_pie_ecn(struct tc_newchain_req *req, __u32 ecn) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.ecn = 1; + req->options.fq_pie.ecn = ecn; +} +static inline void +tc_newchain_req_set_options_fq_pie_bytemode(struct tc_newchain_req *req, + __u32 bytemode) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.bytemode = 1; + req->options.fq_pie.bytemode = bytemode; +} +static inline void +tc_newchain_req_set_options_fq_pie_dq_rate_estimator(struct tc_newchain_req *req, + __u32 dq_rate_estimator) +{ + req->_present.options = 1; + req->options._present.fq_pie = 1; + req->options.fq_pie._present.dq_rate_estimator = 1; + req->options.fq_pie.dq_rate_estimator = dq_rate_estimator; +} +static inline void +tc_newchain_req_set_options_fw_classid(struct tc_newchain_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.classid = 1; + req->options.fw.classid = classid; +} +static inline void +tc_newchain_req_set_options_fw_police_tbf(struct tc_newchain_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.tbf); + req->options.fw.police._len.tbf = len; + req->options.fw.police.tbf = malloc(req->options.fw.police._len.tbf); + memcpy(req->options.fw.police.tbf, tbf, req->options.fw.police._len.tbf); +} +static inline void +tc_newchain_req_set_options_fw_police_rate(struct tc_newchain_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.rate); + req->options.fw.police._len.rate = len; + req->options.fw.police.rate = malloc(req->options.fw.police._len.rate); + memcpy(req->options.fw.police.rate, rate, req->options.fw.police._len.rate); +} +static inline void +tc_newchain_req_set_options_fw_police_peakrate(struct tc_newchain_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.peakrate); + req->options.fw.police._len.peakrate = len; + req->options.fw.police.peakrate = malloc(req->options.fw.police._len.peakrate); + memcpy(req->options.fw.police.peakrate, peakrate, req->options.fw.police._len.peakrate); +} +static inline void +tc_newchain_req_set_options_fw_police_avrate(struct tc_newchain_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.avrate = 1; + req->options.fw.police.avrate = avrate; +} +static inline void +tc_newchain_req_set_options_fw_police_result(struct tc_newchain_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.result = 1; + req->options.fw.police.result = result; +} +static inline void +tc_newchain_req_set_options_fw_police_tm(struct tc_newchain_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + free(req->options.fw.police.tm); + req->options.fw.police._len.tm = len; + req->options.fw.police.tm = malloc(req->options.fw.police._len.tm); + memcpy(req->options.fw.police.tm, tm, req->options.fw.police._len.tm); +} +static inline void +tc_newchain_req_set_options_fw_police_rate64(struct tc_newchain_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.rate64 = 1; + req->options.fw.police.rate64 = rate64; +} +static inline void +tc_newchain_req_set_options_fw_police_peakrate64(struct tc_newchain_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.peakrate64 = 1; + req->options.fw.police.peakrate64 = peakrate64; +} +static inline void +tc_newchain_req_set_options_fw_police_pktrate64(struct tc_newchain_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.pktrate64 = 1; + req->options.fw.police.pktrate64 = pktrate64; +} +static inline void +tc_newchain_req_set_options_fw_police_pktburst64(struct tc_newchain_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.police = 1; + req->options.fw.police._present.pktburst64 = 1; + req->options.fw.police.pktburst64 = pktburst64; +} +static inline void +tc_newchain_req_set_options_fw_indev(struct tc_newchain_req *req, + const char *indev) +{ + req->_present.options = 1; + req->options._present.fw = 1; + free(req->options.fw.indev); + req->options.fw._len.indev = strlen(indev); + req->options.fw.indev = malloc(req->options.fw._len.indev + 1); + memcpy(req->options.fw.indev, indev, req->options.fw._len.indev); + req->options.fw.indev[req->options.fw._len.indev] = 0; +} +static inline void +__tc_newchain_req_set_options_fw_act(struct tc_newchain_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.fw = 1; + free(req->options.fw.act); + req->options.fw.act = act; + req->options.fw._count.act = n_act; +} +static inline void +tc_newchain_req_set_options_fw_mask(struct tc_newchain_req *req, __u32 mask) +{ + req->_present.options = 1; + req->options._present.fw = 1; + req->options.fw._present.mask = 1; + req->options.fw.mask = mask; +} +static inline void +tc_newchain_req_set_options_gred_parms(struct tc_newchain_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.parms); + req->options.gred._len.parms = len; + req->options.gred.parms = malloc(req->options.gred._len.parms); + memcpy(req->options.gred.parms, parms, req->options.gred._len.parms); +} +static inline void +tc_newchain_req_set_options_gred_stab(struct tc_newchain_req *req, __u8 *stab, + size_t count) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.stab); + req->options.gred._count.stab = count; + count *= sizeof(__u8); + req->options.gred.stab = malloc(count); + memcpy(req->options.gred.stab, stab, count); +} +static inline void +tc_newchain_req_set_options_gred_dps(struct tc_newchain_req *req, + const void *dps, size_t len) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.dps); + req->options.gred._len.dps = len; + req->options.gred.dps = malloc(req->options.gred._len.dps); + memcpy(req->options.gred.dps, dps, req->options.gred._len.dps); +} +static inline void +tc_newchain_req_set_options_gred_max_p(struct tc_newchain_req *req, + __u32 *max_p, size_t count) +{ + req->_present.options = 1; + req->options._present.gred = 1; + free(req->options.gred.max_p); + req->options.gred._count.max_p = count; + count *= sizeof(__u32); + req->options.gred.max_p = malloc(count); + memcpy(req->options.gred.max_p, max_p, count); +} +static inline void +tc_newchain_req_set_options_gred_limit(struct tc_newchain_req *req, + __u32 limit) +{ + req->_present.options = 1; + req->options._present.gred = 1; + req->options.gred._present.limit = 1; + req->options.gred.limit = limit; +} +static inline void +__tc_newchain_req_set_options_gred_vq_list_entry(struct tc_newchain_req *req, + struct tc_tca_gred_vq_entry_attrs *entry, + unsigned int n_entry) +{ + unsigned int i; + + req->_present.options = 1; + req->options._present.gred = 1; + req->options.gred._present.vq_list = 1; + for (i = 0; i < req->options.gred.vq_list._count.entry; i++) + tc_tca_gred_vq_entry_attrs_free(&req->options.gred.vq_list.entry[i]); + free(req->options.gred.vq_list.entry); + req->options.gred.vq_list.entry = entry; + req->options.gred.vq_list._count.entry = n_entry; +} +static inline void +tc_newchain_req_set_options_hfsc(struct tc_newchain_req *req, const void *hfsc, + size_t len) +{ + req->_present.options = 1; + free(req->options.hfsc); + req->options._len.hfsc = len; + req->options.hfsc = malloc(req->options._len.hfsc); + memcpy(req->options.hfsc, hfsc, req->options._len.hfsc); +} +static inline void +tc_newchain_req_set_options_hhf_backlog_limit(struct tc_newchain_req *req, + __u32 backlog_limit) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.backlog_limit = 1; + req->options.hhf.backlog_limit = backlog_limit; +} +static inline void +tc_newchain_req_set_options_hhf_quantum(struct tc_newchain_req *req, + __u32 quantum) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.quantum = 1; + req->options.hhf.quantum = quantum; +} +static inline void +tc_newchain_req_set_options_hhf_hh_flows_limit(struct tc_newchain_req *req, + __u32 hh_flows_limit) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.hh_flows_limit = 1; + req->options.hhf.hh_flows_limit = hh_flows_limit; +} +static inline void +tc_newchain_req_set_options_hhf_reset_timeout(struct tc_newchain_req *req, + __u32 reset_timeout) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.reset_timeout = 1; + req->options.hhf.reset_timeout = reset_timeout; +} +static inline void +tc_newchain_req_set_options_hhf_admit_bytes(struct tc_newchain_req *req, + __u32 admit_bytes) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.admit_bytes = 1; + req->options.hhf.admit_bytes = admit_bytes; +} +static inline void +tc_newchain_req_set_options_hhf_evict_timeout(struct tc_newchain_req *req, + __u32 evict_timeout) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.evict_timeout = 1; + req->options.hhf.evict_timeout = evict_timeout; +} +static inline void +tc_newchain_req_set_options_hhf_non_hh_weight(struct tc_newchain_req *req, + __u32 non_hh_weight) +{ + req->_present.options = 1; + req->options._present.hhf = 1; + req->options.hhf._present.non_hh_weight = 1; + req->options.hhf.non_hh_weight = non_hh_weight; +} +static inline void +tc_newchain_req_set_options_htb_parms(struct tc_newchain_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.parms); + req->options.htb._len.parms = len; + req->options.htb.parms = malloc(req->options.htb._len.parms); + memcpy(req->options.htb.parms, parms, req->options.htb._len.parms); +} +static inline void +tc_newchain_req_set_options_htb_init(struct tc_newchain_req *req, + const void *init, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.init); + req->options.htb._len.init = len; + req->options.htb.init = malloc(req->options.htb._len.init); + memcpy(req->options.htb.init, init, req->options.htb._len.init); +} +static inline void +tc_newchain_req_set_options_htb_ctab(struct tc_newchain_req *req, + const void *ctab, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.ctab); + req->options.htb._len.ctab = len; + req->options.htb.ctab = malloc(req->options.htb._len.ctab); + memcpy(req->options.htb.ctab, ctab, req->options.htb._len.ctab); +} +static inline void +tc_newchain_req_set_options_htb_rtab(struct tc_newchain_req *req, + const void *rtab, size_t len) +{ + req->_present.options = 1; + req->options._present.htb = 1; + free(req->options.htb.rtab); + req->options.htb._len.rtab = len; + req->options.htb.rtab = malloc(req->options.htb._len.rtab); + memcpy(req->options.htb.rtab, rtab, req->options.htb._len.rtab); +} +static inline void +tc_newchain_req_set_options_htb_direct_qlen(struct tc_newchain_req *req, + __u32 direct_qlen) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.direct_qlen = 1; + req->options.htb.direct_qlen = direct_qlen; +} +static inline void +tc_newchain_req_set_options_htb_rate64(struct tc_newchain_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.rate64 = 1; + req->options.htb.rate64 = rate64; +} +static inline void +tc_newchain_req_set_options_htb_ceil64(struct tc_newchain_req *req, + __u64 ceil64) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.ceil64 = 1; + req->options.htb.ceil64 = ceil64; +} +static inline void +tc_newchain_req_set_options_htb_offload(struct tc_newchain_req *req) +{ + req->_present.options = 1; + req->options._present.htb = 1; + req->options.htb._present.offload = 1; +} +static inline void +tc_newchain_req_set_options_ingress(struct tc_newchain_req *req) +{ + req->_present.options = 1; + req->options._present.ingress = 1; +} +static inline void +tc_newchain_req_set_options_matchall_classid(struct tc_newchain_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + req->options.matchall._present.classid = 1; + req->options.matchall.classid = classid; +} +static inline void +__tc_newchain_req_set_options_matchall_act(struct tc_newchain_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + free(req->options.matchall.act); + req->options.matchall.act = act; + req->options.matchall._count.act = n_act; +} +static inline void +tc_newchain_req_set_options_matchall_flags(struct tc_newchain_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + req->options.matchall._present.flags = 1; + req->options.matchall.flags = flags; +} +static inline void +tc_newchain_req_set_options_matchall_pcnt(struct tc_newchain_req *req, + const void *pcnt, size_t len) +{ + req->_present.options = 1; + req->options._present.matchall = 1; + free(req->options.matchall.pcnt); + req->options.matchall._len.pcnt = len; + req->options.matchall.pcnt = malloc(req->options.matchall._len.pcnt); + memcpy(req->options.matchall.pcnt, pcnt, req->options.matchall._len.pcnt); +} +static inline void tc_newchain_req_set_options_mq(struct tc_newchain_req *req) +{ + req->_present.options = 1; + req->options._present.mq = 1; +} +static inline void +tc_newchain_req_set_options_mqprio(struct tc_newchain_req *req, + const void *mqprio, size_t len) +{ + req->_present.options = 1; + free(req->options.mqprio); + req->options._len.mqprio = len; + req->options.mqprio = malloc(req->options._len.mqprio); + memcpy(req->options.mqprio, mqprio, req->options._len.mqprio); +} +static inline void +tc_newchain_req_set_options_multiq(struct tc_newchain_req *req, + const void *multiq, size_t len) +{ + req->_present.options = 1; + free(req->options.multiq); + req->options._len.multiq = len; + req->options.multiq = malloc(req->options._len.multiq); + memcpy(req->options.multiq, multiq, req->options._len.multiq); +} +static inline void +tc_newchain_req_set_options_netem_corr(struct tc_newchain_req *req, + const void *corr, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.corr); + req->options.netem._len.corr = len; + req->options.netem.corr = malloc(req->options.netem._len.corr); + memcpy(req->options.netem.corr, corr, req->options.netem._len.corr); +} +static inline void +tc_newchain_req_set_options_netem_delay_dist(struct tc_newchain_req *req, + __s16 *delay_dist, size_t count) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.delay_dist); + req->options.netem._count.delay_dist = count; + count *= sizeof(__s16); + req->options.netem.delay_dist = malloc(count); + memcpy(req->options.netem.delay_dist, delay_dist, count); +} +static inline void +tc_newchain_req_set_options_netem_reorder(struct tc_newchain_req *req, + const void *reorder, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.reorder); + req->options.netem._len.reorder = len; + req->options.netem.reorder = malloc(req->options.netem._len.reorder); + memcpy(req->options.netem.reorder, reorder, req->options.netem._len.reorder); +} +static inline void +tc_newchain_req_set_options_netem_corrupt(struct tc_newchain_req *req, + const void *corrupt, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.corrupt); + req->options.netem._len.corrupt = len; + req->options.netem.corrupt = malloc(req->options.netem._len.corrupt); + memcpy(req->options.netem.corrupt, corrupt, req->options.netem._len.corrupt); +} +static inline void +tc_newchain_req_set_options_netem_loss_gi(struct tc_newchain_req *req, + const void *gi, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.loss = 1; + free(req->options.netem.loss.gi); + req->options.netem.loss._len.gi = len; + req->options.netem.loss.gi = malloc(req->options.netem.loss._len.gi); + memcpy(req->options.netem.loss.gi, gi, req->options.netem.loss._len.gi); +} +static inline void +tc_newchain_req_set_options_netem_loss_ge(struct tc_newchain_req *req, + const void *ge, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.loss = 1; + free(req->options.netem.loss.ge); + req->options.netem.loss._len.ge = len; + req->options.netem.loss.ge = malloc(req->options.netem.loss._len.ge); + memcpy(req->options.netem.loss.ge, ge, req->options.netem.loss._len.ge); +} +static inline void +tc_newchain_req_set_options_netem_rate(struct tc_newchain_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.rate); + req->options.netem._len.rate = len; + req->options.netem.rate = malloc(req->options.netem._len.rate); + memcpy(req->options.netem.rate, rate, req->options.netem._len.rate); +} +static inline void +tc_newchain_req_set_options_netem_ecn(struct tc_newchain_req *req, __u32 ecn) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.ecn = 1; + req->options.netem.ecn = ecn; +} +static inline void +tc_newchain_req_set_options_netem_rate64(struct tc_newchain_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.rate64 = 1; + req->options.netem.rate64 = rate64; +} +static inline void +tc_newchain_req_set_options_netem_pad(struct tc_newchain_req *req, __u32 pad) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.pad = 1; + req->options.netem.pad = pad; +} +static inline void +tc_newchain_req_set_options_netem_latency64(struct tc_newchain_req *req, + __s64 latency64) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.latency64 = 1; + req->options.netem.latency64 = latency64; +} +static inline void +tc_newchain_req_set_options_netem_jitter64(struct tc_newchain_req *req, + __s64 jitter64) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.jitter64 = 1; + req->options.netem.jitter64 = jitter64; +} +static inline void +tc_newchain_req_set_options_netem_slot(struct tc_newchain_req *req, + const void *slot, size_t len) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.slot); + req->options.netem._len.slot = len; + req->options.netem.slot = malloc(req->options.netem._len.slot); + memcpy(req->options.netem.slot, slot, req->options.netem._len.slot); +} +static inline void +tc_newchain_req_set_options_netem_slot_dist(struct tc_newchain_req *req, + __s16 *slot_dist, size_t count) +{ + req->_present.options = 1; + req->options._present.netem = 1; + free(req->options.netem.slot_dist); + req->options.netem._count.slot_dist = count; + count *= sizeof(__s16); + req->options.netem.slot_dist = malloc(count); + memcpy(req->options.netem.slot_dist, slot_dist, count); +} +static inline void +tc_newchain_req_set_options_netem_prng_seed(struct tc_newchain_req *req, + __u64 prng_seed) +{ + req->_present.options = 1; + req->options._present.netem = 1; + req->options.netem._present.prng_seed = 1; + req->options.netem.prng_seed = prng_seed; +} +static inline void +tc_newchain_req_set_options_pfifo(struct tc_newchain_req *req, + const void *pfifo, size_t len) +{ + req->_present.options = 1; + free(req->options.pfifo); + req->options._len.pfifo = len; + req->options.pfifo = malloc(req->options._len.pfifo); + memcpy(req->options.pfifo, pfifo, req->options._len.pfifo); +} +static inline void +tc_newchain_req_set_options_pfifo_fast(struct tc_newchain_req *req, + const void *pfifo_fast, size_t len) +{ + req->_present.options = 1; + free(req->options.pfifo_fast); + req->options._len.pfifo_fast = len; + req->options.pfifo_fast = malloc(req->options._len.pfifo_fast); + memcpy(req->options.pfifo_fast, pfifo_fast, req->options._len.pfifo_fast); +} +static inline void +tc_newchain_req_set_options_pfifo_head_drop(struct tc_newchain_req *req, + const void *pfifo_head_drop, + size_t len) +{ + req->_present.options = 1; + free(req->options.pfifo_head_drop); + req->options._len.pfifo_head_drop = len; + req->options.pfifo_head_drop = malloc(req->options._len.pfifo_head_drop); + memcpy(req->options.pfifo_head_drop, pfifo_head_drop, req->options._len.pfifo_head_drop); +} +static inline void +tc_newchain_req_set_options_pie_target(struct tc_newchain_req *req, + __u32 target) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.target = 1; + req->options.pie.target = target; +} +static inline void +tc_newchain_req_set_options_pie_limit(struct tc_newchain_req *req, __u32 limit) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.limit = 1; + req->options.pie.limit = limit; +} +static inline void +tc_newchain_req_set_options_pie_tupdate(struct tc_newchain_req *req, + __u32 tupdate) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.tupdate = 1; + req->options.pie.tupdate = tupdate; +} +static inline void +tc_newchain_req_set_options_pie_alpha(struct tc_newchain_req *req, __u32 alpha) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.alpha = 1; + req->options.pie.alpha = alpha; +} +static inline void +tc_newchain_req_set_options_pie_beta(struct tc_newchain_req *req, __u32 beta) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.beta = 1; + req->options.pie.beta = beta; +} +static inline void +tc_newchain_req_set_options_pie_ecn(struct tc_newchain_req *req, __u32 ecn) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.ecn = 1; + req->options.pie.ecn = ecn; +} +static inline void +tc_newchain_req_set_options_pie_bytemode(struct tc_newchain_req *req, + __u32 bytemode) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.bytemode = 1; + req->options.pie.bytemode = bytemode; +} +static inline void +tc_newchain_req_set_options_pie_dq_rate_estimator(struct tc_newchain_req *req, + __u32 dq_rate_estimator) +{ + req->_present.options = 1; + req->options._present.pie = 1; + req->options.pie._present.dq_rate_estimator = 1; + req->options.pie.dq_rate_estimator = dq_rate_estimator; +} +static inline void +tc_newchain_req_set_options_plug(struct tc_newchain_req *req, const void *plug, + size_t len) +{ + req->_present.options = 1; + free(req->options.plug); + req->options._len.plug = len; + req->options.plug = malloc(req->options._len.plug); + memcpy(req->options.plug, plug, req->options._len.plug); +} +static inline void +tc_newchain_req_set_options_prio(struct tc_newchain_req *req, const void *prio, + size_t len) +{ + req->_present.options = 1; + free(req->options.prio); + req->options._len.prio = len; + req->options.prio = malloc(req->options._len.prio); + memcpy(req->options.prio, prio, req->options._len.prio); +} +static inline void +tc_newchain_req_set_options_qfq_weight(struct tc_newchain_req *req, + __u32 weight) +{ + req->_present.options = 1; + req->options._present.qfq = 1; + req->options.qfq._present.weight = 1; + req->options.qfq.weight = weight; +} +static inline void +tc_newchain_req_set_options_qfq_lmax(struct tc_newchain_req *req, __u32 lmax) +{ + req->_present.options = 1; + req->options._present.qfq = 1; + req->options.qfq._present.lmax = 1; + req->options.qfq.lmax = lmax; +} +static inline void +tc_newchain_req_set_options_red_parms(struct tc_newchain_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.red = 1; + free(req->options.red.parms); + req->options.red._len.parms = len; + req->options.red.parms = malloc(req->options.red._len.parms); + memcpy(req->options.red.parms, parms, req->options.red._len.parms); +} +static inline void +tc_newchain_req_set_options_red_stab(struct tc_newchain_req *req, + const void *stab, size_t len) +{ + req->_present.options = 1; + req->options._present.red = 1; + free(req->options.red.stab); + req->options.red._len.stab = len; + req->options.red.stab = malloc(req->options.red._len.stab); + memcpy(req->options.red.stab, stab, req->options.red._len.stab); +} +static inline void +tc_newchain_req_set_options_red_max_p(struct tc_newchain_req *req, __u32 max_p) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.max_p = 1; + req->options.red.max_p = max_p; +} +static inline void +tc_newchain_req_set_options_red_flags(struct tc_newchain_req *req, + struct nla_bitfield32 *flags) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.flags = 1; + memcpy(&req->options.red.flags, flags, sizeof(struct nla_bitfield32)); +} +static inline void +tc_newchain_req_set_options_red_early_drop_block(struct tc_newchain_req *req, + __u32 early_drop_block) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.early_drop_block = 1; + req->options.red.early_drop_block = early_drop_block; +} +static inline void +tc_newchain_req_set_options_red_mark_block(struct tc_newchain_req *req, + __u32 mark_block) +{ + req->_present.options = 1; + req->options._present.red = 1; + req->options.red._present.mark_block = 1; + req->options.red.mark_block = mark_block; +} +static inline void +tc_newchain_req_set_options_route_classid(struct tc_newchain_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.classid = 1; + req->options.route.classid = classid; +} +static inline void +tc_newchain_req_set_options_route_to(struct tc_newchain_req *req, __u32 to) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.to = 1; + req->options.route.to = to; +} +static inline void +tc_newchain_req_set_options_route_from(struct tc_newchain_req *req, __u32 from) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.from = 1; + req->options.route.from = from; +} +static inline void +tc_newchain_req_set_options_route_iif(struct tc_newchain_req *req, __u32 iif) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.iif = 1; + req->options.route.iif = iif; +} +static inline void +tc_newchain_req_set_options_route_police_tbf(struct tc_newchain_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.tbf); + req->options.route.police._len.tbf = len; + req->options.route.police.tbf = malloc(req->options.route.police._len.tbf); + memcpy(req->options.route.police.tbf, tbf, req->options.route.police._len.tbf); +} +static inline void +tc_newchain_req_set_options_route_police_rate(struct tc_newchain_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.rate); + req->options.route.police._len.rate = len; + req->options.route.police.rate = malloc(req->options.route.police._len.rate); + memcpy(req->options.route.police.rate, rate, req->options.route.police._len.rate); +} +static inline void +tc_newchain_req_set_options_route_police_peakrate(struct tc_newchain_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.peakrate); + req->options.route.police._len.peakrate = len; + req->options.route.police.peakrate = malloc(req->options.route.police._len.peakrate); + memcpy(req->options.route.police.peakrate, peakrate, req->options.route.police._len.peakrate); +} +static inline void +tc_newchain_req_set_options_route_police_avrate(struct tc_newchain_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.avrate = 1; + req->options.route.police.avrate = avrate; +} +static inline void +tc_newchain_req_set_options_route_police_result(struct tc_newchain_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.result = 1; + req->options.route.police.result = result; +} +static inline void +tc_newchain_req_set_options_route_police_tm(struct tc_newchain_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + free(req->options.route.police.tm); + req->options.route.police._len.tm = len; + req->options.route.police.tm = malloc(req->options.route.police._len.tm); + memcpy(req->options.route.police.tm, tm, req->options.route.police._len.tm); +} +static inline void +tc_newchain_req_set_options_route_police_rate64(struct tc_newchain_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.rate64 = 1; + req->options.route.police.rate64 = rate64; +} +static inline void +tc_newchain_req_set_options_route_police_peakrate64(struct tc_newchain_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.peakrate64 = 1; + req->options.route.police.peakrate64 = peakrate64; +} +static inline void +tc_newchain_req_set_options_route_police_pktrate64(struct tc_newchain_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.pktrate64 = 1; + req->options.route.police.pktrate64 = pktrate64; +} +static inline void +tc_newchain_req_set_options_route_police_pktburst64(struct tc_newchain_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.route = 1; + req->options.route._present.police = 1; + req->options.route.police._present.pktburst64 = 1; + req->options.route.police.pktburst64 = pktburst64; +} +static inline void +__tc_newchain_req_set_options_route_act(struct tc_newchain_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.route = 1; + free(req->options.route.act); + req->options.route.act = act; + req->options.route._count.act = n_act; +} +static inline void +tc_newchain_req_set_options_sfb(struct tc_newchain_req *req, const void *sfb, + size_t len) +{ + req->_present.options = 1; + free(req->options.sfb); + req->options._len.sfb = len; + req->options.sfb = malloc(req->options._len.sfb); + memcpy(req->options.sfb, sfb, req->options._len.sfb); +} +static inline void +tc_newchain_req_set_options_sfq(struct tc_newchain_req *req, const void *sfq, + size_t len) +{ + req->_present.options = 1; + free(req->options.sfq); + req->options._len.sfq = len; + req->options.sfq = malloc(req->options._len.sfq); + memcpy(req->options.sfq, sfq, req->options._len.sfq); +} +static inline void +tc_newchain_req_set_options_taprio_priomap(struct tc_newchain_req *req, + const void *priomap, size_t len) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + free(req->options.taprio.priomap); + req->options.taprio._len.priomap = len; + req->options.taprio.priomap = malloc(req->options.taprio._len.priomap); + memcpy(req->options.taprio.priomap, priomap, req->options.taprio._len.priomap); +} +static inline void +__tc_newchain_req_set_options_taprio_sched_entry_list_entry(struct tc_newchain_req *req, + struct tc_taprio_sched_entry *entry, + unsigned int n_entry) +{ + unsigned int i; + + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_entry_list = 1; + for (i = 0; i < req->options.taprio.sched_entry_list._count.entry; i++) + tc_taprio_sched_entry_free(&req->options.taprio.sched_entry_list.entry[i]); + free(req->options.taprio.sched_entry_list.entry); + req->options.taprio.sched_entry_list.entry = entry; + req->options.taprio.sched_entry_list._count.entry = n_entry; +} +static inline void +tc_newchain_req_set_options_taprio_sched_base_time(struct tc_newchain_req *req, + __s64 sched_base_time) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_base_time = 1; + req->options.taprio.sched_base_time = sched_base_time; +} +static inline void +tc_newchain_req_set_options_taprio_sched_single_entry_index(struct tc_newchain_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.index = 1; + req->options.taprio.sched_single_entry.index = index; +} +static inline void +tc_newchain_req_set_options_taprio_sched_single_entry_cmd(struct tc_newchain_req *req, + __u8 cmd) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.cmd = 1; + req->options.taprio.sched_single_entry.cmd = cmd; +} +static inline void +tc_newchain_req_set_options_taprio_sched_single_entry_gate_mask(struct tc_newchain_req *req, + __u32 gate_mask) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.gate_mask = 1; + req->options.taprio.sched_single_entry.gate_mask = gate_mask; +} +static inline void +tc_newchain_req_set_options_taprio_sched_single_entry_interval(struct tc_newchain_req *req, + __u32 interval) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_single_entry = 1; + req->options.taprio.sched_single_entry._present.interval = 1; + req->options.taprio.sched_single_entry.interval = interval; +} +static inline void +tc_newchain_req_set_options_taprio_sched_clockid(struct tc_newchain_req *req, + __s32 sched_clockid) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_clockid = 1; + req->options.taprio.sched_clockid = sched_clockid; +} +static inline void +tc_newchain_req_set_options_taprio_admin_sched(struct tc_newchain_req *req, + const void *admin_sched, + size_t len) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + free(req->options.taprio.admin_sched); + req->options.taprio._len.admin_sched = len; + req->options.taprio.admin_sched = malloc(req->options.taprio._len.admin_sched); + memcpy(req->options.taprio.admin_sched, admin_sched, req->options.taprio._len.admin_sched); +} +static inline void +tc_newchain_req_set_options_taprio_sched_cycle_time(struct tc_newchain_req *req, + __s64 sched_cycle_time) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_cycle_time = 1; + req->options.taprio.sched_cycle_time = sched_cycle_time; +} +static inline void +tc_newchain_req_set_options_taprio_sched_cycle_time_extension(struct tc_newchain_req *req, + __s64 sched_cycle_time_extension) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.sched_cycle_time_extension = 1; + req->options.taprio.sched_cycle_time_extension = sched_cycle_time_extension; +} +static inline void +tc_newchain_req_set_options_taprio_flags(struct tc_newchain_req *req, + __u32 flags) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.flags = 1; + req->options.taprio.flags = flags; +} +static inline void +tc_newchain_req_set_options_taprio_txtime_delay(struct tc_newchain_req *req, + __u32 txtime_delay) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.txtime_delay = 1; + req->options.taprio.txtime_delay = txtime_delay; +} +static inline void +tc_newchain_req_set_options_taprio_tc_entry_index(struct tc_newchain_req *req, + __u32 index) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.tc_entry = 1; + req->options.taprio.tc_entry._present.index = 1; + req->options.taprio.tc_entry.index = index; +} +static inline void +tc_newchain_req_set_options_taprio_tc_entry_max_sdu(struct tc_newchain_req *req, + __u32 max_sdu) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.tc_entry = 1; + req->options.taprio.tc_entry._present.max_sdu = 1; + req->options.taprio.tc_entry.max_sdu = max_sdu; +} +static inline void +tc_newchain_req_set_options_taprio_tc_entry_fp(struct tc_newchain_req *req, + __u32 fp) +{ + req->_present.options = 1; + req->options._present.taprio = 1; + req->options.taprio._present.tc_entry = 1; + req->options.taprio.tc_entry._present.fp = 1; + req->options.taprio.tc_entry.fp = fp; +} +static inline void +tc_newchain_req_set_options_tbf_parms(struct tc_newchain_req *req, + const void *parms, size_t len) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + free(req->options.tbf.parms); + req->options.tbf._len.parms = len; + req->options.tbf.parms = malloc(req->options.tbf._len.parms); + memcpy(req->options.tbf.parms, parms, req->options.tbf._len.parms); +} +static inline void +tc_newchain_req_set_options_tbf_rtab(struct tc_newchain_req *req, + const void *rtab, size_t len) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + free(req->options.tbf.rtab); + req->options.tbf._len.rtab = len; + req->options.tbf.rtab = malloc(req->options.tbf._len.rtab); + memcpy(req->options.tbf.rtab, rtab, req->options.tbf._len.rtab); +} +static inline void +tc_newchain_req_set_options_tbf_ptab(struct tc_newchain_req *req, + const void *ptab, size_t len) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + free(req->options.tbf.ptab); + req->options.tbf._len.ptab = len; + req->options.tbf.ptab = malloc(req->options.tbf._len.ptab); + memcpy(req->options.tbf.ptab, ptab, req->options.tbf._len.ptab); +} +static inline void +tc_newchain_req_set_options_tbf_rate64(struct tc_newchain_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.rate64 = 1; + req->options.tbf.rate64 = rate64; +} +static inline void +tc_newchain_req_set_options_tbf_prate64(struct tc_newchain_req *req, + __u64 prate64) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.prate64 = 1; + req->options.tbf.prate64 = prate64; +} +static inline void +tc_newchain_req_set_options_tbf_burst(struct tc_newchain_req *req, __u32 burst) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.burst = 1; + req->options.tbf.burst = burst; +} +static inline void +tc_newchain_req_set_options_tbf_pburst(struct tc_newchain_req *req, + __u32 pburst) +{ + req->_present.options = 1; + req->options._present.tbf = 1; + req->options.tbf._present.pburst = 1; + req->options.tbf.pburst = pburst; +} +static inline void +tc_newchain_req_set_options_u32_classid(struct tc_newchain_req *req, + __u32 classid) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.classid = 1; + req->options.u32.classid = classid; +} +static inline void +tc_newchain_req_set_options_u32_hash(struct tc_newchain_req *req, __u32 hash) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.hash = 1; + req->options.u32.hash = hash; +} +static inline void +tc_newchain_req_set_options_u32_link(struct tc_newchain_req *req, __u32 link) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.link = 1; + req->options.u32.link = link; +} +static inline void +tc_newchain_req_set_options_u32_divisor(struct tc_newchain_req *req, + __u32 divisor) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.divisor = 1; + req->options.u32.divisor = divisor; +} +static inline void +tc_newchain_req_set_options_u32_sel(struct tc_newchain_req *req, + const void *sel, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.sel); + req->options.u32._len.sel = len; + req->options.u32.sel = malloc(req->options.u32._len.sel); + memcpy(req->options.u32.sel, sel, req->options.u32._len.sel); +} +static inline void +tc_newchain_req_set_options_u32_police_tbf(struct tc_newchain_req *req, + const void *tbf, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.tbf); + req->options.u32.police._len.tbf = len; + req->options.u32.police.tbf = malloc(req->options.u32.police._len.tbf); + memcpy(req->options.u32.police.tbf, tbf, req->options.u32.police._len.tbf); +} +static inline void +tc_newchain_req_set_options_u32_police_rate(struct tc_newchain_req *req, + const void *rate, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.rate); + req->options.u32.police._len.rate = len; + req->options.u32.police.rate = malloc(req->options.u32.police._len.rate); + memcpy(req->options.u32.police.rate, rate, req->options.u32.police._len.rate); +} +static inline void +tc_newchain_req_set_options_u32_police_peakrate(struct tc_newchain_req *req, + const void *peakrate, + size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.peakrate); + req->options.u32.police._len.peakrate = len; + req->options.u32.police.peakrate = malloc(req->options.u32.police._len.peakrate); + memcpy(req->options.u32.police.peakrate, peakrate, req->options.u32.police._len.peakrate); +} +static inline void +tc_newchain_req_set_options_u32_police_avrate(struct tc_newchain_req *req, + __u32 avrate) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.avrate = 1; + req->options.u32.police.avrate = avrate; +} +static inline void +tc_newchain_req_set_options_u32_police_result(struct tc_newchain_req *req, + __u32 result) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.result = 1; + req->options.u32.police.result = result; +} +static inline void +tc_newchain_req_set_options_u32_police_tm(struct tc_newchain_req *req, + const void *tm, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + free(req->options.u32.police.tm); + req->options.u32.police._len.tm = len; + req->options.u32.police.tm = malloc(req->options.u32.police._len.tm); + memcpy(req->options.u32.police.tm, tm, req->options.u32.police._len.tm); +} +static inline void +tc_newchain_req_set_options_u32_police_rate64(struct tc_newchain_req *req, + __u64 rate64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.rate64 = 1; + req->options.u32.police.rate64 = rate64; +} +static inline void +tc_newchain_req_set_options_u32_police_peakrate64(struct tc_newchain_req *req, + __u64 peakrate64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.peakrate64 = 1; + req->options.u32.police.peakrate64 = peakrate64; +} +static inline void +tc_newchain_req_set_options_u32_police_pktrate64(struct tc_newchain_req *req, + __u64 pktrate64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.pktrate64 = 1; + req->options.u32.police.pktrate64 = pktrate64; +} +static inline void +tc_newchain_req_set_options_u32_police_pktburst64(struct tc_newchain_req *req, + __u64 pktburst64) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.police = 1; + req->options.u32.police._present.pktburst64 = 1; + req->options.u32.police.pktburst64 = pktburst64; +} +static inline void +__tc_newchain_req_set_options_u32_act(struct tc_newchain_req *req, + struct tc_act_attrs *act, + unsigned int n_act) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.act); + req->options.u32.act = act; + req->options.u32._count.act = n_act; +} +static inline void +tc_newchain_req_set_options_u32_indev(struct tc_newchain_req *req, + const char *indev) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.indev); + req->options.u32._len.indev = strlen(indev); + req->options.u32.indev = malloc(req->options.u32._len.indev + 1); + memcpy(req->options.u32.indev, indev, req->options.u32._len.indev); + req->options.u32.indev[req->options.u32._len.indev] = 0; +} +static inline void +tc_newchain_req_set_options_u32_pcnt(struct tc_newchain_req *req, + const void *pcnt, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.pcnt); + req->options.u32._len.pcnt = len; + req->options.u32.pcnt = malloc(req->options.u32._len.pcnt); + memcpy(req->options.u32.pcnt, pcnt, req->options.u32._len.pcnt); +} +static inline void +tc_newchain_req_set_options_u32_mark(struct tc_newchain_req *req, + const void *mark, size_t len) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + free(req->options.u32.mark); + req->options.u32._len.mark = len; + req->options.u32.mark = malloc(req->options.u32._len.mark); + memcpy(req->options.u32.mark, mark, req->options.u32._len.mark); +} +static inline void +tc_newchain_req_set_options_u32_flags(struct tc_newchain_req *req, __u32 flags) +{ + req->_present.options = 1; + req->options._present.u32 = 1; + req->options.u32._present.flags = 1; + req->options.u32.flags = flags; +} +static inline void +tc_newchain_req_set_rate(struct tc_newchain_req *req, const void *rate, + size_t len) +{ + free(req->rate); + req->_len.rate = len; + req->rate = malloc(req->_len.rate); + memcpy(req->rate, rate, req->_len.rate); +} +static inline void +tc_newchain_req_set_chain(struct tc_newchain_req *req, __u32 chain) +{ + req->_present.chain = 1; + req->chain = chain; +} +static inline void +tc_newchain_req_set_ingress_block(struct tc_newchain_req *req, + __u32 ingress_block) +{ + req->_present.ingress_block = 1; + req->ingress_block = ingress_block; +} +static inline void +tc_newchain_req_set_egress_block(struct tc_newchain_req *req, + __u32 egress_block) +{ + req->_present.egress_block = 1; + req->egress_block = egress_block; +} + +/* + * Get / dump tc chain information. + */ +int tc_newchain(struct ynl_sock *ys, struct tc_newchain_req *req); + +/* ============== RTM_DELCHAIN ============== */ +/* RTM_DELCHAIN - do */ +struct tc_delchain_req { + __u16 _nlmsg_flags; + + struct tcmsg _hdr; + + struct { + __u32 chain:1; + } _present; + + __u32 chain; +}; + +static inline struct tc_delchain_req *tc_delchain_req_alloc(void) +{ + return calloc(1, sizeof(struct tc_delchain_req)); +} +void tc_delchain_req_free(struct tc_delchain_req *req); + +static inline void +tc_delchain_req_set_nlflags(struct tc_delchain_req *req, __u16 nl_flags) +{ + req->_nlmsg_flags = nl_flags; +} + +static inline void +tc_delchain_req_set_chain(struct tc_delchain_req *req, __u32 chain) +{ + req->_present.chain = 1; + req->chain = chain; +} + +/* + * Get / dump tc chain information. + */ +int tc_delchain(struct ynl_sock *ys, struct tc_delchain_req *req); + +/* ============== RTM_GETCHAIN ============== */ +/* RTM_GETCHAIN - do */ +struct tc_getchain_req { + __u16 _nlmsg_flags; + + struct tcmsg _hdr; + + struct { + __u32 chain:1; + } _present; + + __u32 chain; +}; + +static inline struct tc_getchain_req *tc_getchain_req_alloc(void) +{ + return calloc(1, sizeof(struct tc_getchain_req)); +} +void tc_getchain_req_free(struct tc_getchain_req *req); + +static inline void +tc_getchain_req_set_nlflags(struct tc_getchain_req *req, __u16 nl_flags) +{ + req->_nlmsg_flags = nl_flags; +} + +static inline void +tc_getchain_req_set_chain(struct tc_getchain_req *req, __u32 chain) +{ + req->_present.chain = 1; + req->chain = chain; +} + +struct tc_getchain_rsp { + struct tcmsg _hdr; + + struct { + __u32 options:1; + __u32 xstats:1; + __u32 fcnt:1; + __u32 stats2:1; + __u32 stab:1; + __u32 chain:1; + __u32 ingress_block:1; + __u32 egress_block:1; + } _present; + struct { + __u32 kind; + __u32 stats; + __u32 rate; + } _len; + + char *kind; + struct tc_options_msg options; + struct tc_stats *stats; + struct tc_tca_stats_app_msg xstats; + struct gnet_estimator *rate; + __u32 fcnt; + struct tc_tca_stats_attrs stats2; + struct tc_tca_stab_attrs stab; + __u32 chain; + __u32 ingress_block; + __u32 egress_block; +}; + +void tc_getchain_rsp_free(struct tc_getchain_rsp *rsp); + +/* + * Get / dump tc chain information. + */ +struct tc_getchain_rsp * +tc_getchain(struct ynl_sock *ys, struct tc_getchain_req *req); + +#endif /* _LINUX_TC_GEN_H */