Author: glebius Date: Thu Mar 21 08:36:15 2013 New Revision: 248570 URL: http://svnweb.freebsd.org/changeset/base/248570
Log: Add NGM_NAT_LIBALIAS_INFO command, that reports internal stats of libalias instance. To be used in the mpd5 daemon. Submitted by: Dmitry Luhtionov <dmitryluhtionov gmail.com> Modified: head/sys/netgraph/ng_nat.c head/sys/netgraph/ng_nat.h Modified: head/sys/netgraph/ng_nat.c ============================================================================== --- head/sys/netgraph/ng_nat.c Thu Mar 21 07:28:15 2013 (r248569) +++ head/sys/netgraph/ng_nat.c Thu Mar 21 08:36:15 2013 (r248570) @@ -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: head/sys/netgraph/ng_nat.h ============================================================================== --- head/sys/netgraph/ng_nat.h Thu Mar 21 07:28:15 2013 (r248569) +++ head/sys/netgraph/ng_nat.h Thu Mar 21 08:36:15 2013 (r248570) @@ -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, }; _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"