Exemple #1
0
static void idiag_msg_dump_stats(struct nl_object *obj, struct nl_dump_params *p)
{
	struct idiagnl_msg *msg = (struct idiagnl_msg *) obj;
	char buf[64];

	idiag_msg_dump_details(obj, p);

	nl_dump(p, "tcp info:  [\n");
	nl_dump(p, "\tsocket state: %s\n",
			idiagnl_state2str(msg->idiag_tcpinfo.tcpi_state,
				buf, sizeof(buf)));
	nl_dump(p, "\ttcp state: %s\n",
			idiagnl_tcpstate2str(msg->idiag_tcpinfo.tcpi_ca_state,
				buf, sizeof(buf)));
	nl_dump(p, "\tretransmits: %d\n",
			msg->idiag_tcpinfo.tcpi_retransmits);
	nl_dump(p, "\tprobes: %d\n",
			msg->idiag_tcpinfo.tcpi_probes);
	nl_dump(p, "\tbackoff: %d\n",
			msg->idiag_tcpinfo.tcpi_backoff);
	nl_dump(p, "\toptions: %s\n",
			idiagnl_tcpopts2str(msg->idiag_tcpinfo.tcpi_options,
				buf, sizeof(buf)));
	nl_dump(p, "\tsnd_wscale: %d\n", msg->idiag_tcpinfo.tcpi_snd_wscale);
	nl_dump(p, "\trcv_wscale: %d\n", msg->idiag_tcpinfo.tcpi_rcv_wscale);
	nl_dump(p, "\trto: %d\n", msg->idiag_tcpinfo.tcpi_rto);
	nl_dump(p, "\tato: %d\n", msg->idiag_tcpinfo.tcpi_ato);
	nl_dump(p, "\tsnd_mss: %s\n", nl_size2str(msg->idiag_tcpinfo.tcpi_snd_mss,
				buf, sizeof(buf)));
	nl_dump(p, "\trcv_mss: %s\n", nl_size2str(msg->idiag_tcpinfo.tcpi_rcv_mss,
				buf, sizeof(buf)));
	nl_dump(p, "\tunacked: %d\n", msg->idiag_tcpinfo.tcpi_unacked);
	nl_dump(p, "\tsacked: %d\n", msg->idiag_tcpinfo.tcpi_sacked);

	nl_dump(p, "\tlost: %d\n", msg->idiag_tcpinfo.tcpi_lost);
	nl_dump(p, "\tretransmit segments: %d\n",
			msg->idiag_tcpinfo.tcpi_retrans);
	nl_dump(p, "\tfackets: %d\n",
			msg->idiag_tcpinfo.tcpi_fackets);
	nl_dump(p, "\tlast data sent: %s\n",
			nl_msec2str(msg->idiag_tcpinfo.tcpi_last_data_sent, buf,
				sizeof(buf)));
	nl_dump(p, "\tlast ack sent: %s\n",
			nl_msec2str(msg->idiag_tcpinfo.tcpi_last_ack_sent, buf, sizeof(buf)));
	nl_dump(p, "\tlast data recv: %s\n",
			nl_msec2str(msg->idiag_tcpinfo.tcpi_last_data_recv, buf,
				sizeof(buf)));
	nl_dump(p, "\tlast ack recv: %s\n",
			nl_msec2str(msg->idiag_tcpinfo.tcpi_last_ack_recv, buf,
				sizeof(buf)));
	nl_dump(p, "\tpath mtu: %s\n",
			nl_size2str(msg->idiag_tcpinfo.tcpi_pmtu, buf,
				sizeof(buf)));
	nl_dump(p, "\trcv ss threshold: %d\n",
			msg->idiag_tcpinfo.tcpi_rcv_ssthresh);
	nl_dump(p, "\tsmoothed round trip time: %d\n",
			msg->idiag_tcpinfo.tcpi_rtt);
	nl_dump(p, "\tround trip time variation: %d\n",
			msg->idiag_tcpinfo.tcpi_rttvar);
	nl_dump(p, "\tsnd ss threshold: %s\n",
			nl_size2str(msg->idiag_tcpinfo.tcpi_snd_ssthresh, buf,
				sizeof(buf)));
	nl_dump(p, "\tsend congestion window: %d\n",
			msg->idiag_tcpinfo.tcpi_snd_cwnd);
	nl_dump(p, "\tadvertised mss: %s\n",
			nl_size2str(msg->idiag_tcpinfo.tcpi_advmss, buf,
				sizeof(buf)));
	nl_dump(p, "\treordering: %d\n",
			msg->idiag_tcpinfo.tcpi_reordering);
	nl_dump(p, "\trcv rround trip time: %d\n",
			msg->idiag_tcpinfo.tcpi_rcv_rtt);
	nl_dump(p, "\treceive queue space: %s\n",
			nl_size2str(msg->idiag_tcpinfo.tcpi_rcv_space, buf,
				sizeof(buf)));
	nl_dump(p, "\ttotal retransmits: %d\n",
			msg->idiag_tcpinfo.tcpi_total_retrans);
	nl_dump(p, "]\n");

	if (msg->idiag_meminfo) {
		nl_dump(p, "meminfo:  [\n");
		nl_dump(p, "\trmem: %s\n",
				nl_size2str(msg->idiag_meminfo->idiag_rmem,
					    buf,
					    sizeof(buf)));
		nl_dump(p, "\twmem: %s\n",
				nl_size2str(msg->idiag_meminfo->idiag_wmem,
					    buf,
					    sizeof(buf)));
		nl_dump(p, "\tfmem: %s\n",
				nl_size2str(msg->idiag_meminfo->idiag_fmem,
					    buf,
					    sizeof(buf)));
		nl_dump(p, "\ttmem: %s\n",
				nl_size2str(msg->idiag_meminfo->idiag_tmem,
					    buf,
					    sizeof(buf)));
		nl_dump(p, "]\n");
	}

	if (msg->idiag_vegasinfo) {
		nl_dump(p, "vegasinfo:  [\n");
		nl_dump(p, "\tvegas enabled: %d\n",
				msg->idiag_vegasinfo->tcpv_enabled);
		if (msg->idiag_vegasinfo->tcpv_enabled) {
			nl_dump(p, "\trtt cnt: %d",
					msg->idiag_vegasinfo->tcpv_rttcnt);
			nl_dump(p, "\trtt (propagation delay): %d",
					msg->idiag_vegasinfo->tcpv_rtt);
			nl_dump(p, "\tmin rtt: %d",
					msg->idiag_vegasinfo->tcpv_minrtt);
		}
		nl_dump(p, "]\n");
	}

	nl_dump(p, "skmeminfo:  [\n");
	nl_dump(p, "\trmem alloc: %d\n",
			msg->idiag_skmeminfo[SK_MEMINFO_RMEM_ALLOC]);
	nl_dump(p, "\trcv buf: %s\n",
			nl_size2str(msg->idiag_skmeminfo[SK_MEMINFO_RCVBUF],
				buf, sizeof(buf)));
	nl_dump(p, "\twmem alloc: %d\n",
			msg->idiag_skmeminfo[SK_MEMINFO_WMEM_ALLOC]);
	nl_dump(p, "\tsnd buf: %s\n",
			nl_size2str(msg->idiag_skmeminfo[SK_MEMINFO_SNDBUF],
				buf, sizeof(buf)));
	nl_dump(p, "\tfwd alloc: %d\n",
			msg->idiag_skmeminfo[SK_MEMINFO_FWD_ALLOC]);
	nl_dump(p, "\twmem queued: %s\n",
			nl_size2str(msg->idiag_skmeminfo[SK_MEMINFO_WMEM_QUEUED],
				buf, sizeof(buf)));
	nl_dump(p, "\topt mem: %d\n",
			msg->idiag_skmeminfo[SK_MEMINFO_OPTMEM]);
	nl_dump(p, "\tbacklog: %d\n",
			msg->idiag_skmeminfo[SK_MEMINFO_BACKLOG]);
	nl_dump(p, "]\n\n");
}
static void inet6_dump_details(struct rtnl_link *link,
				struct nl_dump_params *p, void *data)
{
	struct inet6_data *i6 = data;
	char buf[64], buf2[64];
	int i, n = 0;

