From owner-svn-src-stable@FreeBSD.ORG Mon Jun 24 09:39:07 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 9690A9EC; Mon, 24 Jun 2013 09:39:07 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 787AE1941; Mon, 24 Jun 2013 09:39:07 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5O9d71m015217; Mon, 24 Jun 2013 09:39:07 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r5O9d6tB015213; Mon, 24 Jun 2013 09:39:06 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201306240939.r5O9d6tB015213@svn.freebsd.org> From: Gleb Smirnoff Date: Mon, 24 Jun 2013 09:39:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252156 - in stable/9: share/man/man4 sys/netgraph X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Jun 2013 09:39:07 -0000 Author: glebius Date: Mon Jun 24 09:39:06 2013 New Revision: 252156 URL: http://svnweb.freebsd.org/changeset/base/252156 Log: Merge r248570, 248582: Add NGM_NAT_LIBALIAS_INFO command, that reports internal stats of libalias instance. To be used in the mpd5 daemon. Submitted by: Dmitry Luhtionov Modified: stable/9/share/man/man4/ng_nat.4 stable/9/sys/netgraph/ng_nat.c stable/9/sys/netgraph/ng_nat.h Directory Properties: stable/9/share/man/man4/ (props changed) stable/9/sys/ (props changed) Modified: stable/9/share/man/man4/ng_nat.4 ============================================================================== --- stable/9/share/man/man4/ng_nat.4 Mon Jun 24 09:36:56 2013 (r252155) +++ stable/9/share/man/man4/ng_nat.4 Mon Jun 24 09:39:06 2013 (r252156) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 1, 2008 +.Dd March 21, 2013 .Dt NG_NAT 4 .Os .Sh NAME @@ -239,6 +239,31 @@ supplied as argument). See .Xr libalias 3 for details. +.It Dv NGM_NAT_LIBALIAS_INFO Pq Ic libaliasinfo +Return internal statistics of +.Xr libalias 3 +instance as +.Vt "struct ng_nat_libalias_info" . +.Bd -literal +struct ng_nat_libalias_info { + uint32_t icmpLinkCount; + uint32_t udpLinkCount; + uint32_t tcpLinkCount; + uint32_t sctpLinkCount; + uint32_t pptpLinkCount; + uint32_t protoLinkCount; + uint32_t fragmentIdLinkCount; + uint32_t fragmentPtrLinkCount; + uint32_t sockCount; +}; +.Ed +In case of +.Nm +failed to retreive a certain counter +from its +.Xr libalias +instance, the corresponding field is returned as +.Va UINT32_MAX . .El .Pp In all redirection messages Modified: stable/9/sys/netgraph/ng_nat.c ============================================================================== --- stable/9/sys/netgraph/ng_nat.c Mon Jun 24 09:36:56 2013 (r252155) +++ stable/9/sys/netgraph/ng_nat.c Mon Jun 24 09:39:06 2013 (r252156) @@ -145,6 +145,14 @@ static const struct ng_parse_type ng_nat &ng_nat_list_redirects_fields }; +/* Parse type for struct ng_nat_libalias_info. */ +static const struct ng_parse_struct_field ng_nat_libalias_info_fields[] + = NG_NAT_LIBALIAS_INFO; +static const struct ng_parse_type ng_nat_libalias_info_type = { + &ng_parse_struct_type, + &ng_nat_libalias_info_fields +}; + /* List of commands and how to convert arguments to/from ASCII. */ static const struct ng_cmdlist ng_nat_cmdlist[] = { { @@ -224,6 +232,13 @@ static const struct ng_cmdlist ng_nat_cm &ng_parse_string_type, NULL }, + { + NGM_NAT_COOKIE, + NGM_NAT_LIBALIAS_INFO, + "libaliasinfo", + NULL, + &ng_nat_libalias_info_type + }, { 0 } }; @@ -647,6 +662,36 @@ ng_nat_rcvmsg(node_p node, item_p item, error = ENOMEM; } break; + case NGM_NAT_LIBALIAS_INFO: + { + struct ng_nat_libalias_info *i; + + NG_MKRESPONSE(resp, msg, + sizeof(struct ng_nat_libalias_info), M_NOWAIT); + if (resp == NULL) { + error = ENOMEM; + break; + } + i = (struct ng_nat_libalias_info *)resp->data; +#define COPY(F) do { \ + if (priv->lib->F >= 0 && priv->lib->F < UINT32_MAX) \ + i->F = priv->lib->F; \ + else \ + i->F = UINT32_MAX; \ +} while (0) + + COPY(icmpLinkCount); + COPY(udpLinkCount); + COPY(tcpLinkCount); + COPY(pptpLinkCount); + COPY(sctpLinkCount); + COPY(protoLinkCount); + COPY(fragmentIdLinkCount); + COPY(fragmentPtrLinkCount); + COPY(sockCount); +#undef COPY + } + break; default: error = EINVAL; /* unknown command */ break; Modified: stable/9/sys/netgraph/ng_nat.h ============================================================================== --- stable/9/sys/netgraph/ng_nat.h Mon Jun 24 09:36:56 2013 (r252155) +++ stable/9/sys/netgraph/ng_nat.h Mon Jun 24 09:39:06 2013 (r252156) @@ -172,6 +172,33 @@ struct ng_nat_list_redirects { { NULL } \ } +/* Structure returned by NGM_NAT_LIBALIAS_INFO */ +struct ng_nat_libalias_info { + uint32_t icmpLinkCount; + uint32_t udpLinkCount; + uint32_t tcpLinkCount; + uint32_t sctpLinkCount; + uint32_t pptpLinkCount; + uint32_t protoLinkCount; + uint32_t fragmentIdLinkCount; + uint32_t fragmentPtrLinkCount; + uint32_t sockCount; +}; + +/* Keep this in sync with the above structure definition */ +#define NG_NAT_LIBALIAS_INFO { \ + { "icmpLinkCount", &ng_parse_uint32_type }, \ + { "udpLinkCount", &ng_parse_uint32_type }, \ + { "tcpLinkCount", &ng_parse_uint32_type }, \ + { "sctpLinkCount", &ng_parse_uint32_type }, \ + { "pptpLinkCount", &ng_parse_uint32_type }, \ + { "protoLinkCount", &ng_parse_uint32_type }, \ + { "fragmentIdLinkCount", &ng_parse_uint32_type }, \ + { "fragmentPtrLinkCount", &ng_parse_uint32_type }, \ + { "sockCount", &ng_parse_uint32_type }, \ + { NULL } \ +} + enum { NGM_NAT_SET_IPADDR = 1, NGM_NAT_SET_MODE, @@ -184,4 +211,5 @@ enum { NGM_NAT_ADD_SERVER, NGM_NAT_LIST_REDIRECTS, NGM_NAT_PROXY_RULE, + NGM_NAT_LIBALIAS_INFO, };