• G
    iputils: set scope depending on gateway in iproute_{add,del}() · 55bcbfff
    Guillaume Nault 提交于
    From a logical point of view, we have link scope if no gateway is
    present, and global scope otherwise. Therefore it makes more sense
    to set rtm_scope depending on 'gw' rather than on 'ifindex'.
    
    Currently, callers of iproute_add() and iproute_del() either set
    'ifindex' or 'gw', but never both. So even if confusing, the current
    code results in right scope selection. However one can't figure this
    out without analysing every caller.
    
    We should set rtm_scope based on the presence of the gateway instead.
    Given the current code base, that doesn't change the end result, but
    that better maches the scope concept. Also, that's the way iproute2
    does its selection.
    
    Furthermore, it'd be perfectly valid to have both 'iface' and 'gw' set.
    In that case, scope should be RT_SCOPE_UNIVERSE instead of
    RT_SCOPE_LINK. Basing scope selection on 'gw' makes this case work
    correctly.
    Signed-off-by: NGuillaume Nault <g.nault@alphalink.fr>
    55bcbfff
iputils.c 19.0 KB