Skip to contentSkip to conversation

Allow pktgen to work with loopback devices.

PATCH In review Josh Triplett 2 participants 2 messages Mar 7, 2007 – Mar 9, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Allow pktgen to work with loopback devices.

pktgen currently only works on network devices with type ARPHRD_ETHER. Add support for the loopback device, type ARPHRD_LOOPBACK.

I've tested this on my system, using a modified pktgen.conf-1-1 with s/eth1/lo/g, and it works fine; the network device statistics confirm packet transmission and receipt.

Thanks to Sarah Bailey for discovering and tracking down the problem.

---

I intentionally didn't change the error message "not an ethernet device". For the purposes of pktgen, loopback devices act like ethernet devices.

 net/core/pktgen.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/core/pktgen.c +1 -1
index 74a9a32..6fc6f9d 100644
@@ -1930,7 +1930,7 @@ static struct net_device *pktgen_setup_dev(struct pktgen_dev *pkt_dev)
 		printk("pktgen: no such netdevice: \"%s\"\n", pkt_dev->ifname);
 		goto out;
 	}
-	if (odev->type != ARPHRD_ETHER) {
+	if (odev->type != ARPHRD_LOOPBACK && odev->type != ARPHRD_ETHER) {
 		printk("pktgen: not an ethernet device: \"%s\"\n",
 		       pkt_dev->ifname);
 		goto out_put;
Signature · 1 line
1.5.0.2
#1 lore raw
Quoted 23 lines · Josh Triplett

pktgen currently only works on network devices with type ARPHRD_ETHER. Add support for the loopback device, type ARPHRD_LOOPBACK.

I've tested this on my system, using a modified pktgen.conf-1-1 with s/eth1/lo/g, and it works fine; the network device statistics confirm packet transmission and receipt.

Thanks to Sarah Bailey for discovering and tracking down the problem.

---

I intentionally didn't change the error message "not an ethernet device". For the purposes of pktgen, loopback devices act like ethernet devices.

 net/core/pktgen.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/core/pktgen.c +0 -0
index 74a9a32..6fc6f9d 100644

net/core/pktgen.c static struct net_device *pktgen_setup_dev(struct pktgen_dev *pkt_dev) · line 1935

Quoted 7 lines
net/core/pktgen.c +1 -1
@@ -1930,7 +1930,7 @@ static struct net_device *pktgen_setup_dev(struct pktgen_dev *pkt_dev)
 		printk("pktgen: no such netdevice: \"%s\"\n", pkt_dev->ifname);
 		goto out;
 	}
-	if (odev->type != ARPHRD_ETHER) {
+	if (odev->type != ARPHRD_LOOPBACK && odev->type != ARPHRD_ETHER) {
 		printk("pktgen: not an ethernet device: \"%s\"\n",
 		       pkt_dev->ifname);

I'll let DaveM queue this (or not)