• Alexander Duyck's avatar
    fib_trie: Provide a deterministic order for fib_alias w/ tables merged · 0b65bd97
    Alexander Duyck authored
    This change makes it so that we should always have a deterministic ordering
    for the main and local aliases within the merged table when two leaves
    overlap.
    
    So for example if we have a leaf with a key of 192.168.254.0.  If we
    previously added two aliases with a prefix length of 24 from both local and
    main the first entry would be first and the second would be second.  When I
    was coding this I had added a WARN_ON should such a situation occur as I
    wasn't sure how likely it would be.  However this WARN_ON has been
    triggered so this is something that should be addressed.
    
    With this patch the ordering of the aliases is as follows.  First they are
    sorted on prefix length, then on their table ID, then tos, and finally
    priority.  This way what we end up doing is essentially interleaving the
    two tables on what used to be leaf_info structure boundaries.
    
    Fixes: 0ddcf43d ("ipv4: FIB Local/MAIN table collapse")
    Reported-by: default avatarEric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarAlexander Duyck <alexander.h.duyck@redhat.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    0b65bd97
fib_trie.c 63.5 KB