• Stefan Richter's avatar
    firewire: net: fix fragmented datagram_size off-by-one · 9b2e3803
    Stefan Richter authored
    commit e9300a4b upstream.
    
    RFC 2734 defines the datagram_size field in fragment encapsulation
    headers thus:
    
        datagram_size:  The encoded size of the entire IP datagram.  The
        value of datagram_size [...] SHALL be one less than the value of
        Total Length in the datagram's IP header (see STD 5, RFC 791).
    
    Accordingly, the eth1394 driver of Linux 2.6.36 and older set and got
    this field with a -/+1 offset:
    
        ether1394_tx() /* transmit */
            ether1394_encapsulate_prep()
                hdr->ff.dg_size = dg_size - 1;
    
        ether1394_data_handler() /* receive */
            if (hdr->common.lf == ETH1394_HDR_LF_FF)
                dg_size = hdr->ff.dg_size + 1;
            else
                dg_size = hdr->sf.dg_size + 1;
    
    Likewise, I observe OS X 10.4 and Windows XP Pro SP3 to transmit 1500
    byte sized datagrams in fragments with datagram_size=1499 if link
    fragmentation is required.
    
    Only firewire-net sets and gets datagram_size without this offset.  The
    result is lacking interoperability of firewire-net with OS X, Windows
    XP, and presumably Linux' eth1394.  (I did not test with the latter.)
    For example, FTP data transfers to a Linux firewire-net box with max_rec
    smaller than the 1500 bytes MTU
      - from OS X fail entirely,
      - from Win XP start out with a bunch of fragmented datagrams which
        time out, then continue with unfragmented datagrams because Win XP
        temporarily reduces the MTU to 576 bytes.
    
    So let's fix firewire-net's datagram_size accessors.
    
    Note that firewire-net thereby loses interoperability with unpatched
    firewire-net, but only if link fragmentation is employed.  (This happens
    with large broadcast datagrams, and with large datagrams on several
    FireWire CardBus cards with smaller max_rec than equivalent PCI cards,
    and it can be worked around by setting a small enough MTU.)
    Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
    Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
    9b2e3803
net.c 42.2 KB