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 /trafgen.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 'trafgen.c')
-rw-r--r-- | trafgen.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -55,7 +55,7 @@ #include "csum.h" struct ctx { - bool rand, rfraw, jumbo_support, verbose, smoke_test, enforce; + bool rand, rfraw, jumbo_support, verbose, smoke_test, enforce, qdisc_path; unsigned long kpull, num, reserve_size; unsigned int cpus; uid_t uid; gid_t gid; @@ -80,7 +80,7 @@ size_t plen = 0; struct packet_dyn *packet_dyn = NULL; size_t dlen = 0; -static const char *short_options = "d:c:n:t:vJhS:rk:i:o:VRs:P:eE:pu:g:CHQ"; +static const char *short_options = "d:c:n:t:vJhS:rk:i:o:VRs:P:eE:pu:g:CHQq"; static const struct option long_options[] = { {"dev", required_argument, NULL, 'd'}, {"out", required_argument, NULL, 'o'}, @@ -97,6 +97,7 @@ static const struct option long_options[] = { {"group", required_argument, NULL, 'g'}, {"prio-high", no_argument, NULL, 'H'}, {"notouch-irq", no_argument, NULL, 'Q'}, + {"qdisc-path", no_argument, NULL, 'q'}, {"jumbo-support", no_argument, NULL, 'J'}, {"no-cpu-stats", no_argument, NULL, 'C'}, {"cpp", no_argument, NULL, 'p'}, @@ -193,6 +194,7 @@ static void __noreturn help(void) " -g|--group <groupid> Drop privileges and change to groupid\n" " -H|--prio-high Make this high priority process\n" " -Q|--notouch-irq Do not touch IRQ CPU affinity of NIC\n" + " -q|--qdisc-path Enabled qdisc kernel path (default off since 3.14)\n" " -V|--verbose Be more verbose\n" " -C|--no-cpu-stats Do not print CPU time statistics on exit\n" " -v|--version Show version and exit\n" @@ -856,6 +858,9 @@ static void main_loop(struct ctx *ctx, char *confname, bool slow, sock = pf_tx_socket(); + if (ctx->qdisc_path == false) + set_sock_qdisc_bypass(sock, ctx->verbose); + if (slow) xmit_slowpath_or_die(ctx, cpu, orig_num); else @@ -897,6 +902,7 @@ int main(int argc, char **argv) ctx.cpus = get_number_cpus_online(); ctx.uid = getuid(); ctx.gid = getgid(); + ctx.qdisc_path = false; while ((c = getopt_long(argc, argv, short_options, long_options, &opt_index)) != EOF) { @@ -934,6 +940,9 @@ int main(int argc, char **argv) case 'Q': set_irq_aff = false; break; + case 'q': + ctx.qdisc_path = true; + break; case 'r': ctx.rand = true; break; |