diff options
author | Jesper Dangaard Brouer <brouer@redhat.com> | 2013-12-12 13:41:51 +0100 |
---|---|---|
committer | Jesper Dangaard Brouer <brouer@redhat.com> | 2013-12-12 13:41:51 +0100 |
commit | 7d1ba2b499fcd904bdea7a965688ab7ffd3e390e (patch) | |
tree | 22e6ce832be46bc0cbffeb8b15d352d4e2b8ba9e /sock.c | |
parent | c3602a995b21e8133c7f4fd1fb1e7e21b6a844f1 (diff) |
trafgen: take advantage of PACKET_QDISC_BYPASS sock option
Since Linux 3.14, the kernel supports a socket option PACKET_QDISC_BYPASS,
which trafgen enables by default. That allow us to bypass the kernels
normal qdisc (traffic control) layer.
An option -q, --qdisc-path is added to allow enabling the qdisc path
explicity, useful for testing purposes.
This will be avail in kernels >= 3.14 via
commit d346a3fae3 (packet: introduce PACKET_QDISC_BYPASS socket option).
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Diffstat (limited to 'sock.c')
-rw-r--r-- | sock.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -42,6 +42,24 @@ int pf_tx_socket(void) return sock; } +/* Avail in kernel >= 3.14 + * in commit d346a3fae3 (packet: introduce PACKET_QDISC_BYPASS socket option) + */ +void set_sock_qdisc_bypass(int fd, int verbose) +{ + int ret, val = 1; + + ret = setsockopt(fd, SOL_PACKET, PACKET_QDISC_BYPASS, &val, sizeof(val)); + if (ret < 0) { + if (errno == ENOPROTOOPT) { + if (verbose) + printf("No kernel support for PACKET_QDISC_BYPASS" + " (kernel < 3.14?)\n"); + } else + perror("Cannot set PACKET_QDISC_BYPASS"); + } else + if (verbose) printf("Enabled kernel qdisc bypass\n"); +} void set_sock_prio(int fd, int prio) { |