@@ -447,7 +447,8 @@ static void death_by_timeout(unsigned long ul_conntrack)
447447static inline bool
448448nf_ct_key_equal (struct nf_conntrack_tuple_hash * h ,
449449 const struct nf_conntrack_tuple * tuple ,
450- const struct nf_conntrack_zone * zone )
450+ const struct nf_conntrack_zone * zone ,
451+ const struct net * net )
451452{
452453 struct nf_conn * ct = nf_ct_tuplehash_to_ctrack (h );
453454
@@ -456,7 +457,8 @@ nf_ct_key_equal(struct nf_conntrack_tuple_hash *h,
456457 */
457458 return nf_ct_tuple_equal (tuple , & h -> tuple ) &&
458459 nf_ct_zone_equal (ct , zone , NF_CT_DIRECTION (h )) &&
459- nf_ct_is_confirmed (ct );
460+ nf_ct_is_confirmed (ct ) &&
461+ net_eq (net , nf_ct_net (ct ));
460462}
461463
462464/*
@@ -481,7 +483,7 @@ ____nf_conntrack_find(struct net *net, const struct nf_conntrack_zone *zone,
481483 } while (read_seqcount_retry (& nf_conntrack_generation , sequence ));
482484
483485 hlist_nulls_for_each_entry_rcu (h , n , & ct_hash [bucket ], hnnode ) {
484- if (nf_ct_key_equal (h , tuple , zone )) {
486+ if (nf_ct_key_equal (h , tuple , zone , net )) {
485487 NF_CT_STAT_INC_ATOMIC (net , found );
486488 return h ;
487489 }
@@ -517,7 +519,7 @@ __nf_conntrack_find_get(struct net *net, const struct nf_conntrack_zone *zone,
517519 !atomic_inc_not_zero (& ct -> ct_general .use )))
518520 h = NULL ;
519521 else {
520- if (unlikely (!nf_ct_key_equal (h , tuple , zone ))) {
522+ if (unlikely (!nf_ct_key_equal (h , tuple , zone , net ))) {
521523 nf_ct_put (ct );
522524 goto begin ;
523525 }
@@ -573,12 +575,12 @@ nf_conntrack_hash_check_insert(struct nf_conn *ct)
573575 /* See if there's one in the list already, including reverse */
574576 hlist_nulls_for_each_entry (h , n , & net -> ct .hash [hash ], hnnode )
575577 if (nf_ct_key_equal (h , & ct -> tuplehash [IP_CT_DIR_ORIGINAL ].tuple ,
576- zone ))
578+ zone , net ))
577579 goto out ;
578580
579581 hlist_nulls_for_each_entry (h , n , & net -> ct .hash [reply_hash ], hnnode )
580582 if (nf_ct_key_equal (h , & ct -> tuplehash [IP_CT_DIR_REPLY ].tuple ,
581- zone ))
583+ zone , net ))
582584 goto out ;
583585
584586 add_timer (& ct -> timeout );
@@ -663,12 +665,12 @@ __nf_conntrack_confirm(struct sk_buff *skb)
663665 not in the hash. If there is, we lost race. */
664666 hlist_nulls_for_each_entry (h , n , & net -> ct .hash [hash ], hnnode )
665667 if (nf_ct_key_equal (h , & ct -> tuplehash [IP_CT_DIR_ORIGINAL ].tuple ,
666- zone ))
668+ zone , net ))
667669 goto out ;
668670
669671 hlist_nulls_for_each_entry (h , n , & net -> ct .hash [reply_hash ], hnnode )
670672 if (nf_ct_key_equal (h , & ct -> tuplehash [IP_CT_DIR_REPLY ].tuple ,
671- zone ))
673+ zone , net ))
672674 goto out ;
673675
674676 /* Timer relative to confirmation time, not original
@@ -740,7 +742,7 @@ nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
740742 hlist_nulls_for_each_entry_rcu (h , n , & ct_hash [hash ], hnnode ) {
741743 ct = nf_ct_tuplehash_to_ctrack (h );
742744 if (ct != ignored_conntrack &&
743- nf_ct_key_equal (h , tuple , zone )) {
745+ nf_ct_key_equal (h , tuple , zone , net )) {
744746 NF_CT_STAT_INC_ATOMIC (net , found );
745747 rcu_read_unlock ();
746748 return 1 ;
@@ -1383,7 +1385,8 @@ get_next_corpse(struct net *net, int (*iter)(struct nf_conn *i, void *data),
13831385 if (NF_CT_DIRECTION (h ) != IP_CT_DIR_ORIGINAL )
13841386 continue ;
13851387 ct = nf_ct_tuplehash_to_ctrack (h );
1386- if (iter (ct , data ))
1388+ if (net_eq (nf_ct_net (ct ), net ) &&
1389+ iter (ct , data ))
13871390 goto found ;
13881391 }
13891392 }
0 commit comments