0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 17:51:53 +00:00

Netlink: Fixed handling of undefined bitfields in filters

The default value is obviously false everywhere so we just return zero
if nothing is found, instead of undef.
This commit is contained in:
Maria Matejka 2024-11-25 17:14:32 +01:00
parent 7491cdbd1d
commit 1dd21f6024
4 changed files with 9 additions and 2 deletions

View File

@ -886,6 +886,8 @@
}]]);
}
}
else if (da->empty)
RESULT_VAL(da->empty(da));
else if ((empty = f_get_empty(da->type)).type != T_VOID)
RESULT_VAL(empty);
else

View File

@ -2301,9 +2301,9 @@ bool t;
krt_source = 17;
krt_metric = 19;
# krt_lock_mtu = false;
# if krt_lock_congctl then krt_lock_mtu = false;
# krt_lock_window = true;
# krt_lock_rtt = krt_lock_rttvar && krt_lock_sstresh || krt_lock_cwnd;
# krt_lock_rtt = krt_lock_rttvar && krt_lock_ssthresh || krt_lock_cwnd;
accept "ok I take that";
}

View File

@ -278,6 +278,7 @@ struct ea_class {
void (*format)(const eattr *ea, byte *buf, uint size); \
void (*stored)(const eattr *ea); /* When stored into global hash */ \
void (*freed)(const eattr *ea); /* When released from global hash */ \
struct f_val (*empty)(const struct ea_class *); /* Return this instead of T_VOID as default value for filters */ \
EA_CLASS_INSIDE;
};

View File

@ -51,6 +51,8 @@ struct nl_parse_state
#define KRT_FEATURES_MAX 4
static void krt_bitfield_format(const eattr *e, byte *buf, uint buflen);
static struct f_val krt_bitfield_empty(const struct ea_class *cls UNUSED)
{ return (struct f_val) { .type = T_INT }; }
static struct ea_class
ea_krt_prefsrc = {
@ -71,11 +73,13 @@ static struct ea_class ea_krt_metrics[] = {
.name = "krt_lock",
.type = T_INT,
.format = krt_bitfield_format,
.empty = krt_bitfield_empty,
},
[RTAX_FEATURES] = {
.name = "krt_features",
.type = T_INT,
.format = krt_bitfield_format,
.empty = krt_bitfield_empty,
},
[RTAX_CC_ALGO] = {
.name = "krt_congctl",