summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2022-09-29 09:58:27 +0200
committerMaria Matejka <mq@ucw.cz>2022-09-29 09:59:32 +0200
commit61c127c021ac34eba25d3245ccf8f9eb9dd352f5 (patch)
tree92108ea957c157ea1f8cbc8089cebb953dcad6d4 /filter
parent9be7aa9b450f22cec9c97143d0cb7650f4fd7cc9 (diff)
parent9efaf6bafea1c69629e59c6504980fb2986287fe (diff)
Merge commit '9efaf6ba' into tmp-bad-learn
Also fixed forgotten best route selection among alien routes.
Diffstat (limited to 'filter')
-rw-r--r--filter/config.Y11
-rw-r--r--filter/f-inst.c12
-rw-r--r--filter/test.conf6
3 files changed, 21 insertions, 8 deletions
diff --git a/filter/config.Y b/filter/config.Y
index ca792593..8cecf936 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -27,6 +27,9 @@ static inline u32 pair_b(u32 p) { return p & 0xFFFF; }
cf_error("Can't empty %s: not an attribute", sym->name); \
f_generate_complex(fi_code, sym->attribute, arg); \
})
+
+#define f_generate_complex_default(fi_code, da, arg, def) \
+ f_new_inst(FI_EA_SET, f_new_inst(fi_code, f_new_inst(FI_DEFAULT, f_new_inst(FI_EA_GET, da), f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = def })), arg), da)
/*
@@ -902,10 +905,10 @@ cmd:
}
| attr_bit '=' term ';' {
$$ = f_new_inst(FI_CONDITION, $3,
- f_generate_complex(FI_BITOR, $1.class,
- f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = (1U << $1.bit)})),
- f_generate_complex(FI_BITAND, $1.class,
- f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = ~(1U << $1.bit)}))
+ f_generate_complex_default(FI_BITOR, $1.class,
+ f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = (1U << $1.bit)}), 0),
+ f_generate_complex_default(FI_BITAND, $1.class,
+ f_new_inst(FI_CONSTANT, (struct f_val) { .type = T_INT, .val.i = ~(1U << $1.bit)}), 0)
);
}
| break_command print_list ';' {
diff --git a/filter/f-inst.c b/filter/f-inst.c
index 9ff5f79a..e7b642ab 100644
--- a/filter/f-inst.c
+++ b/filter/f-inst.c
@@ -768,6 +768,18 @@
ea_unset_attr(fs->eattrs, 1, da);
}
+ INST(FI_DEFAULT, 2, 1) {
+ ARG_ANY(1);
+ ARG_ANY(2);
+
+ log(L_INFO "Type of arg 1 is: %d", v1.type);
+
+ if (v1.type == T_VOID)
+ RESULT_VAL(v2);
+ else
+ RESULT_VAL(v1);
+ }
+
INST(FI_LENGTH, 1, 1) { /* Get length of */
ARG_ANY(1);
switch(v1.type) {
diff --git a/filter/test.conf b/filter/test.conf
index 21e7330f..cd2fa8db 100644
--- a/filter/test.conf
+++ b/filter/test.conf
@@ -1445,6 +1445,8 @@ bool t;
rip_metric = 14;
unset(rip_metric);
+ preference = 1234;
+
test_ca_int1 = 42;
test_ca_ip2 = 1.3.5.7;
test_ca_quad3 = 2.4.6.8;
@@ -1468,11 +1470,7 @@ bool t;
bgp_community = -empty-;
bgp_originator_id = 9.7.5.3;
bgp_cluster_list = -empty-;
- t = defined(bgp_mp_reach_nlri);
- t = defined(bgp_mp_unreach_nlri);
bgp_ext_community = --empty--;
- bgp_as4_path = +empty+;
- t = defined(bgp_as4_aggregator);
t = defined(bgp_aigp);
bgp_large_community = ---empty---;
t = defined(bgp_mpls_label_stack);