Lines Matching refs:key
385 static int parse_ipv6hdr(struct sk_buff *skb, struct sw_flow_key *key) in parse_ipv6hdr() argument
400 get_ipv6_ext_hdrs(skb, nh, &key->ipv6.exthdrs); in parse_ipv6hdr()
402 key->ip.proto = NEXTHDR_NONE; in parse_ipv6hdr()
403 key->ip.tos = ipv6_get_dsfield(nh); in parse_ipv6hdr()
404 key->ip.ttl = nh->hop_limit; in parse_ipv6hdr()
405 key->ipv6.label = *(__be32 *)nh & htonl(IPV6_FLOWINFO_FLOWLABEL); in parse_ipv6hdr()
406 key->ipv6.addr.src = nh->saddr; in parse_ipv6hdr()
407 key->ipv6.addr.dst = nh->daddr; in parse_ipv6hdr()
412 key->ip.frag = OVS_FRAG_TYPE_LATER; in parse_ipv6hdr()
413 key->ip.proto = NEXTHDR_FRAGMENT; in parse_ipv6hdr()
416 key->ip.frag = OVS_FRAG_TYPE_FIRST; in parse_ipv6hdr()
418 key->ip.frag = OVS_FRAG_TYPE_NONE; in parse_ipv6hdr()
430 key->ip.proto = nexthdr; in parse_ipv6hdr()
486 static void clear_vlan(struct sw_flow_key *key) in clear_vlan() argument
488 key->eth.vlan.tci = 0; in clear_vlan()
489 key->eth.vlan.tpid = 0; in clear_vlan()
490 key->eth.cvlan.tci = 0; in clear_vlan()
491 key->eth.cvlan.tpid = 0; in clear_vlan()
494 static int parse_vlan(struct sk_buff *skb, struct sw_flow_key *key) in parse_vlan() argument
499 key->eth.vlan.tci = htons(skb->vlan_tci) | htons(VLAN_CFI_MASK); in parse_vlan()
500 key->eth.vlan.tpid = skb->vlan_proto; in parse_vlan()
503 res = parse_vlan_tag(skb, &key->eth.vlan, true); in parse_vlan()
509 res = parse_vlan_tag(skb, &key->eth.cvlan, false); in parse_vlan()
554 static int parse_icmpv6(struct sk_buff *skb, struct sw_flow_key *key, in parse_icmpv6() argument
562 key->tp.src = htons(icmp->icmp6_type); in parse_icmpv6()
563 key->tp.dst = htons(icmp->icmp6_code); in parse_icmpv6()
564 memset(&key->ipv6.nd, 0, sizeof(key->ipv6.nd)); in parse_icmpv6()
583 key->ipv6.nd.target = nd->target; in parse_icmpv6()
601 if (unlikely(!is_zero_ether_addr(key->ipv6.nd.sll))) in parse_icmpv6()
603 ether_addr_copy(key->ipv6.nd.sll, in parse_icmpv6()
607 if (unlikely(!is_zero_ether_addr(key->ipv6.nd.tll))) in parse_icmpv6()
609 ether_addr_copy(key->ipv6.nd.tll, in parse_icmpv6()
621 memset(&key->ipv6.nd.target, 0, sizeof(key->ipv6.nd.target)); in parse_icmpv6()
622 memset(key->ipv6.nd.sll, 0, sizeof(key->ipv6.nd.sll)); in parse_icmpv6()
623 memset(key->ipv6.nd.tll, 0, sizeof(key->ipv6.nd.tll)); in parse_icmpv6()
628 static int parse_nsh(struct sk_buff *skb, struct sw_flow_key *key) in parse_nsh() argument
651 key->nsh.base.flags = nsh_get_flags(nh); in parse_nsh()
652 key->nsh.base.ttl = nsh_get_ttl(nh); in parse_nsh()
653 key->nsh.base.mdtype = nh->mdtype; in parse_nsh()
654 key->nsh.base.np = nh->np; in parse_nsh()
655 key->nsh.base.path_hdr = nh->path_hdr; in parse_nsh()
656 switch (key->nsh.base.mdtype) { in parse_nsh()
660 memcpy(key->nsh.context, nh->md1.context, in parse_nsh()
664 memset(key->nsh.context, 0, in parse_nsh()
682 static int key_extract_l3l4(struct sk_buff *skb, struct sw_flow_key *key) in key_extract_l3l4() argument
687 if (key->eth.type == htons(ETH_P_IP)) { in key_extract_l3l4()
693 memset(&key->ip, 0, sizeof(key->ip)); in key_extract_l3l4()
694 memset(&key->ipv4, 0, sizeof(key->ipv4)); in key_extract_l3l4()
703 key->ipv4.addr.src = nh->saddr; in key_extract_l3l4()
704 key->ipv4.addr.dst = nh->daddr; in key_extract_l3l4()
706 key->ip.proto = nh->protocol; in key_extract_l3l4()
707 key->ip.tos = nh->tos; in key_extract_l3l4()
708 key->ip.ttl = nh->ttl; in key_extract_l3l4()
712 key->ip.frag = OVS_FRAG_TYPE_LATER; in key_extract_l3l4()
713 memset(&key->tp, 0, sizeof(key->tp)); in key_extract_l3l4()
718 key->ip.frag = OVS_FRAG_TYPE_FIRST; in key_extract_l3l4()
720 key->ip.frag = OVS_FRAG_TYPE_NONE; in key_extract_l3l4()
723 if (key->ip.proto == IPPROTO_TCP) { in key_extract_l3l4()
726 key->tp.src = tcp->source; in key_extract_l3l4()
727 key->tp.dst = tcp->dest; in key_extract_l3l4()
728 key->tp.flags = TCP_FLAGS_BE16(tcp); in key_extract_l3l4()
730 memset(&key->tp, 0, sizeof(key->tp)); in key_extract_l3l4()
733 } else if (key->ip.proto == IPPROTO_UDP) { in key_extract_l3l4()
736 key->tp.src = udp->source; in key_extract_l3l4()
737 key->tp.dst = udp->dest; in key_extract_l3l4()
739 memset(&key->tp, 0, sizeof(key->tp)); in key_extract_l3l4()
741 } else if (key->ip.proto == IPPROTO_SCTP) { in key_extract_l3l4()
744 key->tp.src = sctp->source; in key_extract_l3l4()
745 key->tp.dst = sctp->dest; in key_extract_l3l4()
747 memset(&key->tp, 0, sizeof(key->tp)); in key_extract_l3l4()
749 } else if (key->ip.proto == IPPROTO_ICMP) { in key_extract_l3l4()
755 key->tp.src = htons(icmp->type); in key_extract_l3l4()
756 key->tp.dst = htons(icmp->code); in key_extract_l3l4()
758 memset(&key->tp, 0, sizeof(key->tp)); in key_extract_l3l4()
762 } else if (key->eth.type == htons(ETH_P_ARP) || in key_extract_l3l4()
763 key->eth.type == htons(ETH_P_RARP)) { in key_extract_l3l4()
777 key->ip.proto = ntohs(arp->ar_op); in key_extract_l3l4()
779 key->ip.proto = 0; in key_extract_l3l4()
781 memcpy(&key->ipv4.addr.src, arp->ar_sip, sizeof(key->ipv4.addr.src)); in key_extract_l3l4()
782 memcpy(&key->ipv4.addr.dst, arp->ar_tip, sizeof(key->ipv4.addr.dst)); in key_extract_l3l4()
783 ether_addr_copy(key->ipv4.arp.sha, arp->ar_sha); in key_extract_l3l4()
784 ether_addr_copy(key->ipv4.arp.tha, arp->ar_tha); in key_extract_l3l4()
786 memset(&key->ip, 0, sizeof(key->ip)); in key_extract_l3l4()
787 memset(&key->ipv4, 0, sizeof(key->ipv4)); in key_extract_l3l4()
789 } else if (eth_p_mpls(key->eth.type)) { in key_extract_l3l4()
792 memset(&key->mpls, 0, sizeof(key->mpls)); in key_extract_l3l4()
805 memcpy(&key->mpls.lse[label_count - 1], &lse, in key_extract_l3l4()
818 key->mpls.num_labels_mask = GENMASK(label_count - 1, 0); in key_extract_l3l4()
819 } else if (key->eth.type == htons(ETH_P_IPV6)) { in key_extract_l3l4()
822 nh_len = parse_ipv6hdr(skb, key); in key_extract_l3l4()
826 memset(&key->ip, 0, sizeof(key->ip)); in key_extract_l3l4()
827 memset(&key->ipv6.addr, 0, sizeof(key->ipv6.addr)); in key_extract_l3l4()
839 if (key->ip.frag == OVS_FRAG_TYPE_LATER) { in key_extract_l3l4()
840 memset(&key->tp, 0, sizeof(key->tp)); in key_extract_l3l4()
844 key->ip.frag = OVS_FRAG_TYPE_FIRST; in key_extract_l3l4()
847 if (key->ip.proto == NEXTHDR_TCP) { in key_extract_l3l4()
850 key->tp.src = tcp->source; in key_extract_l3l4()
851 key->tp.dst = tcp->dest; in key_extract_l3l4()
852 key->tp.flags = TCP_FLAGS_BE16(tcp); in key_extract_l3l4()
854 memset(&key->tp, 0, sizeof(key->tp)); in key_extract_l3l4()
856 } else if (key->ip.proto == NEXTHDR_UDP) { in key_extract_l3l4()
859 key->tp.src = udp->source; in key_extract_l3l4()
860 key->tp.dst = udp->dest; in key_extract_l3l4()
862 memset(&key->tp, 0, sizeof(key->tp)); in key_extract_l3l4()
864 } else if (key->ip.proto == NEXTHDR_SCTP) { in key_extract_l3l4()
867 key->tp.src = sctp->source; in key_extract_l3l4()
868 key->tp.dst = sctp->dest; in key_extract_l3l4()
870 memset(&key->tp, 0, sizeof(key->tp)); in key_extract_l3l4()
872 } else if (key->ip.proto == NEXTHDR_ICMP) { in key_extract_l3l4()
874 error = parse_icmpv6(skb, key, nh_len); in key_extract_l3l4()
878 memset(&key->tp, 0, sizeof(key->tp)); in key_extract_l3l4()
881 } else if (key->eth.type == htons(ETH_P_NSH)) { in key_extract_l3l4()
882 error = parse_nsh(skb, key); in key_extract_l3l4()
914 static int key_extract(struct sk_buff *skb, struct sw_flow_key *key) in key_extract() argument
919 key->tp.flags = 0; in key_extract()
924 clear_vlan(key); in key_extract()
925 if (ovs_key_mac_proto(key) == MAC_PROTO_NONE) { in key_extract()
930 key->eth.type = skb->protocol; in key_extract()
933 ether_addr_copy(key->eth.src, eth->h_source); in key_extract()
934 ether_addr_copy(key->eth.dst, eth->h_dest); in key_extract()
941 if (unlikely(parse_vlan(skb, key))) in key_extract()
944 key->eth.type = parse_ethertype(skb); in key_extract()
945 if (unlikely(key->eth.type == htons(0))) in key_extract()
952 if (key->eth.cvlan.tci & htons(VLAN_CFI_MASK)) in key_extract()
953 skb->protocol = key->eth.cvlan.tpid; in key_extract()
955 skb->protocol = key->eth.type; in key_extract()
964 return key_extract_l3l4(skb, key); in key_extract()
970 int ovs_flow_key_update_l3l4(struct sk_buff *skb, struct sw_flow_key *key) in ovs_flow_key_update_l3l4() argument
972 return key_extract_l3l4(skb, key); in ovs_flow_key_update_l3l4()
975 int ovs_flow_key_update(struct sk_buff *skb, struct sw_flow_key *key) in ovs_flow_key_update() argument
979 res = key_extract(skb, key); in ovs_flow_key_update()
981 key->mac_proto &= ~SW_FLOW_KEY_INVALID; in ovs_flow_key_update()
1001 struct sk_buff *skb, struct sw_flow_key *key) in ovs_flow_key_extract() argument
1012 key->tun_proto = ip_tunnel_info_af(tun_info); in ovs_flow_key_extract()
1013 memcpy(&key->tun_key, &tun_info->key, sizeof(key->tun_key)); in ovs_flow_key_extract()
1018 > sizeof(key->tun_opts)); in ovs_flow_key_extract()
1020 ip_tunnel_info_opts_get(TUN_METADATA_OPTS(key, tun_info->options_len), in ovs_flow_key_extract()
1022 key->tun_opts_len = tun_info->options_len; in ovs_flow_key_extract()
1024 key->tun_opts_len = 0; in ovs_flow_key_extract()
1027 key->tun_proto = 0; in ovs_flow_key_extract()
1028 key->tun_opts_len = 0; in ovs_flow_key_extract()
1029 memset(&key->tun_key, 0, sizeof(key->tun_key)); in ovs_flow_key_extract()
1032 key->phy.priority = skb->priority; in ovs_flow_key_extract()
1033 key->phy.in_port = OVS_CB(skb)->input_vport->port_no; in ovs_flow_key_extract()
1034 key->phy.skb_mark = skb->mark; in ovs_flow_key_extract()
1035 key->ovs_flow_hash = 0; in ovs_flow_key_extract()
1039 key->mac_proto = res; in ovs_flow_key_extract()
1044 key->recirc_id = tc_ext && !tc_ext->act_miss ? in ovs_flow_key_extract()
1052 key->recirc_id = 0; in ovs_flow_key_extract()
1055 key->recirc_id = 0; in ovs_flow_key_extract()
1058 err = key_extract(skb, key); in ovs_flow_key_extract()
1060 ovs_ct_fill_key(skb, key, post_ct); /* Must be after key_extract(). */ in ovs_flow_key_extract()
1063 key->ct_zone = zone; in ovs_flow_key_extract()
1066 key->ct_state &= ~OVS_CS_F_DST_NAT; in ovs_flow_key_extract()
1068 key->ct_state &= ~OVS_CS_F_SRC_NAT; in ovs_flow_key_extract()
1077 struct sw_flow_key *key, bool log) in ovs_flow_key_extract_userspace() argument
1088 err = ovs_nla_get_flow_metadata(net, a, attrs, key, log); in ovs_flow_key_extract_userspace()
1101 skb->protocol = key->eth.type; in ovs_flow_key_extract_userspace()
1102 err = key_extract(skb, key); in ovs_flow_key_extract_userspace()
1111 key->eth.type != htons(ETH_P_IP)) in ovs_flow_key_extract_userspace()
1114 (key->eth.type != htons(ETH_P_IPV6) || in ovs_flow_key_extract_userspace()
1115 sw_flow_key_is_nd(key))) in ovs_flow_key_extract_userspace()