diff options
author | paul <paul> | 2003-10-13 09:47:32 +0000 |
---|---|---|
committer | paul <paul> | 2003-10-13 09:47:32 +0000 |
commit | 3b424979f54c6b128d1ee8a7c33d072d321f2f0c (patch) | |
tree | c3c684d2e1576610d3a0cedefa3bab23610c8d61 /bgpd/bgp_routemap.c | |
parent | 7ddf1d6eaf5a339d13661469212ac33f77e808fc (diff) |
2003-10-13 Jay Fenlason <fenlason@redhat.com>
* lib/zebra.h: define UINT32_MAX for those systems which do not
provide it.
* bgp_attr.h: define BGP_MED_MAX.
* bgp_route.c: update defines/constants to BGP_MED_MAX.
* bgp_routemap.c: ditto. clean up route_match_metric_compile
slightly to avoid unneccesary XMALLOC.
Diffstat (limited to 'bgpd/bgp_routemap.c')
-rw-r--r-- | bgpd/bgp_routemap.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index a2923fb1..a2635151 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -310,14 +310,13 @@ route_match_metric_compile (char *arg) { u_int32_t *med; char *endptr = NULL; + unsigned long tmpval; + tmpval = strtoul (arg, &endptr, 10); + if (*endptr != '\0' || tmpval == ULONG_MAX) + return NULL; med = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_int32_t)); - *med = strtoul (arg, &endptr, 10); - if (*endptr != '\0' || *med == ULONG_MAX) - { - XFREE (MTYPE_ROUTE_MAP_COMPILED, med); - return NULL; - } + *med = tmpval; return med; } @@ -879,8 +878,8 @@ route_set_metric (void *rule, struct prefix *prefix, if (strncmp (metric, "+", 1) == 0) { - if (bgp_info->attr->med/2 + metric_val/2 > UINT32_MAX/2) - bgp_info->attr->med = UINT32_MAX-1; + if (bgp_info->attr->med/2 + metric_val/2 > BGP_MED_MAX/2) + bgp_info->attr->med = BGP_MED_MAX - 1; else bgp_info->attr->med += metric_val; } |