]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Netlink: Fixed handling of undefined bitfields in filters
authorMaria Matejka <mq@ucw.cz>
Mon, 25 Nov 2024 16:14:32 +0000 (17:14 +0100)
committerMaria Matejka <mq@ucw.cz>
Mon, 25 Nov 2024 16:14:32 +0000 (17:14 +0100)
The default value is obviously false everywhere so we just return zero
if nothing is found, instead of undef.

filter/f-inst.c
filter/test.conf
lib/route.h
sysdep/linux/netlink.c

index 6c3724ad7ffe9464d0291b2cdc2a2c0d93a9d5ca..6820b89868207b1903562f8e133cdb69c3614ef5 100644 (file)
                }]]);
        }
       }
+      else if (da->empty)
+       RESULT_VAL(da->empty(da));
       else if ((empty = f_get_empty(da->type)).type != T_VOID)
        RESULT_VAL(empty);
       else
index 24094e80785c9d17d8e4419ab32b0f9c848bb17f..39ec0edc5718c22ba89ecdb9fabac798104e9712 100644 (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";
 }
index 8d744e4399910003f93fe004ede8d303db90fb2f..882e6fd483b82c193c2f049b819b5b7eac943b70 100644 (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;
 };
index 6e10f54396743691487ba90ff15eec04c12eb056..ea79a1aa70faf42c19ad98bed3b73bd6702c6a53 100644 (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",