Lines Matching refs:match
91 static void update_range(struct sw_flow_match *match, in update_range() argument
99 range = &match->range; in update_range()
101 range = &match->mask->range; in update_range()
116 #define SW_FLOW_KEY_PUT(match, field, value, is_mask) \ argument
118 update_range(match, offsetof(struct sw_flow_key, field), \
119 sizeof((match)->key->field), is_mask); \
121 (match)->mask->key.field = value; \
123 (match)->key->field = value; \
126 #define SW_FLOW_KEY_MEMCPY_OFFSET(match, offset, value_p, len, is_mask) \ argument
128 update_range(match, offset, len, is_mask); \
130 memcpy((u8 *)&(match)->mask->key + offset, value_p, \
133 memcpy((u8 *)(match)->key + offset, value_p, len); \
136 #define SW_FLOW_KEY_MEMCPY(match, field, value_p, len, is_mask) \ argument
137 SW_FLOW_KEY_MEMCPY_OFFSET(match, offsetof(struct sw_flow_key, field), \
140 #define SW_FLOW_KEY_MEMSET_FIELD(match, field, value, is_mask) \ argument
142 update_range(match, offsetof(struct sw_flow_key, field), \
143 sizeof((match)->key->field), is_mask); \
145 memset((u8 *)&(match)->mask->key.field, value, \
146 sizeof((match)->mask->key.field)); \
148 memset((u8 *)&(match)->key->field, value, \
149 sizeof((match)->key->field)); \
152 static bool match_validate(const struct sw_flow_match *match, in match_validate() argument
181 if (match->key->eth.type == htons(ETH_P_ARP) in match_validate()
182 || match->key->eth.type == htons(ETH_P_RARP)) { in match_validate()
184 if (match->mask && (match->mask->key.eth.type == htons(0xffff))) in match_validate()
188 if (eth_p_mpls(match->key->eth.type)) { in match_validate()
190 if (match->mask && (match->mask->key.eth.type == htons(0xffff))) in match_validate()
194 if (match->key->eth.type == htons(ETH_P_IP)) { in match_validate()
196 if (match->mask && match->mask->key.eth.type == htons(0xffff)) { in match_validate()
201 if (match->key->ip.frag != OVS_FRAG_TYPE_LATER) { in match_validate()
202 if (match->key->ip.proto == IPPROTO_UDP) { in match_validate()
204 if (match->mask && (match->mask->key.ip.proto == 0xff)) in match_validate()
208 if (match->key->ip.proto == IPPROTO_SCTP) { in match_validate()
210 if (match->mask && (match->mask->key.ip.proto == 0xff)) in match_validate()
214 if (match->key->ip.proto == IPPROTO_TCP) { in match_validate()
217 if (match->mask && (match->mask->key.ip.proto == 0xff)) { in match_validate()
223 if (match->key->ip.proto == IPPROTO_ICMP) { in match_validate()
225 if (match->mask && (match->mask->key.ip.proto == 0xff)) in match_validate()
231 if (match->key->eth.type == htons(ETH_P_IPV6)) { in match_validate()
233 if (match->mask && match->mask->key.eth.type == htons(0xffff)) { in match_validate()
238 if (match->key->ip.frag != OVS_FRAG_TYPE_LATER) { in match_validate()
239 if (match->key->ip.proto == IPPROTO_UDP) { in match_validate()
241 if (match->mask && (match->mask->key.ip.proto == 0xff)) in match_validate()
245 if (match->key->ip.proto == IPPROTO_SCTP) { in match_validate()
247 if (match->mask && (match->mask->key.ip.proto == 0xff)) in match_validate()
251 if (match->key->ip.proto == IPPROTO_TCP) { in match_validate()
254 if (match->mask && (match->mask->key.ip.proto == 0xff)) { in match_validate()
260 if (match->key->ip.proto == IPPROTO_ICMPV6) { in match_validate()
262 if (match->mask && (match->mask->key.ip.proto == 0xff)) in match_validate()
265 if (match->key->tp.src == in match_validate()
267 match->key->tp.src == htons(NDISC_NEIGHBOUR_ADVERTISEMENT)) { in match_validate()
275 if (match->mask && (match->mask->key.tp.src == htons(0xff))) in match_validate()
282 if (match->key->eth.type == htons(ETH_P_NSH)) { in match_validate()
284 if (match->mask && in match_validate()
285 match->mask->key.eth.type == htons(0xffff)) { in match_validate()
522 struct sw_flow_match *match, bool is_mask, in genev_tun_opt_from_nlattr() argument
527 if (nla_len(a) > sizeof(match->key->tun_opts)) { in genev_tun_opt_from_nlattr()
529 nla_len(a), sizeof(match->key->tun_opts)); in genev_tun_opt_from_nlattr()
544 SW_FLOW_KEY_PUT(match, tun_opts_len, nla_len(a), in genev_tun_opt_from_nlattr()
557 if (match->key->tun_opts_len != nla_len(a)) { in genev_tun_opt_from_nlattr()
559 match->key->tun_opts_len, nla_len(a)); in genev_tun_opt_from_nlattr()
563 SW_FLOW_KEY_PUT(match, tun_opts_len, 0xff, true); in genev_tun_opt_from_nlattr()
567 SW_FLOW_KEY_MEMCPY_OFFSET(match, opt_key_offset, nla_data(a), in genev_tun_opt_from_nlattr()
573 struct sw_flow_match *match, bool is_mask, in vxlan_tun_opt_from_nlattr() argument
581 BUILD_BUG_ON(sizeof(opts) > sizeof(match->key->tun_opts)); in vxlan_tun_opt_from_nlattr()
618 SW_FLOW_KEY_PUT(match, tun_opts_len, sizeof(opts), false); in vxlan_tun_opt_from_nlattr()
620 SW_FLOW_KEY_PUT(match, tun_opts_len, 0xff, true); in vxlan_tun_opt_from_nlattr()
623 SW_FLOW_KEY_MEMCPY_OFFSET(match, opt_key_offset, &opts, sizeof(opts), in vxlan_tun_opt_from_nlattr()
629 struct sw_flow_match *match, bool is_mask, in erspan_tun_opt_from_nlattr() argument
635 sizeof(match->key->tun_opts)); in erspan_tun_opt_from_nlattr()
637 if (nla_len(a) > sizeof(match->key->tun_opts)) { in erspan_tun_opt_from_nlattr()
639 nla_len(a), sizeof(match->key->tun_opts)); in erspan_tun_opt_from_nlattr()
644 SW_FLOW_KEY_PUT(match, tun_opts_len, in erspan_tun_opt_from_nlattr()
647 SW_FLOW_KEY_PUT(match, tun_opts_len, 0xff, true); in erspan_tun_opt_from_nlattr()
650 SW_FLOW_KEY_MEMCPY_OFFSET(match, opt_key_offset, nla_data(a), in erspan_tun_opt_from_nlattr()
656 struct sw_flow_match *match, bool is_mask, in ip_tun_from_nlattr() argument
685 SW_FLOW_KEY_PUT(match, tun_key.tun_id, in ip_tun_from_nlattr()
690 SW_FLOW_KEY_PUT(match, tun_key.u.ipv4.src, in ip_tun_from_nlattr()
695 SW_FLOW_KEY_PUT(match, tun_key.u.ipv4.dst, in ip_tun_from_nlattr()
700 SW_FLOW_KEY_PUT(match, tun_key.u.ipv6.src, in ip_tun_from_nlattr()
705 SW_FLOW_KEY_PUT(match, tun_key.u.ipv6.dst, in ip_tun_from_nlattr()
710 SW_FLOW_KEY_PUT(match, tun_key.tos, in ip_tun_from_nlattr()
714 SW_FLOW_KEY_PUT(match, tun_key.ttl, in ip_tun_from_nlattr()
725 SW_FLOW_KEY_PUT(match, tun_key.tp_src, in ip_tun_from_nlattr()
729 SW_FLOW_KEY_PUT(match, tun_key.tp_dst, in ip_tun_from_nlattr()
741 err = genev_tun_opt_from_nlattr(a, match, is_mask, log); in ip_tun_from_nlattr()
754 err = vxlan_tun_opt_from_nlattr(a, match, is_mask, log); in ip_tun_from_nlattr()
769 err = erspan_tun_opt_from_nlattr(a, match, is_mask, in ip_tun_from_nlattr()
788 SW_FLOW_KEY_PUT(match, tun_key.tun_flags, tun_flags, is_mask); in ip_tun_from_nlattr()
790 SW_FLOW_KEY_MEMSET_FIELD(match, tun_proto, 0xff, true); in ip_tun_from_nlattr()
792 SW_FLOW_KEY_PUT(match, tun_proto, ipv6 ? AF_INET6 : AF_INET, in ip_tun_from_nlattr()
813 if (match->key->tun_key.u.ipv4.src || in ip_tun_from_nlattr()
814 match->key->tun_key.u.ipv4.dst || in ip_tun_from_nlattr()
815 match->key->tun_key.tp_src || in ip_tun_from_nlattr()
816 match->key->tun_key.tp_dst || in ip_tun_from_nlattr()
817 match->key->tun_key.ttl || in ip_tun_from_nlattr()
818 match->key->tun_key.tos || in ip_tun_from_nlattr()
823 } else if (!match->key->tun_key.u.ipv4.dst) { in ip_tun_from_nlattr()
828 if (ipv6 && ipv6_addr_any(&match->key->tun_key.u.ipv6.dst)) { in ip_tun_from_nlattr()
962 static int encode_vlan_from_nlattrs(struct sw_flow_match *match, in encode_vlan_from_nlattrs() argument
976 SW_FLOW_KEY_PUT(match, eth.vlan.tpid, tpid, is_mask); in encode_vlan_from_nlattrs()
977 SW_FLOW_KEY_PUT(match, eth.vlan.tci, tci, is_mask); in encode_vlan_from_nlattrs()
979 SW_FLOW_KEY_PUT(match, eth.cvlan.tpid, tpid, is_mask); in encode_vlan_from_nlattrs()
980 SW_FLOW_KEY_PUT(match, eth.cvlan.tci, tci, is_mask); in encode_vlan_from_nlattrs()
985 static int validate_vlan_from_nlattrs(const struct sw_flow_match *match, in validate_vlan_from_nlattrs() argument
1023 static int validate_vlan_mask_from_nlattrs(const struct sw_flow_match *match, in validate_vlan_mask_from_nlattrs() argument
1029 bool encap_valid = !!(match->key->eth.vlan.tci & in validate_vlan_mask_from_nlattrs()
1031 bool i_encap_valid = !!(match->key->eth.cvlan.tci & in validate_vlan_mask_from_nlattrs()
1065 static int __parse_vlan_from_nlattrs(struct sw_flow_match *match, in __parse_vlan_from_nlattrs() argument
1074 err = validate_vlan_from_nlattrs(match, *key_attrs, inner, in __parse_vlan_from_nlattrs()
1077 err = validate_vlan_mask_from_nlattrs(match, *key_attrs, inner, in __parse_vlan_from_nlattrs()
1082 err = encode_vlan_from_nlattrs(match, a, is_mask, inner); in __parse_vlan_from_nlattrs()
1100 static int parse_vlan_from_nlattrs(struct sw_flow_match *match, in parse_vlan_from_nlattrs() argument
1107 err = __parse_vlan_from_nlattrs(match, key_attrs, false, a, in parse_vlan_from_nlattrs()
1112 encap_valid = !!(match->key->eth.vlan.tci & htons(VLAN_CFI_MASK)); in parse_vlan_from_nlattrs()
1114 err = __parse_vlan_from_nlattrs(match, key_attrs, true, a, in parse_vlan_from_nlattrs()
1123 static int parse_eth_type_from_nlattrs(struct sw_flow_match *match, in parse_eth_type_from_nlattrs() argument
1139 SW_FLOW_KEY_PUT(match, eth.type, eth_type, is_mask); in parse_eth_type_from_nlattrs()
1144 static int metadata_from_nlattrs(struct net *net, struct sw_flow_match *match, in metadata_from_nlattrs() argument
1153 SW_FLOW_KEY_PUT(match, ovs_flow_hash, hash_val, is_mask); in metadata_from_nlattrs()
1160 SW_FLOW_KEY_PUT(match, recirc_id, recirc_id, is_mask); in metadata_from_nlattrs()
1165 SW_FLOW_KEY_PUT(match, phy.priority, in metadata_from_nlattrs()
1181 SW_FLOW_KEY_PUT(match, phy.in_port, in_port, is_mask); in metadata_from_nlattrs()
1184 SW_FLOW_KEY_PUT(match, phy.in_port, DP_MAX_PORTS, is_mask); in metadata_from_nlattrs()
1190 SW_FLOW_KEY_PUT(match, phy.skb_mark, mark, is_mask); in metadata_from_nlattrs()
1194 if (ip_tun_from_nlattr(a[OVS_KEY_ATTR_TUNNEL], match, in metadata_from_nlattrs()
1210 SW_FLOW_KEY_PUT(match, ct_state, ct_state, is_mask); in metadata_from_nlattrs()
1217 SW_FLOW_KEY_PUT(match, ct_zone, ct_zone, is_mask); in metadata_from_nlattrs()
1224 SW_FLOW_KEY_PUT(match, ct.mark, mark, is_mask); in metadata_from_nlattrs()
1232 SW_FLOW_KEY_MEMCPY(match, ct.labels, cl->ct_labels, in metadata_from_nlattrs()
1241 SW_FLOW_KEY_PUT(match, ipv4.ct_orig.src, ct->ipv4_src, is_mask); in metadata_from_nlattrs()
1242 SW_FLOW_KEY_PUT(match, ipv4.ct_orig.dst, ct->ipv4_dst, is_mask); in metadata_from_nlattrs()
1243 SW_FLOW_KEY_PUT(match, ct.orig_tp.src, ct->src_port, is_mask); in metadata_from_nlattrs()
1244 SW_FLOW_KEY_PUT(match, ct.orig_tp.dst, ct->dst_port, is_mask); in metadata_from_nlattrs()
1245 SW_FLOW_KEY_PUT(match, ct_orig_proto, ct->ipv4_proto, is_mask); in metadata_from_nlattrs()
1253 SW_FLOW_KEY_MEMCPY(match, ipv6.ct_orig.src, &ct->ipv6_src, in metadata_from_nlattrs()
1254 sizeof(match->key->ipv6.ct_orig.src), in metadata_from_nlattrs()
1256 SW_FLOW_KEY_MEMCPY(match, ipv6.ct_orig.dst, &ct->ipv6_dst, in metadata_from_nlattrs()
1257 sizeof(match->key->ipv6.ct_orig.dst), in metadata_from_nlattrs()
1259 SW_FLOW_KEY_PUT(match, ct.orig_tp.src, ct->src_port, is_mask); in metadata_from_nlattrs()
1260 SW_FLOW_KEY_PUT(match, ct.orig_tp.dst, ct->dst_port, is_mask); in metadata_from_nlattrs()
1261 SW_FLOW_KEY_PUT(match, ct_orig_proto, ct->ipv6_proto, is_mask); in metadata_from_nlattrs()
1273 SW_FLOW_KEY_PUT(match, mac_proto, is_mask ? 0xff : mac_proto, is_mask); in metadata_from_nlattrs()
1276 return parse_eth_type_from_nlattrs(match, attrs, a, is_mask, in metadata_from_nlattrs()
1377 struct sw_flow_match *match, bool is_mask, in nsh_key_put_from_nlattr() argument
1419 SW_FLOW_KEY_PUT(match, nsh.base.flags, in nsh_key_put_from_nlattr()
1421 SW_FLOW_KEY_PUT(match, nsh.base.ttl, in nsh_key_put_from_nlattr()
1423 SW_FLOW_KEY_PUT(match, nsh.base.mdtype, in nsh_key_put_from_nlattr()
1425 SW_FLOW_KEY_PUT(match, nsh.base.np, in nsh_key_put_from_nlattr()
1427 SW_FLOW_KEY_PUT(match, nsh.base.path_hdr, in nsh_key_put_from_nlattr()
1436 SW_FLOW_KEY_PUT(match, nsh.context[i], in nsh_key_put_from_nlattr()
1497 static int ovs_key_from_nlattrs(struct net *net, struct sw_flow_match *match, in ovs_key_from_nlattrs() argument
1503 err = metadata_from_nlattrs(net, match, &attrs, a, is_mask, log); in ovs_key_from_nlattrs()
1511 SW_FLOW_KEY_MEMCPY(match, eth.src, in ovs_key_from_nlattrs()
1513 SW_FLOW_KEY_MEMCPY(match, eth.dst, in ovs_key_from_nlattrs()
1526 err = parse_eth_type_from_nlattrs(match, &attrs, a, is_mask, in ovs_key_from_nlattrs()
1531 SW_FLOW_KEY_PUT(match, eth.type, htons(ETH_P_802_2), is_mask); in ovs_key_from_nlattrs()
1533 } else if (!match->key->eth.type) { in ovs_key_from_nlattrs()
1547 SW_FLOW_KEY_PUT(match, ip.proto, in ovs_key_from_nlattrs()
1549 SW_FLOW_KEY_PUT(match, ip.tos, in ovs_key_from_nlattrs()
1551 SW_FLOW_KEY_PUT(match, ip.ttl, in ovs_key_from_nlattrs()
1553 SW_FLOW_KEY_PUT(match, ip.frag, in ovs_key_from_nlattrs()
1555 SW_FLOW_KEY_PUT(match, ipv4.addr.src, in ovs_key_from_nlattrs()
1557 SW_FLOW_KEY_PUT(match, ipv4.addr.dst, in ovs_key_from_nlattrs()
1578 SW_FLOW_KEY_PUT(match, ipv6.label, in ovs_key_from_nlattrs()
1580 SW_FLOW_KEY_PUT(match, ip.proto, in ovs_key_from_nlattrs()
1582 SW_FLOW_KEY_PUT(match, ip.tos, in ovs_key_from_nlattrs()
1584 SW_FLOW_KEY_PUT(match, ip.ttl, in ovs_key_from_nlattrs()
1586 SW_FLOW_KEY_PUT(match, ip.frag, in ovs_key_from_nlattrs()
1588 SW_FLOW_KEY_MEMCPY(match, ipv6.addr.src, in ovs_key_from_nlattrs()
1590 sizeof(match->key->ipv6.addr.src), in ovs_key_from_nlattrs()
1592 SW_FLOW_KEY_MEMCPY(match, ipv6.addr.dst, in ovs_key_from_nlattrs()
1594 sizeof(match->key->ipv6.addr.dst), in ovs_key_from_nlattrs()
1610 SW_FLOW_KEY_PUT(match, ipv4.addr.src, in ovs_key_from_nlattrs()
1612 SW_FLOW_KEY_PUT(match, ipv4.addr.dst, in ovs_key_from_nlattrs()
1614 SW_FLOW_KEY_PUT(match, ip.proto, in ovs_key_from_nlattrs()
1616 SW_FLOW_KEY_MEMCPY(match, ipv4.arp.sha, in ovs_key_from_nlattrs()
1618 SW_FLOW_KEY_MEMCPY(match, ipv4.arp.tha, in ovs_key_from_nlattrs()
1625 if (nsh_key_put_from_nlattr(a[OVS_KEY_ATTR_NSH], match, in ovs_key_from_nlattrs()
1647 SW_FLOW_KEY_PUT(match, mpls.lse[i], in ovs_key_from_nlattrs()
1650 SW_FLOW_KEY_PUT(match, mpls.num_labels_mask, in ovs_key_from_nlattrs()
1660 SW_FLOW_KEY_PUT(match, tp.src, tcp_key->tcp_src, is_mask); in ovs_key_from_nlattrs()
1661 SW_FLOW_KEY_PUT(match, tp.dst, tcp_key->tcp_dst, is_mask); in ovs_key_from_nlattrs()
1666 SW_FLOW_KEY_PUT(match, tp.flags, in ovs_key_from_nlattrs()
1676 SW_FLOW_KEY_PUT(match, tp.src, udp_key->udp_src, is_mask); in ovs_key_from_nlattrs()
1677 SW_FLOW_KEY_PUT(match, tp.dst, udp_key->udp_dst, is_mask); in ovs_key_from_nlattrs()
1685 SW_FLOW_KEY_PUT(match, tp.src, sctp_key->sctp_src, is_mask); in ovs_key_from_nlattrs()
1686 SW_FLOW_KEY_PUT(match, tp.dst, sctp_key->sctp_dst, is_mask); in ovs_key_from_nlattrs()
1694 SW_FLOW_KEY_PUT(match, tp.src, in ovs_key_from_nlattrs()
1696 SW_FLOW_KEY_PUT(match, tp.dst, in ovs_key_from_nlattrs()
1705 SW_FLOW_KEY_PUT(match, tp.src, in ovs_key_from_nlattrs()
1707 SW_FLOW_KEY_PUT(match, tp.dst, in ovs_key_from_nlattrs()
1716 SW_FLOW_KEY_MEMCPY(match, ipv6.nd.target, in ovs_key_from_nlattrs()
1718 sizeof(match->key->ipv6.nd.target), in ovs_key_from_nlattrs()
1720 SW_FLOW_KEY_MEMCPY(match, ipv6.nd.sll, in ovs_key_from_nlattrs()
1722 SW_FLOW_KEY_MEMCPY(match, ipv6.nd.tll, in ovs_key_from_nlattrs()
1775 int ovs_nla_get_match(struct net *net, struct sw_flow_match *match, in ovs_nla_get_match() argument
1790 err = parse_vlan_from_nlattrs(match, &key_attrs, a, false, log); in ovs_nla_get_match()
1794 err = ovs_key_from_nlattrs(net, match, key_attrs, a, false, log); in ovs_nla_get_match()
1798 if (match->mask) { in ovs_nla_get_match()
1821 if (match->key->tun_proto) in ovs_nla_get_match()
1822 SW_FLOW_KEY_MEMSET_FIELD(match, tun_key, in ovs_nla_get_match()
1833 SW_FLOW_KEY_PUT(match, eth.vlan.tci, htons(0xffff), true); in ovs_nla_get_match()
1834 SW_FLOW_KEY_PUT(match, eth.cvlan.tci, htons(0xffff), true); in ovs_nla_get_match()
1836 err = parse_vlan_from_nlattrs(match, &mask_attrs, a, true, log); in ovs_nla_get_match()
1840 err = ovs_key_from_nlattrs(net, match, mask_attrs, a, true, in ovs_nla_get_match()
1846 if (!match_validate(match, key_attrs, mask_attrs, log)) in ovs_nla_get_match()
1931 struct sw_flow_match match; in ovs_nla_get_flow_metadata() local
1933 memset(&match, 0, sizeof(match)); in ovs_nla_get_flow_metadata()
1934 match.key = key; in ovs_nla_get_flow_metadata()
1945 return metadata_from_nlattrs(net, &match, &attrs, a, false, log); in ovs_nla_get_flow_metadata()
2580 void ovs_match_init(struct sw_flow_match *match, in ovs_match_init() argument
2585 memset(match, 0, sizeof(*match)); in ovs_match_init()
2586 match->key = key; in ovs_match_init()
2587 match->mask = mask; in ovs_match_init()
2629 struct sw_flow_match match; in validate_and_copy_set_tun() local
2639 ovs_match_init(&match, &key, true, NULL); in validate_and_copy_set_tun()
2640 opts_type = ip_tun_from_nlattr(nla_data(attr), &match, false, log); in validate_and_copy_set_tun()
2710 struct sw_flow_match match; in validate_nsh() local
2714 ovs_match_init(&match, &key, true, NULL); in validate_nsh()
2715 ret = nsh_key_put_from_nlattr(attr, &match, is_mask, in validate_nsh()