summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--netsniff-ng.c6
-rw-r--r--pcap_io.h2
-rw-r--r--pcap_mm.c5
-rw-r--r--pcap_rw.c5
-rw-r--r--pcap_sg.c5
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);
diff --git a/pcap_io.h b/pcap_io.h
index c3fc951..35faa51 100644
--- a/pcap_io.h
+++ b/pcap_io.h
@@ -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);
diff --git a/pcap_mm.c b/pcap_mm.c
index 5b3cfcb..f7b248e 100644
--- a/pcap_mm.c
+++ b/pcap_mm.c
@@ -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)
diff --git a/pcap_rw.c b/pcap_rw.c
index 5a739da..b6be922 100644
--- a/pcap_rw.c
+++ b/pcap_rw.c
@@ -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)
diff --git a/pcap_sg.c b/pcap_sg.c
index 9d07656..80c2c5d 100644
--- a/pcap_sg.c
+++ b/pcap_sg.c
@@ -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)