Lines Matching full:vec
187 static bool vec_is_stale(struct aa_profile **vec, int n) in vec_is_stale() argument
191 AA_BUG(!vec); in vec_is_stale()
194 if (profile_is_stale(vec[i])) in vec_is_stale()
201 static long accum_vec_flags(struct aa_profile **vec, int n) in accum_vec_flags() argument
206 AA_BUG(!vec); in accum_vec_flags()
209 u |= vec[i]->label.flags & (FLAG_DEBUG1 | FLAG_DEBUG2 | in accum_vec_flags()
211 if (!(u & vec[i]->label.flags & FLAG_UNCONFINED)) in accum_vec_flags()
224 * assumes vec is sorted
225 * Assumes @vec has null terminator at vec[n], and will null terminate
226 * vec[n - dups]
228 static inline int unique(struct aa_profile **vec, int n) in unique() argument
233 AA_BUG(!vec); in unique()
237 int res = profile_cmp(vec[pos], vec[i]); in unique()
239 AA_BUG(res > 0, "vec not sorted"); in unique()
242 aa_put_profile(vec[i]); in unique()
248 vec[pos] = vec[i]; in unique()
259 * @vec: list of profiles to sort and merge
260 * @flags: null terminator flags of @vec
264 * If @flags & VEC_FLAG_TERMINATE @vec has null terminator at vec[n], and will
265 * null terminate vec[n - dups]
267 int aa_vec_unique(struct aa_profile **vec, int n, int flags) in aa_vec_unique() argument
272 AA_BUG(!vec); in aa_vec_unique()
276 sort(vec, n, sizeof(struct aa_profile *), sort_cmp, NULL); in aa_vec_unique()
277 dups = unique(vec, n); in aa_vec_unique()
283 struct aa_profile *tmp = vec[i]; in aa_vec_unique()
287 int res = profile_cmp(vec[pos], tmp); in aa_vec_unique()
301 vec[j] = vec[j - 1]; in aa_vec_unique()
302 vec[pos] = tmp; in aa_vec_unique()
311 vec[n - dups] = NULL; in aa_vec_unique()
329 label->vec[i.i] = (struct aa_profile *) in aa_label_destroy()
384 on_list_rcu(&label->vec[0]->base.profiles)); in aa_label_kref()
386 on_list_rcu(&label->vec[0]->base.list)); in aa_label_kref()
410 label->vec[size] = NULL; /* null terminate */ in aa_label_init()
432 /* + 1 for null terminator entry on vec */ in aa_label_alloc()
433 new = kzalloc(struct_size(new, vec, size + 1), gfp); in aa_label_alloc()
475 return vec_cmp(a->vec, a->size, b->vec, b->size); in label_cmp()
485 if (!profile_unconfined(label->vec[i])) in aa_label_next_confined()
514 int res = profile_cmp(sub->vec[I->j], set->vec[I->i]); in __aa_label_next_not_in_set()
522 return sub->vec[(I->j)++]; in __aa_label_next_not_in_set()
526 return sub->vec[(I->j)++]; in __aa_label_next_not_in_set()
713 * __vec_find - find label that matches @vec in label set
714 * @vec: vec of profiles to find matching label for (NOT NULL)
715 * @n: length of @vec
717 * Requires: @vec_labelset(vec) lock held
722 * else NULL if @vec equiv is not in tree
724 static struct aa_label *__vec_find(struct aa_profile **vec, int n) in __vec_find() argument
728 AA_BUG(!vec); in __vec_find()
729 AA_BUG(!*vec); in __vec_find()
732 node = vec_labelset(vec, n)->root.rb_node; in __vec_find()
735 int result = vec_cmp(this->vec, this->size, vec, n); in __vec_find()
763 return __vec_find(label->vec, label->size); in __label_find()
832 * @vec: array of profiles to find equiv label for (NOT NULL)
833 * @n: length of @vec
835 * Returns: refcounted label if @vec equiv is in tree
836 * else NULL if @vec equiv is not in tree
838 static struct aa_label *vec_find(struct aa_profile **vec, int n) in vec_find() argument
844 AA_BUG(!vec); in vec_find()
845 AA_BUG(!*vec); in vec_find()
848 ls = vec_labelset(vec, n); in vec_find()
850 label = __vec_find(vec, n); in vec_find()
857 static struct aa_label *vec_create_and_insert_label(struct aa_profile **vec, in vec_create_and_insert_label() argument
866 AA_BUG(!vec); in vec_create_and_insert_label()
869 return aa_get_label(&vec[0]->label); in vec_create_and_insert_label()
871 ls = labels_set(&vec[len - 1]->label); in vec_create_and_insert_label()
881 new->vec[i] = aa_get_profile(vec[i]); in vec_create_and_insert_label()
891 struct aa_label *aa_vec_find_or_create_label(struct aa_profile **vec, int len, in aa_vec_find_or_create_label() argument
894 struct aa_label *label = vec_find(vec, len); in aa_vec_find_or_create_label()
899 return vec_create_and_insert_label(vec, len, gfp); in aa_vec_find_or_create_label()
916 return vec_find(label->vec, label->size); in aa_label_find()
978 int res = profile_cmp(a->vec[I->i], b->vec[I->j]); in aa_label_next_in_merge()
981 return b->vec[(I->j)++]; in aa_label_next_in_merge()
986 return a->vec[(I->i)++]; in aa_label_next_in_merge()
990 return b->vec[(I->j)++]; in aa_label_next_in_merge()
1021 int res = profile_cmp(p, z->vec[k]); in label_merge_cmp()
1073 new->vec[k] = aa_get_newest_profile(next); in label_merge_insert()
1074 AA_BUG(!new->vec[k]->label.proxy); in label_merge_insert()
1075 AA_BUG(!new->vec[k]->label.proxy->label); in label_merge_insert()
1076 if (next->label.proxy != new->vec[k]->label.proxy) in label_merge_insert()
1081 new->vec[k++] = aa_get_profile(next); in label_merge_insert()
1085 new->vec[k] = NULL; in label_merge_insert()
1088 new->size -= aa_vec_unique(&new->vec[0], new->size, in label_merge_insert()
1092 label = aa_get_label(&new->vec[0]->label); in label_merge_insert()
1105 new->flags |= accum_vec_flags(new->vec, new->size); in label_merge_insert()
1891 DEFINE_VEC(profile, vec); in aa_label_strn_parse()
1914 error = vec_setup(profile, vec, len, gfp); in aa_label_strn_parse()
1919 vec[i] = aa_get_profile(base->vec[i]); in aa_label_strn_parse()
1923 vec[i] = fqlookupn_profile(base, currbase, str, split - str); in aa_label_strn_parse()
1924 if (!vec[i]) in aa_label_strn_parse()
1930 if (vec[i]->ns != labels_ns(currbase)) in aa_label_strn_parse()
1931 currbase = &vec[i]->label; in aa_label_strn_parse()
1937 vec[i] = fqlookupn_profile(base, currbase, str, end - str); in aa_label_strn_parse()
1938 if (!vec[i]) in aa_label_strn_parse()
1942 /* no need to free vec as len < LOCAL_VEC_ENTRIES */ in aa_label_strn_parse()
1943 return &vec[0]->label; in aa_label_strn_parse()
1945 len -= aa_vec_unique(vec, len, VEC_FLAG_TERMINATE); in aa_label_strn_parse()
1948 label = aa_get_label(&vec[0]->label); in aa_label_strn_parse()
1953 label = aa_vec_find_or_create_label(vec, len, gfp); in aa_label_strn_parse()
1955 label = vec_find(vec, len); in aa_label_strn_parse()
1961 vec_cleanup(profile, vec, len); in aa_label_strn_parse()
2027 vec_is_stale(label->vec, label->size)) && in labelset_next_stale()
2073 AA_BUG(!label->vec[i]); in __label_update()
2074 new->vec[i] = aa_get_newest_profile(label->vec[i]); in __label_update()
2075 AA_BUG(!new->vec[i]); in __label_update()
2076 AA_BUG(!new->vec[i]->label.proxy); in __label_update()
2077 AA_BUG(!new->vec[i]->label.proxy->label); in __label_update()
2078 if (new->vec[i]->label.proxy != label->vec[i]->label.proxy) in __label_update()
2084 new->size -= aa_vec_unique(&new->vec[0], new->size, in __label_update()
2088 tmp = aa_get_label(&new->vec[0]->label); in __label_update()