Date: Wed, 19 Aug 2009 03:08:24 GMT From: Gabor Pali <pgj@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 167492 for review Message-ID: <200908190308.n7J38OpP066326@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=167492 Change 167492 by pgj@petymeg-current on 2009/08/19 03:07:31 Add support for exporting IPv6 multicast forwarding table as a streamed data flow, via sysctl(3) [net.inet6.ip6.smf6ctable]. Affected files ... .. //depot/projects/soc2009/pgj_libstat/src/sys/netinet6/ip6_mroute.c#5 edit .. //depot/projects/soc2009/pgj_libstat/src/sys/netinet6/ip6_mroute.h#4 edit Differences ... ==== //depot/projects/soc2009/pgj_libstat/src/sys/netinet6/ip6_mroute.c#5 (text+ko) ==== @@ -601,6 +601,78 @@ "IPv6 Multicast Interfaces (streamed)"); static int +export_mf6ctable(SYSCTL_HANDLER_ARGS) +{ + struct mf6c_stream ms; + struct mf6c_data md; + struct sbuf sbuf; + int error, buflen; + char *buffer; + struct mf6c *m; + struct rtdetq *r; + u_int32_t i; + + error = 0; + bzero(&ms, sizeof(ms)); + ms.ms_version = MF6C_STREAM_VERSION; + + MFC6_LOCK(); + + /* Count entries. */ + ms.ms_count = 0; + for (i = 0; i < MF6CTBLSIZ; i++) { + for (m = mf6ctable[i]; m != NULL; m = m->mf6c_next) + ms.ms_count++; + } + + buflen = sizeof(ms) + ms.ms_count * sizeof(md) + 1; + buffer = malloc(buflen, M_TEMP, M_WAITOK | M_ZERO); + sbuf_new(&sbuf, buffer, buflen, SBUF_FIXEDLEN); + + if (sbuf_bcat(&sbuf, &ms, sizeof(ms)) < 0) { + error = ENOMEM; + goto out; + } + + for (i = 0; i < MF6CTBLSIZ; i++) { + for (m = mf6ctable[i]; m != NULL; m = m->mf6c_next) { + bzero(&md, sizeof(md)); + bcopy(&m->mf6c_origin.sin6_addr, md.md_origin, + sizeof(md.md_origin)); + bcopy(&m->mf6c_mcastgrp.sin6_addr, md.md_mcastgrp, + sizeof(md.md_mcastgrp)); + md.md_pkt_cnt = m->mf6c_pkt_cnt; + md.md_byte_cnt = m->mf6c_byte_cnt; + + md.md_nstall = 0; + for (r = m->mf6c_stall; r != NULL; r = r->next) + md.md_nstall++; + + md.md_parent = m->mf6c_parent; + bcopy(&m->mf6c_ifset, md.md_ifs_bits, + sizeof(md.md_ifs_bits)); + + if (sbuf_bcat(&sbuf, &md, sizeof(md)) < 0) { + error = ENOMEM; + goto out; + } + } + } + + MFC6_UNLOCK(); + + sbuf_finish(&sbuf); + error = SYSCTL_OUT(req, sbuf_data(&sbuf), sbuf_len(&sbuf)); +out: + free(buffer, M_TEMP); + return (error); +} + +SYSCTL_PROC(_net_inet6_ip6, OID_AUTO, smf6ctable, CTLFLAG_RD|CTLTYPE_STRUCT, + 0, 0, export_mf6ctable, "s,struct mf6c_data", + "IPv6 Multicast Forwarding Table (streamed)"); + +static int set_pim6(int *i) { INIT_VNET_INET6(curvnet); ==== //depot/projects/soc2009/pgj_libstat/src/sys/netinet6/ip6_mroute.h#4 (text+ko) ==== @@ -260,6 +260,24 @@ #define MF6C_INCOMPLETE_PARENT ((mifi_t)-1) +#define MF6C_STREAM_VERSION 0x00000001 + +struct mf6c_stream { + u_int32_t ms_version; + u_int32_t ms_count; +}; + +struct mf6c_data { + u_int8_t md_origin[16]; /* 128-bit IP6 address */ + u_int8_t md_mcastgrp[16]; /* 128-bit IP6 address */ + u_int64_t md_pkt_cnt; + u_int64_t md_byte_cnt; + u_int64_t md_nstall; + u_int32_t md_parent; + u_int32_t md_ifs_bits[8]; + u_int8_t _md_pad[36]; +}; + /* * Argument structure used for pkt info. while upcall is made */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200908190308.n7J38OpP066326>