[Click] [PATCH] EtherAddress needs packing
    Harald Schiöberg 
    harald at net.t-labs.tu-berlin.de
       
    Wed Feb 18 14:14:10 EST 2009
    
    
  
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Eddie Kohler wrote:
> Hi Harald,
> 
> On which machine is sizeof(EtherAddress) not 6?  Just curious what
> problem this is solving.
> 
this is the compiler:
armeb-linux-g++ -pipe -march=armv5te -mtune=xscale -funit-at-a-time -O2 -g3
The elements of "uint16_t[3] _data" seem to end up 32-bit aligned.
here is a bit more detail:
test config at the bottom of the mail (basically a
ICMPPingResponder/ARPResponder duo)
this is the result when pinging the host:
01:10:28.822327 00:40:48:b2:3a:c7 > 00:d0:12:09:89:42, ethertype IPv4
(0x0800), length 98: 172.17.2.12 > 172.17.2.203: ICMP echo request, id
31529, seq 1, length 64
01:10:28.823319 00:d0:12:09:89:42 > 48:b2:12:09:3a:c7, ethertype IPv4
(0x0800), length 98: 172.17.2.203 > 172.17.2.12: ICMP echo reply, id
31529, seq 1, length 64
note the src-mac of the echo req. and the dst-mac of the reply, you see
that the reply contains bytes [3][4][garbage][garbage[5][6] of the mac
address.
It all seems to break in arptable.hh:188:
 *eth = it->_eth;
(*eth points to the dst_mac field in the packet, "it->_eth" is the
EtherAddress that was just looked up in the table)
but that's rather hard to tell since the bug only occurs at -O2 which
means this piece of code is inlined, and giving a hard time to the
debugger.
- ---snip click configuration ---
ControlSocket(TCP, 9200);
AddressInfo(eth0 172.17.2.203/24);
elementclass IPDevice {
$device |
        td :: Queue -> ToDevice($device);
        FromDevice($device, SNIFFER true) ->
        cl :: Classifier(12/0806 20/0001, 12/0806 20/0002, 3/ffffff,
12/0800 30/AC1102CB);
        cl[1] -> [1]aq :: ARPQuerier($device, $device)  -> td;
        input[0] -> [0] aq;
        cl[0] -> ARPResponder($device:ip $device) -> td;
        cl[2] -> [1]output;
        cl[3] -> Strip(14) -> CheckIPHeader -> IPPrint (ip-in) -> [0]output;
        input[1] -> td;
}
wired_if :: IPDevice (eth0);
wired_if[0] -> ICMPPingResponder -> SetIPChecksum -> [0]wired_if ;
Idle -> [1]wired_if[1] ->  Discard;
- --
Harald Schiöberg
Technische Universität Berlin | T-Laboratories | FG INET
www: http://www.net.t-labs.tu-berlin.de
Phone: +49-(0)30-8353-58476 | Fax: +49-(0)391 534 783 47
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFJnF4Cy8wrZ9OvkU0RAnb0AKCOTzPuuMhuopEiY1V2cDDbKMjbGQCgtp4B
SrMDutFwIwDSiNo/dIxihAY=
=TvH8
-----END PGP SIGNATURE-----
    
    
More information about the click
mailing list