Skip to content
  • Pablo Neira Ayuso's avatar
    [NETFILTER]: fix list traversal order in ctnetlink · ff21d577
    Pablo Neira Ayuso authored
    
    
    Currently conntracks are inserted after the head. That means that
    conntracks are sorted from the biggest to the smallest id. This happens
    because we use list_prepend (list_add) instead list_add_tail. This can
    result in problems during the list iteration.
    
                     list_for_each(i, &ip_conntrack_hash[cb->args[0]]) {
                             h = (struct ip_conntrack_tuple_hash *) i;
                             if (DIRECTION(h) != IP_CT_DIR_ORIGINAL)
                                     continue;
                             ct = tuplehash_to_ctrack(h);
                             if (ct->id <= *id)
                                     continue;
    
    In that case just the first conntrack in the bucket will be dumped. To
    fix this, we iterate the list from the tail to the head via
    list_for_each_prev. Same thing for the list of expectations.
    
    Signed-off-by: default avatarPablo Neira Ayuso <pablo@eurodev.net>
    Signed-off-by: default avatarHarald Welte <laforge@netfilter.org>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    ff21d577