• Neil Horman's avatar
    tipc: fix endianness on tipc subscriber messages · d88dca79
    Neil Horman authored
    Remove htohl implementation from tipc
    
    I was working on forward porting the downstream commits for TIPC and ran accross this one:
    http://tipc.cslab.ericsson.net/cgi-bin/gitweb.cgi?p=people/allan/tipc.git;a=commitdiff;h=894279b9437b63cbb02405ad5b8e033b51e4e31e
    
    I was going to just take it, when I looked closer and noted what it was doing.
    This is basically a routine to byte swap fields of data in sent/received packets
    for tipc, dependent upon the receivers guessed endianness of the peer when a
    connection is established.  Asside from just seeming silly to me, it appears to
    violate the latest RFC draft for tipc:
    http://tipc.sourceforge.net/doc/draft-spec-tipc-02.txt
    Which, according to section 4.2 and 4.3.3, requires that all fields of all
    commands be sent in network byte order.  So instead of just taking this patch,
    instead I'm removing the htohl function and replacing the calls with calls to
    ntohl in the rx path and htonl in the send path.
    
    As part of this fix, I'm also changing the subscr_cancel function, which
    searches the list of subscribers, using a memcmp of the entire subscriber list,
    for the entry to tear down.  unfortunately it memcmps the entire tipc_subscr
    structure which has several bits that are private to the local side, so nothing
    will ever match.  section 5.2 of the draft spec indicates the <type,upper,lower>
    tuple should uniquely identify a subscriber, so convert subscr_cancel to just
    match on those fields (properly endian swapped).
    
    I've tested this using the tipc test suite, and its passed without issue.
    Signed-off-by: default avatarNeil Horman <nhorman@tuxdriver.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    d88dca79
subscr.h 3.24 KB