summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-12-26 19:01:06 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2019-01-09 02:20:34 +0100
commite9a223ac31df473ebbb264219a9e004708c0a79d (patch)
tree06abbe8e13756823efbcad29175be9e15b252d50 /bgpd
parentMerge pull request #3565 from rhonda/patch-1 (diff)
downloadfrr-e9a223ac31df473ebbb264219a9e004708c0a79d.tar.xz
frr-e9a223ac31df473ebbb264219a9e004708c0a79d.zip
bgpd: Use `struct rmap_community` when we use community_list_lookup
The community_list_lookup function is being changed in a future commit. As such we want to use the `struct rmap_community` data structure for storing compiled information about communities,ecommunities or lcommunities. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_routemap.c52
1 files changed, 38 insertions, 14 deletions
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 30159f902..b236fc7ee 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -1048,7 +1048,7 @@ static route_map_result_t route_match_community(void *rule,
{
struct community_list *list;
struct bgp_path_info *path;
- struct rmap_community *rcom;
+ struct rmap_community *rcom = rule;
if (type == RMAP_BGP) {
path = object;
@@ -1115,11 +1115,10 @@ static route_map_result_t route_match_lcommunity(void *rule,
{
struct community_list *list;
struct bgp_path_info *path;
- struct rmap_community *rcom;
+ struct rmap_community *rcom = rule;
if (type == RMAP_BGP) {
path = object;
- rcom = rule;
list = community_list_lookup(bgp_clist, rcom->name,
LARGE_COMMUNITY_LIST_MASTER);
@@ -1176,11 +1175,12 @@ static route_map_result_t route_match_ecommunity(void *rule,
{
struct community_list *list;
struct bgp_path_info *path;
+ struct rmap_community *rcom = rule;
if (type == RMAP_BGP) {
path = object;
- list = community_list_lookup(bgp_clist, (char *)rule,
+ list = community_list_lookup(bgp_clist, rcom->name,
EXTCOMMUNITY_LIST_MASTER);
if (!list)
return RMAP_NOMATCH;
@@ -1194,13 +1194,21 @@ static route_map_result_t route_match_ecommunity(void *rule,
/* Compile function for extcommunity match. */
static void *route_match_ecommunity_compile(const char *arg)
{
- return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
+ struct rmap_community *rcom;
+
+ rcom = XCALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct rmap_community));
+ rcom->name = XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
+
+ return rcom;
}
/* Compile function for extcommunity match. */
static void route_match_ecommunity_free(void *rule)
{
- XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
+ struct rmap_community *rcom = rule;
+
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, rcom->name);
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, rcom);
}
/* Route map commands for community matching. */
@@ -1932,13 +1940,14 @@ static route_map_result_t route_set_lcommunity_delete(void *rule,
struct lcommunity *new;
struct lcommunity *old;
struct bgp_path_info *path;
+ struct rmap_community *rcom = rule;
if (type == RMAP_BGP) {
- if (!rule)
+ if (!rcom)
return RMAP_OKAY;
path = object;
- list = community_list_lookup(bgp_clist, rule,
+ list = community_list_lookup(bgp_clist, rcom->name,
LARGE_COMMUNITY_LIST_MASTER);
old = path->attr->lcommunity;
@@ -1975,10 +1984,13 @@ static route_map_result_t route_set_lcommunity_delete(void *rule,
/* Compile function for set lcommunity. */
static void *route_set_lcommunity_delete_compile(const char *arg)
{
+ struct rmap_community *rcom;
char *p;
char *str;
int len;
+ rcom = XCALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct rmap_community));
+
p = strchr(arg, ' ');
if (p) {
len = p - arg;
@@ -1987,13 +1999,17 @@ static void *route_set_lcommunity_delete_compile(const char *arg)
} else
str = NULL;
- return str;
+ rcom->name = str;
+ return rcom;
}
/* Free function for set lcommunity. */
static void route_set_lcommunity_delete_free(void *rule)
{
- XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
+ struct rmap_community *rcom = rule;
+
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, rcom->name);
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, rcom);
}
/* Set lcommunity rule structure. */
@@ -2017,13 +2033,14 @@ static route_map_result_t route_set_community_delete(
struct community *new;
struct community *old;
struct bgp_path_info *path;
+ struct rmap_community *rcom = rule;
if (type == RMAP_BGP) {
- if (!rule)
+ if (!rcom)
return RMAP_OKAY;
path = object;
- list = community_list_lookup(bgp_clist, rule,
+ list = community_list_lookup(bgp_clist, rcom->name,
COMMUNITY_LIST_MASTER);
old = path->attr->community;
@@ -2060,10 +2077,13 @@ static route_map_result_t route_set_community_delete(
/* Compile function for set community. */
static void *route_set_community_delete_compile(const char *arg)
{
+ struct rmap_community *rcom;
char *p;
char *str;
int len;
+ rcom = XCALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct rmap_community));
+
p = strchr(arg, ' ');
if (p) {
len = p - arg;
@@ -2072,13 +2092,17 @@ static void *route_set_community_delete_compile(const char *arg)
} else
str = NULL;
- return str;
+ rcom->name = str;
+ return rcom;
}
/* Free function for set community. */
static void route_set_community_delete_free(void *rule)
{
- XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
+ struct rmap_community *rcom = rule;
+
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, rcom->name);
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, rcom);
}
/* Set community rule structure. */