Add 64bit statistic counters to the ng_ppp node.
64bit counters are needed to simplify traffic accounting and reduce system load at the big PPP concentrators. Approved by: re (rwatson), glebius (mentor)
This commit is contained in:
parent
7613322fdb
commit
d6fe462ac1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=171688
@ -395,6 +395,10 @@ containing statistics for the corresponding link.
|
|||||||
Here
|
Here
|
||||||
.Dv NG_PPP_BUNDLE_LINKNUM
|
.Dv NG_PPP_BUNDLE_LINKNUM
|
||||||
is a valid link number corresponding to the multi-link bundle.
|
is a valid link number corresponding to the multi-link bundle.
|
||||||
|
.It Dv NGM_PPP_GET_LINK_STATS64
|
||||||
|
Same as NGM_PPP_GET_LINK_STATS but returns
|
||||||
|
.Dv "struct ng_ppp_link_stat64"
|
||||||
|
containing 64bit counters.
|
||||||
.It Dv NGM_PPP_CLR_LINK_STATS
|
.It Dv NGM_PPP_CLR_LINK_STATS
|
||||||
This command takes a two byte link number as an argument and
|
This command takes a two byte link number as an argument and
|
||||||
clears the statistics for that link.
|
clears the statistics for that link.
|
||||||
@ -402,6 +406,10 @@ clears the statistics for that link.
|
|||||||
Same as
|
Same as
|
||||||
.Dv NGM_PPP_GET_LINK_STATS ,
|
.Dv NGM_PPP_GET_LINK_STATS ,
|
||||||
but also atomically clears the statistics as well.
|
but also atomically clears the statistics as well.
|
||||||
|
.It Dv NGM_PPP_GETCLR_LINK_STATS64
|
||||||
|
Same as NGM_PPP_GETCLR_LINK_STATS but returns
|
||||||
|
.Dv "struct ng_ppp_link_stat64"
|
||||||
|
containing 64bit counters.
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
This node type also accepts the control messages accepted by the
|
This node type also accepts the control messages accepted by the
|
||||||
|
@ -196,7 +196,7 @@ struct ng_ppp_frag {
|
|||||||
/* Per-link private information */
|
/* Per-link private information */
|
||||||
struct ng_ppp_link {
|
struct ng_ppp_link {
|
||||||
struct ng_ppp_link_conf conf; /* link configuration */
|
struct ng_ppp_link_conf conf; /* link configuration */
|
||||||
struct ng_ppp_link_stat stats; /* link stats */
|
struct ng_ppp_link_stat64 stats; /* link stats */
|
||||||
hook_p hook; /* connection to link data */
|
hook_p hook; /* connection to link data */
|
||||||
int32_t seq; /* highest rec'd seq# - MSEQ */
|
int32_t seq; /* highest rec'd seq# - MSEQ */
|
||||||
uint32_t latency; /* calculated link latency */
|
uint32_t latency; /* calculated link latency */
|
||||||
@ -207,7 +207,7 @@ struct ng_ppp_link {
|
|||||||
/* Total per-node private information */
|
/* Total per-node private information */
|
||||||
struct ng_ppp_private {
|
struct ng_ppp_private {
|
||||||
struct ng_ppp_bund_conf conf; /* bundle config */
|
struct ng_ppp_bund_conf conf; /* bundle config */
|
||||||
struct ng_ppp_link_stat bundleStats; /* bundle stats */
|
struct ng_ppp_link_stat64 bundleStats; /* bundle stats */
|
||||||
struct ng_ppp_link links[NG_PPP_MAX_LINKS];/* per-link info */
|
struct ng_ppp_link links[NG_PPP_MAX_LINKS];/* per-link info */
|
||||||
int32_t xseq; /* next out MP seq # */
|
int32_t xseq; /* next out MP seq # */
|
||||||
int32_t mseq; /* min links[i].seq */
|
int32_t mseq; /* min links[i].seq */
|
||||||
@ -383,6 +383,14 @@ static const struct ng_parse_type ng_ppp_stats_type = {
|
|||||||
&ng_ppp_stats_type_fields
|
&ng_ppp_stats_type_fields
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Parse type for struct ng_ppp_link_stat64 */
|
||||||
|
static const struct ng_parse_struct_field ng_ppp_stats64_type_fields[]
|
||||||
|
= NG_PPP_STATS64_TYPE_INFO;
|
||||||
|
static const struct ng_parse_type ng_ppp_stats64_type = {
|
||||||
|
&ng_parse_struct_type,
|
||||||
|
&ng_ppp_stats64_type_fields
|
||||||
|
};
|
||||||
|
|
||||||
/* List of commands and how to convert arguments to/from ASCII */
|
/* List of commands and how to convert arguments to/from ASCII */
|
||||||
static const struct ng_cmdlist ng_ppp_cmds[] = {
|
static const struct ng_cmdlist ng_ppp_cmds[] = {
|
||||||
{
|
{
|
||||||
@ -427,6 +435,20 @@ static const struct ng_cmdlist ng_ppp_cmds[] = {
|
|||||||
&ng_parse_int16_type,
|
&ng_parse_int16_type,
|
||||||
&ng_ppp_stats_type
|
&ng_ppp_stats_type
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
NGM_PPP_COOKIE,
|
||||||
|
NGM_PPP_GET_LINK_STATS64,
|
||||||
|
"getstats64",
|
||||||
|
&ng_parse_int16_type,
|
||||||
|
&ng_ppp_stats64_type
|
||||||
|
},
|
||||||
|
{
|
||||||
|
NGM_PPP_COOKIE,
|
||||||
|
NGM_PPP_GETCLR_LINK_STATS64,
|
||||||
|
"getclrstats64",
|
||||||
|
&ng_parse_int16_type,
|
||||||
|
&ng_ppp_stats64_type
|
||||||
|
},
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -617,10 +639,13 @@ ng_ppp_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
|||||||
case NGM_PPP_GET_LINK_STATS:
|
case NGM_PPP_GET_LINK_STATS:
|
||||||
case NGM_PPP_CLR_LINK_STATS:
|
case NGM_PPP_CLR_LINK_STATS:
|
||||||
case NGM_PPP_GETCLR_LINK_STATS:
|
case NGM_PPP_GETCLR_LINK_STATS:
|
||||||
|
case NGM_PPP_GET_LINK_STATS64:
|
||||||
|
case NGM_PPP_GETCLR_LINK_STATS64:
|
||||||
{
|
{
|
||||||
struct ng_ppp_link_stat *stats;
|
struct ng_ppp_link_stat64 *stats;
|
||||||
uint16_t linkNum;
|
uint16_t linkNum;
|
||||||
|
|
||||||
|
/* Process request. */
|
||||||
if (msg->header.arglen != sizeof(uint16_t))
|
if (msg->header.arglen != sizeof(uint16_t))
|
||||||
ERROUT(EINVAL);
|
ERROUT(EINVAL);
|
||||||
linkNum = *((uint16_t *) msg->data);
|
linkNum = *((uint16_t *) msg->data);
|
||||||
@ -629,14 +654,38 @@ ng_ppp_rcvmsg(node_p node, item_p item, hook_p lasthook)
|
|||||||
ERROUT(EINVAL);
|
ERROUT(EINVAL);
|
||||||
stats = (linkNum == NG_PPP_BUNDLE_LINKNUM) ?
|
stats = (linkNum == NG_PPP_BUNDLE_LINKNUM) ?
|
||||||
&priv->bundleStats : &priv->links[linkNum].stats;
|
&priv->bundleStats : &priv->links[linkNum].stats;
|
||||||
if (msg->header.cmd != NGM_PPP_CLR_LINK_STATS) {
|
|
||||||
|
/* Make 64bit reply. */
|
||||||
|
if (msg->header.cmd == NGM_PPP_GET_LINK_STATS64 ||
|
||||||
|
msg->header.cmd == NGM_PPP_GETCLR_LINK_STATS64) {
|
||||||
|
NG_MKRESPONSE(resp, msg,
|
||||||
|
sizeof(struct ng_ppp_link_stat64), M_NOWAIT);
|
||||||
|
if (resp == NULL)
|
||||||
|
ERROUT(ENOMEM);
|
||||||
|
bcopy(stats, resp->data, sizeof(*stats));
|
||||||
|
} else
|
||||||
|
/* Make 32bit reply. */
|
||||||
|
if (msg->header.cmd == NGM_PPP_GET_LINK_STATS ||
|
||||||
|
msg->header.cmd == NGM_PPP_GETCLR_LINK_STATS) {
|
||||||
|
struct ng_ppp_link_stat *rs;
|
||||||
NG_MKRESPONSE(resp, msg,
|
NG_MKRESPONSE(resp, msg,
|
||||||
sizeof(struct ng_ppp_link_stat), M_NOWAIT);
|
sizeof(struct ng_ppp_link_stat), M_NOWAIT);
|
||||||
if (resp == NULL)
|
if (resp == NULL)
|
||||||
ERROUT(ENOMEM);
|
ERROUT(ENOMEM);
|
||||||
bcopy(stats, resp->data, sizeof(*stats));
|
rs = (struct ng_ppp_link_stat *)resp->data;
|
||||||
|
/* Truncate 64->32 bits. */
|
||||||
|
rs->xmitFrames = stats->xmitFrames;
|
||||||
|
rs->xmitOctets = stats->xmitOctets;
|
||||||
|
rs->recvFrames = stats->recvFrames;
|
||||||
|
rs->recvOctets = stats->recvOctets;
|
||||||
|
rs->badProtos = stats->badProtos;
|
||||||
|
rs->runts = stats->runts;
|
||||||
|
rs->dupFragments = stats->dupFragments;
|
||||||
|
rs->dropFragments = stats->dropFragments;
|
||||||
}
|
}
|
||||||
if (msg->header.cmd != NGM_PPP_GET_LINK_STATS)
|
/* Clear stats. */
|
||||||
|
if (msg->header.cmd != NGM_PPP_GET_LINK_STATS &&
|
||||||
|
msg->header.cmd != NGM_PPP_GET_LINK_STATS64)
|
||||||
bzero(stats, sizeof(*stats));
|
bzero(stats, sizeof(*stats));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,9 @@
|
|||||||
#define NG_PPP_NODE_TYPE "ppp"
|
#define NG_PPP_NODE_TYPE "ppp"
|
||||||
#define NGM_PPP_COOKIE 940897795
|
#define NGM_PPP_COOKIE 940897795
|
||||||
|
|
||||||
|
/* 64bit stats presence flag */
|
||||||
|
#define NG_PPP_STATS64
|
||||||
|
|
||||||
/* Maximum number of supported links */
|
/* Maximum number of supported links */
|
||||||
#define NG_PPP_MAX_LINKS 16
|
#define NG_PPP_MAX_LINKS 16
|
||||||
|
|
||||||
@ -97,6 +100,8 @@ enum {
|
|||||||
NGM_PPP_GET_LINK_STATS, /* takes link #, returns stats struct */
|
NGM_PPP_GET_LINK_STATS, /* takes link #, returns stats struct */
|
||||||
NGM_PPP_CLR_LINK_STATS, /* takes link #, clears link stats */
|
NGM_PPP_CLR_LINK_STATS, /* takes link #, clears link stats */
|
||||||
NGM_PPP_GETCLR_LINK_STATS, /* takes link #, returns & clrs stats */
|
NGM_PPP_GETCLR_LINK_STATS, /* takes link #, returns & clrs stats */
|
||||||
|
NGM_PPP_GET_LINK_STATS64, /* takes link #, returns stats64 struct */
|
||||||
|
NGM_PPP_GETCLR_LINK_STATS64, /* takes link #, returns stats64 & clrs */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Multi-link sequence number state (for debugging) */
|
/* Multi-link sequence number state (for debugging) */
|
||||||
@ -212,4 +217,29 @@ struct ng_ppp_link_stat {
|
|||||||
{ NULL } \
|
{ NULL } \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Statistics struct for a link (or the bundle if NG_PPP_BUNDLE_LINKNUM) */
|
||||||
|
struct ng_ppp_link_stat64 {
|
||||||
|
u_int64_t xmitFrames; /* xmit frames on link */
|
||||||
|
u_int64_t xmitOctets; /* xmit octets on link */
|
||||||
|
u_int64_t recvFrames; /* recv frames on link */
|
||||||
|
u_int64_t recvOctets; /* recv octets on link */
|
||||||
|
u_int64_t badProtos; /* frames rec'd with bogus protocol */
|
||||||
|
u_int64_t runts; /* Too short MP fragments */
|
||||||
|
u_int64_t dupFragments; /* MP frames with duplicate seq # */
|
||||||
|
u_int64_t dropFragments; /* MP fragments we had to drop */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Keep this in sync with the above structure definition */
|
||||||
|
#define NG_PPP_STATS64_TYPE_INFO { \
|
||||||
|
{ "xmitFrames", &ng_parse_uint64_type }, \
|
||||||
|
{ "xmitOctets", &ng_parse_uint64_type }, \
|
||||||
|
{ "recvFrames", &ng_parse_uint64_type }, \
|
||||||
|
{ "recvOctets", &ng_parse_uint64_type }, \
|
||||||
|
{ "badProtos", &ng_parse_uint64_type }, \
|
||||||
|
{ "runts", &ng_parse_uint64_type }, \
|
||||||
|
{ "dupFragments", &ng_parse_uint64_type }, \
|
||||||
|
{ "dropFragments", &ng_parse_uint64_type }, \
|
||||||
|
{ NULL } \
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _NETGRAPH_NG_PPP_H_ */
|
#endif /* _NETGRAPH_NG_PPP_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user