summaryrefslogtreecommitdiff
path: root/nest/rt-attr.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-03-14 11:13:48 +0100
committerMaria Matejka <mq@ucw.cz>2022-04-06 18:14:08 +0200
commit0f68515263e91dd49b2d845cdff35af40c064dc2 (patch)
tree8ae7a4859016173a191bd38e8d4aab160dc49825 /nest/rt-attr.c
parent63cf5d5d8c8e156a1f427614c8017ca71c32191c (diff)
Unsetting route attributes without messing with type system
Diffstat (limited to 'nest/rt-attr.c')
-rw-r--r--nest/rt-attr.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/nest/rt-attr.c b/nest/rt-attr.c
index 2f0395c7..22b45db9 100644
--- a/nest/rt-attr.c
+++ b/nest/rt-attr.c
@@ -448,8 +448,7 @@ ea_find(ea_list *e, unsigned id)
{
eattr *a = ea__find(e, id & EA_CODE_MASK);
- if (a && (a->type & EAF_TYPE_MASK) == EAF_TYPE_UNDEF &&
- !(id & EA_ALLOW_UNDEF))
+ if (a && a->undef && !(id & EA_ALLOW_UNDEF))
return NULL;
return a;
}
@@ -516,7 +515,7 @@ ea_walk(struct ea_walk_state *s, uint id, uint max)
BIT32_SET(s->visited, n);
- if ((a->type & EAF_TYPE_MASK) == EAF_TYPE_UNDEF)
+ if (a->undef)
continue;
s->eattrs = e;
@@ -616,7 +615,7 @@ ea_do_prune(ea_list *e)
/* Now s0 is the most recent version, s[-1] the oldest one */
/* Drop undefs */
- if ((s0->type & EAF_TYPE_MASK) == EAF_TYPE_UNDEF)
+ if (s0->undef)
continue;
/* Copy the newest version to destination */
@@ -742,6 +741,7 @@ ea_same(ea_list *x, ea_list *y)
a->type != b->type ||
a->originated != b->originated ||
a->fresh != b->fresh ||
+ a->undef != b->undef ||
((a->type & EAF_EMBEDDED) ? a->u.data != b->u.data : !adata_same(a->u.ptr, b->u.ptr)))
return 0;
}
@@ -944,6 +944,10 @@ ea_show(struct cli *c, const eattr *e)
{
*pos++ = ':';
*pos++ = ' ';
+
+ if (e->undef)
+ bsprintf(pos, "undefined");
+ else
switch (e->type & EAF_TYPE_MASK)
{
case EAF_TYPE_INT:
@@ -973,7 +977,6 @@ ea_show(struct cli *c, const eattr *e)
case EAF_TYPE_LC_SET:
ea_show_lc_set(c, ad, pos, buf, end);
return;
- case EAF_TYPE_UNDEF:
default:
bsprintf(pos, "<type %02x>", e->type);
}