Example #1
0
static struct element *handle_tc_obj(struct rtnl_tc *tc, const char *prefix,
				     struct rdata *rdata)
{
	char buf[IFNAME_MAX], name[IFNAME_MAX];
	uint32_t id = rtnl_tc_get_handle(tc);
	struct element *e;

	rtnl_tc_handle2str(id, buf, sizeof(buf));
	snprintf(name, sizeof(name), "%s %s (%s)",
		 prefix, buf, rtnl_tc_get_kind(tc));

	if (!(e = element_lookup(grp, name, id, rdata ? rdata->parent : NULL, ELEMENT_CREAT)))
		return NULL;

	if (e->e_flags & ELEMENT_FLAG_CREATED) {
		e->e_level = rdata ? rdata->level : 0;

		if (element_set_key_attr(e, "tc_bytes", "tc_packets") ||
		    element_set_usage_attr(e, "tc_bytes"))
			BUG();

		update_tc_infos(e, tc);

		e->e_flags &= ~ELEMENT_FLAG_CREATED;
	}

	update_tc_attrs(e, tc);

	element_notify_update(e, NULL);
	element_lifesign(e, 1);

	return e;
}
Example #2
0
static void fw_dump_line(struct rtnl_cls *cls, struct nl_dump_params *p)
{
	struct rtnl_fw *f = rtnl_cls_data(cls);
	char buf[32];

	if (f->cf_mask & FW_ATTR_CLASSID)
		nl_dump(p, " target %s",
			rtnl_tc_handle2str(f->cf_classid, buf, sizeof(buf)));
}
Example #3
0
static void u32_dump_line(struct rtnl_cls *cls, struct nl_dump_params *p)
{
	struct rtnl_u32 *u = rtnl_cls_data(cls);
	char buf[32];

	if (u->cu_mask & U32_ATTR_DIVISOR)
		nl_dump(p, " divisor %u", u->cu_divisor);
	else if (u->cu_mask & U32_ATTR_CLASSID)
		nl_dump(p, " target %s",
			rtnl_tc_handle2str(u->cu_classid, buf, sizeof(buf)));
}
Example #4
0
void tca_dump_line(struct rtnl_tc *g, const char *type,
		   struct nl_dump_params *p)
{
	char handle[32], parent[32];
	struct nl_cache *link_cache;
	
	link_cache = nl_cache_mngt_require("route/link");

	nl_dump_line(p, "%s %s ", type, g->tc_kind);

	if (link_cache) {
		char buf[32];
		nl_dump(p, "dev %s ",
			rtnl_link_i2name(link_cache, g->tc_ifindex,
					 buf, sizeof(buf)));
	} else
		nl_dump(p, "dev %u ", g->tc_ifindex);
	
	nl_dump(p, "id %s parent %s",
		rtnl_tc_handle2str(g->tc_handle, handle, sizeof(handle)),
		rtnl_tc_handle2str(g->tc_parent, parent, sizeof(parent)));
}
Example #5
0
static void htb_qdisc_dump_line(struct rtnl_tc *tc, void *data,
				struct nl_dump_params *p)
{
	struct rtnl_htb_qdisc *htb = data;

	if (!htb)
		return;

	if (htb->qh_mask & SCH_HTB_HAS_RATE2QUANTUM)
		nl_dump(p, " r2q %u", htb->qh_rate2quantum);

	if (htb->qh_mask & SCH_HTB_HAS_DEFCLS) {
		char buf[64];
		nl_dump(p, " default-class %s",
			rtnl_tc_handle2str(htb->qh_defcls, buf, sizeof(buf)));
	}
}