public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* dummy ethernet driver
@ 2003-01-06  5:57 Dave Airlie
  2003-01-06 10:16 ` Nick Holloway
  2003-01-06 14:54 ` Alan Cox
  0 siblings, 2 replies; 5+ messages in thread
From: Dave Airlie @ 2003-01-06  5:57 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1036 bytes --]


Hi,
 I have a VAX simulator running on my PC which uses pcap to send/recv
packets, however these packets are never seen on the local machine when
using a real ethernet device (everyone else on the network sees them), now
I only really want the local machine to see them not the network so I
decided I might get away with using loopback, however the simulator
configures its own IP and loopback isn't useful for this as the sim starts
arping and we don't do any arp on loopback.

so I turned to the dummy device but it isn't really a dummy Ethernet
device but rather a useless one :-), so I patched the dummy so it had an
address (hardcoded) is broadcast and loops back packets to itself...

the patch is attached.. is there any reason why the dummy device doesn't
want to do this stuff? I'm just submitting the patch as a request for
comments on why this isn't done anyway in the dummy?

Dave.

-- 
David Airlie, Software Engineer
http://www.skynet.ie/~airlied / airlied@skynet.ie
pam_smb / Linux DecStation / Linux VAX / ILUG person


[-- Attachment #2: Type: TEXT/PLAIN, Size: 1772 bytes --]

--- /usr/src/linux/drivers/net/dummy.c	2001-10-01 05:26:06.000000000 +1000
+++ ./dummy.c	2003-01-06 17:06:44.000000000 +1100
@@ -35,6 +35,7 @@
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
 #include <linux/init.h>
+#include <linux/etherdevice.h>
 
 static int dummy_xmit(struct sk_buff *skb, struct net_device *dev);
 static struct net_device_stats *dummy_get_stats(struct net_device *dev);
@@ -53,6 +54,7 @@
 
 static int __init dummy_init(struct net_device *dev)
 {
+	unsigned char myaddr[]="123456";
 	/* Initialize the device structure. */
 
 	dev->priv = kmalloc(sizeof(struct net_device_stats), GFP_KERNEL);
@@ -60,6 +62,7 @@
 		return -ENOMEM;
 	memset(dev->priv, 0, sizeof(struct net_device_stats));
 
+	memcpy(dev->dev_addr, myaddr, 6);
 	dev->get_stats = dummy_get_stats;
 	dev->hard_start_xmit = dummy_xmit;
 	dev->set_multicast_list = set_multicast_list;
@@ -70,7 +73,8 @@
 	/* Fill in device structure with ethernet-generic values. */
 	ether_setup(dev);
 	dev->tx_queue_len = 0;
-	dev->flags |= IFF_NOARP;
+/*	dev->flags |= IFF_NOARP; */
+	dev->flags |= IFF_BROADCAST;
 	dev->flags &= ~IFF_MULTICAST;
 
 	return 0;
@@ -82,8 +86,28 @@
 
 	stats->tx_packets++;
 	stats->tx_bytes+=skb->len;
+	
+	if(atomic_read(&skb->users) != 1)
+	  {
+	    struct sk_buff *skb2=skb;
+	    skb=skb_clone(skb, GFP_ATOMIC);         /* Clone the buffer */
+	    if(skb==NULL) {
+	      dev_kfree_skb(skb2);
+	      return 0;
+	    }
+	    dev_kfree_skb(skb2);
+	  }
+        else
+	  skb_orphan(skb);
+
+	skb->protocol=eth_type_trans(skb,dev);
+        skb->dev=dev;
+
+        skb->ip_summed = CHECKSUM_UNNECESSARY;
+	dev->last_rx = jiffies;
+
+	netif_rx(skb);
 
-	dev_kfree_skb(skb);
 	return 0;
 }
 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-01-07  6:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-06  5:57 dummy ethernet driver Dave Airlie
2003-01-06 10:16 ` Nick Holloway
2003-01-06 14:54 ` Alan Cox
2003-01-06 22:33   ` Dave Airlie
2003-01-07  6:51     ` Peter Svensson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox