skb / netif_rx problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

sorry if this is again a very stupid question, i think i must have
overlooked a very obvious thing, but i don't see it myself.

I am trying to generate IP/UDP packets from within another device
driver and inject them into the kernel. So i register an own net device,
set up the packets and "receive" them via netif_rx. I tested the packet
generation and stuff by simply dropping it into airo.c (just had it
lying around, and there's not much traffic on this device), and there it
works as i would have expected. However, with my own device, i have to
use an offset of 14 bytes (ETH_HLEN???) when copying in the raw packet,
and the packet is still discarded by the kernel, while perfectly valid
for tcpdump/ethereal.

This is how i fill the skb:
  skb=dev_alloc_skb(len+16+ETH_HLEN); /* +2+14, because of 14 offset?! */
  if(!skb)
  {
    printk("dvb_netdev: packet dropped!\n");
    return(-1);
  }
  skb_reserve(skb, 2); /* align IP on 16B boundary */

/* do it twice, maybe somebody looks in front of the packet? */
  memcpy(skb_put(skb,len+ETH_HLEN+14),(unsigned char *)(&dvb->dvb_netdev_hardhdr
),ETH_HLEN);
  memcpy(skb->data+14,(unsigned char *)(&dvb->dvb_netdev_hardhdr),ETH_HLEN);

  /* put in the data */
  memcpy((unsigned char *)skb->data+ETH_HLEN+14, data, len);
Note the 14 bytes offset everywhere! If i leave them out, the packet is
truncated, and the ip header is where the eth header should be (at least
this is how ethereal shows it). Where are the first 14 bytes of the packets
gone? :)

I attached the whole netdev_init and calling code at the end, in case
somebody wants to take the time to look at it and it is not obvious from
the above... :)

Thanks in advance,
Wolfgang



/* initialization stuff for network device */
static int dvb_netdev_init(struct net_device *dev)
{
  ether_setup(dev);
  
/* rather crude, but should work */
  dev->base_addr=((struct dvb_struct *)(dev->priv))->saa->device->resource[0].st
art;
  dev->irq=((struct dvb_struct *)dev->priv)->saa->device->irq;
  dev->open = dvb_netdev_dummy;
  dev->stop = dvb_netdev_dummy;
  dev->set_config = dvb_netdev_config;
  memcpy(dev->dev_addr, "\0DVBN0", ETH_ALEN); 
  dev->get_stats = dvb_netdev_stats;
  dev->hard_header = NULL;
  dev->hard_start_xmit = dvb_netdev_tx;
  SET_MODULE_OWNER(dev);
  return(0);
}

and this is at the end of module initialisation:
...
        strcpy(dvb->dvb_netdev.name,"dvbmc%d");
        dvb->dvb_netdev.priv=(void *)(dvb);
        dvb->dvb_netdev.init = dvb_netdev_init;
        memset(&dvb->netdev_stats,0,sizeof(struct net_device_stats));
        if(register_netdev(&dvb->dvb_netdev))
          return -ENODEV;
        dvb->dmxdev.dvb_netdev=&dvb->dvb_netdev;
        dvb->dmxdev.recv_mc_packet=dvb_netdev_recv;
        memcpy(dvb->dvb_netdev_hardhdr.h_dest,dvb->dvb_netdev.dev_addr,ETH_ALEN);
        memcpy(dvb->dvb_netdev_hardhdr.h_source,"\0DVBNI",ETH_ALEN);
        dvb->dvb_netdev_hardhdr.h_proto=htons(0x0800); /* is used later */
...

-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux