• Julian Anastasov's avatar
    ipv4: consider TOS in fib_select_default · 2392debc
    Julian Anastasov authored
    fib_select_default considers alternative routes only when
    res->fi is for the first alias in res->fa_head. In the
    common case this can happen only when the initial lookup
    matches the first alias with highest TOS value. This
    prevents the alternative routes to require specific TOS.
    
    This patch solves the problem as follows:
    
    - routes that require specific TOS should be returned by
    fib_select_default only when TOS matches, as already done
    in fib_table_lookup. This rule implies that depending on the
    TOS we can have many different lists of alternative gateways
    and we have to keep the last used gateway (fa_default) in first
    alias for the TOS instead of using single tb_default value.
    
    - as the aliases are ordered by many keys (TOS desc,
    fib_priority asc), we restrict the possible results to
    routes with matching TOS and lowest metric (fib_priority)
    and routes that match any TOS, again with lowest metric.
    
    For example, packet with TOS 8 can not use gw3 (not lowest
    metric), g...
    2392debc
fib_lookup.h 1.33 KB