if (ifindex > -1) { if (bpf_xdp_query_id(ifindex, xdp_flags, &curr_prog_id)) {
printf("bpf_xdp_query_id failed\n"); exit(1);
} if (prog_id == curr_prog_id)
bpf_xdp_detach(ifindex, xdp_flags, NULL); elseif (!curr_prog_id)
printf("couldn't find a prog id on a given iface\n"); else
printf("program on interface changed, not removing\n");
} exit(0);
}
while (!kill_after_s || time(NULL) - started_at <= kill_after_s) {
sleep(STATS_INTERVAL_S);
for (proto = 0; proto < nr_protos; proto++) {
__u64 sum = 0;
assert(bpf_map_lookup_elem(rxcnt_map_fd, &proto,
values) == 0); for (i = 0; i < nr_cpus; i++)
sum += (values[i] - prev[proto][i]);
if (sum)
printf("proto %u: sum:%10llu pkts, rate:%10llu pkts/s\n",
proto, sum, sum / STATS_INTERVAL_S);
memcpy(prev[proto], values, sizeof(values));
}
}
}
staticvoid usage(constchar *cmd)
{
printf("Start a XDP prog which encapsulates incoming packets\n" "in an IPv4/v6 header and XDP_TX it out. The dst \n" "is used to select packets to encapsulate\n\n");
printf("Usage: %s [...]\n", cmd);
printf(" -i Interface\n");
printf(" -a IPv4 or IPv6\n");
printf(" -p A port range (e.g. 433-444) is also allowed\n");
printf(" -s Used in the IPTunnel header\n");
printf(" -d Used in the IPTunnel header\n");
printf(" -m Used in sending the IP Tunneled pkt\n");
printf(" -T Default: 0 (forever)\n");
printf(" -P Default is TCP\n");
printf(" -S use skb-mode\n");
printf(" -N enforce native mode\n");
printf(" -F Force loading the XDP prog\n");
printf(" -h Display this help\n");
}
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.