MCPcopy Create free account
hub / github.com/F-Stack/f-stack / pfsync_stats

Function pfsync_stats

tools/netstat/if.c:135–188  ·  view source on GitHub ↗

* Dump pfsync statistics structure. */

Source from the content-addressed store, hash-verified

133 * Dump pfsync statistics structure.
134 */
135void
136pfsync_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
137{
138 struct pfsyncstats pfsyncstat;
139
140 if (fetch_stats("net.pfsync.stats", off, &pfsyncstat,
141 sizeof(pfsyncstat), kread) != 0)
142 return;
143
144 xo_emit("{T:/%s}:\n", name);
145 xo_open_container(name);
146
147#define p(f, m) if (pfsyncstat.f || sflag <= 1) \
148 xo_emit(m, (uintmax_t)pfsyncstat.f, plural(pfsyncstat.f))
149
150 p(pfsyncs_ipackets, "\t{:received-inet-packets/%ju} "
151 "{N:/packet%s received (IPv4)}\n");
152 p(pfsyncs_ipackets6, "\t{:received-inet6-packets/%ju} "
153 "{N:/packet%s received (IPv6)}\n");
154 pfsync_acts_stats("input-histogram", "received",
155 &pfsyncstat.pfsyncs_iacts[0]);
156 p(pfsyncs_badif, "\t\t/{:dropped-bad-interface/%ju} "
157 "{N:/packet%s discarded for bad interface}\n");
158 p(pfsyncs_badttl, "\t\t{:dropped-bad-ttl/%ju} "
159 "{N:/packet%s discarded for bad ttl}\n");
160 p(pfsyncs_hdrops, "\t\t{:dropped-short-header/%ju} "
161 "{N:/packet%s shorter than header}\n");
162 p(pfsyncs_badver, "\t\t{:dropped-bad-version/%ju} "
163 "{N:/packet%s discarded for bad version}\n");
164 p(pfsyncs_badauth, "\t\t{:dropped-bad-auth/%ju} "
165 "{N:/packet%s discarded for bad HMAC}\n");
166 p(pfsyncs_badact,"\t\t{:dropped-bad-action/%ju} "
167 "{N:/packet%s discarded for bad action}\n");
168 p(pfsyncs_badlen, "\t\t{:dropped-short/%ju} "
169 "{N:/packet%s discarded for short packet}\n");
170 p(pfsyncs_badval, "\t\t{:dropped-bad-values/%ju} "
171 "{N:/state%s discarded for bad values}\n");
172 p(pfsyncs_stale, "\t\t{:dropped-stale-state/%ju} "
173 "{N:/stale state%s}\n");
174 p(pfsyncs_badstate, "\t\t{:dropped-failed-lookup/%ju} "
175 "{N:/failed state lookup\\/insert%s}\n");
176 p(pfsyncs_opackets, "\t{:sent-inet-packets/%ju} "
177 "{N:/packet%s sent (IPv4})\n");
178 p(pfsyncs_opackets6, "\t{:send-inet6-packets/%ju} "
179 "{N:/packet%s sent (IPv6})\n");
180 pfsync_acts_stats("output-histogram", "sent",
181 &pfsyncstat.pfsyncs_oacts[0]);
182 p(pfsyncs_onomem, "\t\t{:discarded-no-memory/%ju} "
183 "{N:/failure%s due to mbuf memory error}\n");
184 p(pfsyncs_oerrors, "\t\t{:send-errors/%ju} "
185 "{N:/send error%s}\n");
186#undef p
187 xo_close_container(name);
188}
189#endif /* PF */
190
191/*

Callers

nothing calls this directly

Calls 5

fetch_statsFunction · 0.85
xo_emitFunction · 0.85
xo_open_containerFunction · 0.85
pfsync_acts_statsFunction · 0.85
xo_close_containerFunction · 0.85

Tested by

no test coverage detected