	nl_dump_line(p, "    ipv6 max-reasm-len %s",
		nl_size2str(i6->i6_cacheinfo.max_reasm_len, buf, sizeof(buf)));

	nl_dump(p, " <%s>\n",
		inet6_flags2str(i6->i6_flags, buf, sizeof(buf)));


	nl_dump_line(p, "      create-stamp %.2fs reachable-time %s",
		(double) i6->i6_cacheinfo.tstamp / 100.,
		nl_msec2str(i6->i6_cacheinfo.reachable_time, buf, sizeof(buf)));

	nl_dump(p, " retrans-time %s\n",
		nl_msec2str(i6->i6_cacheinfo.retrans_time, buf, sizeof(buf)));

	nl_dump_line(p, "      devconf:\n");
	nl_dump_line(p, "      ");

	for (i = 0; i < DEVCONF_MAX; i++) {
		uint32_t value = i6->i6_conf[i];
		int x, offset;

		switch (i) {
		case DEVCONF_TEMP_VALID_LFT:
		case DEVCONF_TEMP_PREFERED_LFT:
			nl_msec2str((uint64_t) value * 1000., buf2, sizeof(buf2));
			break;

		case DEVCONF_RTR_PROBE_INTERVAL:
		case DEVCONF_RTR_SOLICIT_INTERVAL:
		case DEVCONF_RTR_SOLICIT_DELAY:
			nl_msec2str(value, buf2, sizeof(buf2));
			break;

		default:
			snprintf(buf2, sizeof(buf2), "%u", value);
			break;
			
		}

		inet6_devconf2str(i, buf, sizeof(buf));

		offset = 23 - strlen(buf2);
		if (offset < 0)
			offset = 0;

		for (x = strlen(buf); x < offset; x++)
			buf[x] = ' ';

		strncpy(&buf[offset], buf2, strlen(buf2));

		nl_dump_line(p, "%s", buf);

		if (++n == 3) {
			nl_dump(p, "\n");
			nl_dump_line(p, "      ");
			n = 0;
		} else
			nl_dump(p, "  ");
	}

	if (n != 0)
		nl_dump(p, "\n");
}