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()
532 struct sw_flow_match *match, bool is_mask, in genev_tun_opt_from_nlattr() argument
537 if (nla_len(a) > sizeof(match->key->tun_opts)) { in genev_tun_opt_from_nlattr()
539 nla_len(a), sizeof(match->key->tun_opts)); in genev_tun_opt_from_nlattr()
554 SW_FLOW_KEY_PUT(match, tun_opts_len, nla_len(a), in genev_tun_opt_from_nlattr()
567 if (match->key->tun_opts_len != nla_len(a)) { in genev_tun_opt_from_nlattr()
569 match->key->tun_opts_len, nla_len(a)); in genev_tun_opt_from_nlattr()
573 SW_FLOW_KEY_PUT(match, tun_opts_len, 0xff, true); in genev_tun_opt_from_nlattr()
577 SW_FLOW_KEY_MEMCPY_OFFSET(match, opt_key_offset, nla_data(a), in genev_tun_opt_from_nlattr()
583 struct sw_flow_match *match, bool is_mask, in vxlan_tun_opt_from_nlattr() argument
591 BUILD_BUG_ON(sizeof(opts) > sizeof(match->key->tun_opts)); in vxlan_tun_opt_from_nlattr()
628 SW_FLOW_KEY_PUT(match, tun_opts_len, sizeof(opts), false); in vxlan_tun_opt_from_nlattr()
630 SW_FLOW_KEY_PUT(match, tun_opts_len, 0xff, true); in vxlan_tun_opt_from_nlattr()
633 SW_FLOW_KEY_MEMCPY_OFFSET(match, opt_key_offset, &opts, sizeof(opts), in vxlan_tun_opt_from_nlattr()
639 struct sw_flow_match *match, bool is_mask, in erspan_tun_opt_from_nlattr() argument
645 sizeof(match->key->tun_opts)); in erspan_tun_opt_from_nlattr()
647 if (nla_len(a) > sizeof(match->key->tun_opts)) { in erspan_tun_opt_from_nlattr()
649 nla_len(a), sizeof(match->key->tun_opts)); in erspan_tun_opt_from_nlattr()
654 SW_FLOW_KEY_PUT(match, tun_opts_len, in erspan_tun_opt_from_nlattr()
657 SW_FLOW_KEY_PUT(match, tun_opts_len, 0xff, true); in erspan_tun_opt_from_nlattr()
660 SW_FLOW_KEY_MEMCPY_OFFSET(match, opt_key_offset, nla_data(a), in erspan_tun_opt_from_nlattr()
666 struct sw_flow_match *match, bool is_mask, in ip_tun_from_nlattr() argument
695 SW_FLOW_KEY_PUT(match, tun_key.tun_id, in ip_tun_from_nlattr()
700 SW_FLOW_KEY_PUT(match, tun_key.u.ipv4.src, in ip_tun_from_nlattr()
705 SW_FLOW_KEY_PUT(match, tun_key.u.ipv4.dst, in ip_tun_from_nlattr()
710 SW_FLOW_KEY_PUT(match, tun_key.u.ipv6.src, in ip_tun_from_nlattr()
715 SW_FLOW_KEY_PUT(match, tun_key.u.ipv6.dst, in ip_tun_from_nlattr()
720 SW_FLOW_KEY_PUT(match, tun_key.tos, in ip_tun_from_nlattr()
724 SW_FLOW_KEY_PUT(match, tun_key.ttl, in ip_tun_from_nlattr()
735 SW_FLOW_KEY_PUT(match, tun_key.tp_src, in ip_tun_from_nlattr()
739 SW_FLOW_KEY_PUT(match, tun_key.tp_dst, in ip_tun_from_nlattr()
751 err = genev_tun_opt_from_nlattr(a, match, is_mask, log); in ip_tun_from_nlattr()
764 err = vxlan_tun_opt_from_nlattr(a, match, is_mask, log); in ip_tun_from_nlattr()
779 err = erspan_tun_opt_from_nlattr(a, match, is_mask, in ip_tun_from_nlattr()
798 SW_FLOW_KEY_PUT(match, tun_key.tun_flags, tun_flags, is_mask); in ip_tun_from_nlattr()
800 SW_FLOW_KEY_MEMSET_FIELD(match, tun_proto, 0xff, true); in ip_tun_from_nlattr()
802 SW_FLOW_KEY_PUT(match, tun_proto, ipv6 ? AF_INET6 : AF_INET, in ip_tun_from_nlattr()
823 if (match->key->tun_key.u.ipv4.src || in ip_tun_from_nlattr()
824 match->key->tun_key.u.ipv4.dst || in ip_tun_from_nlattr()
825 match->key->tun_key.tp_src || in ip_tun_from_nlattr()
826 match->key->tun_key.tp_dst || in ip_tun_from_nlattr()
827 match->key->tun_key.ttl || in ip_tun_from_nlattr()
828 match->key->tun_key.tos || in ip_tun_from_nlattr()
833 } else if (!match->key->tun_key.u.ipv4.dst) { in ip_tun_from_nlattr()
838 if (ipv6 && ipv6_addr_any(&match->key->tun_key.u.ipv6.dst)) { in ip_tun_from_nlattr()
972 static int encode_vlan_from_nlattrs(struct sw_flow_match *match, in encode_vlan_from_nlattrs() argument
986 SW_FLOW_KEY_PUT(match, eth.vlan.tpid, tpid, is_mask); in encode_vlan_from_nlattrs()
987 SW_FLOW_KEY_PUT(match, eth.vlan.tci, tci, is_mask); in encode_vlan_from_nlattrs()
989 SW_FLOW_KEY_PUT(match, eth.cvlan.tpid, tpid, is_mask); in encode_vlan_from_nlattrs()
990 SW_FLOW_KEY_PUT(match, eth.cvlan.tci, tci, is_mask); in encode_vlan_from_nlattrs()
995 static int validate_vlan_from_nlattrs(const struct sw_flow_match *match, in validate_vlan_from_nlattrs() argument
1033 static int validate_vlan_mask_from_nlattrs(const struct sw_flow_match *match, in validate_vlan_mask_from_nlattrs() argument
1039 bool encap_valid = !!(match->key->eth.vlan.tci & in validate_vlan_mask_from_nlattrs()
1041 bool i_encap_valid = !!(match->key->eth.cvlan.tci & in validate_vlan_mask_from_nlattrs()
1075 static int __parse_vlan_from_nlattrs(struct sw_flow_match *match, in __parse_vlan_from_nlattrs() argument
1084 err = validate_vlan_from_nlattrs(match, *key_attrs, inner, in __parse_vlan_from_nlattrs()
1087 err = validate_vlan_mask_from_nlattrs(match, *key_attrs, inner, in __parse_vlan_from_nlattrs()
1092 err = encode_vlan_from_nlattrs(match, a, is_mask, inner); in __parse_vlan_from_nlattrs()
1110 static int parse_vlan_from_nlattrs(struct sw_flow_match *match, in parse_vlan_from_nlattrs() argument
1117 err = __parse_vlan_from_nlattrs(match, key_attrs, false, a, in parse_vlan_from_nlattrs()
1122 encap_valid = !!(match->key->eth.vlan.tci & htons(VLAN_CFI_MASK)); in parse_vlan_from_nlattrs()
1124 err = __parse_vlan_from_nlattrs(match, key_attrs, true, a, in parse_vlan_from_nlattrs()
1133 static int parse_eth_type_from_nlattrs(struct sw_flow_match *match, in parse_eth_type_from_nlattrs() argument
1149 SW_FLOW_KEY_PUT(match, eth.type, eth_type, is_mask); in parse_eth_type_from_nlattrs()
1154 static int metadata_from_nlattrs(struct net *net, struct sw_flow_match *match, in metadata_from_nlattrs() argument
1163 SW_FLOW_KEY_PUT(match, ovs_flow_hash, hash_val, is_mask); in metadata_from_nlattrs()
1170 SW_FLOW_KEY_PUT(match, recirc_id, recirc_id, is_mask); in metadata_from_nlattrs()
1175 SW_FLOW_KEY_PUT(match, phy.priority, in metadata_from_nlattrs()
1191 SW_FLOW_KEY_PUT(match, phy.in_port, in_port, is_mask); in metadata_from_nlattrs()
1194 SW_FLOW_KEY_PUT(match, phy.in_port, DP_MAX_PORTS, is_mask); in metadata_from_nlattrs()
1200 SW_FLOW_KEY_PUT(match, phy.skb_mark, mark, is_mask); in metadata_from_nlattrs()
1204 if (ip_tun_from_nlattr(a[OVS_KEY_ATTR_TUNNEL], match, in metadata_from_nlattrs()
1220 SW_FLOW_KEY_PUT(match, ct_state, ct_state, is_mask); in metadata_from_nlattrs()
1227 SW_FLOW_KEY_PUT(match, ct_zone, ct_zone, is_mask); in metadata_from_nlattrs()
1234 SW_FLOW_KEY_PUT(match, ct.mark, mark, is_mask); in metadata_from_nlattrs()
1242 SW_FLOW_KEY_MEMCPY(match, ct.labels, cl->ct_labels, in metadata_from_nlattrs()
1251 SW_FLOW_KEY_PUT(match, ipv4.ct_orig.src, ct->ipv4_src, is_mask); in metadata_from_nlattrs()
1252 SW_FLOW_KEY_PUT(match, ipv4.ct_orig.dst, ct->ipv4_dst, is_mask); in metadata_from_nlattrs()
1253 SW_FLOW_KEY_PUT(match, ct.orig_tp.src, ct->src_port, is_mask); in metadata_from_nlattrs()
1254 SW_FLOW_KEY_PUT(match, ct.orig_tp.dst, ct->dst_port, is_mask); in metadata_from_nlattrs()
1255 SW_FLOW_KEY_PUT(match, ct_orig_proto, ct->ipv4_proto, is_mask); in metadata_from_nlattrs()
1263 SW_FLOW_KEY_MEMCPY(match, ipv6.ct_orig.src, &ct->ipv6_src, in metadata_from_nlattrs()
1264 sizeof(match->key->ipv6.ct_orig.src), in metadata_from_nlattrs()
1266 SW_FLOW_KEY_MEMCPY(match, ipv6.ct_orig.dst, &ct->ipv6_dst, in metadata_from_nlattrs()
1267 sizeof(match->key->ipv6.ct_orig.dst), in metadata_from_nlattrs()
1269 SW_FLOW_KEY_PUT(match, ct.orig_tp.src, ct->src_port, is_mask); in metadata_from_nlattrs()
1270 SW_FLOW_KEY_PUT(match, ct.orig_tp.dst, ct->dst_port, is_mask); in metadata_from_nlattrs()
1271 SW_FLOW_KEY_PUT(match, ct_orig_proto, ct->ipv6_proto, is_mask); in metadata_from_nlattrs()
1283 SW_FLOW_KEY_PUT(match, mac_proto, is_mask ? 0xff : mac_proto, is_mask); in metadata_from_nlattrs()
1286 return parse_eth_type_from_nlattrs(match, attrs, a, is_mask, in metadata_from_nlattrs()
1387 struct sw_flow_match *match, bool is_mask, in nsh_key_put_from_nlattr() argument
1429 SW_FLOW_KEY_PUT(match, nsh.base.flags, in nsh_key_put_from_nlattr()
1431 SW_FLOW_KEY_PUT(match, nsh.base.ttl, in nsh_key_put_from_nlattr()
1433 SW_FLOW_KEY_PUT(match, nsh.base.mdtype, in nsh_key_put_from_nlattr()
1435 SW_FLOW_KEY_PUT(match, nsh.base.np, in nsh_key_put_from_nlattr()
1437 SW_FLOW_KEY_PUT(match, nsh.base.path_hdr, in nsh_key_put_from_nlattr()
1446 SW_FLOW_KEY_PUT(match, nsh.context[i], in nsh_key_put_from_nlattr()
1507 static int ovs_key_from_nlattrs(struct net *net, struct sw_flow_match *match, in ovs_key_from_nlattrs() argument
1513 err = metadata_from_nlattrs(net, match, &attrs, a, is_mask, log); in ovs_key_from_nlattrs()
1521 SW_FLOW_KEY_MEMCPY(match, eth.src, in ovs_key_from_nlattrs()
1523 SW_FLOW_KEY_MEMCPY(match, eth.dst, in ovs_key_from_nlattrs()
1536 err = parse_eth_type_from_nlattrs(match, &attrs, a, is_mask, in ovs_key_from_nlattrs()
1541 SW_FLOW_KEY_PUT(match, eth.type, htons(ETH_P_802_2), is_mask); in ovs_key_from_nlattrs()
1543 } else if (!match->key->eth.type) { in ovs_key_from_nlattrs()
1557 SW_FLOW_KEY_PUT(match, ip.proto, in ovs_key_from_nlattrs()
1559 SW_FLOW_KEY_PUT(match, ip.tos, in ovs_key_from_nlattrs()
1561 SW_FLOW_KEY_PUT(match, ip.ttl, in ovs_key_from_nlattrs()
1563 SW_FLOW_KEY_PUT(match, ip.frag, in ovs_key_from_nlattrs()
1565 SW_FLOW_KEY_PUT(match, ipv4.addr.src, in ovs_key_from_nlattrs()
1567 SW_FLOW_KEY_PUT(match, ipv4.addr.dst, in ovs_key_from_nlattrs()
1588 SW_FLOW_KEY_PUT(match, ipv6.label, in ovs_key_from_nlattrs()
1590 SW_FLOW_KEY_PUT(match, ip.proto, in ovs_key_from_nlattrs()
1592 SW_FLOW_KEY_PUT(match, ip.tos, in ovs_key_from_nlattrs()
1594 SW_FLOW_KEY_PUT(match, ip.ttl, in ovs_key_from_nlattrs()
1596 SW_FLOW_KEY_PUT(match, ip.frag, in ovs_key_from_nlattrs()
1598 SW_FLOW_KEY_MEMCPY(match, ipv6.addr.src, in ovs_key_from_nlattrs()
1600 sizeof(match->key->ipv6.addr.src), in ovs_key_from_nlattrs()
1602 SW_FLOW_KEY_MEMCPY(match, ipv6.addr.dst, in ovs_key_from_nlattrs()
1604 sizeof(match->key->ipv6.addr.dst), in ovs_key_from_nlattrs()
1615 SW_FLOW_KEY_PUT(match, ipv6.exthdrs, in ovs_key_from_nlattrs()
1631 SW_FLOW_KEY_PUT(match, ipv4.addr.src, in ovs_key_from_nlattrs()
1633 SW_FLOW_KEY_PUT(match, ipv4.addr.dst, in ovs_key_from_nlattrs()
1635 SW_FLOW_KEY_PUT(match, ip.proto, in ovs_key_from_nlattrs()
1637 SW_FLOW_KEY_MEMCPY(match, ipv4.arp.sha, in ovs_key_from_nlattrs()
1639 SW_FLOW_KEY_MEMCPY(match, ipv4.arp.tha, in ovs_key_from_nlattrs()
1646 if (nsh_key_put_from_nlattr(a[OVS_KEY_ATTR_NSH], match, in ovs_key_from_nlattrs()
1668 SW_FLOW_KEY_PUT(match, mpls.lse[i], in ovs_key_from_nlattrs()
1671 SW_FLOW_KEY_PUT(match, mpls.num_labels_mask, in ovs_key_from_nlattrs()
1681 SW_FLOW_KEY_PUT(match, tp.src, tcp_key->tcp_src, is_mask); in ovs_key_from_nlattrs()
1682 SW_FLOW_KEY_PUT(match, tp.dst, tcp_key->tcp_dst, is_mask); in ovs_key_from_nlattrs()
1687 SW_FLOW_KEY_PUT(match, tp.flags, in ovs_key_from_nlattrs()
1697 SW_FLOW_KEY_PUT(match, tp.src, udp_key->udp_src, is_mask); in ovs_key_from_nlattrs()
1698 SW_FLOW_KEY_PUT(match, tp.dst, udp_key->udp_dst, is_mask); in ovs_key_from_nlattrs()
1706 SW_FLOW_KEY_PUT(match, tp.src, sctp_key->sctp_src, is_mask); in ovs_key_from_nlattrs()
1707 SW_FLOW_KEY_PUT(match, tp.dst, sctp_key->sctp_dst, is_mask); in ovs_key_from_nlattrs()
1715 SW_FLOW_KEY_PUT(match, tp.src, in ovs_key_from_nlattrs()
1717 SW_FLOW_KEY_PUT(match, tp.dst, in ovs_key_from_nlattrs()
1726 SW_FLOW_KEY_PUT(match, tp.src, in ovs_key_from_nlattrs()
1728 SW_FLOW_KEY_PUT(match, tp.dst, in ovs_key_from_nlattrs()
1737 SW_FLOW_KEY_MEMCPY(match, ipv6.nd.target, in ovs_key_from_nlattrs()
1739 sizeof(match->key->ipv6.nd.target), in ovs_key_from_nlattrs()
1741 SW_FLOW_KEY_MEMCPY(match, ipv6.nd.sll, in ovs_key_from_nlattrs()
1743 SW_FLOW_KEY_MEMCPY(match, ipv6.nd.tll, in ovs_key_from_nlattrs()
1796 int ovs_nla_get_match(struct net *net, struct sw_flow_match *match, in ovs_nla_get_match() argument
1811 err = parse_vlan_from_nlattrs(match, &key_attrs, a, false, log); in ovs_nla_get_match()
1815 err = ovs_key_from_nlattrs(net, match, key_attrs, a, false, log); in ovs_nla_get_match()
1819 if (match->mask) { in ovs_nla_get_match()
1842 if (match->key->tun_proto) in ovs_nla_get_match()
1843 SW_FLOW_KEY_MEMSET_FIELD(match, tun_key, in ovs_nla_get_match()
1854 SW_FLOW_KEY_PUT(match, eth.vlan.tci, htons(0xffff), true); in ovs_nla_get_match()
1855 SW_FLOW_KEY_PUT(match, eth.cvlan.tci, htons(0xffff), true); in ovs_nla_get_match()
1857 err = parse_vlan_from_nlattrs(match, &mask_attrs, a, true, log); in ovs_nla_get_match()
1861 err = ovs_key_from_nlattrs(net, match, mask_attrs, a, true, in ovs_nla_get_match()
1867 if (!match_validate(match, key_attrs, mask_attrs, log)) in ovs_nla_get_match()
1952 struct sw_flow_match match; in ovs_nla_get_flow_metadata() local
1954 memset(&match, 0, sizeof(match)); in ovs_nla_get_flow_metadata()
1955 match.key = key; in ovs_nla_get_flow_metadata()
1966 return metadata_from_nlattrs(net, &match, &attrs, a, false, log); in ovs_nla_get_flow_metadata()
2704 void ovs_match_init(struct sw_flow_match *match, in ovs_match_init() argument
2709 memset(match, 0, sizeof(*match)); in ovs_match_init()
2710 match->key = key; in ovs_match_init()
2711 match->mask = mask; in ovs_match_init()
2753 struct sw_flow_match match; in validate_and_copy_set_tun() local
2763 ovs_match_init(&match, &key, true, NULL); in validate_and_copy_set_tun()
2764 opts_type = ip_tun_from_nlattr(nla_data(attr), &match, false, log); in validate_and_copy_set_tun()
2834 struct sw_flow_match match; in validate_nsh() local
2838 ovs_match_init(&match, &key, true, NULL); in validate_nsh()
2839 ret = nsh_key_put_from_nlattr(attr, &match, is_mask, in validate_nsh()