pktgen: Allow on loopback device
authorLukas Wunner <lukas@wunner.de>
Tue, 10 Mar 2020 10:49:46 +0000 (11:49 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 10 Mar 2020 22:44:59 +0000 (15:44 -0700)
When pktgen is used to measure the performance of dev_queue_xmit()
packet handling in the core, it is preferable to not hand down
packets to a low-level Ethernet driver as it would distort the
measurements.

Allow using pktgen on the loopback device, thus constraining
measurements to core code.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/pktgen.c

index acc849df60b5aa6acb66ee50dbecb6f51f699ba4..f2b3d8dd40f443d787090cf0be168ec346f778f3 100644 (file)
@@ -2003,8 +2003,8 @@ static int pktgen_setup_dev(const struct pktgen_net *pn,
                return -ENODEV;
        }
 
-       if (odev->type != ARPHRD_ETHER) {
-               pr_err("not an ethernet device: \"%s\"\n", ifname);
+       if (odev->type != ARPHRD_ETHER && odev->type != ARPHRD_LOOPBACK) {
+               pr_err("not an ethernet or loopback device: \"%s\"\n", ifname);
                err = -EINVAL;
        } else if (!netif_running(odev)) {
                pr_err("device is down: \"%s\"\n", ifname);