Lines Matching refs:ct
60 struct nf_conn *ct; member
150 static u32 ovs_ct_get_mark(const struct nf_conn *ct) in ovs_ct_get_mark() argument
153 return ct ? ct->mark : 0; in ovs_ct_get_mark()
164 static void ovs_ct_get_labels(const struct nf_conn *ct, in ovs_ct_get_labels() argument
167 struct nf_conn_labels *cl = ct ? nf_ct_labels_find(ct) : NULL; in ovs_ct_get_labels()
181 key->ct.orig_tp.src = htons(orig->dst.u.icmp.type); in __ovs_ct_update_key_orig_tp()
182 key->ct.orig_tp.dst = htons(orig->dst.u.icmp.code); in __ovs_ct_update_key_orig_tp()
184 key->ct.orig_tp.src = orig->src.u.all; in __ovs_ct_update_key_orig_tp()
185 key->ct.orig_tp.dst = orig->dst.u.all; in __ovs_ct_update_key_orig_tp()
191 const struct nf_conn *ct) in __ovs_ct_update_key() argument
195 key->ct.mark = ovs_ct_get_mark(ct); in __ovs_ct_update_key()
196 ovs_ct_get_labels(ct, &key->ct.labels); in __ovs_ct_update_key()
198 if (ct) { in __ovs_ct_update_key()
202 if (ct->master) in __ovs_ct_update_key()
203 ct = ct->master; in __ovs_ct_update_key()
204 orig = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple; in __ovs_ct_update_key()
208 nf_ct_l3num(ct) == NFPROTO_IPV4) { in __ovs_ct_update_key()
215 nf_ct_l3num(ct) == NFPROTO_IPV6) { in __ovs_ct_update_key()
240 struct nf_conn *ct; in ovs_ct_update_key() local
243 ct = nf_ct_get(skb, &ctinfo); in ovs_ct_update_key()
244 if (ct) { in ovs_ct_update_key()
247 if (!nf_ct_is_confirmed(ct)) in ovs_ct_update_key()
252 if (ct->master) in ovs_ct_update_key()
257 if (ct->status & IPS_SRC_NAT) in ovs_ct_update_key()
259 if (ct->status & IPS_DST_NAT) in ovs_ct_update_key()
262 zone = nf_ct_zone(ct); in ovs_ct_update_key()
268 __ovs_ct_update_key(key, state, zone, ct); in ovs_ct_update_key()
292 nla_put_u32(skb, OVS_KEY_ATTR_CT_MARK, output->ct.mark)) in ovs_ct_put_key()
296 nla_put(skb, OVS_KEY_ATTR_CT_LABELS, sizeof(output->ct.labels), in ovs_ct_put_key()
297 &output->ct.labels)) in ovs_ct_put_key()
307 orig.src_port = output->ct.orig_tp.src; in ovs_ct_put_key()
308 orig.dst_port = output->ct.orig_tp.dst; in ovs_ct_put_key()
322 orig.src_port = output->ct.orig_tp.src; in ovs_ct_put_key()
323 orig.dst_port = output->ct.orig_tp.dst; in ovs_ct_put_key()
335 static int ovs_ct_set_mark(struct nf_conn *ct, struct sw_flow_key *key, in ovs_ct_set_mark() argument
341 new_mark = ct_mark | (ct->mark & ~(mask)); in ovs_ct_set_mark()
342 if (ct->mark != new_mark) { in ovs_ct_set_mark()
343 ct->mark = new_mark; in ovs_ct_set_mark()
344 if (nf_ct_is_confirmed(ct)) in ovs_ct_set_mark()
345 nf_conntrack_event_cache(IPCT_MARK, ct); in ovs_ct_set_mark()
346 key->ct.mark = new_mark; in ovs_ct_set_mark()
355 static struct nf_conn_labels *ovs_ct_get_conn_labels(struct nf_conn *ct) in ovs_ct_get_conn_labels() argument
359 cl = nf_ct_labels_find(ct); in ovs_ct_get_conn_labels()
361 nf_ct_labels_ext_add(ct); in ovs_ct_get_conn_labels()
362 cl = nf_ct_labels_find(ct); in ovs_ct_get_conn_labels()
372 static int ovs_ct_init_labels(struct nf_conn *ct, struct sw_flow_key *key, in ovs_ct_init_labels() argument
380 master_cl = ct->master ? nf_ct_labels_find(ct->master) : NULL; in ovs_ct_init_labels()
385 cl = ovs_ct_get_conn_labels(ct); in ovs_ct_init_labels()
406 nf_conntrack_event_cache(IPCT_LABEL, ct); in ovs_ct_init_labels()
408 memcpy(&key->ct.labels, cl->bits, OVS_CT_LABELS_LEN); in ovs_ct_init_labels()
413 static int ovs_ct_set_labels(struct nf_conn *ct, struct sw_flow_key *key, in ovs_ct_set_labels() argument
420 cl = ovs_ct_get_conn_labels(ct); in ovs_ct_set_labels()
424 err = nf_connlabels_replace(ct, labels->ct_labels_32, in ovs_ct_set_labels()
430 memcpy(&key->ct.labels, cl->bits, OVS_CT_LABELS_LEN); in ovs_ct_set_labels()
442 struct nf_conn *ct; in ovs_ct_helper() local
445 ct = nf_ct_get(skb, &ctinfo); in ovs_ct_helper()
446 if (!ct || ctinfo == IP_CT_RELATED_REPLY) in ovs_ct_helper()
449 help = nfct_help(ct); in ovs_ct_helper()
480 err = helper->help(skb, protoff, ct, ctinfo); in ovs_ct_helper()
488 if (test_bit(IPS_SEQ_ADJUST_BIT, &ct->status) && in ovs_ct_helper()
489 !nf_ct_seq_adjust(skb, ct, ctinfo, protoff)) in ovs_ct_helper()
574 struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(h); in ovs_ct_expect_find() local
576 nf_ct_delete(ct, 0, 0); in ovs_ct_expect_find()
577 nf_conntrack_put(&ct->ct_general); in ovs_ct_expect_find()
588 const struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(h); in ovs_ct_get_info() local
593 if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) in ovs_ct_get_info()
595 if (test_bit(IPS_EXPECTED_BIT, &ct->status)) in ovs_ct_get_info()
615 struct nf_conn *ct; in ovs_ct_find_existing() local
639 ct = nf_ct_tuplehash_to_ctrack(h); in ovs_ct_find_existing()
646 h = &ct->tuplehash[!h->tuple.dst.dir]; in ovs_ct_find_existing()
648 nf_ct_set(skb, ct, ovs_ct_get_info(h)); in ovs_ct_find_existing()
649 return ct; in ovs_ct_find_existing()
659 struct nf_conn *ct = NULL; in ovs_ct_executed() local
672 ct = ovs_ct_find_existing(net, &info->zone, info->family, skb, in ovs_ct_executed()
677 return ct; in ovs_ct_executed()
687 struct nf_conn *ct; in skb_nfct_cached() local
690 ct = nf_ct_get(skb, &ctinfo); in skb_nfct_cached()
691 if (!ct) in skb_nfct_cached()
692 ct = ovs_ct_executed(net, key, info, skb, &ct_executed); in skb_nfct_cached()
694 if (ct) in skb_nfct_cached()
699 if (!net_eq(net, read_pnet(&ct->ct_net))) in skb_nfct_cached()
701 if (!nf_ct_zone_equal_any(info->ct, nf_ct_zone(ct))) in skb_nfct_cached()
706 help = nf_ct_ext_find(ct, NF_CT_EXT_HELPER); in skb_nfct_cached()
713 timeout_ext = nf_ct_timeout_find(ct); in skb_nfct_cached()
723 if (nf_ct_is_confirmed(ct)) in skb_nfct_cached()
724 nf_ct_delete(ct, 0, 0); in skb_nfct_cached()
726 nf_conntrack_put(&ct->ct_general); in skb_nfct_cached()
739 static int ovs_ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct, in ovs_ct_nat_execute() argument
761 if (!nf_nat_icmp_reply_translation(skb, ct, ctinfo, in ovs_ct_nat_execute()
774 if (!nf_nat_icmpv6_reply_translation(skb, ct, in ovs_ct_nat_execute()
788 if (!nf_nat_initialized(ct, maniptype)) { in ovs_ct_nat_execute()
794 ? nf_nat_setup_info(ct, range, maniptype) in ovs_ct_nat_execute()
795 : nf_nat_alloc_null_binding(ct, hooknum); in ovs_ct_nat_execute()
810 err = nf_nat_packet(ct, ctinfo, hooknum, skb); in ovs_ct_nat_execute()
871 struct sk_buff *skb, struct nf_conn *ct, in ovs_ct_nat() argument
878 if (!nf_ct_is_confirmed(ct) && !nf_ct_nat_ext_add(ct)) in ovs_ct_nat()
887 ct->status & IPS_NAT_MASK && in ovs_ct_nat()
895 maniptype = ct->status & IPS_SRC_NAT in ovs_ct_nat()
898 maniptype = ct->status & IPS_SRC_NAT in ovs_ct_nat()
907 err = ovs_ct_nat_execute(skb, ct, ctinfo, &info->range, maniptype); in ovs_ct_nat()
909 if (err == NF_ACCEPT && ct->status & IPS_DST_NAT) { in ovs_ct_nat()
910 if (ct->status & IPS_SRC_NAT) { in ovs_ct_nat()
916 err = ovs_ct_nat_execute(skb, ct, ctinfo, &info->range, in ovs_ct_nat()
919 err = ovs_ct_nat_execute(skb, ct, ctinfo, NULL, in ovs_ct_nat()
933 struct sk_buff *skb, struct nf_conn *ct, in ovs_ct_nat() argument
957 struct nf_conn *ct; in __ovs_ct_lookup() local
965 struct nf_conn *tmpl = info->ct; in __ovs_ct_lookup()
989 ct = nf_ct_get(skb, &ctinfo); in __ovs_ct_lookup()
990 if (ct) { in __ovs_ct_lookup()
1004 (nf_ct_is_confirmed(ct) || info->commit) && in __ovs_ct_lookup()
1005 ovs_ct_nat(net, key, info, skb, ct, ctinfo) != NF_ACCEPT) { in __ovs_ct_lookup()
1015 if (info->commit && info->helper && !nfct_help(ct)) { in __ovs_ct_lookup()
1016 int err = __nf_ct_try_assign_helper(ct, info->ct, in __ovs_ct_lookup()
1023 if (info->nat && !nfct_seqadj(ct)) { in __ovs_ct_lookup()
1024 if (!nfct_seqadj_ext_add(ct)) in __ovs_ct_lookup()
1035 if ((nf_ct_is_confirmed(ct) ? !cached || add_helper : in __ovs_ct_lookup()
1041 if (nf_ct_protonum(ct) == IPPROTO_TCP && in __ovs_ct_lookup()
1042 nf_ct_is_confirmed(ct) && nf_conntrack_tcp_established(ct)) { in __ovs_ct_lookup()
1046 nf_ct_set_tcp_be_liberal(ct); in __ovs_ct_lookup()
1077 struct nf_conn *ct; in ovs_ct_lookup() local
1084 ct = (struct nf_conn *)skb_nfct(skb); in ovs_ct_lookup()
1085 if (ct) in ovs_ct_lookup()
1086 nf_ct_deliver_cached_events(ct); in ovs_ct_lookup()
1192 struct nf_conn *ct; in ovs_ct_commit() local
1200 ct = nf_ct_get(skb, &ctinfo); in ovs_ct_commit()
1201 if (!ct) in ovs_ct_commit()
1206 if (!nf_ct_is_confirmed(ct)) { in ovs_ct_commit()
1208 &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); in ovs_ct_commit()
1227 struct nf_conntrack_ecache *cache = nf_ct_ecache_find(ct); in ovs_ct_commit()
1238 err = ovs_ct_set_mark(ct, key, info->mark.value, in ovs_ct_commit()
1243 if (!nf_ct_is_confirmed(ct)) { in ovs_ct_commit()
1244 err = ovs_ct_init_labels(ct, key, &info->labels.value, in ovs_ct_commit()
1250 err = ovs_ct_set_labels(ct, key, &info->labels.value, in ovs_ct_commit()
1352 help = nf_ct_helper_ext_add(info->ct, GFP_KERNEL); in ovs_ct_add_helper()
1690 ct_info.ct = nf_ct_tmpl_alloc(net, &ct_info.zone, GFP_KERNEL); in ovs_ct_copy_action()
1691 if (!ct_info.ct) { in ovs_ct_copy_action()
1697 if (nf_ct_set_timeout(net, ct_info.ct, family, key->ip.proto, in ovs_ct_copy_action()
1703 nf_ct_timeout_find(ct_info.ct)->timeout); in ovs_ct_copy_action()
1718 __set_bit(IPS_CONFIRMED_BIT, &ct_info.ct->status); in ovs_ct_copy_action()
1719 nf_conntrack_get(&ct_info.ct->ct_general); in ovs_ct_copy_action()
1857 if (ct_info->ct) { in __ovs_ct_free_action()
1859 nf_ct_destroy_timeout(ct_info->ct); in __ovs_ct_free_action()
1860 nf_ct_tmpl_free(ct_info->ct); in __ovs_ct_free_action()