tools/net/ynl/tests/tc.c

Source file repositories/reference/linux-study-clean/tools/net/ynl/tests/tc.c

File Facts

System
Linux kernel
Corpus path
tools/net/ynl/tests/tc.c
Extension
.c
Size
9827 bytes
Lines
410
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

if (q->options._present.fq_codel) {
			struct tc_fq_codel_attrs *fq_codel;
			struct tc_fq_codel_xstats *stats;

			fq_codel = &q->options.fq_codel;
			stats = q->stats2.app.fq_codel;

			EXPECT_EQ(true,
				  fq_codel->_present.limit &&
				  fq_codel->_present.target &&
				  q->stats2.app._len.fq_codel);

			if (fq_codel->_present.limit)
				printf("limit: %dp ", fq_codel->limit);
			if (fq_codel->_present.target)
				printf("target: %dms ",
				       (fq_codel->target + 500) / 1000);
			if (q->stats2.app._len.fq_codel)
				printf("new_flow_cnt: %d ",
				       stats->qdisc_stats.new_flow_count);
			was_fq_codel = true;
		}
	}
	printf("\n");

	return was_fq_codel;
}

static const char *vlan_act_name(struct tc_vlan *p)
{
	switch (p->v_action) {
	case TCA_VLAN_ACT_POP:
		return "pop";
	case TCA_VLAN_ACT_PUSH:
		return "push";
	case TCA_VLAN_ACT_MODIFY:
		return "modify";
	default:
		break;
	}

	return "not supported";
}

static const char *gact_act_name(struct tc_gact *p)
{
	switch (p->action) {
	case TC_ACT_SHOT:
		return "drop";
	case TC_ACT_OK:
		return "ok";
	case TC_ACT_PIPE:
		return "pipe";
	default:
		break;
	}

	return "not supported";
}

static void print_vlan(struct tc_act_vlan_attrs *vlan)
{
	printf("%s ", vlan_act_name(vlan->parms));
	if (vlan->_present.push_vlan_id)
		printf("id %u ", vlan->push_vlan_id);
	if (vlan->_present.push_vlan_protocol)
		printf("protocol %#x ", ntohs(vlan->push_vlan_protocol));
	if (vlan->_present.push_vlan_priority)
		printf("priority %u ", vlan->push_vlan_priority);
}

static void print_gact(struct tc_act_gact_attrs *gact)
{
	struct tc_gact *p = gact->parms;

	printf("%s ", gact_act_name(p));
}

static void flower_print(struct tc_flower_attrs *flower, const char *kind)
{
	struct tc_act_attrs *a;
	unsigned int i;

	ksft_print_msg("%s:\n", kind);

	if (flower->_present.key_vlan_id)
		ksft_print_msg("  vlan_id: %u\n", flower->key_vlan_id);
	if (flower->_present.key_vlan_prio)
		ksft_print_msg("  vlan_prio: %u\n", flower->key_vlan_prio);
	if (flower->_present.key_num_of_vlans)

Annotation

Implementation Notes