Lines Matching refs:key

109 static u16 key_to_nfproto(const struct sw_flow_key *key)  in key_to_nfproto()  argument
111 switch (ntohs(key->eth.type)) { in key_to_nfproto()
184 static void __ovs_ct_update_key_orig_tp(struct sw_flow_key *key, in __ovs_ct_update_key_orig_tp() argument
188 key->ct_orig_proto = orig->dst.protonum; in __ovs_ct_update_key_orig_tp()
190 key->ct.orig_tp.src = htons(orig->dst.u.icmp.type); in __ovs_ct_update_key_orig_tp()
191 key->ct.orig_tp.dst = htons(orig->dst.u.icmp.code); in __ovs_ct_update_key_orig_tp()
193 key->ct.orig_tp.src = orig->src.u.all; in __ovs_ct_update_key_orig_tp()
194 key->ct.orig_tp.dst = orig->dst.u.all; in __ovs_ct_update_key_orig_tp()
198 static void __ovs_ct_update_key(struct sw_flow_key *key, u8 state, in __ovs_ct_update_key() argument
202 key->ct_state = state; in __ovs_ct_update_key()
203 key->ct_zone = zone->id; in __ovs_ct_update_key()
204 key->ct.mark = ovs_ct_get_mark(ct); in __ovs_ct_update_key()
205 ovs_ct_get_labels(ct, &key->ct.labels); in __ovs_ct_update_key()
216 if (key->eth.type == htons(ETH_P_IP) && in __ovs_ct_update_key()
218 key->ipv4.ct_orig.src = orig->src.u3.ip; in __ovs_ct_update_key()
219 key->ipv4.ct_orig.dst = orig->dst.u3.ip; in __ovs_ct_update_key()
220 __ovs_ct_update_key_orig_tp(key, orig, IPPROTO_ICMP); in __ovs_ct_update_key()
222 } else if (key->eth.type == htons(ETH_P_IPV6) && in __ovs_ct_update_key()
223 !sw_flow_key_is_nd(key) && in __ovs_ct_update_key()
225 key->ipv6.ct_orig.src = orig->src.u3.in6; in __ovs_ct_update_key()
226 key->ipv6.ct_orig.dst = orig->dst.u3.in6; in __ovs_ct_update_key()
227 __ovs_ct_update_key_orig_tp(key, orig, NEXTHDR_ICMP); in __ovs_ct_update_key()
234 key->ct_orig_proto = 0; in __ovs_ct_update_key()
244 struct sw_flow_key *key, bool post_ct, in ovs_ct_update_key() argument
264 state |= key->ct_state & OVS_CS_F_NAT_MASK; in ovs_ct_update_key()
277 __ovs_ct_update_key(key, state, zone, ct); in ovs_ct_update_key()
284 struct sw_flow_key *key, in ovs_ct_fill_key() argument
287 ovs_ct_update_key(skb, NULL, key, post_ct, false); in ovs_ct_fill_key()
344 static int ovs_ct_set_mark(struct nf_conn *ct, struct sw_flow_key *key, in ovs_ct_set_mark() argument
355 key->ct.mark = new_mark; in ovs_ct_set_mark()
381 static int ovs_ct_init_labels(struct nf_conn *ct, struct sw_flow_key *key, in ovs_ct_init_labels() argument
417 memcpy(&key->ct.labels, cl->bits, OVS_CT_LABELS_LEN); in ovs_ct_init_labels()
422 static int ovs_ct_set_labels(struct nf_conn *ct, struct sw_flow_key *key, in ovs_ct_set_labels() argument
439 memcpy(&key->ct.labels, cl->bits, OVS_CT_LABELS_LEN); in ovs_ct_set_labels()
444 static int ovs_ct_handle_fragments(struct net *net, struct sw_flow_key *key, in ovs_ct_handle_fragments() argument
450 err = nf_ct_handle_fragments(net, skb, zone, family, &key->ip.proto, &ovs_cb.mru); in ovs_ct_handle_fragments()
457 ovs_flow_key_update_l3l4(skb, key); in ovs_ct_handle_fragments()
458 key->ip.frag = OVS_FRAG_TYPE_NONE; in ovs_ct_handle_fragments()
534 const struct sw_flow_key *key, in ovs_ct_executed() argument
547 *ct_executed = (key->ct_state & OVS_CS_F_TRACKED) && in ovs_ct_executed()
548 !(key->ct_state & OVS_CS_F_INVALID) && in ovs_ct_executed()
549 (key->ct_zone == info->zone.id); in ovs_ct_executed()
551 if (*ct_executed || (!key->ct_state && info->force)) { in ovs_ct_executed()
553 !!(key->ct_state & in ovs_ct_executed()
562 const struct sw_flow_key *key, in skb_nfct_cached() argument
572 ct = ovs_ct_executed(net, key, info, skb, &ct_executed); in skb_nfct_cached()
615 static void ovs_nat_update_key(struct sw_flow_key *key, in ovs_nat_update_key() argument
622 key->ct_state |= OVS_CS_F_SRC_NAT; in ovs_nat_update_key()
623 if (key->eth.type == htons(ETH_P_IP)) in ovs_nat_update_key()
624 key->ipv4.addr.src = ip_hdr(skb)->saddr; in ovs_nat_update_key()
625 else if (key->eth.type == htons(ETH_P_IPV6)) in ovs_nat_update_key()
626 memcpy(&key->ipv6.addr.src, &ipv6_hdr(skb)->saddr, in ovs_nat_update_key()
627 sizeof(key->ipv6.addr.src)); in ovs_nat_update_key()
631 if (key->ip.proto == IPPROTO_UDP) in ovs_nat_update_key()
633 else if (key->ip.proto == IPPROTO_TCP) in ovs_nat_update_key()
635 else if (key->ip.proto == IPPROTO_SCTP) in ovs_nat_update_key()
640 key->tp.src = src; in ovs_nat_update_key()
644 key->ct_state |= OVS_CS_F_DST_NAT; in ovs_nat_update_key()
645 if (key->eth.type == htons(ETH_P_IP)) in ovs_nat_update_key()
646 key->ipv4.addr.dst = ip_hdr(skb)->daddr; in ovs_nat_update_key()
647 else if (key->eth.type == htons(ETH_P_IPV6)) in ovs_nat_update_key()
648 memcpy(&key->ipv6.addr.dst, &ipv6_hdr(skb)->daddr, in ovs_nat_update_key()
649 sizeof(key->ipv6.addr.dst)); in ovs_nat_update_key()
653 if (key->ip.proto == IPPROTO_UDP) in ovs_nat_update_key()
655 else if (key->ip.proto == IPPROTO_TCP) in ovs_nat_update_key()
657 else if (key->ip.proto == IPPROTO_SCTP) in ovs_nat_update_key()
662 key->tp.dst = dst; in ovs_nat_update_key()
667 static int ovs_ct_nat(struct net *net, struct sw_flow_key *key, in ovs_ct_nat() argument
684 ovs_nat_update_key(key, skb, NF_NAT_MANIP_SRC); in ovs_ct_nat()
686 ovs_nat_update_key(key, skb, NF_NAT_MANIP_DST); in ovs_ct_nat()
691 static int ovs_ct_nat(struct net *net, struct sw_flow_key *key, in ovs_ct_nat() argument
706 static int __ovs_ct_lookup(struct net *net, struct sw_flow_key *key, in __ovs_ct_lookup() argument
715 bool cached = skb_nfct_cached(net, key, info, skb); in __ovs_ct_lookup()
744 key->ct_state = 0; in __ovs_ct_lookup()
747 ovs_ct_update_key(skb, info, key, true, true); in __ovs_ct_lookup()
764 if (info->nat && !(key->ct_state & OVS_CS_F_NAT_MASK) && in __ovs_ct_lookup()
766 ovs_ct_nat(net, key, info, skb, ct, ctinfo) != NF_ACCEPT) { in __ovs_ct_lookup()
818 static int ovs_ct_lookup(struct net *net, struct sw_flow_key *key, in ovs_ct_lookup() argument
825 err = __ovs_ct_lookup(net, key, info, skb); in ovs_ct_lookup()
931 static int ovs_ct_commit(struct net *net, struct sw_flow_key *key, in ovs_ct_commit() argument
939 err = __ovs_ct_lookup(net, key, info, skb); in ovs_ct_commit()
982 err = ovs_ct_set_mark(ct, key, info->mark.value, in ovs_ct_commit()
988 err = ovs_ct_init_labels(ct, key, &info->labels.value, in ovs_ct_commit()
996 err = ovs_ct_set_labels(ct, key, &info->labels.value, in ovs_ct_commit()
1014 struct sw_flow_key *key, in ovs_ct_execute() argument
1030 if (key->ip.frag != OVS_FRAG_TYPE_NONE) { in ovs_ct_execute()
1031 err = ovs_ct_handle_fragments(net, key, info->zone.id, in ovs_ct_execute()
1038 err = ovs_ct_commit(net, key, info, skb); in ovs_ct_execute()
1040 err = ovs_ct_lookup(net, key, info, skb); in ovs_ct_execute()
1048 int ovs_ct_clear(struct sk_buff *skb, struct sw_flow_key *key) in ovs_ct_clear() argument
1058 if (key) in ovs_ct_clear()
1059 ovs_ct_fill_key(skb, key, false); in ovs_ct_clear()
1354 const struct sw_flow_key *key, in ovs_ct_copy_action() argument
1362 family = key_to_nfproto(key); in ovs_ct_copy_action()
1386 if (nf_ct_set_timeout(net, ct_info.ct, family, key->ip.proto, in ovs_ct_copy_action()
1399 key->ip.proto, ct_info.nat, &ct_info.helper); in ovs_ct_copy_action()