• Julian Wiedmann's avatar
    s390/qeth: fix IP address lookup for L3 devices · c5c48c58
    Julian Wiedmann authored
    Current code ("qeth_l3_ip_from_hash()") matches a queried address object
    against objects in the IP table by IP address, Mask/Prefix Length and
    MAC address ("qeth_l3_ipaddrs_is_equal()"). But what callers actually
    require is either
    a) "is this IP address registered" (ie. match by IP address only),
    before adding a new address.
    b) or "is this address object registered" (ie. match all relevant
       attributes), before deleting an address.
    
    Right now
    1. the ADD path is too strict in its lookup, and eg. doesn't detect
    conflicts between an existing NORMAL address and a new VIPA address
    (because the NORMAL address will have mask != 0, while VIPA has
    a mask == 0),
    2. the DELETE path is not strict enough, and eg. allows del_rxip() to
    delete a VIPA address as long as the IP address matches.
    
    Fix all this by adding helpers (_addr_match_ip() and _addr_match_all())
    that do the appropriate checking.
    
    Note that the ADD path for NORMAL addresses is special, as qeth keeps
    track of how many times such an address is in use (and there is no
    immediate way of returning errors to the caller). So when a requested
    NORMAL address _fully_ matches an existing one, it's not considered a
    conflict and we merely increment the refcount.
    
    Fixes: 5f78e29c ("qeth: optimize IP handling in rx_mode callback")
    Signed-off-by: default avatarJulian Wiedmann <jwi@linux.vnet.ibm.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    c5c48c58
qeth_l3.h 3.47 KB