Truncated ethernet frames

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

I've written most of a layer 2.5 ad hoc network driver, which sits
between the IP stack and the physical device drivers.  I'm having
trouble sending packets, however; I can send, but all packets get
truncated to 46 bytes (Ethernet's minimum).

Debug messages on the sending host show correct packet lengths
(skb->len), but debug messages on the receiver show all packets are 46
bytes long.

I'm creating a sk_buff with data copied from my own packet structures
(which are shared with a userland daemon).

Here's my transmission code:


- ---

/**
 * sahn_tx_packetbuf - prepare and dispatch a pktbuf for transmission
 * @pkt packet to send
 * @dest Dest address
 * @dev device to send with
 * @priv sahn private structure
 *
 *		Returns error code, 0 on success.
 */
 int sahn_tx_packetbuf(struct sahn_pktbuf* pkt, void* dest, struct
	net_device* dev, struct sahn_priv* priv)
 {
    // Allocate sk_buff
    struct sk_buff* skb;
    char* data;

    if ( !sahn_pb_alldata(pkt) )
    {
        SAHNDP(1, "Invalid packet encountered!\n");
        return -EINVAL;
    }

    skb = alloc_skb(sahn_pb_len(pkt) + LL_RESERVED_SPACE(dev),
	GFP_KERNEL);

    if ( !skb )
    {
        SAHNERRP("Could not allocate packet buffer while 	
		transmitting.\n");
        priv->stats.tx_dropped++;
        return -ENOMEM;
    }

    skb_reserve(skb, LL_RESERVED_SPACE(dev));

    // Prepare space, and copy packet data in
    data = skb_put(skb, sahn_pb_len(pkt));
    memcpy(data, sahn_pb_alldata(pkt), sahn_pb_len(pkt));

    // Set parameters
    skb->dev = dev;
    skb->input_dev = dev;
    skb->nh.raw = (unsigned char*) data;
    skb->protocol = htons(SAHN_ETHERTYPE);

    if ( dev->hard_header &&
        dev->hard_header(skb, dev, SAHN_ETHERTYPE, dest, dev->dev_addr,
		skb->len) < 0 )
    {
        SAHNERRP("Could not create hardware header while
		transmitting.\n");
        priv->stats.tx_dropped++;
        return -EINVAL;
    }

    SAHNDP(9, "Transmitting packet of %lu bytes (%u with header) from
		%s.\n", sahn_pb_len(pkt), skb->len, dev->name);

    // Send to device driver
    dev_queue_xmit(skb);

    // Update statistics
    priv->stats.tx_packets++;
    priv->stats.tx_bytes += sahn_pb_len(pkt);
}

- ---




Have I missed something obvious?

Cheers =)

Mike




- --
Mike Tyson <mike@xxxxxxxxxxx>
M: (+61) 0407 754 124
W: http://mike.tyson.id.au
B: http://mike.tyson.id.au/blog
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDT1Hf/eih+gEb7pQRAr1TAJ906xJ6EwiYDYDN5UMIlYloukye6QCg6lAS
XEFAs1vqtsnjBPRgDC1gWow=
=RYpv
-----END PGP SIGNATURE-----

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux