• Xin Long's avatar
    sched: act_ct: add netns into the key of tcf_ct_flow_table · 88c67aeb
    Xin Long authored
    zones_ht is a global hashtable for flow_table with zone as key. However,
    it does not consider netns when getting a flow_table from zones_ht in
    tcf_ct_init(), and it means an act_ct action in netns A may get a
    flow_table that belongs to netns B if it has the same zone value.
    
    In Shuang's test with the TOPO:
    
      tcf2_c <---> tcf2_sw1 <---> tcf2_sw2 <---> tcf2_s
    
    tcf2_sw1 and tcf2_sw2 saw the same flow and used the same flow table,
    which caused their ct entries entering unexpected states and the
    TCP connection not able to end normally.
    
    This patch fixes the issue simply by adding netns into the key of
    tcf_ct_flow_table so that an act_ct action gets a flow_table that
    belongs to its own netns in tcf_ct_init().
    
    Note that for easy coding we don't use tcf_ct_flow_table.nf_ft.net,
    as the ct_ft is initialized after inserting it to the hashtable in
    tcf_ct_flow_table_get() and also it requires to implement several
    functions in rhashtable_params including hashfn, obj_hashfn and
    obj_cmpfn.
    
    Fixes: 64ff70b8 ("net/sched: act_ct: Offload established connections to flow table")
    Reported-by: default avatarShuang Li <shuali@redhat.com>
    Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
    Reviewed-by: default avatarSimon Horman <horms@kernel.org>
    Link: https://lore.kernel.org/r/1db5b6cc6902c5fc6f8c6cbd85494a2008087be5.1718488050.git.lucien.xin@gmail.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
    88c67aeb
act_ct.c 40.6 KB