summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>2000-04-26 09:30:12 +0000
committerPavel Machek <pavel@ucw.cz>2000-04-26 09:30:12 +0000
commitf71bded6e97a3eeb4dc58458d042cbe1af631380 (patch)
tree6738efc7c1d206b92d46930e6b0ecdd991ab3bc3 /filter
parent7a86a8b08db03f002a672d1e8a6481ad52114d1e (diff)
Bugfix in i_same (comparing of paths still does not work).
Diffstat (limited to 'filter')
-rw-r--r--filter/config.Y2
-rw-r--r--filter/filter.c11
-rw-r--r--filter/test.conf18
3 files changed, 11 insertions, 20 deletions
diff --git a/filter/config.Y b/filter/config.Y
index ffb9a74c..5f362723 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -335,7 +335,7 @@ constant:
| prefix_s {NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
| '[' set_items ']' { DBG( "We've got a set here..." ); $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_SET; $$->a2.p = build_tree($2); DBG( "ook\n" ); }
| ENUM { $$ = f_new_inst(); $$->code = 'c'; $$->aux = $1 >> 16; $$->a2.i = $1 & 0xffff; }
- | '/' bgp_path '/' { $$ = f_new_inst(); $$->code = 'c'; $$->aux = T_PATH_MASK; $$->a2.p = $2; }
+ | '/' bgp_path '/' { NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; val->type = T_PATH_MASK; val->val.path_mask = $2; $$->a1.p = val; }
;
/*
diff --git a/filter/filter.c b/filter/filter.c
index fd099a6c..350cb08e 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -39,8 +39,10 @@ val_compare(struct f_val v1, struct f_val v2)
if (v2.type == T_VOID)
return 1;
- if (v1.type != v2.type)
+ if (v1.type != v2.type) {
+ debug( "Types do not match in val_compare\n" );
return CMP_ERROR;
+ }
switch (v1.type) {
case T_ENUM:
case T_INT:
@@ -52,11 +54,12 @@ val_compare(struct f_val v1, struct f_val v2)
case T_PREFIX:
return ipa_compare(v1.val.px.ip, v2.val.px.ip);
default:
+ debug( "Compare of unkown entities: %x\n", v1.type );
return CMP_ERROR;
}
}
-int
+int
val_simple_in_range(struct f_val v1, struct f_val v2)
{
if ((v1.type == T_PATH) && (v2.type == T_PATH_MASK))
@@ -574,7 +577,7 @@ i_same(struct f_inst *f1, struct f_inst *f2)
case 'c': A2_SAME; break;
case 'C':
- if (val_compare(* (struct f_val *) f1->a1.p, * (struct f_val *) f2->a2.p))
+ if (val_compare(* (struct f_val *) f1->a1.p, * (struct f_val *) f2->a1.p))
return 0;
break;
case 'p': case 'L': ONEARG; break;
@@ -629,8 +632,10 @@ filters_postconfig(void)
{
struct f_val res;
+#if 1
if (!i_same(test1_func, test2_func))
bug("i_same does not work");
+#endif
if (startup_func) {
debug( "Launching startup function...\n" );
f_pool = lp_new(&root_pool, 1024);
diff --git a/filter/test.conf b/filter/test.conf
index f0441778..e03f5914 100644
--- a/filter/test.conf
+++ b/filter/test.conf
@@ -118,26 +118,12 @@ ip p;
function __test1()
{
- if source = RTS_STATIC then {
- bgp_community = -empty-;
- bgp_community.add((65000,5678));
- if bgp_path ~ / 65000 / then
- bgp_path.prepend(65000);
- accept;
- }
- reject;
+ print bgp_path ~ / 65000 /;
}
function __test2()
{
- if source = RTS_STATIC then {
- bgp_community = -empty-;
- bgp_community.add((65000,5678));
- if bgp_path ~ / 65000 / then
- bgp_path.prepend(65000);
- accept;
- }
- reject;
+ print bgp_path ~ / 65000 /;
}
filter testf