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

Function pfkey_stats

tools/netstat/pfkey.c:115–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115void
116pfkey_stats(u_long off, const char *name, int family __unused,
117 int proto __unused)
118{
119 struct pfkeystat pfkeystat;
120 unsigned first, type;
121
122 if (off == 0)
123 return;
124 xo_emit("{T:/%s}:\n", name);
125 xo_open_container(name);
126 kread_counters(off, (char *)&pfkeystat, sizeof(pfkeystat));
127
128#define p(f, m) if (pfkeystat.f || sflag <= 1) \
129 xo_emit(m, (uintmax_t)pfkeystat.f, plural(pfkeystat.f))
130
131 /* userland -> kernel */
132 p(out_total, "\t{:sent-requests/%ju} "
133 "{N:/request%s sent from userland}\n");
134 p(out_bytes, "\t{:sent-bytes/%ju} "
135 "{N:/byte%s sent from userland}\n");
136 for (first = 1, type = 0;
137 type<sizeof(pfkeystat.out_msgtype)/sizeof(pfkeystat.out_msgtype[0]);
138 type++) {
139 if (pfkeystat.out_msgtype[type] <= 0)
140 continue;
141 if (first) {
142 xo_open_list("output-histogram");
143 xo_emit("\t{T:histogram by message type}:\n");
144 first = 0;
145 }
146 xo_open_instance("output-histogram");
147 xo_emit("\t\t{k::type/%s}: {:count/%ju}\n",
148 pfkey_msgtype_names(type),
149 (uintmax_t)pfkeystat.out_msgtype[type]);
150 xo_close_instance("output-histogram");
151 }
152 if (!first)
153 xo_close_list("output-histogram");
154
155 p(out_invlen, "\t{:dropped-bad-length/%ju} "
156 "{N:/message%s with invalid length field}\n");
157 p(out_invver, "\t{:dropped-bad-version/%ju} "
158 "{N:/message%s with invalid version field}\n");
159 p(out_invmsgtype, "\t{:dropped-bad-type/%ju} "
160 "{N:/message%s with invalid message type field}\n");
161 p(out_tooshort, "\t{:dropped-too-short/%ju} "
162 "{N:/message%s too short}\n");
163 p(out_nomem, "\t{:dropped-no-memory/%ju} "
164 "{N:/message%s with memory allocation failure}\n");
165 p(out_dupext, "\t{:dropped-duplicate-extension/%ju} "
166 "{N:/message%s with duplicate extension}\n");
167 p(out_invexttype, "\t{:dropped-bad-extension/%ju} "
168 "{N:/message%s with invalid extension type}\n");
169 p(out_invsatype, "\t{:dropped-bad-sa-type/%ju} "
170 "{N:/message%s with invalid sa type}\n");
171 p(out_invaddr, "\t{:dropped-bad-address-extension/%ju} "
172 "{N:/message%s with invalid address extension}\n");

Callers

nothing calls this directly

Calls 9

xo_emitFunction · 0.85
xo_open_containerFunction · 0.85
kread_countersFunction · 0.85
xo_open_listFunction · 0.85
xo_open_instanceFunction · 0.85
pfkey_msgtype_namesFunction · 0.85
xo_close_instanceFunction · 0.85
xo_close_listFunction · 0.85
xo_close_containerFunction · 0.85

Tested by

no test coverage detected