mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-07-06 02:05:55 +00:00
bgpd: route-map: share aspath object compilation code where possible
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
This commit is contained in:
parent
9e7a53c179
commit
b304dcb8ab
@ -101,6 +101,26 @@ o Local extensions
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* generic as path object to be shared in multiple rules */
|
||||||
|
|
||||||
|
static void *
|
||||||
|
route_aspath_compile (const char *arg)
|
||||||
|
{
|
||||||
|
struct aspath *aspath;
|
||||||
|
|
||||||
|
aspath = aspath_str2aspath (arg);
|
||||||
|
if (! aspath)
|
||||||
|
return NULL;
|
||||||
|
return aspath;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
route_aspath_free (void *rule)
|
||||||
|
{
|
||||||
|
struct aspath *aspath = rule;
|
||||||
|
aspath_free (aspath);
|
||||||
|
}
|
||||||
|
|
||||||
/* 'match peer (A.B.C.D|X:X::X:X)' */
|
/* 'match peer (A.B.C.D|X:X::X:X)' */
|
||||||
|
|
||||||
/* Compares the peer specified in the 'match peer' clause with the peer
|
/* Compares the peer specified in the 'match peer' clause with the peer
|
||||||
@ -1228,33 +1248,13 @@ route_set_aspath_prepend (void *rule, struct prefix *prefix, route_map_object_t
|
|||||||
return RMAP_OKAY;
|
return RMAP_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compile function for as-path prepend. */
|
|
||||||
static void *
|
|
||||||
route_set_aspath_prepend_compile (const char *arg)
|
|
||||||
{
|
|
||||||
struct aspath *aspath;
|
|
||||||
|
|
||||||
aspath = aspath_str2aspath (arg);
|
|
||||||
if (! aspath)
|
|
||||||
return NULL;
|
|
||||||
return aspath;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Compile function for as-path prepend. */
|
|
||||||
static void
|
|
||||||
route_set_aspath_prepend_free (void *rule)
|
|
||||||
{
|
|
||||||
struct aspath *aspath = rule;
|
|
||||||
aspath_free (aspath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set as-path prepend rule structure. */
|
/* Set as-path prepend rule structure. */
|
||||||
struct route_map_rule_cmd route_set_aspath_prepend_cmd =
|
struct route_map_rule_cmd route_set_aspath_prepend_cmd =
|
||||||
{
|
{
|
||||||
"as-path prepend",
|
"as-path prepend",
|
||||||
route_set_aspath_prepend,
|
route_set_aspath_prepend,
|
||||||
route_set_aspath_prepend_compile,
|
route_aspath_compile,
|
||||||
route_set_aspath_prepend_free,
|
route_aspath_free,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* `set as-path exclude ASn' */
|
/* `set as-path exclude ASn' */
|
||||||
@ -1282,37 +1282,13 @@ route_set_aspath_exclude (void *rule, struct prefix *dummy, route_map_object_t t
|
|||||||
return RMAP_OKAY;
|
return RMAP_OKAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: consider using route_set_aspath_prepend_compile() and
|
|
||||||
* route_set_aspath_prepend_free(), which two below function are
|
|
||||||
* exact clones of.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Compile function for as-path exclude. */
|
|
||||||
static void *
|
|
||||||
route_set_aspath_exclude_compile (const char *arg)
|
|
||||||
{
|
|
||||||
struct aspath *aspath;
|
|
||||||
|
|
||||||
aspath = aspath_str2aspath (arg);
|
|
||||||
if (! aspath)
|
|
||||||
return NULL;
|
|
||||||
return aspath;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
route_set_aspath_exclude_free (void *rule)
|
|
||||||
{
|
|
||||||
struct aspath *aspath = rule;
|
|
||||||
aspath_free (aspath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set ASn exlude rule structure. */
|
/* Set ASn exlude rule structure. */
|
||||||
struct route_map_rule_cmd route_set_aspath_exclude_cmd =
|
struct route_map_rule_cmd route_set_aspath_exclude_cmd =
|
||||||
{
|
{
|
||||||
"as-path exclude",
|
"as-path exclude",
|
||||||
route_set_aspath_exclude,
|
route_set_aspath_exclude,
|
||||||
route_set_aspath_exclude_compile,
|
route_aspath_compile,
|
||||||
route_set_aspath_exclude_free,
|
route_aspath_free,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* `set community COMMUNITY' */
|
/* `set community COMMUNITY' */
|
||||||
|
Loading…
Reference in New Issue
Block a user