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 ? READ_ONCE(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()
290 nla_put_u32(skb, OVS_KEY_ATTR_CT_MARK, output->ct.mark)) in ovs_ct_put_key()
294 nla_put(skb, OVS_KEY_ATTR_CT_LABELS, sizeof(output->ct.labels), in ovs_ct_put_key()
295 &output->ct.labels)) in ovs_ct_put_key()
305 orig.src_port = output->ct.orig_tp.src; in ovs_ct_put_key()
306 orig.dst_port = output->ct.orig_tp.dst; in ovs_ct_put_key()
320 orig.src_port = output->ct.orig_tp.src; in ovs_ct_put_key()
321 orig.dst_port = output->ct.orig_tp.dst; in ovs_ct_put_key()
333 static int ovs_ct_set_mark(struct nf_conn *ct, struct sw_flow_key *key, in ovs_ct_set_mark() argument
339 new_mark = ct_mark | (READ_ONCE(ct->mark) & ~(mask)); in ovs_ct_set_mark()
340 if (READ_ONCE(ct->mark) != new_mark) { in ovs_ct_set_mark()
341 WRITE_ONCE(ct->mark, new_mark); in ovs_ct_set_mark()
342 if (nf_ct_is_confirmed(ct)) in ovs_ct_set_mark()
343 nf_conntrack_event_cache(IPCT_MARK, ct); in ovs_ct_set_mark()
344 key->ct.mark = new_mark; in ovs_ct_set_mark()
353 static struct nf_conn_labels *ovs_ct_get_conn_labels(struct nf_conn *ct) in ovs_ct_get_conn_labels() argument
357 cl = nf_ct_labels_find(ct); in ovs_ct_get_conn_labels()
359 nf_ct_labels_ext_add(ct); in ovs_ct_get_conn_labels()
360 cl = nf_ct_labels_find(ct); in ovs_ct_get_conn_labels()
370 static int ovs_ct_init_labels(struct nf_conn *ct, struct sw_flow_key *key, in ovs_ct_init_labels() argument
378 master_cl = ct->master ? nf_ct_labels_find(ct->master) : NULL; in ovs_ct_init_labels()
383 cl = ovs_ct_get_conn_labels(ct); in ovs_ct_init_labels()
404 nf_conntrack_event_cache(IPCT_LABEL, ct); in ovs_ct_init_labels()
406 memcpy(&key->ct.labels, cl->bits, OVS_CT_LABELS_LEN); in ovs_ct_init_labels()
411 static int ovs_ct_set_labels(struct nf_conn *ct, struct sw_flow_key *key, in ovs_ct_set_labels() argument
418 cl = ovs_ct_get_conn_labels(ct); in ovs_ct_set_labels()
422 err = nf_connlabels_replace(ct, labels->ct_labels_32, in ovs_ct_set_labels()
428 memcpy(&key->ct.labels, cl->bits, OVS_CT_LABELS_LEN); in ovs_ct_set_labels()
440 struct nf_conn *ct; in ovs_ct_helper() local
443 ct = nf_ct_get(skb, &ctinfo); in ovs_ct_helper()
444 if (!ct || ctinfo == IP_CT_RELATED_REPLY) in ovs_ct_helper()
447 help = nfct_help(ct); in ovs_ct_helper()
478 err = helper->help(skb, protoff, ct, ctinfo); in ovs_ct_helper()
486 if (test_bit(IPS_SEQ_ADJUST_BIT, &ct->status) && in ovs_ct_helper()
487 !nf_ct_seq_adjust(skb, ct, ctinfo, protoff)) in ovs_ct_helper()
572 struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(h); in ovs_ct_expect_find() local
574 nf_ct_delete(ct, 0, 0); in ovs_ct_expect_find()
575 nf_conntrack_put(&ct->ct_general); in ovs_ct_expect_find()
586 const struct nf_conn *ct = nf_ct_tuplehash_to_ctrack(h); in ovs_ct_get_info() local
591 if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) in ovs_ct_get_info()
593 if (test_bit(IPS_EXPECTED_BIT, &ct->status)) in ovs_ct_get_info()
613 struct nf_conn *ct; in ovs_ct_find_existing() local
637 ct = nf_ct_tuplehash_to_ctrack(h); in ovs_ct_find_existing()
644 h = &ct->tuplehash[!h->tuple.dst.dir]; in ovs_ct_find_existing()
646 nf_ct_set(skb, ct, ovs_ct_get_info(h)); in ovs_ct_find_existing()
647 return ct; in ovs_ct_find_existing()
657 struct nf_conn *ct = NULL; in ovs_ct_executed() local
670 ct = ovs_ct_find_existing(net, &info->zone, info->family, skb, in ovs_ct_executed()
675 return ct; in ovs_ct_executed()
685 struct nf_conn *ct; in skb_nfct_cached() local
688 ct = nf_ct_get(skb, &ctinfo); in skb_nfct_cached()
689 if (!ct) in skb_nfct_cached()
690 ct = ovs_ct_executed(net, key, info, skb, &ct_executed); in skb_nfct_cached()
692 if (ct) in skb_nfct_cached()
697 if (!net_eq(net, read_pnet(&ct->ct_net))) in skb_nfct_cached()
699 if (!nf_ct_zone_equal_any(info->ct, nf_ct_zone(ct))) in skb_nfct_cached()
704 help = nf_ct_ext_find(ct, NF_CT_EXT_HELPER); in skb_nfct_cached()
711 timeout_ext = nf_ct_timeout_find(ct); in skb_nfct_cached()
721 if (nf_ct_is_confirmed(ct)) in skb_nfct_cached()
722 nf_ct_delete(ct, 0, 0); in skb_nfct_cached()
724 nf_conntrack_put(&ct->ct_general); in skb_nfct_cached()
788 static int ovs_ct_nat_execute(struct sk_buff *skb, struct nf_conn *ct, in ovs_ct_nat_execute() argument
810 if (!nf_nat_icmp_reply_translation(skb, ct, ctinfo, in ovs_ct_nat_execute()
823 if (!nf_nat_icmpv6_reply_translation(skb, ct, in ovs_ct_nat_execute()
837 if (!nf_nat_initialized(ct, maniptype)) { in ovs_ct_nat_execute()
843 ? nf_nat_setup_info(ct, range, maniptype) in ovs_ct_nat_execute()
844 : nf_nat_alloc_null_binding(ct, hooknum); in ovs_ct_nat_execute()
859 err = nf_nat_packet(ct, ctinfo, hooknum, skb); in ovs_ct_nat_execute()
874 struct sk_buff *skb, struct nf_conn *ct, in ovs_ct_nat() argument
881 if (!nf_ct_is_confirmed(ct) && !nf_ct_nat_ext_add(ct)) in ovs_ct_nat()
890 ct->status & IPS_NAT_MASK && in ovs_ct_nat()
898 maniptype = ct->status & IPS_SRC_NAT in ovs_ct_nat()
901 maniptype = ct->status & IPS_SRC_NAT in ovs_ct_nat()
910 err = ovs_ct_nat_execute(skb, ct, ctinfo, &info->range, maniptype, key); in ovs_ct_nat()
912 if (err == NF_ACCEPT && ct->status & IPS_DST_NAT) { in ovs_ct_nat()
913 if (ct->status & IPS_SRC_NAT) { in ovs_ct_nat()
919 err = ovs_ct_nat_execute(skb, ct, ctinfo, &info->range, in ovs_ct_nat()
922 err = ovs_ct_nat_execute(skb, ct, ctinfo, NULL, in ovs_ct_nat()
932 struct sk_buff *skb, struct nf_conn *ct, in ovs_ct_nat() argument
956 struct nf_conn *ct; in __ovs_ct_lookup() local
964 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()
1069 struct nf_conn *ct; in ovs_ct_lookup() local
1076 ct = (struct nf_conn *)skb_nfct(skb); in ovs_ct_lookup()
1077 if (ct) in ovs_ct_lookup()
1078 nf_ct_deliver_cached_events(ct); in ovs_ct_lookup()
1184 struct nf_conn *ct; in ovs_ct_commit() local
1192 ct = nf_ct_get(skb, &ctinfo); in ovs_ct_commit()
1193 if (!ct) in ovs_ct_commit()
1198 if (!nf_ct_is_confirmed(ct)) { in ovs_ct_commit()
1200 &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple); in ovs_ct_commit()
1219 struct nf_conntrack_ecache *cache = nf_ct_ecache_find(ct); in ovs_ct_commit()
1230 err = ovs_ct_set_mark(ct, key, info->mark.value, in ovs_ct_commit()
1235 if (!nf_ct_is_confirmed(ct)) { in ovs_ct_commit()
1236 err = ovs_ct_init_labels(ct, key, &info->labels.value, in ovs_ct_commit()
1242 err = ovs_ct_set_labels(ct, key, &info->labels.value, in ovs_ct_commit()
1348 help = nf_ct_helper_ext_add(info->ct, GFP_KERNEL); in ovs_ct_add_helper()
1686 ct_info.ct = nf_ct_tmpl_alloc(net, &ct_info.zone, GFP_KERNEL); in ovs_ct_copy_action()
1687 if (!ct_info.ct) { in ovs_ct_copy_action()
1693 if (nf_ct_set_timeout(net, ct_info.ct, family, key->ip.proto, in ovs_ct_copy_action()
1699 nf_ct_timeout_find(ct_info.ct)->timeout); in ovs_ct_copy_action()
1714 __set_bit(IPS_CONFIRMED_BIT, &ct_info.ct->status); in ovs_ct_copy_action()
1715 nf_conntrack_get(&ct_info.ct->ct_general); in ovs_ct_copy_action()
1853 if (ct_info->ct) { in __ovs_ct_free_action()
1855 nf_ct_destroy_timeout(ct_info->ct); in __ovs_ct_free_action()
1856 nf_ct_tmpl_free(ct_info->ct); in __ovs_ct_free_action()