/* * Opening thread-self instead of /proc/net/... as the latter * points to /proc/self/net/ which instantiates thread-leader's * net-ns, see: * commit 155134fef2b6 ("Revert "proc: Point /proc/{mounts,net} at..")
*/
errno = 0;
fnetstat = fopen("/proc/thread-self/net/netstat", "r"); if (fnetstat == NULL)
test_error("failed to open /proc/net/netstat");
while (getline(&line, &line_sz, fnetstat) != -1)
netstat_read_type(fnetstat, &ret, line);
fclose(fnetstat);
errno = 0;
fnetstat = fopen("/proc/thread-self/net/snmp", "r"); if (fnetstat == NULL)
test_error("failed to open /proc/net/snmp");
while (getline(&line, &line_sz, fnetstat) != -1)
netstat_read_type(fnetstat, &ret, line);
fclose(fnetstat);
errno = 0;
fnetstat = fopen("/proc/thread-self/net/snmp6", "r"); if (fnetstat == NULL)
test_error("failed to open /proc/net/snmp6");
while (nsb != NULL) { if (unlikely(strcmp(nsb->header_name, nsa->header_name))) { for (i = 0; i < nsb->counters_nr; i++)
__netstat_print_diff(0, nsb, i);
nsb = nsb->next; continue;
}
if (nsb->counters_nr < nsa->counters_nr)
test_error("Unexpected: some counters disappeared!");
for (j = 0, i = 0; i < nsb->counters_nr; i++) { if (strcmp(nsb->counters[i].name, nsa->counters[j].name)) {
__netstat_print_diff(0, nsb, i); continue;
}
if (nsa->counters[j].val == nsb->counters[i].val) {
j++; continue;
}
__netstat_print_diff(nsa->counters[j].val, nsb, i);
j++;
} if (j != nsa->counters_nr)
test_error("Unexpected: some counters disappeared!");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.