Lines Matching full:new

62 	struct aa_proxy *new;  in aa_alloc_proxy()  local
64 new = kzalloc(sizeof(struct aa_proxy), gfp); in aa_alloc_proxy()
65 if (new) { in aa_alloc_proxy()
66 kref_init(&new->count); in aa_alloc_proxy()
67 rcu_assign_pointer(new->label, aa_get_label(label)); in aa_alloc_proxy()
69 return new; in aa_alloc_proxy()
73 void __aa_proxy_redirect(struct aa_label *orig, struct aa_label *new) in __aa_proxy_redirect() argument
78 AA_BUG(!new); in __aa_proxy_redirect()
83 rcu_assign_pointer(orig->proxy->label, aa_get_label(new)); in __aa_proxy_redirect()
88 static void __proxy_share(struct aa_label *old, struct aa_label *new) in __proxy_share() argument
90 struct aa_proxy *proxy = new->proxy; in __proxy_share()
92 new->proxy = aa_get_proxy(old->proxy); in __proxy_share()
93 __aa_proxy_redirect(old, new); in __proxy_share()
387 static void label_free_or_put_new(struct aa_label *label, struct aa_label *new) in label_free_or_put_new() argument
389 if (label != new) in label_free_or_put_new()
391 aa_label_free(new); in label_free_or_put_new()
393 aa_put_label(new); in label_free_or_put_new()
415 * @proxy: proxy to use OR null if to allocate a new one
418 * Returns: new label
423 struct aa_label *new; in aa_label_alloc() local
428 new = kzalloc(sizeof(*new) + sizeof(struct aa_profile *) * (size + 1), in aa_label_alloc()
430 AA_DEBUG("%s (%p)\n", __func__, new); in aa_label_alloc()
431 if (!new) in aa_label_alloc()
434 if (!aa_label_init(new, size, gfp)) in aa_label_alloc()
438 proxy = aa_alloc_proxy(new, gfp); in aa_label_alloc()
443 /* just set new's proxy, don't redirect proxy here if it was passed in*/ in aa_label_alloc()
444 new->proxy = proxy; in aa_label_alloc()
446 return new; in aa_label_alloc()
449 kfree(new); in aa_label_alloc()
586 * @new: label to redirect to
591 static bool __label_remove(struct aa_label *label, struct aa_label *new) in __label_remove() argument
599 if (new) in __label_remove()
600 __aa_proxy_redirect(label, new); in __label_remove()
615 * __label_replace - replace @old with @new in label set
617 * @new: label to replace @old with
620 * valid ref count be held on @new
621 * Returns: true if @old was in set and replaced by @new
624 * that @new directly replaces @old position in the set (ie.
627 static bool __label_replace(struct aa_label *old, struct aa_label *new) in __label_replace() argument
633 AA_BUG(!new); in __label_replace()
635 AA_BUG(new->flags & FLAG_IN_TREE); in __label_replace()
641 rb_replace_node(&old->node, &new->node, &ls->root); in __label_replace()
643 new->flags |= FLAG_IN_TREE; in __label_replace()
653 * @label: new label to insert (NOT NULL)
666 struct rb_node **new, *parent = NULL; in __label_insert() local
674 /* Figure out where to put new node */ in __label_insert()
675 new = &ls->root.rb_node; in __label_insert()
676 while (*new) { in __label_insert()
677 struct aa_label *this = rb_entry(*new, struct aa_label, node); in __label_insert()
680 parent = *new; in __label_insert()
695 new = &((*new)->rb_left); in __label_insert()
697 new = &((*new)->rb_right); in __label_insert()
700 /* Add new node and rebalance tree. */ in __label_insert()
701 rb_link_node(&label->node, parent, new); in __label_insert()
786 * aa_label_replace - replace a label @old with a new version @new
788 * @new: label replacing @old
791 * else @old was not in tree, and @new was not inserted
793 bool aa_label_replace(struct aa_label *old, struct aa_label *new) in aa_label_replace() argument
798 if (name_is_shared(old, new) && labels_ns(old) == labels_ns(new)) { in aa_label_replace()
800 if (old->proxy != new->proxy) in aa_label_replace()
801 __proxy_share(old, new); in aa_label_replace()
803 __aa_proxy_redirect(old, new); in aa_label_replace()
804 res = __label_replace(old, new); in aa_label_replace()
811 res = __label_remove(old, new); in aa_label_replace()
812 if (labels_ns(old) != labels_ns(new)) { in aa_label_replace()
814 ls = labels_set(new); in aa_label_replace()
817 l = __label_insert(ls, new, true); in aa_label_replace()
818 res = (l == new); in aa_label_replace()
859 struct aa_label *new; in vec_create_and_insert_label() local
872 new = aa_label_alloc(len, NULL, gfp); in vec_create_and_insert_label()
873 if (!new) in vec_create_and_insert_label()
877 new->vec[i] = aa_get_profile(vec[i]); in vec_create_and_insert_label()
880 label = __label_insert(ls, new, false); in vec_create_and_insert_label()
882 label_free_or_put_new(label, new); in vec_create_and_insert_label()
1031 * label_merge_insert - create a new label by merging @a and @b
1032 * @new: preallocated label to merge into (NOT NULL)
1038 * Returns: ref counted label either @new if merge is unique
1042 * NOTE: will not use @new if the merge results in @new == @a or @b
1047 static struct aa_label *label_merge_insert(struct aa_label *new, in label_merge_insert() argument
1063 AA_BUG(!new); in label_merge_insert()
1064 AA_BUG(new->size < a->size + b->size); in label_merge_insert()
1069 new->vec[k] = aa_get_newest_profile(next); in label_merge_insert()
1070 AA_BUG(!new->vec[k]->label.proxy); in label_merge_insert()
1071 AA_BUG(!new->vec[k]->label.proxy->label); in label_merge_insert()
1072 if (next->label.proxy != new->vec[k]->label.proxy) in label_merge_insert()
1077 new->vec[k++] = aa_get_profile(next); in label_merge_insert()
1080 new->size = k; in label_merge_insert()
1081 new->vec[k] = NULL; in label_merge_insert()
1084 new->size -= aa_vec_unique(&new->vec[0], new->size, in label_merge_insert()
1087 if (new->size == 1) { in label_merge_insert()
1088 label = aa_get_label(&new->vec[0]->label); in label_merge_insert()
1094 * for new->size == a->size == b->size unless a == b in label_merge_insert()
1101 if (vec_unconfined(new->vec, new->size)) in label_merge_insert()
1102 new->flags |= FLAG_UNCONFINED; in label_merge_insert()
1103 ls = labels_set(new); in label_merge_insert()
1105 label = __label_insert(labels_set(new), new, false); in label_merge_insert()
1205 * aa_label_merge - attempt to insert new merged label of @a and @b
1214 * Returns: ref counted new label if successful in inserting merge of a & b
1236 struct aa_label *new; in aa_label_merge() local
1244 new = aa_label_alloc(a->size + b->size, NULL, gfp); in aa_label_merge()
1245 if (!new) in aa_label_merge()
1248 label = label_merge_insert(new, a, b); in aa_label_merge()
1249 label_free_or_put_new(label, new); in aa_label_merge()
1924 * if component specified a new ns it becomes the new base in aa_label_strn_parse()
2041 * Returns: new label that is up to date
2051 struct aa_label *new, *tmp; in __label_update() local
2059 new = aa_label_alloc(label->size, label->proxy, GFP_KERNEL); in __label_update()
2060 if (!new) in __label_update()
2071 new->vec[i] = aa_get_newest_profile(label->vec[i]); in __label_update()
2072 AA_BUG(!new->vec[i]); in __label_update()
2073 AA_BUG(!new->vec[i]->label.proxy); in __label_update()
2074 AA_BUG(!new->vec[i]->label.proxy->label); in __label_update()
2075 if (new->vec[i]->label.proxy != label->vec[i]->label.proxy) in __label_update()
2081 new->size -= aa_vec_unique(&new->vec[0], new->size, in __label_update()
2084 if (new->size == 1) { in __label_update()
2085 tmp = aa_get_label(&new->vec[0]->label); in __label_update()
2089 if (labels_set(label) != labels_set(new)) { in __label_update()
2091 tmp = aa_label_insert(labels_set(new), new); in __label_update()
2096 AA_BUG(labels_ns(label) != labels_ns(new)); in __label_update()
2098 tmp = __label_insert(labels_set(label), new, true); in __label_update()
2103 label_free_or_put_new(tmp, new); in __label_update()