• Sridhar Samudrala's avatar
    [IPV4/IPV6]: Fix to avoid overriding TCP/UDP with a new protocol of same type. · 380a2a35
    Sridhar Samudrala authored
    Registering a new protocol of type SOCK_STREAM with a protocol value other
    than IPPROTO_TCP will override TCP if the application passes 0 as the protocol
    to the socket() call.
    socket(AF_INET, SOCK_STREAM, 0)
    I guess many applications follow this syntax as they assume TCP is the default
    protocol for SOCK_STREAM type.
    The same holds true for SOCK_DGRAM type sockets assuing UDP as the default.
    
    This is due to the insertion of a new inet_protosw entry into the inetsw list
    of a particular type at the head of the list. inet_create() uses the first
    entry in the list if a wild-card protocol is passed.
    
    The following patch fixes the insertion of a new entry so that it is added
    after the last permanent entry in the list. This makes sure that the new 
    entries do not override any existing permanent entries.
    380a2a35
af_inet.c 30.9 KB