buglwIP - A Lightweight TCP/IP stack - Bugs: bug #8708, Fix for IP and TCP header...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #8708: Fix for IP and TCP header alignment with Ethernet

Submitted by:  None
Submitted on:  Tue 27 Apr 2004 03:33:10 PM UTC  
 
Category: pbufsSeverity: 3 - Normal
Item Group: Faulty BehaviourStatus: Fixed
Privacy: PublicAssigned to: Leon Woestenberg <likewise>
Open/Closed: ClosedPlanned Release: None
lwIP version: None

Thu 29 Apr 2004 09:38:08 AM UTC, comment #3:

The etherpad2.patch file should not be applied after all. Instead, apply etherpad3.patch, which addresses the following:

There was another unaligned access that was masked from the compiler by the cast in the macro ip_addr_set. Removing the cast of (src) catches this error and doesn't reveal any others, indicating that the cast is no longer needed.

The second param of update_arp_entry() is now reverted from (struct ip_addr2 ) back to (struct ip_addr ), and update_arp_entry() is mostly reverted to what it was. Instead, etharp_arp_input() takes copies of sipaddr and dipaddr and passes those. This removes the calls to memcmp() and also helps dhcp_arp_reply().

The loops through the ARP table in update_arp_entry() and etharp_query() should test that the entry is not empty before comparing its address.

The etherpad3.patch is against CVS as at 29-Apr-04.

Tony Mountifield <softins>
Wed 28 Apr 2004 11:04:07 AM UTC, comment #2:

A further correction is required in etharp.c when compiling with debug enabled. See the second patch file, just added.

Tony Mountifield <softins>
Tue 27 Apr 2004 03:38:36 PM UTC, comment #1:

Actually submitted by softins, but forgot to log in first.

Tony Mountifield <softins>
Tue 27 Apr 2004 03:33:10 PM UTC, original submission:

On 32-bit processors that cannot do unaligned accesses, there are problems with 32-bit values in the IP and TCP headers, due to their being preceded by an ethernet header of 14 bytes.

This patch (against CVS as at 27-Apr-04) overcomes this problem by optionally putting two bytes of padding at the beginning of the Ethernet header. This makes the Ethernet header 16 bytes long, and the transferring of data to or from the Ethernet chip starts two bytes into the buffer. Thanks to Timmy Brolin for the original suggestion.

Some comments on the patch:

ip_addr.h: A new struct ip_addr2 is defined for use in the ARP packets. Depending on the amount of padding, either dipaddr or sipaddr will be unaligned. ip_addr2 contains a two-element 16-bit array, addrw[2]. There is only one place where this field must be accessed by name.

etharp.h: PAD_ETH_SIZE is normally defined as 2. If it is undefined or zero, the adjustments are not performed (but struct ip_addr2 is still used)

etharp.c: The test for 0.0.0.0 is the only place where addrw[] is used. The various assigments of IP addresses are performed using structure copies instead, with pointer casts where necessary to change between struct ip_addr and struct ip_addr2. Address compatison is performed using memcmp().

ethernetif.c: As this template is now up-to-date with etharp, it shows the modifications required in an ethernet driver to support PAD_ETH_SIZE. pbuf_header() is used to drop and regain the two bytes padding for eas of transferring to and from the chip. In low_level_input(), the allocated pbuf must allow for PAD_ETH_SIZE. The call to pbuf_header in case ETHTYPE_IP must use -sizeof(struct eth_hdr) instead of just -14.

Anonymous

 

Attached Files
file #1267:  etherpad3.patch added by softins (6KiB - text/plain - Replaces etherpad2.patch. Includes a better approach and couple more fixes to etharp.c and one to ip_addr.h)
file #1264:  etherpad2.patch added by softins (1KiB - text/plain - Extra patch for etharp.c to correct debug statement)
file #1255:  etherpad.patch added by None (8KiB - text/plain - Patch for ip_addr.h, etharp.h, etharp.c and ethernetif.c (against CVS as at 27-Apr-04))

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 7 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Thu 29 Apr 2004 09:38:08 AM UTCsoftinsAttached File-=>Added etherpad3.patch, #1252
Wed 28 Apr 2004 11:25:30 PM UTClikewiseCategoryNone=>pbufs
  StatusNone=>Fixed
  Assigned toNone=>likewise
  Open/ClosedOpen=>Closed
Wed 28 Apr 2004 11:04:07 AM UTCsoftinsAttached File-=>Added etherpad2.patch, #1249
Tue 27 Apr 2004 03:33:11 PM UTCNoneAttached File-=>Added etherpad.patch, #1240

Back to the top


Powered by Savane 3.1-cleanup1