Lines Matching full:mask

111 	struct fl_flow_key mask;  member
126 struct fl_flow_mask *mask; member
155 static unsigned short int fl_mask_range(const struct fl_flow_mask *mask) in fl_mask_range() argument
157 return mask->range.end - mask->range.start; in fl_mask_range()
160 static void fl_mask_update_range(struct fl_flow_mask *mask) in fl_mask_update_range() argument
162 const u8 *bytes = (const u8 *) &mask->key; in fl_mask_update_range()
163 size_t size = sizeof(mask->key); in fl_mask_update_range()
179 mask->range.start = rounddown(first, sizeof(long)); in fl_mask_update_range()
180 mask->range.end = roundup(last + 1, sizeof(long)); in fl_mask_update_range()
184 const struct fl_flow_mask *mask) in fl_key_get_start() argument
186 return (u8 *) key + mask->range.start; in fl_key_get_start()
190 struct fl_flow_mask *mask) in fl_set_masked_key() argument
192 const long *lkey = fl_key_get_start(key, mask); in fl_set_masked_key()
193 const long *lmask = fl_key_get_start(&mask->key, mask); in fl_set_masked_key()
194 long *lmkey = fl_key_get_start(mkey, mask); in fl_set_masked_key()
197 for (i = 0; i < fl_mask_range(mask); i += sizeof(long)) in fl_set_masked_key()
202 struct fl_flow_mask *mask) in fl_mask_fits_tmplt() argument
204 const long *lmask = fl_key_get_start(&mask->key, mask); in fl_mask_fits_tmplt()
210 ltmplt = fl_key_get_start(&tmplt->mask, mask); in fl_mask_fits_tmplt()
211 for (i = 0; i < fl_mask_range(mask); i += sizeof(long)) { in fl_mask_fits_tmplt()
219 struct fl_flow_mask *mask) in fl_clear_masked_range() argument
221 memset(fl_key_get_start(key, mask), 0, fl_mask_range(mask)); in fl_clear_masked_range()
230 min_mask = ntohs(filter->mask->key.tp_range.tp_min.dst); in fl_range_port_dst_cmp()
231 max_mask = ntohs(filter->mask->key.tp_range.tp_max.dst); in fl_range_port_dst_cmp()
253 min_mask = ntohs(filter->mask->key.tp_range.tp_min.src); in fl_range_port_src_cmp()
254 max_mask = ntohs(filter->mask->key.tp_range.tp_max.src); in fl_range_port_src_cmp()
270 static struct cls_fl_filter *__fl_lookup(struct fl_flow_mask *mask, in __fl_lookup() argument
273 return rhashtable_lookup_fast(&mask->ht, fl_key_get_start(mkey, mask), in __fl_lookup()
274 mask->filter_ht_params); in __fl_lookup()
277 static struct cls_fl_filter *fl_lookup_range(struct fl_flow_mask *mask, in fl_lookup_range() argument
283 list_for_each_entry_rcu(filter, &mask->filters, list) { in fl_lookup_range()
290 f = __fl_lookup(mask, mkey); in fl_lookup_range()
298 struct cls_fl_filter *fl_mask_lookup(struct fl_flow_mask *mask, struct fl_flow_key *key) in fl_mask_lookup() argument
302 fl_set_masked_key(&mkey, key, mask); in fl_mask_lookup()
303 if ((mask->flags & TCA_FLOWER_MASK_FLAGS_RANGE)) in fl_mask_lookup()
304 return fl_lookup_range(mask, &mkey, key); in fl_mask_lookup()
306 return __fl_lookup(mask, &mkey); in fl_mask_lookup()
332 struct fl_flow_mask *mask; in fl_classify() local
335 list_for_each_entry_rcu(mask, &head->masks, list) { in fl_classify()
337 fl_clear_masked_range(&skb_key, mask); in fl_classify()
339 skb_flow_dissect_meta(skb, &mask->dissector, &skb_key); in fl_classify()
344 skb_flow_dissect_tunnel_info(skb, &mask->dissector, &skb_key); in fl_classify()
345 skb_flow_dissect_ct(skb, &mask->dissector, &skb_key, in fl_classify()
349 skb_flow_dissect_hash(skb, &mask->dissector, &skb_key); in fl_classify()
350 skb_flow_dissect(skb, &mask->dissector, &skb_key, in fl_classify()
353 f = fl_mask_lookup(mask, &skb_key); in fl_classify()
379 static void fl_mask_free(struct fl_flow_mask *mask, bool mask_init_done) in fl_mask_free() argument
383 WARN_ON(!list_empty(&mask->filters)); in fl_mask_free()
384 rhashtable_destroy(&mask->ht); in fl_mask_free()
386 kfree(mask); in fl_mask_free()
391 struct fl_flow_mask *mask = container_of(to_rcu_work(work), in fl_mask_free_work() local
394 fl_mask_free(mask, true); in fl_mask_free_work()
399 struct fl_flow_mask *mask = container_of(to_rcu_work(work), in fl_uninit_mask_free_work() local
402 fl_mask_free(mask, false); in fl_uninit_mask_free_work()
405 static bool fl_mask_put(struct cls_fl_head *head, struct fl_flow_mask *mask) in fl_mask_put() argument
407 if (!refcount_dec_and_test(&mask->refcnt)) in fl_mask_put()
410 rhashtable_remove_fast(&head->ht, &mask->ht_node, mask_ht_params); in fl_mask_put()
413 list_del_rcu(&mask->list); in fl_mask_put()
416 tcf_queue_work(&mask->rwork, fl_mask_free_work); in fl_mask_put()
479 cls_flower.rule->match.dissector = &f->mask->dissector; in fl_hw_replace_filter()
480 cls_flower.rule->match.mask = &f->mask->key; in fl_hw_replace_filter()
573 rhashtable_remove_fast(&f->mask->ht, &f->ht_node, in __fl_delete()
574 f->mask->filter_ht_params); in __fl_delete()
579 *last = fl_mask_put(head, f->mask); in __fl_delete()
603 struct fl_flow_mask *mask, *next_mask; in fl_destroy() local
607 list_for_each_entry_safe(mask, next_mask, &head->masks, list) { in fl_destroy()
608 list_for_each_entry_safe(f, next, &mask->filters, list) { in fl_destroy()
815 void *mask, int mask_type, int len) in fl_set_key_val() argument
821 memset(mask, 0xff, len); in fl_set_key_val()
823 nla_memcpy(mask, tb[mask_type], len); in fl_set_key_val()
827 struct fl_flow_key *mask, in fl_set_key_spi() argument
839 &mask->ipsec.spi, TCA_FLOWER_KEY_SPI_MASK, in fl_set_key_spi()
845 struct fl_flow_key *mask, in fl_set_key_port_range() argument
849 TCA_FLOWER_KEY_PORT_DST_MIN, &mask->tp_range.tp_min.dst, in fl_set_key_port_range()
852 TCA_FLOWER_KEY_PORT_DST_MAX, &mask->tp_range.tp_max.dst, in fl_set_key_port_range()
855 TCA_FLOWER_KEY_PORT_SRC_MIN, &mask->tp_range.tp_min.src, in fl_set_key_port_range()
858 TCA_FLOWER_KEY_PORT_SRC_MAX, &mask->tp_range.tp_max.src, in fl_set_key_port_range()
861 if (mask->tp_range.tp_min.dst != mask->tp_range.tp_max.dst) { in fl_set_key_port_range()
866 if (mask->tp_range.tp_min.src != mask->tp_range.tp_max.src) { in fl_set_key_port_range()
871 if (mask->tp_range.tp_min.dst && mask->tp_range.tp_max.dst && in fl_set_key_port_range()
879 if (mask->tp_range.tp_min.src && mask->tp_range.tp_max.src && in fl_set_key_port_range()
1123 struct fl_flow_key *mask) in fl_set_key_pppoe() argument
1146 mask->basic.n_proto = cpu_to_be16(~0); in fl_set_key_pppoe()
1149 mask->basic.n_proto = cpu_to_be16(~0); in fl_set_key_pppoe()
1152 mask->basic.n_proto = cpu_to_be16(~0); in fl_set_key_pppoe()
1155 mask->basic.n_proto = cpu_to_be16(~0); in fl_set_key_pppoe()
1159 mask->basic.n_proto = cpu_to_be16(0); in fl_set_key_pppoe()
1179 u32 key, mask; in fl_set_key_flags() local
1189 /* mask is mandatory for flags */ in fl_set_key_flags()
1191 NL_SET_ERR_MSG(extack, "Missing flags mask"); in fl_set_key_flags()
1196 mask = be32_to_cpu(nla_get_be32(tb[fl_mask])); in fl_set_key_flags()
1201 fl_set_key_flag(key, mask, flags_key, flags_mask, in fl_set_key_flags()
1203 fl_set_key_flag(key, mask, flags_key, flags_mask, in fl_set_key_flags()
1207 fl_set_key_flag(key, mask, flags_key, flags_mask, in fl_set_key_flags()
1211 fl_set_key_flag(key, mask, flags_key, flags_mask, in fl_set_key_flags()
1215 fl_set_key_flag(key, mask, flags_key, flags_mask, in fl_set_key_flags()
1218 fl_set_key_flag(key, mask, flags_key, flags_mask, in fl_set_key_flags()
1227 struct flow_dissector_key_ip *mask) in fl_set_key_ip() argument
1234 fl_set_key_val(tb, &key->tos, tos_key, &mask->tos, tos_mask, sizeof(key->tos)); in fl_set_key_ip()
1235 fl_set_key_val(tb, &key->ttl, ttl_key, &mask->ttl, ttl_mask, sizeof(key->ttl)); in fl_set_key_ip()
1260 /* If no mask has been prodived we assume an exact match. */ in fl_set_geneve_opt()
1265 NL_SET_ERR_MSG(extack, "Non-geneve option type for mask"); in fl_set_geneve_opt()
1287 * for the mask. in fl_set_geneve_opt()
1341 NL_SET_ERR_MSG(extack, "Non-vxlan option type for mask"); in fl_set_vxlan_opt()
1379 NL_SET_ERR_MSG(extack, "Non-erspan option type for mask"); in fl_set_erspan_opt()
1444 NL_SET_ERR_MSG_MOD(extack, "Non-gtp option type for mask"); in fl_set_gtp_opt()
1486 NL_SET_ERR_MSG_MOD(extack, "Non-pfcp option type for mask"); in fl_set_pfcp_opt()
1510 struct fl_flow_key *mask, in fl_set_enc_opt() argument
1558 /* At the same time we need to parse through the mask in fl_set_enc_opt()
1559 * in order to verify exact and mask attribute lengths. in fl_set_enc_opt()
1561 mask->enc_opts.dst_opt_type = IP_TUNNEL_GENEVE_OPT_BIT; in fl_set_enc_opt()
1562 option_len = fl_set_geneve_opt(nla_opt_msk, mask, in fl_set_enc_opt()
1568 mask->enc_opts.len += option_len; in fl_set_enc_opt()
1569 if (key->enc_opts.len != mask->enc_opts.len) { in fl_set_enc_opt()
1570 NL_SET_ERR_MSG(extack, "Key and mask miss aligned"); in fl_set_enc_opt()
1588 /* At the same time we need to parse through the mask in fl_set_enc_opt()
1589 * in order to verify exact and mask attribute lengths. in fl_set_enc_opt()
1591 mask->enc_opts.dst_opt_type = IP_TUNNEL_VXLAN_OPT_BIT; in fl_set_enc_opt()
1592 option_len = fl_set_vxlan_opt(nla_opt_msk, mask, in fl_set_enc_opt()
1598 mask->enc_opts.len += option_len; in fl_set_enc_opt()
1599 if (key->enc_opts.len != mask->enc_opts.len) { in fl_set_enc_opt()
1600 NL_SET_ERR_MSG(extack, "Key and mask miss aligned"); in fl_set_enc_opt()
1618 /* At the same time we need to parse through the mask in fl_set_enc_opt()
1619 * in order to verify exact and mask attribute lengths. in fl_set_enc_opt()
1621 mask->enc_opts.dst_opt_type = IP_TUNNEL_ERSPAN_OPT_BIT; in fl_set_enc_opt()
1622 option_len = fl_set_erspan_opt(nla_opt_msk, mask, in fl_set_enc_opt()
1628 mask->enc_opts.len += option_len; in fl_set_enc_opt()
1629 if (key->enc_opts.len != mask->enc_opts.len) { in fl_set_enc_opt()
1630 NL_SET_ERR_MSG(extack, "Key and mask miss aligned"); in fl_set_enc_opt()
1649 /* At the same time we need to parse through the mask in fl_set_enc_opt()
1650 * in order to verify exact and mask attribute lengths. in fl_set_enc_opt()
1652 mask->enc_opts.dst_opt_type = IP_TUNNEL_GTP_OPT_BIT; in fl_set_enc_opt()
1653 option_len = fl_set_gtp_opt(nla_opt_msk, mask, in fl_set_enc_opt()
1659 mask->enc_opts.len += option_len; in fl_set_enc_opt()
1660 if (key->enc_opts.len != mask->enc_opts.len) { in fl_set_enc_opt()
1662 "Key and mask miss aligned"); in fl_set_enc_opt()
1680 /* At the same time we need to parse through the mask in fl_set_enc_opt()
1681 * in order to verify exact and mask attribute lengths. in fl_set_enc_opt()
1683 mask->enc_opts.dst_opt_type = IP_TUNNEL_PFCP_OPT_BIT; in fl_set_enc_opt()
1684 option_len = fl_set_pfcp_opt(nla_opt_msk, mask, in fl_set_enc_opt()
1690 mask->enc_opts.len += option_len; in fl_set_enc_opt()
1691 if (key->enc_opts.len != mask->enc_opts.len) { in fl_set_enc_opt()
1692 NL_SET_ERR_MSG_MOD(extack, "Key and mask miss aligned"); in fl_set_enc_opt()
1705 NL_SET_ERR_MSG(extack, "A mask attribute is invalid"); in fl_set_enc_opt()
1750 struct flow_dissector_key_ct *mask, in fl_set_key_ct() argument
1761 &mask->ct_state, TCA_FLOWER_KEY_CT_STATE_MASK, in fl_set_key_ct()
1764 err = fl_validate_ct_state(key->ct_state & mask->ct_state, in fl_set_key_ct()
1777 &mask->ct_zone, TCA_FLOWER_KEY_CT_ZONE_MASK, in fl_set_key_ct()
1786 &mask->ct_mark, TCA_FLOWER_KEY_CT_MARK_MASK, in fl_set_key_ct()
1795 mask->ct_labels, TCA_FLOWER_KEY_CT_LABELS_MASK, in fl_set_key_ct()
1803 struct fl_flow_key *key, struct fl_flow_key *mask, in is_vlan_key() argument
1818 mask->basic.n_proto = cpu_to_be16(~0); in is_vlan_key()
1824 struct fl_flow_key *mask, in fl_set_key_cfm_md_level() argument
1834 mask->cfm.mdl_ver = FLOW_DIS_CFM_MDL_MASK; in fl_set_key_cfm_md_level()
1839 struct fl_flow_key *mask, in fl_set_key_cfm_opcode() argument
1843 &mask->cfm.opcode, TCA_FLOWER_UNSPEC, in fl_set_key_cfm_opcode()
1849 struct fl_flow_key *mask, in fl_set_key_cfm() argument
1863 fl_set_key_cfm_opcode(nla_cfm_opt, key, mask, extack); in fl_set_key_cfm()
1864 fl_set_key_cfm_md_level(nla_cfm_opt, key, mask, extack); in fl_set_key_cfm()
1871 struct fl_flow_key *mask, struct netlink_ext_ack *extack) in fl_set_key() argument
1881 mask->meta.ingress_ifindex = 0xffffffff; in fl_set_key()
1885 &mask->meta.l2_miss, TCA_FLOWER_UNSPEC, in fl_set_key()
1889 mask->eth.dst, TCA_FLOWER_KEY_ETH_DST_MASK, in fl_set_key()
1892 mask->eth.src, TCA_FLOWER_KEY_ETH_SRC_MASK, in fl_set_key()
1896 &mask->num_of_vlans, in fl_set_key()
1900 if (is_vlan_key(tb[TCA_FLOWER_KEY_ETH_TYPE], &ethertype, key, mask, 0)) { in fl_set_key()
1904 &key->vlan, &mask->vlan); in fl_set_key()
1907 &ethertype, key, mask, 1)) { in fl_set_key()
1912 &key->cvlan, &mask->cvlan); in fl_set_key()
1915 &mask->basic.n_proto, in fl_set_key()
1922 fl_set_key_pppoe(tb, &key->pppoe, &mask->pppoe, key, mask); in fl_set_key()
1927 &mask->basic.ip_proto, TCA_FLOWER_UNSPEC, in fl_set_key()
1929 fl_set_key_ip(tb, false, &key->ip, &mask->ip); in fl_set_key()
1934 mask->control.addr_type = ~0; in fl_set_key()
1936 &mask->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC_MASK, in fl_set_key()
1939 &mask->ipv4.dst, TCA_FLOWER_KEY_IPV4_DST_MASK, in fl_set_key()
1943 mask->control.addr_type = ~0; in fl_set_key()
1945 &mask->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC_MASK, in fl_set_key()
1948 &mask->ipv6.dst, TCA_FLOWER_KEY_IPV6_DST_MASK, in fl_set_key()
1954 &mask->tp.src, TCA_FLOWER_KEY_TCP_SRC_MASK, in fl_set_key()
1957 &mask->tp.dst, TCA_FLOWER_KEY_TCP_DST_MASK, in fl_set_key()
1960 &mask->tcp.flags, TCA_FLOWER_KEY_TCP_FLAGS_MASK, in fl_set_key()
1964 &mask->tp.src, TCA_FLOWER_KEY_UDP_SRC_MASK, in fl_set_key()
1967 &mask->tp.dst, TCA_FLOWER_KEY_UDP_DST_MASK, in fl_set_key()
1971 &mask->tp.src, TCA_FLOWER_KEY_SCTP_SRC_MASK, in fl_set_key()
1974 &mask->tp.dst, TCA_FLOWER_KEY_SCTP_DST_MASK, in fl_set_key()
1979 &mask->icmp.type, in fl_set_key()
1983 &mask->icmp.code, in fl_set_key()
1989 &mask->icmp.type, in fl_set_key()
1993 &mask->icmp.code, in fl_set_key()
1998 ret = fl_set_key_mpls(tb, &key->mpls, &mask->mpls, extack); in fl_set_key()
2004 &mask->arp.sip, TCA_FLOWER_KEY_ARP_SIP_MASK, in fl_set_key()
2007 &mask->arp.tip, TCA_FLOWER_KEY_ARP_TIP_MASK, in fl_set_key()
2010 &mask->arp.op, TCA_FLOWER_KEY_ARP_OP_MASK, in fl_set_key()
2013 mask->arp.sha, TCA_FLOWER_KEY_ARP_SHA_MASK, in fl_set_key()
2016 mask->arp.tha, TCA_FLOWER_KEY_ARP_THA_MASK, in fl_set_key()
2021 &mask->l2tpv3.session_id, TCA_FLOWER_UNSPEC, in fl_set_key()
2024 ret = fl_set_key_cfm(tb, key, mask, extack); in fl_set_key()
2032 ret = fl_set_key_port_range(tb, key, mask, extack); in fl_set_key()
2038 ret = fl_set_key_spi(tb, key, mask, extack); in fl_set_key()
2046 mask->enc_control.addr_type = ~0; in fl_set_key()
2049 &mask->enc_ipv4.src, in fl_set_key()
2054 &mask->enc_ipv4.dst, in fl_set_key()
2062 mask->enc_control.addr_type = ~0; in fl_set_key()
2065 &mask->enc_ipv6.src, in fl_set_key()
2070 &mask->enc_ipv6.dst, in fl_set_key()
2076 &mask->enc_key_id.keyid, TCA_FLOWER_UNSPEC, in fl_set_key()
2080 &mask->enc_tp.src, TCA_FLOWER_KEY_ENC_UDP_SRC_PORT_MASK, in fl_set_key()
2084 &mask->enc_tp.dst, TCA_FLOWER_KEY_ENC_UDP_DST_PORT_MASK, in fl_set_key()
2087 fl_set_key_ip(tb, true, &key->enc_ip, &mask->enc_ip); in fl_set_key()
2090 &mask->hash.hash, TCA_FLOWER_KEY_HASH_MASK, in fl_set_key()
2094 ret = fl_set_enc_opt(tb, key, mask, extack); in fl_set_key()
2099 ret = fl_set_key_ct(tb, &key->ct, &mask->ct, extack); in fl_set_key()
2106 &mask->control.flags, extack); in fl_set_key()
2114 &mask->enc_control.flags, extack); in fl_set_key()
2135 static int fl_init_mask_hashtable(struct fl_flow_mask *mask) in fl_init_mask_hashtable() argument
2137 mask->filter_ht_params = fl_ht_params; in fl_init_mask_hashtable()
2138 mask->filter_ht_params.key_len = fl_mask_range(mask); in fl_init_mask_hashtable()
2139 mask->filter_ht_params.key_offset += mask->range.start; in fl_init_mask_hashtable()
2141 return rhashtable_init(&mask->ht, &mask->filter_ht_params); in fl_init_mask_hashtable()
2147 #define FL_KEY_IS_MASKED(mask, member) \ argument
2148 memchr_inv(((char *)mask) + FL_KEY_MEMBER_OFFSET(member), \
2158 #define FL_KEY_SET_IF_MASKED(mask, keys, cnt, id, member) \ argument
2160 if (FL_KEY_IS_MASKED(mask, member)) \
2165 struct fl_flow_key *mask) in fl_init_dissector() argument
2170 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2174 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2176 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2178 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2180 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2182 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2184 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2186 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2188 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2190 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2192 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2194 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2196 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2198 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2200 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2202 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2204 if (FL_KEY_IS_MASKED(mask, enc_ipv4) || in fl_init_dissector()
2205 FL_KEY_IS_MASKED(mask, enc_ipv6) || in fl_init_dissector()
2206 FL_KEY_IS_MASKED(mask, enc_control)) in fl_init_dissector()
2209 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2211 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2213 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2215 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2217 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2219 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2221 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2223 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2225 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2227 FL_KEY_SET_IF_MASKED(mask, keys, cnt, in fl_init_dissector()
2234 struct fl_flow_mask *mask) in fl_create_new_mask() argument
2243 fl_mask_copy(newmask, mask); in fl_create_new_mask()
2260 err = rhashtable_replace_fast(&head->ht, &mask->ht_node, in fl_create_new_mask()
2282 struct fl_flow_mask *mask) in fl_check_assign_mask() argument
2289 /* Insert mask as temporary node to prevent concurrent creation of mask in fl_check_assign_mask()
2291 * -EAGAIN because mask's refcnt is zero. in fl_check_assign_mask()
2293 fnew->mask = rhashtable_lookup_get_insert_fast(&head->ht, in fl_check_assign_mask()
2294 &mask->ht_node, in fl_check_assign_mask()
2296 if (!fnew->mask) { in fl_check_assign_mask()
2304 newmask = fl_create_new_mask(head, mask); in fl_check_assign_mask()
2310 fnew->mask = newmask; in fl_check_assign_mask()
2312 } else if (IS_ERR(fnew->mask)) { in fl_check_assign_mask()
2313 ret = PTR_ERR(fnew->mask); in fl_check_assign_mask()
2314 } else if (fold && fold->mask != fnew->mask) { in fl_check_assign_mask()
2316 } else if (!refcount_inc_not_zero(&fnew->mask->refcnt)) { in fl_check_assign_mask()
2317 /* Mask was deleted concurrently, try again */ in fl_check_assign_mask()
2324 rhashtable_remove_fast(&head->ht, &mask->ht_node, in fl_check_assign_mask()
2329 static bool fl_needs_tc_skb_ext(const struct fl_flow_key *mask) in fl_needs_tc_skb_ext() argument
2331 return mask->meta.l2_miss; in fl_needs_tc_skb_ext()
2338 struct fl_flow_mask *mask = fnew->mask; in fl_ht_insert_unique() local
2341 err = rhashtable_lookup_insert_fast(&mask->ht, in fl_ht_insert_unique()
2343 mask->filter_ht_params); in fl_ht_insert_unique()
2368 struct fl_flow_mask *mask; in fl_change() local
2378 mask = kzalloc(sizeof(struct fl_flow_mask), GFP_KERNEL); in fl_change()
2379 if (!mask) { in fl_change()
2467 err = fl_set_key(net, tca_opts, tb, &fnew->key, &mask->key, extack); in fl_change()
2471 fl_mask_update_range(mask); in fl_change()
2472 fl_set_masked_key(&fnew->mkey, &fnew->key, mask); in fl_change()
2474 if (!fl_mask_fits_tmplt(tp->chain->tmplt_priv, mask)) { in fl_change()
2475 NL_SET_ERR_MSG_MOD(extack, "Mask does not fit the template"); in fl_change()
2483 if (fl_needs_tc_skb_ext(&mask->key)) { in fl_change()
2488 err = fl_check_assign_mask(head, fnew, fold, mask); in fl_change()
2526 fnew->mask->filter_ht_params; in fl_change()
2528 err = rhashtable_insert_fast(&fnew->mask->ht, in fl_change()
2537 rhashtable_remove_fast(&fold->mask->ht, in fl_change()
2539 fold->mask->filter_ht_params); in fl_change()
2546 fl_mask_put(head, fold->mask); in fl_change()
2559 list_add_tail_rcu(&fnew->list, &fnew->mask->filters); in fl_change()
2566 tcf_queue_work(&mask->rwork, fl_uninit_mask_free_work); in fl_change()
2577 rhashtable_remove_fast(&fnew->mask->ht, &fnew->ht_node, in fl_change()
2578 fnew->mask->filter_ht_params); in fl_change()
2580 fl_mask_put(head, fnew->mask); in fl_change()
2601 tcf_queue_work(&mask->rwork, fl_uninit_mask_free_work); in fl_change()
2705 cls_flower.rule->match.dissector = &f->mask->dissector; in fl_reoffload()
2706 cls_flower.rule->match.mask = &f->mask->key; in fl_reoffload()
2778 cls_flower.rule->match.mask = &tmplt->mask; in fl_hw_create_tmplt()
2830 &tmplt->mask, extack); in fl_tmplt_create()
2834 fl_init_dissector(&tmplt->dissector, &tmplt->mask); in fl_tmplt_create()
2873 cls_flower.rule->match.mask = &tmplt->mask; in fl_tmplt_reoffload()
2882 void *mask, int mask_type, int len) in fl_dump_key_val() argument
2886 if (!memchr_inv(mask, 0, len)) in fl_dump_key_val()
2892 err = nla_put(skb, mask_type, len, mask); in fl_dump_key_val()
2900 struct fl_flow_key *mask) in fl_dump_key_port_range() argument
2904 &mask->tp_range.tp_min.dst, TCA_FLOWER_UNSPEC, in fl_dump_key_port_range()
2908 &mask->tp_range.tp_max.dst, TCA_FLOWER_UNSPEC, in fl_dump_key_port_range()
2912 &mask->tp_range.tp_min.src, TCA_FLOWER_UNSPEC, in fl_dump_key_port_range()
2916 &mask->tp_range.tp_max.src, TCA_FLOWER_UNSPEC, in fl_dump_key_port_range()
3057 struct flow_dissector_key_ip *mask) in fl_dump_key_ip() argument
3064 if (fl_dump_key_val(skb, &key->tos, tos_key, &mask->tos, tos_mask, sizeof(key->tos)) || in fl_dump_key_ip()
3065 fl_dump_key_val(skb, &key->ttl, ttl_key, &mask->ttl, ttl_mask, sizeof(key->ttl))) in fl_dump_key_ip()
3111 u32 key, mask; in fl_dump_key_flags() local
3126 mask = 0; in fl_dump_key_flags()
3128 fl_get_key_flag(flags_key, flags_mask, &key, &mask, in fl_dump_key_flags()
3130 fl_get_key_flag(flags_key, flags_mask, &key, &mask, in fl_dump_key_flags()
3134 fl_get_key_flag(flags_key, flags_mask, &key, &mask, in fl_dump_key_flags()
3138 fl_get_key_flag(flags_key, flags_mask, &key, &mask, in fl_dump_key_flags()
3142 fl_get_key_flag(flags_key, flags_mask, &key, &mask, in fl_dump_key_flags()
3145 fl_get_key_flag(flags_key, flags_mask, &key, &mask, in fl_dump_key_flags()
3150 _mask = cpu_to_be32(mask); in fl_dump_key_flags()
3304 struct flow_dissector_key_ct *mask) in fl_dump_key_ct() argument
3308 &mask->ct_state, TCA_FLOWER_KEY_CT_STATE_MASK, in fl_dump_key_ct()
3314 &mask->ct_zone, TCA_FLOWER_KEY_CT_ZONE_MASK, in fl_dump_key_ct()
3320 &mask->ct_mark, TCA_FLOWER_KEY_CT_MARK_MASK, in fl_dump_key_ct()
3326 &mask->ct_labels, TCA_FLOWER_KEY_CT_LABELS_MASK, in fl_dump_key_ct()
3338 struct flow_dissector_key_cfm *mask) in fl_dump_key_cfm() argument
3344 if (!memchr_inv(mask, 0, sizeof(*mask))) in fl_dump_key_cfm()
3351 if (FIELD_GET(FLOW_DIS_CFM_MDL_MASK, mask->mdl_ver)) { in fl_dump_key_cfm()
3358 if (mask->opcode) { in fl_dump_key_cfm()
3437 struct fl_flow_key *key, struct fl_flow_key *mask) in fl_dump_key() argument
3439 if (mask->meta.ingress_ifindex) { in fl_dump_key()
3448 TCA_FLOWER_L2_MISS, &mask->meta.l2_miss, in fl_dump_key()
3453 mask->eth.dst, TCA_FLOWER_KEY_ETH_DST_MASK, in fl_dump_key()
3456 mask->eth.src, TCA_FLOWER_KEY_ETH_SRC_MASK, in fl_dump_key()
3459 &mask->basic.n_proto, TCA_FLOWER_UNSPEC, in fl_dump_key()
3463 if (mask->num_of_vlans.num_of_vlans) { in fl_dump_key()
3468 if (fl_dump_key_mpls(skb, &key->mpls, &mask->mpls)) in fl_dump_key()
3472 TCA_FLOWER_KEY_VLAN_PRIO, &key->vlan, &mask->vlan)) in fl_dump_key()
3477 &key->cvlan, &mask->cvlan) || in fl_dump_key()
3478 (mask->cvlan.vlan_tpid && in fl_dump_key()
3483 if (mask->basic.n_proto) { in fl_dump_key()
3484 if (mask->cvlan.vlan_eth_type) { in fl_dump_key()
3488 } else if (mask->vlan.vlan_eth_type) { in fl_dump_key()
3498 &mask->basic.ip_proto, TCA_FLOWER_UNSPEC, in fl_dump_key()
3500 fl_dump_key_ip(skb, false, &key->ip, &mask->ip))) in fl_dump_key()
3503 if (mask->pppoe.session_id) { in fl_dump_key()
3508 if (mask->basic.n_proto && mask->pppoe.ppp_proto) { in fl_dump_key()
3516 &mask->ipv4.src, TCA_FLOWER_KEY_IPV4_SRC_MASK, in fl_dump_key()
3519 &mask->ipv4.dst, TCA_FLOWER_KEY_IPV4_DST_MASK, in fl_dump_key()
3524 &mask->ipv6.src, TCA_FLOWER_KEY_IPV6_SRC_MASK, in fl_dump_key()
3527 &mask->ipv6.dst, TCA_FLOWER_KEY_IPV6_DST_MASK, in fl_dump_key()
3533 &mask->tp.src, TCA_FLOWER_KEY_TCP_SRC_MASK, in fl_dump_key()
3536 &mask->tp.dst, TCA_FLOWER_KEY_TCP_DST_MASK, in fl_dump_key()
3539 &mask->tcp.flags, TCA_FLOWER_KEY_TCP_FLAGS_MASK, in fl_dump_key()
3544 &mask->tp.src, TCA_FLOWER_KEY_UDP_SRC_MASK, in fl_dump_key()
3547 &mask->tp.dst, TCA_FLOWER_KEY_UDP_DST_MASK, in fl_dump_key()
3552 &mask->tp.src, TCA_FLOWER_KEY_SCTP_SRC_MASK, in fl_dump_key()
3555 &mask->tp.dst, TCA_FLOWER_KEY_SCTP_DST_MASK, in fl_dump_key()
3561 TCA_FLOWER_KEY_ICMPV4_TYPE, &mask->icmp.type, in fl_dump_key()
3565 TCA_FLOWER_KEY_ICMPV4_CODE, &mask->icmp.code, in fl_dump_key()
3572 TCA_FLOWER_KEY_ICMPV6_TYPE, &mask->icmp.type, in fl_dump_key()
3576 TCA_FLOWER_KEY_ICMPV6_CODE, &mask->icmp.code, in fl_dump_key()
3583 TCA_FLOWER_KEY_ARP_SIP, &mask->arp.sip, in fl_dump_key()
3587 TCA_FLOWER_KEY_ARP_TIP, &mask->arp.tip, in fl_dump_key()
3591 TCA_FLOWER_KEY_ARP_OP, &mask->arp.op, in fl_dump_key()
3595 mask->arp.sha, TCA_FLOWER_KEY_ARP_SHA_MASK, in fl_dump_key()
3598 mask->arp.tha, TCA_FLOWER_KEY_ARP_THA_MASK, in fl_dump_key()
3604 &mask->l2tpv3.session_id, in fl_dump_key()
3611 &mask->ipsec.spi, TCA_FLOWER_KEY_SPI_MASK, in fl_dump_key()
3618 fl_dump_key_port_range(skb, key, mask)) in fl_dump_key()
3623 TCA_FLOWER_KEY_ENC_IPV4_SRC, &mask->enc_ipv4.src, in fl_dump_key()
3627 TCA_FLOWER_KEY_ENC_IPV4_DST, &mask->enc_ipv4.dst, in fl_dump_key()
3633 TCA_FLOWER_KEY_ENC_IPV6_SRC, &mask->enc_ipv6.src, in fl_dump_key()
3638 &mask->enc_ipv6.dst, in fl_dump_key()
3644 &mask->enc_key_id, TCA_FLOWER_UNSPEC, in fl_dump_key()
3648 &mask->enc_tp.src, in fl_dump_key()
3653 &mask->enc_tp.dst, in fl_dump_key()
3656 fl_dump_key_ip(skb, true, &key->enc_ip, &mask->enc_ip) || in fl_dump_key()
3657 fl_dump_key_enc_opt(skb, &key->enc_opts, &mask->enc_opts)) in fl_dump_key()
3660 if (fl_dump_key_ct(skb, &key->ct, &mask->ct)) in fl_dump_key()
3664 mask->control.flags)) in fl_dump_key()
3668 &mask->hash.hash, TCA_FLOWER_KEY_HASH_MASK, in fl_dump_key()
3672 if (fl_dump_key_cfm(skb, &key->cfm, &mask->cfm)) in fl_dump_key()
3676 mask->enc_control.flags)) in fl_dump_key()
3690 struct fl_flow_key *key, *mask; in fl_dump() local
3709 mask = &f->mask->key; in fl_dump()
3712 if (fl_dump_key(skb, net, key, mask)) in fl_dump()
3788 struct fl_flow_key *key, *mask; in fl_tmplt_dump() local
3796 mask = &tmplt->mask; in fl_tmplt_dump()
3798 if (fl_dump_key(skb, net, key, mask)) in fl_tmplt_dump()