Ejemplo n.º 1
0
void
mrt6_stats(u_long mrpaddr, u_long mstaddr)
{
	struct mrt6stat mrtstat;
	u_int mrtproto;

	if (mrpaddr == 0) {
		printf("mrt6_stats: symbol not in namelist\n");
		return;
	}

	kread(mrpaddr, (char *)&mrtproto, sizeof(mrtproto));
	switch (mrtproto) {
	case 0:
		 printf("no IPv6 multicast routing compiled into this system\n");
		 return;

	case IPPROTO_PIM:
		 break;

	default:
		printf("IPv6 multicast routing protocol %u, unknown\n",
		    mrtproto);
		return;
	}

	if (mstaddr == 0) {
		printf("mrt6_stats: symbol not in namelist\n");
		return;
	}

	kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
	printf("multicast forwarding:\n");
	printf(" %10qu multicast forwarding cache lookup%s\n",
	    mrtstat.mrt6s_mfc_lookups, plural(mrtstat.mrt6s_mfc_lookups));
	printf(" %10qu multicast forwarding cache miss%s\n",
	    mrtstat.mrt6s_mfc_misses, plurales(mrtstat.mrt6s_mfc_misses));
	printf(" %10qu upcall%s to mrouted\n",
	    mrtstat.mrt6s_upcalls, plural(mrtstat.mrt6s_upcalls));
	printf(" %10qu upcall queue overflow%s\n",
	    mrtstat.mrt6s_upq_ovflw, plural(mrtstat.mrt6s_upq_ovflw));
	printf(" %10qu upcall%s dropped due to full socket buffer\n",
	    mrtstat.mrt6s_upq_sockfull, plural(mrtstat.mrt6s_upq_sockfull));
	printf(" %10qu cache cleanup%s\n",
	    mrtstat.mrt6s_cache_cleanups, plural(mrtstat.mrt6s_cache_cleanups));
	printf(" %10qu datagram%s with no route for origin\n",
	    mrtstat.mrt6s_no_route, plural(mrtstat.mrt6s_no_route));
	printf(" %10qu datagram%s arrived with bad tunneling\n",
	    mrtstat.mrt6s_bad_tunnel, plural(mrtstat.mrt6s_bad_tunnel));
	printf(" %10qu datagram%s could not be tunneled\n",
	    mrtstat.mrt6s_cant_tunnel, plural(mrtstat.mrt6s_cant_tunnel));
	printf(" %10qu datagram%s arrived on wrong interface\n",
	    mrtstat.mrt6s_wrong_if, plural(mrtstat.mrt6s_wrong_if));
	printf(" %10qu datagram%s selectively dropped\n",
	    mrtstat.mrt6s_drop_sel, plural(mrtstat.mrt6s_drop_sel));
	printf(" %10qu datagram%s dropped due to queue overflow\n",
	    mrtstat.mrt6s_q_overflow, plural(mrtstat.mrt6s_q_overflow));
	printf(" %10qu datagram%s dropped for being too large\n",
	    mrtstat.mrt6s_pkt2large, plural(mrtstat.mrt6s_pkt2large));
}
Ejemplo n.º 2
0
void
mrt6_stats(void)
{
	struct mrt6stat mrt6stat;
	u_int mrt6proto;
	int mib[] = { CTL_NET, AF_INET6, IPPROTO_IPV6, IPV6CTL_MRTPROTO };
	int mib2[] = { CTL_NET, AF_INET6, IPPROTO_IPV6, IPV6CTL_MRTSTATS };
	size_t len = sizeof(int);

	if (sysctl(mib, sizeof(mib) / sizeof(mib[0]),
	    &mrt6proto, &len, NULL, 0) == -1) {
		if (errno != ENOPROTOOPT)
			warn("mroute");
		return;
	}
	switch (mrt6proto) {
	case 0:
		printf("no IPv6 multicast routing compiled into this system\n");
		return;
	case IPPROTO_PIM:
		break;
	default:
		printf("IPv6 multicast routing protocol %u, unknown\n",
		    mrt6proto);
		return;
	}

	len = sizeof(mrt6stat);
	if (sysctl(mib2, sizeof(mib2) / sizeof(mib2[0]),
	    &mrt6stat, &len, NULL, 0) == -1) {
		if (errno != ENOPROTOOPT)
			warn("mroute");
		return;
	}

	printf("multicast forwarding:\n");
	printf("\t%llu multicast forwarding cache lookup%s\n",
	    mrt6stat.mrt6s_mfc_lookups, plural(mrt6stat.mrt6s_mfc_lookups));
	printf("\t%llu multicast forwarding cache miss%s\n",
	    mrt6stat.mrt6s_mfc_misses, plurales(mrt6stat.mrt6s_mfc_misses));
	printf("\t%llu upcall%s to mrouted\n",
	    mrt6stat.mrt6s_upcalls, plural(mrt6stat.mrt6s_upcalls));
	printf("\t%llu upcall queue overflow%s\n",
	    mrt6stat.mrt6s_upq_ovflw, plural(mrt6stat.mrt6s_upq_ovflw));
	printf("\t%llu upcall%s dropped due to full socket buffer\n",
	    mrt6stat.mrt6s_upq_sockfull, plural(mrt6stat.mrt6s_upq_sockfull));
	printf("\t%llu cache cleanup%s\n",
	    mrt6stat.mrt6s_cache_cleanups, plural(mrt6stat.mrt6s_cache_cleanups));
	printf("\t%llu datagram%s with no route for origin\n",
	    mrt6stat.mrt6s_no_route, plural(mrt6stat.mrt6s_no_route));
	printf("\t%llu datagram%s arrived with bad tunneling\n",
	    mrt6stat.mrt6s_bad_tunnel, plural(mrt6stat.mrt6s_bad_tunnel));
	printf("\t%llu datagram%s could not be tunneled\n",
	    mrt6stat.mrt6s_cant_tunnel, plural(mrt6stat.mrt6s_cant_tunnel));
	printf("\t%llu datagram%s arrived on wrong interface\n",
	    mrt6stat.mrt6s_wrong_if, plural(mrt6stat.mrt6s_wrong_if));
	printf("\t%llu datagram%s selectively dropped\n",
	    mrt6stat.mrt6s_drop_sel, plural(mrt6stat.mrt6s_drop_sel));
	printf("\t%llu datagram%s dropped due to queue overflow\n",
	    mrt6stat.mrt6s_q_overflow, plural(mrt6stat.mrt6s_q_overflow));
	printf("\t%llu datagram%s dropped for being too large\n",
	    mrt6stat.mrt6s_pkt2large, plural(mrt6stat.mrt6s_pkt2large));
}