From owner-p4-projects@FreeBSD.ORG Tue Aug 18 02:55:56 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 34231106568F; Tue, 18 Aug 2009 02:55:56 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ED2AD106568C for ; Tue, 18 Aug 2009 02:55:55 +0000 (UTC) (envelope-from pgj@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id C3AB68FC61 for ; Tue, 18 Aug 2009 02:55:55 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n7I2ttW0069215 for ; Tue, 18 Aug 2009 02:55:55 GMT (envelope-from pgj@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n7I2ttpF069213 for perforce@freebsd.org; Tue, 18 Aug 2009 02:55:55 GMT (envelope-from pgj@FreeBSD.org) Date: Tue, 18 Aug 2009 02:55:55 GMT Message-Id: <200908180255.n7I2ttpF069213@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to pgj@FreeBSD.org using -f From: Gabor Pali To: Perforce Change Reviews Cc: Subject: PERFORCE change 167459 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Aug 2009 02:55:56 -0000 http://perforce.freebsd.org/chv.cgi?CH=167459 Change 167459 by pgj@petymeg-current on 2009/08/18 02:55:38 Add support for exporting IPv6 multicast interface data in a standardized format via sysctl(3) [net.inet6.ip6.smif6table]. Affected files ... .. //depot/projects/soc2009/pgj_libstat/src/sys/netinet6/ip6_mroute.c#4 edit .. //depot/projects/soc2009/pgj_libstat/src/sys/netinet6/ip6_mroute.h#3 edit Differences ... ==== //depot/projects/soc2009/pgj_libstat/src/sys/netinet6/ip6_mroute.c#4 (text+ko) ==== @@ -95,6 +95,7 @@ #include #include #include +#include #include #include #include @@ -541,6 +542,65 @@ } static int +export_mif6table(SYSCTL_HANDLER_ARGS) +{ + struct mif6_stream ms; + struct mif6_data md; + struct sbuf sbuf; + int error, buflen; + char *buffer; + struct mif6* m; + mifi_t mifi; + + error = 0; + bzero(&ms, sizeof(ms)); + ms.ms_version = MIF6_STREAM_VERSION; + + MIF6_LOCK(); + + ms.ms_count = nummifs; + 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 (mifi = 0; mifi < nummifs; mifi++) { + m = &mif6table[mifi]; + + bzero(&md, sizeof(md)); + md.md_flags = m->m6_flags; + md.md_rate_limit = m->m6_rate_limit; + bcopy(&m->m6_lcl_addr, md.md_lcl_addr, sizeof(md.md_lcl_addr)); + md.md_if_index = m->m6_ifp->if_index; + md.md_pkt_in = m->m6_pkt_in; + md.md_pkt_out = m->m6_pkt_out; + md.md_bytes_in = m->m6_bytes_in; + md.md_bytes_out = m->m6_bytes_out; + + if (sbuf_bcat(&sbuf, &md, sizeof(md)) < 0) { + error = ENOMEM; + goto out; + } + } + + MIF6_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, smif6table, CTLFLAG_RD|CTLTYPE_STRUCT, + 0, 0, export_mif6table, "s,struct mif6_data", + "IPv6 Multicast Interfaces (streamed)"); + +static int set_pim6(int *i) { INIT_VNET_INET6(curvnet); ==== //depot/projects/soc2009/pgj_libstat/src/sys/netinet6/ip6_mroute.h#3 (text+ko) ==== @@ -201,6 +201,25 @@ u_quad_t obytes; /* Output byte count on mif */ }; +#define MIF6_STREAM_VERSION 0x00000001 + +struct mif6_stream { + u_int32_t ms_version; + u_int32_t ms_count; +}; + +struct mif6_data { + u_int8_t md_flags; + u_int16_t md_rate_limit; + u_int8_t md_lcl_addr[16]; /* 128-bit IP6 address */ + u_int32_t md_if_index; + u_int64_t md_pkt_in; + u_int64_t md_pkt_out; + u_int64_t md_bytes_in; + u_int64_t md_bytes_out; + u_int8_t _md_pad[9]; +}; + #if defined(_KERNEL) || defined(KERNEL) /* * The kernel's multicast-interface structure.