From f4c6ca8c9c7ca7c0d481e6059396beed6adc768d Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 17 Sep 2009 13:35:37 +0200 Subject: Fixes preference bounds. --- filter/filter.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'filter/filter.c') diff --git a/filter/filter.c b/filter/filter.c index 3df0f0c..9617482 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -702,6 +702,8 @@ interpret(struct f_inst *what) ONEARG; if (v1.type != T_INT) runtime( "Can't set preference to non-integer" ); + if ((v1.val.i < 0) || (v1.val.i > 0xFFFF)) + runtime( "Setting preference value out of bounds" ); *f_rte = rte_cow(*f_rte); (*f_rte)->pref = v1.val.i; break; -- cgit v1.2.3 From db96fccb31bc0436ec182ff825f592d6c16dc930 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Fri, 18 Sep 2009 01:11:09 +0200 Subject: Fixes bug in filter rta copy-on-write. Filters should try to copy-on-write just cached rtas. --- filter/filter.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'filter/filter.c') diff --git a/filter/filter.c b/filter/filter.c index 9617482..6356632 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -291,7 +291,6 @@ static struct rte **f_rte, *f_rte_old; static struct linpool *f_pool; static struct ea_list **f_tmp_attrs; static int f_flags; -static rta *f_rta_copy; /* * rta_cow - prepare rta for modification by filter @@ -299,8 +298,8 @@ static rta *f_rta_copy; static void rta_cow(void) { - if (!f_rta_copy) { - f_rta_copy = lp_alloc(f_pool, sizeof(rta)); + if ((*f_rte)->attrs->aflags & RTAF_CACHED) { + rta *f_rta_copy = lp_alloc(f_pool, sizeof(rta)); memcpy(f_rta_copy, (*f_rte)->attrs, sizeof(rta)); f_rta_copy->aflags = 0; *f_rte = rte_cow(*f_rte); @@ -686,8 +685,8 @@ interpret(struct f_inst *what) if (!(what->aux & EAF_TEMP) && (!(f_flags & FF_FORCE_TMPATTR))) { rta_cow(); - l->next = f_rta_copy->eattrs; - f_rta_copy->eattrs = l; + l->next = (*f_rte)->attrs->eattrs; + (*f_rte)->attrs->eattrs = l; } else { l->next = (*f_tmp_attrs); (*f_tmp_attrs) = l; @@ -946,7 +945,6 @@ f_run(struct filter *filter, struct rte **rte, struct ea_list **tmp_attrs, struc f_tmp_attrs = tmp_attrs; f_rte = rte; f_rte_old = *rte; - f_rta_copy = NULL; f_pool = tmp_pool; inst = filter->root; res = interpret(inst); @@ -967,7 +965,6 @@ f_eval_int(struct f_inst *expr) f_tmp_attrs = NULL; f_rte = NULL; f_rte_old = NULL; - f_rta_copy = NULL; f_pool = cfg_mem; res = interpret(expr); if (res.type != T_INT) -- cgit v1.2.3 From 54fe0d9230be440d9f627ff7f94a202e6117e1b9 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Fri, 18 Sep 2009 13:59:04 +0200 Subject: Fixes setting of IP addresses to route attributes (NEXT_HOP). --- filter/filter.c | 1 + 1 file changed, 1 insertion(+) (limited to 'filter/filter.c') diff --git a/filter/filter.c b/filter/filter.c index 6356632..8c0c4ab 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -664,6 +664,7 @@ interpret(struct f_inst *what) struct adata *ad = lp_alloc(f_pool, sizeof(struct adata) + len); ad->length = len; (* (ip_addr *) ad->data) = v1.val.px.ip; + l->attrs[0].u.ptr = ad; break; case EAF_TYPE_AS_PATH: if (v1.type != T_PATH) -- cgit v1.2.3 From 7ea5b00f42bd3d1fdafb0be349e3ebbcdf3ea466 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 8 Oct 2009 15:23:24 +0100 Subject: First and last accessors to as_paths. --- filter/filter.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'filter/filter.c') diff --git a/filter/filter.c b/filter/filter.c index 8c0c4ab..7bcf383 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -353,6 +353,7 @@ interpret(struct f_inst *what) struct f_val v1, v2, res; unsigned u1, u2; int i; + u32 as; res.type = T_VOID; if (!what) @@ -727,6 +728,26 @@ interpret(struct f_inst *what) default: bug( "Unknown prefix to conversion" ); } break; + case P('a','f'): /* Get first ASN from AS PATH */ + ONEARG; + if (v1.type != T_PATH) + runtime( "AS Path expected" ); + + as = 0; + as_path_get_last(v1.val.ad, &as); /* really last */ + res.type = T_INT; + res.val.i = as; + break; + case P('a','l'): /* Get last ASN from AS PATH */ + ONEARG; + if (v1.type != T_PATH) + runtime( "AS path expected" ); + + as = 0; + as_path_get_first(v1.val.ad, &as); /* really first */ + res.type = T_INT; + res.val.i = as; + break; case 'r': ONEARG; res = v1; -- cgit v1.2.3 From 52b9b2a1786140c38af03de570b0cc96c835c1d3 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Mon, 12 Oct 2009 20:44:58 +0200 Subject: Rename as_path_get_last/as_path_get_first to be consistent. --- filter/filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'filter/filter.c') diff --git a/filter/filter.c b/filter/filter.c index 7bcf383..07a25f4 100644 --- a/filter/filter.c +++ b/filter/filter.c @@ -734,7 +734,7 @@ interpret(struct f_inst *what) runtime( "AS Path expected" ); as = 0; - as_path_get_last(v1.val.ad, &as); /* really last */ + as_path_get_first(v1.val.ad, &as); res.type = T_INT; res.val.i = as; break; @@ -744,7 +744,7 @@ interpret(struct f_inst *what) runtime( "AS path expected" ); as = 0; - as_path_get_first(v1.val.ad, &as); /* really first */ + as_path_get_last(v1.val.ad, &as); res.type = T_INT; res.val.i = as; break; -- cgit v1.2.3