DF-3420 / statloop.c
/* DF-3420: tight DIOCGETSTATUS loop -> pfi_update_status group branch */ #include <sys/types.h> #include <sys/ioctl.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/socket.h> #include <net/if.h> #include <net/pf/pfvar.h> int main(int argc, char **argv) { static struct pf_status st; long n, i, lim; lim = argc > 1 ? atol(argv[1]) : 1000000; int fd = open("/dev/pf", O_RDWR); if (fd < 0) { perror("open"); return 2; } for (i = 0; i < lim; i++) { if (ioctl(fd, DIOCGETSTATUS, &st) != 0) { perror("DIOCGETSTATUS"); return 2; } } printf("statloop done %ld\n", lim); return 0; } |