diff options
-rw-r--r-- | netsniff-ng.c | 6 | ||||
-rw-r--r-- | pcap_io.h | 2 | ||||
-rw-r--r-- | pcap_mm.c | 5 | ||||
-rw-r--r-- | pcap_rw.c | 5 | ||||
-rw-r--r-- | pcap_sg.c | 5 |
5 files changed, 13 insertions, 10 deletions
diff --git a/netsniff-ng.c b/netsniff-ng.c index 4ad8b19..ee9dc38 100644 --- a/netsniff-ng.c +++ b/netsniff-ng.c @@ -228,7 +228,7 @@ static void pcap_to_xmit(struct ctx *ctx) } if (__pcap_io->init_once_pcap) - __pcap_io->init_once_pcap(); + __pcap_io->init_once_pcap(true); ret = __pcap_io->pull_fhdr_pcap(fd, &ctx->magic, &ctx->link_type); if (ret) @@ -567,7 +567,7 @@ static void read_pcap(struct ctx *ctx) } if (__pcap_io->init_once_pcap) - __pcap_io->init_once_pcap(); + __pcap_io->init_once_pcap(false); ret = __pcap_io->pull_fhdr_pcap(fd, &ctx->magic, &ctx->link_type); if (ret) @@ -963,7 +963,7 @@ static void recv_only_or_dump(struct ctx *ctx) ifflags = device_enter_promiscuous_mode(ctx->device_in); if (dump_to_pcap(ctx) && __pcap_io->init_once_pcap) - __pcap_io->init_once_pcap(); + __pcap_io->init_once_pcap(true); drop_privileges(ctx->enforce, ctx->uid, ctx->gid); @@ -122,7 +122,7 @@ enum pcap_mode { }; struct pcap_file_ops { - void (*init_once_pcap)(void); + void (*init_once_pcap)(bool enforce_prio); int (*pull_fhdr_pcap)(int fd, uint32_t *magic, uint32_t *linktype); int (*push_fhdr_pcap)(int fd, uint32_t magic, uint32_t linktype); int (*prepare_access_pcap)(int fd, enum pcap_mode mode, bool jumbo); @@ -148,9 +148,10 @@ static void __pcap_mm_prepare_access_rd(int fd) ptr_va_curr = ptr_va_start + sizeof(struct pcap_filehdr); } -static void pcap_mm_init_once(void) +static void pcap_mm_init_once(bool enforce_prio) { - set_ioprio_be(); + if (enforce_prio) + set_ioprio_be(); } static int pcap_mm_prepare_access(int fd, enum pcap_mode mode, bool jumbo) @@ -57,9 +57,10 @@ static ssize_t pcap_rw_read(int fd, pcap_pkthdr_t *phdr, enum pcap_type type, return hdrsize + hdrlen; } -static void pcap_rw_init_once(void) +static void pcap_rw_init_once(bool enforce_prio) { - set_ioprio_rt(); + if (enforce_prio) + set_ioprio_rt(); } static void pcap_rw_fsync(int fd) @@ -145,9 +145,10 @@ static void pcap_sg_fsync(int fd) fdatasync(fd); } -static void pcap_sg_init_once(void) +static void pcap_sg_init_once(bool enforce_prio) { - set_ioprio_rt(); + if (enforce_prio) + set_ioprio_rt(); } static int pcap_sg_prepare_access(int fd, enum pcap_mode mode, bool jumbo) |