Commit 790ce3cf authored by Dave Marchevsky's avatar Dave Marchevsky Committed by Alexei Starovoitov

bpf: Move GRAPH_{ROOT,NODE}_MASK macros into btf_field_type enum

This refactoring patch removes the unused BPF_GRAPH_NODE_OR_ROOT
btf_field_type and moves BPF_GRAPH_{NODE,ROOT} macros into the
btf_field_type enum. Further patches in the series will use
BPF_GRAPH_NODE, so let's move this useful definition out of btf.c.
Signed-off-by: default avatarDave Marchevsky <davemarchevsky@fb.com>
Link: https://lore.kernel.org/r/20231107085639.3016113-5-davemarchevsky@fb.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 649924b7
...@@ -186,8 +186,8 @@ enum btf_field_type { ...@@ -186,8 +186,8 @@ enum btf_field_type {
BPF_LIST_NODE = (1 << 6), BPF_LIST_NODE = (1 << 6),
BPF_RB_ROOT = (1 << 7), BPF_RB_ROOT = (1 << 7),
BPF_RB_NODE = (1 << 8), BPF_RB_NODE = (1 << 8),
BPF_GRAPH_NODE_OR_ROOT = BPF_LIST_NODE | BPF_LIST_HEAD | BPF_GRAPH_NODE = BPF_RB_NODE | BPF_LIST_NODE,
BPF_RB_NODE | BPF_RB_ROOT, BPF_GRAPH_ROOT = BPF_RB_ROOT | BPF_LIST_HEAD,
BPF_REFCOUNT = (1 << 9), BPF_REFCOUNT = (1 << 9),
}; };
......
...@@ -3840,9 +3840,6 @@ struct btf_record *btf_parse_fields(const struct btf *btf, const struct btf_type ...@@ -3840,9 +3840,6 @@ struct btf_record *btf_parse_fields(const struct btf *btf, const struct btf_type
return ERR_PTR(ret); return ERR_PTR(ret);
} }
#define GRAPH_ROOT_MASK (BPF_LIST_HEAD | BPF_RB_ROOT)
#define GRAPH_NODE_MASK (BPF_LIST_NODE | BPF_RB_NODE)
int btf_check_and_fixup_fields(const struct btf *btf, struct btf_record *rec) int btf_check_and_fixup_fields(const struct btf *btf, struct btf_record *rec)
{ {
int i; int i;
...@@ -3855,13 +3852,13 @@ int btf_check_and_fixup_fields(const struct btf *btf, struct btf_record *rec) ...@@ -3855,13 +3852,13 @@ int btf_check_and_fixup_fields(const struct btf *btf, struct btf_record *rec)
* Hence we only need to ensure that bpf_{list_head,rb_root} ownership * Hence we only need to ensure that bpf_{list_head,rb_root} ownership
* does not form cycles. * does not form cycles.
*/ */
if (IS_ERR_OR_NULL(rec) || !(rec->field_mask & GRAPH_ROOT_MASK)) if (IS_ERR_OR_NULL(rec) || !(rec->field_mask & BPF_GRAPH_ROOT))
return 0; return 0;
for (i = 0; i < rec->cnt; i++) { for (i = 0; i < rec->cnt; i++) {
struct btf_struct_meta *meta; struct btf_struct_meta *meta;
u32 btf_id; u32 btf_id;
if (!(rec->fields[i].type & GRAPH_ROOT_MASK)) if (!(rec->fields[i].type & BPF_GRAPH_ROOT))
continue; continue;
btf_id = rec->fields[i].graph_root.value_btf_id; btf_id = rec->fields[i].graph_root.value_btf_id;
meta = btf_find_struct_meta(btf, btf_id); meta = btf_find_struct_meta(btf, btf_id);
...@@ -3873,7 +3870,7 @@ int btf_check_and_fixup_fields(const struct btf *btf, struct btf_record *rec) ...@@ -3873,7 +3870,7 @@ int btf_check_and_fixup_fields(const struct btf *btf, struct btf_record *rec)
* to check ownership cycle for a type unless it's also a * to check ownership cycle for a type unless it's also a
* node type. * node type.
*/ */
if (!(rec->field_mask & GRAPH_NODE_MASK)) if (!(rec->field_mask & BPF_GRAPH_NODE))
continue; continue;
/* We need to ensure ownership acyclicity among all types. The /* We need to ensure ownership acyclicity among all types. The
...@@ -3909,7 +3906,7 @@ int btf_check_and_fixup_fields(const struct btf *btf, struct btf_record *rec) ...@@ -3909,7 +3906,7 @@ int btf_check_and_fixup_fields(const struct btf *btf, struct btf_record *rec)
* - A is both an root and node. * - A is both an root and node.
* - B is only an node. * - B is only an node.
*/ */
if (meta->record->field_mask & GRAPH_ROOT_MASK) if (meta->record->field_mask & BPF_GRAPH_ROOT)
return -ELOOP; return -ELOOP;
} }
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment