char *pp_data_counters(struct data_counters *dc, bool showValues)
{
	char *res;

	if (!dc)
		res = kasprintf(GFP_ATOMIC, "data_counters@null{}");
	else if (showValues)
		res = kasprintf(
			GFP_ATOMIC, "data_counters@%p{"
			"set0{"
			"rx{"
			"tcp{b=%llu, p=%llu}, "
			"udp{b=%llu, p=%llu},"
			"other{b=%llu, p=%llu}}, "
			"tx{"
			"tcp{b=%llu, p=%llu}, "
			"udp{b=%llu, p=%llu},"
			"other{b=%llu, p=%llu}}}, "
			"set1{"
			"rx{"
			"tcp{b=%llu, p=%llu}, "
			"udp{b=%llu, p=%llu},"
			"other{b=%llu, p=%llu}}, "
			"tx{"
			"tcp{b=%llu, p=%llu}, "
			"udp{b=%llu, p=%llu},"
			"other{b=%llu, p=%llu}}}}",
			dc,
			dc->bpc[0][IFS_RX][IFS_TCP].bytes,
			dc->bpc[0][IFS_RX][IFS_TCP].packets,
			dc->bpc[0][IFS_RX][IFS_UDP].bytes,
			dc->bpc[0][IFS_RX][IFS_UDP].packets,
			dc->bpc[0][IFS_RX][IFS_PROTO_OTHER].bytes,
			dc->bpc[0][IFS_RX][IFS_PROTO_OTHER].packets,
			dc->bpc[0][IFS_TX][IFS_TCP].bytes,
			dc->bpc[0][IFS_TX][IFS_TCP].packets,
			dc->bpc[0][IFS_TX][IFS_UDP].bytes,
			dc->bpc[0][IFS_TX][IFS_UDP].packets,
			dc->bpc[0][IFS_TX][IFS_PROTO_OTHER].bytes,
			dc->bpc[0][IFS_TX][IFS_PROTO_OTHER].packets,
			dc->bpc[1][IFS_RX][IFS_TCP].bytes,
			dc->bpc[1][IFS_RX][IFS_TCP].packets,
			dc->bpc[1][IFS_RX][IFS_UDP].bytes,
			dc->bpc[1][IFS_RX][IFS_UDP].packets,
			dc->bpc[1][IFS_RX][IFS_PROTO_OTHER].bytes,
			dc->bpc[1][IFS_RX][IFS_PROTO_OTHER].packets,
			dc->bpc[1][IFS_TX][IFS_TCP].bytes,
			dc->bpc[1][IFS_TX][IFS_TCP].packets,
			dc->bpc[1][IFS_TX][IFS_UDP].bytes,
			dc->bpc[1][IFS_TX][IFS_UDP].packets,
			dc->bpc[1][IFS_TX][IFS_PROTO_OTHER].bytes,
			dc->bpc[1][IFS_TX][IFS_PROTO_OTHER].packets);
	else
		res = kasprintf(GFP_ATOMIC, "data_counters@%p{...}", dc);
	_bug_on_err_or_null(res);
	return res;
}
char *pp_tag_ref(struct tag_ref *tr)
{
	char *tn_str;
	char *res;

	if (!tr) {
		res = kasprintf(GFP_ATOMIC, "tag_ref@null{}");
		_bug_on_err_or_null(res);
		return res;
	}
	tn_str = pp_tag_node(&tr->tn);
	res = kasprintf(GFP_ATOMIC,
			"tag_ref@%p{%s, num_sock_tags=%d}",
			tr, tn_str, tr->num_sock_tags);
	_bug_on_err_or_null(res);
	kfree(tn_str);
	return res;
}
char *pp_tag_node(struct tag_node *tn)
{
	char *tag_str;
	char *res;

	if (!tn) {
		res = kasprintf(GFP_ATOMIC, "tag_node@null{}");
		_bug_on_err_or_null(res);
		return res;
	}
	tag_str = pp_tag_t(&tn->tag);
	res = kasprintf(GFP_ATOMIC,
			"tag_node@%p{tag=%s}",
			tn, tag_str);
	_bug_on_err_or_null(res);
	kfree(tag_str);
	return res;
}
char *pp_proc_qtu_data(struct proc_qtu_data *pqd)
{
	char *parent_tag_data_str;
	char *res;

	if (!pqd) {
		res = kasprintf(GFP_ATOMIC, "proc_qtu_data@null{}");
		_bug_on_err_or_null(res);
		return res;
	}
	parent_tag_data_str = pp_uid_tag_data(pqd->parent_tag_data);
	res = kasprintf(GFP_ATOMIC, "proc_qtu_data@%p{"
			"node=rb_node{...}, pid=%u, "
			"parent_tag_data=%s, "
			"sock_tag_list=list_head{...}}",
			pqd, pqd->pid, parent_tag_data_str
		);
	_bug_on_err_or_null(res);
	kfree(parent_tag_data_str);
	return res;
}
char *pp_tag_t(tag_t *tag)
{
	char *res;

	if (!tag)
		res = kasprintf(GFP_ATOMIC, "tag_t@null{}");
	else
		res = kasprintf(GFP_ATOMIC,
				"tag_t@%p{tag=0x%llx, uid=%u}",
				tag, *tag, get_uid_from_tag(*tag));
	_bug_on_err_or_null(res);
	return res;
}
char *pp_sock_tag(struct sock_tag *st)
{
	char *tag_str;
	char *res;

	if (!st) {
		res = kasprintf(GFP_ATOMIC, "sock_tag@null{}");
		_bug_on_err_or_null(res);
		return res;
	}
	tag_str = pp_tag_t(&st->tag);
	res = kasprintf(GFP_ATOMIC, "sock_tag@%p{"
			"sock_node=rb_node{...}, "
			"sk=%p socket=%p (f_count=%lu), list=list_head{...}, "
			"pid=%u, tag=%s}",
			st, st->sk, st->socket, atomic_long_read(
				&st->socket->file->f_count),
			st->pid, tag_str);
	_bug_on_err_or_null(res);
	kfree(tag_str);
	return res;
}
char *pp_iface_stat(struct iface_stat *is)
{
	char *res;
	if (!is) {
		res = kasprintf(GFP_ATOMIC, "iface_stat@null{}");
	} else {
		struct data_counters *cnts = &is->totals_via_skb;
		res = kasprintf(GFP_ATOMIC, "iface_stat@%p{"
				"list=list_head{...}, "
				"ifname=%s, "
				"total_dev={rx={bytes=%llu, "
				"packets=%llu}, "
				"tx={bytes=%llu, "
				"packets=%llu}}, "
				"total_skb={rx={bytes=%llu, "
				"packets=%llu}, "
				"tx={bytes=%llu, "
				"packets=%llu}}, "
				"last_known_valid=%d, "
				"last_known={rx={bytes=%llu, "
				"packets=%llu}, "
				"tx={bytes=%llu, "
				"packets=%llu}}, "
				"active=%d, "
				"net_dev=%p, "
				"proc_ptr=%p, "
				"tag_stat_tree=rb_root{...}}",
				is,
				is->ifname,
				is->totals_via_dev[IFS_RX].bytes,
				is->totals_via_dev[IFS_RX].packets,
				is->totals_via_dev[IFS_TX].bytes,
				is->totals_via_dev[IFS_TX].packets,
				dc_sum_bytes(cnts, 0, IFS_RX),
				dc_sum_packets(cnts, 0, IFS_RX),
				dc_sum_bytes(cnts, 0, IFS_TX),
				dc_sum_packets(cnts, 0, IFS_TX),
				is->last_known_valid,
				is->last_known[IFS_RX].bytes,
				is->last_known[IFS_RX].packets,
				is->last_known[IFS_TX].bytes,
				is->last_known[IFS_TX].packets,
				is->active,
				is->net_dev,
				is->proc_ptr);
	}
	_bug_on_err_or_null(res);
	return res;
}
char *pp_tag_stat(struct tag_stat *ts)
{
	char *tn_str;
	char *counters_str;
	char *parent_counters_str;
	char *res;

	if (!ts) {
		res = kasprintf(GFP_ATOMIC, "tag_stat@null{}");
		_bug_on_err_or_null(res);
		return res;
	}
	tn_str = pp_tag_node(&ts->tn);
	counters_str = pp_data_counters(&ts->counters, true);
	parent_counters_str = pp_data_counters(ts->parent_counters, false);
	res = kasprintf(GFP_ATOMIC,
			"tag_stat@%p{%s, counters=%s, parent_counters=%s}",
			ts, tn_str, counters_str, parent_counters_str);
	_bug_on_err_or_null(res);
	kfree(tn_str);
	kfree(counters_str);
	kfree(parent_counters_str);
	return res;
}
char *pp_uid_tag_data(struct uid_tag_data *utd)
{
	char *res;

	if (!utd)
		res = kasprintf(GFP_ATOMIC, "uid_tag_data@null{}");
	else
		res = kasprintf(GFP_ATOMIC, "uid_tag_data@%p{"
				"uid=%u, num_active_acct_tags=%d, "
				"num_pqd=%d, "
				"tag_node_tree=rb_root{...}, "
				"proc_qtu_data_tree=rb_root{...}}",
				utd, utd->uid,
				utd->num_active_tags, utd->num_pqd);
	_bug_on_err_or_null(res);
	return res;
}
Пример #10
0
char *pp_iface_stat(struct iface_stat *is)
{
	char *res;
	if (!is)
		res = kasprintf(GFP_ATOMIC, "iface_stat@null{}");
	else
		res = kasprintf(GFP_ATOMIC, "iface_stat@%p{"
				"list=list_head{...}, "
				"ifname=%s, "
				"total={rx={bytes=%llu, "
				"packets=%llu}, "
				"tx={bytes=%llu, "
				"packets=%llu}}, "
				"last_known_valid=%d, "
				"last_known={rx={bytes=%llu, "
				"packets=%llu}, "
				"tx={bytes=%llu, "
				"packets=%llu}}, "
				"active=%d, "
				"net_dev=%p, "
				"proc_ptr=%p, "
				"tag_stat_tree=rb_root{...}}",
				is,
				is->ifname,
				is->totals[IFS_RX].bytes,
				is->totals[IFS_RX].packets,
				is->totals[IFS_TX].bytes,
				is->totals[IFS_TX].packets,
				is->last_known_valid,
				is->last_known[IFS_RX].bytes,
				is->last_known[IFS_RX].packets,
				is->last_known[IFS_TX].bytes,
				is->last_known[IFS_TX].packets,
				is->active,
				is->net_dev,
				is->proc_ptr);
	_bug_on_err_or_null(res);
	return res;
}