bgpd: lcommunity: fix whitespace & copyright

(to match surrounding code)
"git diff -w" should be almost empty.

Copyright edited to say FRR, this is not GNU Zebra :)

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2017-01-25 22:29:31 +01:00
parent 47350fd9f4
commit 2acb4ac250
8 changed files with 225 additions and 229 deletions

View file

@ -673,7 +673,7 @@ attrhash_key_make (void *p)
if (extra) if (extra)
{ {
if (extra->lcommunity) if (extra->lcommunity)
MIX(lcommunity_hash_make (extra->lcommunity)); MIX(lcommunity_hash_make (extra->lcommunity));
if (extra->ecommunity) if (extra->ecommunity)
MIX(ecommunity_hash_make (extra->ecommunity)); MIX(ecommunity_hash_make (extra->ecommunity));
if (extra->cluster) if (extra->cluster)
@ -1042,7 +1042,7 @@ bgp_attr_unintern_sub (struct attr *attr)
if (attr->extra->lcommunity) if (attr->extra->lcommunity)
lcommunity_unintern (&attr->extra->lcommunity); lcommunity_unintern (&attr->extra->lcommunity);
UNSET_FLAG(attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES)); UNSET_FLAG(attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES));
if (attr->extra->cluster) if (attr->extra->cluster)
cluster_unintern (attr->extra->cluster); cluster_unintern (attr->extra->cluster);
UNSET_FLAG(attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST)); UNSET_FLAG(attr->flag, ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST));
@ -1113,7 +1113,7 @@ bgp_attr_flush (struct attr *attr)
if (attre->ecommunity && ! attre->ecommunity->refcnt) if (attre->ecommunity && ! attre->ecommunity->refcnt)
ecommunity_free (&attre->ecommunity); ecommunity_free (&attre->ecommunity);
if (attre->lcommunity && ! attre->lcommunity->refcnt) if (attre->lcommunity && ! attre->lcommunity->refcnt)
lcommunity_free (&attre->lcommunity); lcommunity_free (&attre->lcommunity);
if (attre->cluster && ! attre->cluster->refcnt) if (attre->cluster && ! attre->cluster->refcnt)
{ {
cluster_free (attre->cluster); cluster_free (attre->cluster);
@ -1272,7 +1272,7 @@ const u_int8_t attr_flags_values [] = {
[BGP_ATTR_EXT_COMMUNITIES] = BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS, [BGP_ATTR_EXT_COMMUNITIES] = BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_AS4_PATH] = BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS, [BGP_ATTR_AS4_PATH] = BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_AS4_AGGREGATOR] = BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS, [BGP_ATTR_AS4_AGGREGATOR] = BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_LARGE_COMMUNITIES] = BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL [BGP_ATTR_LARGE_COMMUNITIES]= BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
}; };
static const size_t attr_flags_values_max = array_size(attr_flags_values) - 1; static const size_t attr_flags_values_max = array_size(attr_flags_values) - 1;
@ -3165,17 +3165,17 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
&& (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES))) && (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES)))
{ {
if (attr->extra->lcommunity->size * 12 > 255) if (attr->extra->lcommunity->size * 12 > 255)
{ {
stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN);
stream_putc (s, BGP_ATTR_LARGE_COMMUNITIES); stream_putc (s, BGP_ATTR_LARGE_COMMUNITIES);
stream_putw (s, attr->extra->lcommunity->size * 12); stream_putw (s, attr->extra->lcommunity->size * 12);
} }
else else
{ {
stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS);
stream_putc (s, BGP_ATTR_LARGE_COMMUNITIES); stream_putc (s, BGP_ATTR_LARGE_COMMUNITIES);
stream_putc (s, attr->extra->lcommunity->size * 12); stream_putc (s, attr->extra->lcommunity->size * 12);
} }
stream_put (s, attr->extra->lcommunity->val, attr->extra->lcommunity->size * 12); stream_put (s, attr->extra->lcommunity->val, attr->extra->lcommunity->size * 12);
} }
@ -3532,17 +3532,17 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr,
if (attr->extra && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES)) if (attr->extra && attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES))
{ {
if (attr->extra->lcommunity->size * 12 > 255) if (attr->extra->lcommunity->size * 12 > 255)
{ {
stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN); stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS|BGP_ATTR_FLAG_EXTLEN);
stream_putc (s, BGP_ATTR_LARGE_COMMUNITIES); stream_putc (s, BGP_ATTR_LARGE_COMMUNITIES);
stream_putw (s, attr->extra->lcommunity->size * 12); stream_putw (s, attr->extra->lcommunity->size * 12);
} }
else else
{ {
stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_TRANS);
stream_putc (s, BGP_ATTR_LARGE_COMMUNITIES); stream_putc (s, BGP_ATTR_LARGE_COMMUNITIES);
stream_putc (s, attr->extra->lcommunity->size * 12); stream_putc (s, attr->extra->lcommunity->size * 12);
} }
stream_put (s, attr->extra->lcommunity->val, attr->extra->lcommunity->size * 12); stream_put (s, attr->extra->lcommunity->val, attr->extra->lcommunity->size * 12);
} }

View file

@ -95,7 +95,7 @@ struct attr_extra
/* Large Communities attribute. */ /* Large Communities attribute. */
struct lcommunity *lcommunity; struct lcommunity *lcommunity;
/* Route-Reflector Cluster attribute */ /* Route-Reflector Cluster attribute */
struct cluster_list *cluster; struct cluster_list *cluster;

View file

@ -43,11 +43,11 @@ community_list_master_lookup (struct community_list_handler *ch, int master)
switch (master) switch (master)
{ {
case COMMUNITY_LIST_MASTER: case COMMUNITY_LIST_MASTER:
return &ch->community_list; return &ch->community_list;
case EXTCOMMUNITY_LIST_MASTER: case EXTCOMMUNITY_LIST_MASTER:
return &ch->extcommunity_list; return &ch->extcommunity_list;
case LARGE_COMMUNITY_LIST_MASTER: case LARGE_COMMUNITY_LIST_MASTER:
return &ch->lcommunity_list; return &ch->lcommunity_list;
} }
return NULL; return NULL;
} }
@ -412,15 +412,14 @@ community_str_get (struct community *com, int i)
} }
/* Internal function to perform regular expression match for /* Internal function to perform regular expression match for
* * a single community. */ * a single community. */
static int static int
community_regexp_include (regex_t * reg, struct community *com, int i) community_regexp_include (regex_t * reg, struct community *com, int i)
{ {
char *str; char *str;
int rv; int rv;
/* When there is no communities attribute it is treated as empty /* When there is no communities attribute it is treated as empty string. */
* string. */
if (com == NULL || com->size == 0) if (com == NULL || com->size == 0)
str = XSTRDUP(MTYPE_COMMUNITY_STR, ""); str = XSTRDUP(MTYPE_COMMUNITY_STR, "");
else else
@ -503,14 +502,13 @@ lcommunity_str_get (struct lcommunity *lcom, int i)
} }
/* Internal function to perform regular expression match for /* Internal function to perform regular expression match for
* * a single community. */ * a single community. */
static int static int
lcommunity_regexp_include (regex_t * reg, struct lcommunity *lcom, int i) lcommunity_regexp_include (regex_t * reg, struct lcommunity *lcom, int i)
{ {
const char *str; const char *str;
/* When there is no communities attribute it is treated as empty /* When there is no communities attribute it is treated as empty string. */
* string. */
if (lcom == NULL || lcom->size == 0) if (lcom == NULL || lcom->size == 0)
str = ""; str = "";
else else
@ -826,7 +824,7 @@ community_list_dup_check (struct community_list *list,
break; break;
case COMMUNITY_LIST_EXPANDED: case COMMUNITY_LIST_EXPANDED:
case EXTCOMMUNITY_LIST_EXPANDED: case EXTCOMMUNITY_LIST_EXPANDED:
case LARGE_COMMUNITY_LIST_EXPANDED: case LARGE_COMMUNITY_LIST_EXPANDED:
if (strcmp (entry->config, new->config) == 0) if (strcmp (entry->config, new->config) == 0)
return 1; return 1;
break; break;
@ -947,7 +945,7 @@ community_list_unset (struct community_list_handler *ch,
/* Delete all permitted large communities in the list from com. */ /* Delete all permitted large communities in the list from com. */
struct lcommunity * struct lcommunity *
lcommunity_list_match_delete (struct lcommunity *lcom, lcommunity_list_match_delete (struct lcommunity *lcom,
struct community_list *list) struct community_list *list)
{ {
struct community_entry *entry; struct community_entry *entry;
u_int32_t com_index_to_delete[lcom->size]; u_int32_t com_index_to_delete[lcom->size];
@ -1013,7 +1011,7 @@ lcommunity_list_match_delete (struct lcommunity *lcom,
/* Set lcommunity-list. */ /* Set lcommunity-list. */
int int
lcommunity_list_set (struct community_list_handler *ch, lcommunity_list_set (struct community_list_handler *ch,
const char *name, const char *str, int direct, int style) const char *name, const char *str, int direct, int style)
{ {
struct community_entry *entry = NULL; struct community_entry *entry = NULL;
struct community_list *list; struct community_list *list;
@ -1033,22 +1031,22 @@ lcommunity_list_set (struct community_list_handler *ch,
first = list->head; first = list->head;
if (style != first->style) if (style != first->style)
{ {
return (first->style == COMMUNITY_LIST_STANDARD return (first->style == COMMUNITY_LIST_STANDARD
? COMMUNITY_LIST_ERR_STANDARD_CONFLICT ? COMMUNITY_LIST_ERR_STANDARD_CONFLICT
: COMMUNITY_LIST_ERR_EXPANDED_CONFLICT); : COMMUNITY_LIST_ERR_EXPANDED_CONFLICT);
} }
} }
if (str) if (str)
{ {
if (style == LARGE_COMMUNITY_LIST_STANDARD) if (style == LARGE_COMMUNITY_LIST_STANDARD)
lcom = lcommunity_str2com (str); lcom = lcommunity_str2com (str);
else else
regex = bgp_regcomp (str); regex = bgp_regcomp (str);
if (! lcom && ! regex) if (! lcom && ! regex)
return COMMUNITY_LIST_ERR_MALFORMED_VAL; return COMMUNITY_LIST_ERR_MALFORMED_VAL;
} }
entry = community_entry_new (); entry = community_entry_new ();
@ -1077,8 +1075,8 @@ lcommunity_list_set (struct community_list_handler *ch,
community-list entry belongs to the specified name. */ community-list entry belongs to the specified name. */
int int
lcommunity_list_unset (struct community_list_handler *ch, lcommunity_list_unset (struct community_list_handler *ch,
const char *name, const char *str, const char *name, const char *str,
int direct, int style) int direct, int style)
{ {
struct community_entry *entry = NULL; struct community_entry *entry = NULL;
struct community_list *list; struct community_list *list;

View file

@ -1,23 +1,22 @@
/* BGP Large Communities Attribute /* BGP Large Communities Attribute
*
Copyright (C) 2016 Keyur Patel <keyur@arrcus.com> * Copyright (C) 2016 Keyur Patel <keyur@arrcus.com>
*
This file is part of GNU Zebra. * This file is part of FreeRangeRouting (FRR).
*
GNU Zebra is free software; you can redistribute it and/or modify it * FRR is free software; you can redistribute it and/or modify it under the
under the terms of the GNU General Public License as published by the * terms of the GNU General Public License as published by the Free Software
Free Software Foundation; either version 2, or (at your option) any * Foundation; either version 2, or (at your option) any later version.
later version. *
* FRR is distributed in the hope that it will be useful, but WITHOUT ANY
GNU Zebra is distributed in the hope that it will be useful, but * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
WITHOUT ANY WARRANTY; without even the implied warranty of * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * details.
General Public License for more details. *
* You should have received a copy of the GNU General Public License along
You should have received a copy of the GNU General Public License * with FRR; see the file COPYING. If not, write to the Free Software
along with GNU Zebra; see the file COPYING. If not, write to the Free * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA */
02111-1307, USA. */
#include <zebra.h> #include <zebra.h>

View file

@ -1,23 +1,22 @@
/* BGP Large Communities Attribute. /* BGP Large Communities Attribute.
*
Copyright (C) 2016 Keyur Patel <keyur@arrcus.com> * Copyright (C) 2016 Keyur Patel <keyur@arrcus.com>
*
This file is part of GNU Zebra. * This file is part of FreeRangeRouting (FRR).
*
GNU Zebra is free software; you can redistribute it and/or modify it * FRR is free software; you can redistribute it and/or modify it under the
under the terms of the GNU General Public License as published by the * terms of the GNU General Public License as published by the Free Software
Free Software Foundation; either version 2, or (at your option) any * Foundation; either version 2, or (at your option) any later version.
later version. *
* FRR is distributed in the hope that it will be useful, but WITHOUT ANY
GNU Zebra is distributed in the hope that it will be useful, but * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
WITHOUT ANY WARRANTY; without even the implied warranty of * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * details.
General Public License for more details. *
* You should have received a copy of the GNU General Public License along
You should have received a copy of the GNU General Public License * with FRR; see the file COPYING. If not, write to the Free Software
along with GNU Zebra; see the file COPYING. If not, write to the Free * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA */
02111-1307, USA. */
#ifndef _QUAGGA_BGP_LCOMMUNITY_H #ifndef _QUAGGA_BGP_LCOMMUNITY_H
#define _QUAGGA_BGP_LCOMMUNITY_H #define _QUAGGA_BGP_LCOMMUNITY_H

View file

@ -7063,8 +7063,8 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
/* Line 6 display Large community */ /* Line 6 display Large community */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)) if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES))
vty_out (vty, " Large Community: %s%s", vty_out (vty, " Large Community: %s%s",
attr->extra->lcommunity->str, VTY_NEWLINE); attr->extra->lcommunity->str, VTY_NEWLINE);
/* Line 7 display Originator, Cluster-id */ /* Line 7 display Originator, Cluster-id */
if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) || if ((attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
@ -7426,32 +7426,32 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table,
if (! community_list_exact_match (ri->attr->community, list)) if (! community_list_exact_match (ri->attr->community, list))
continue; continue;
} }
if (type == bgp_show_type_community_all) if (type == bgp_show_type_community_all)
{ {
if (! ri->attr->community) if (! ri->attr->community)
continue; continue;
} }
if (type == bgp_show_type_lcommunity) if (type == bgp_show_type_lcommunity)
{ {
struct lcommunity *lcom = output_arg; struct lcommunity *lcom = output_arg;
if (! ri->attr->extra || ! ri->attr->extra->lcommunity || if (! ri->attr->extra || ! ri->attr->extra->lcommunity ||
! lcommunity_match (ri->attr->extra->lcommunity, lcom)) ! lcommunity_match (ri->attr->extra->lcommunity, lcom))
continue; continue;
} }
if (type == bgp_show_type_lcommunity_list) if (type == bgp_show_type_lcommunity_list)
{ {
struct community_list *list = output_arg; struct community_list *list = output_arg;
if (! ri->attr->extra || if (! ri->attr->extra ||
! lcommunity_list_match (ri->attr->extra->lcommunity, list)) ! lcommunity_list_match (ri->attr->extra->lcommunity, list))
continue; continue;
} }
if (type == bgp_show_type_lcommunity_all) if (type == bgp_show_type_lcommunity_all)
{ {
if (! ri->attr->extra || ! ri->attr->extra->lcommunity) if (! ri->attr->extra || ! ri->attr->extra->lcommunity)
continue; continue;
} }
if (type == bgp_show_type_dampend_paths if (type == bgp_show_type_dampend_paths
|| type == bgp_show_type_damp_neighbor) || type == bgp_show_type_damp_neighbor)
{ {
@ -7870,7 +7870,7 @@ bgp_show_route (struct vty *vty, const char *view_name, const char *ip_str,
static int static int
bgp_show_lcommunity (struct vty *vty, struct bgp *bgp, int argc, bgp_show_lcommunity (struct vty *vty, struct bgp *bgp, int argc,
struct cmd_token **argv, afi_t afi, safi_t safi, u_char uj) struct cmd_token **argv, afi_t afi, safi_t safi, u_char uj)
{ {
struct lcommunity *lcom; struct lcommunity *lcom;
struct buffer *b; struct buffer *b;
@ -7884,13 +7884,13 @@ bgp_show_lcommunity (struct vty *vty, struct bgp *bgp, int argc,
if (first) if (first)
buffer_putc (b, ' '); buffer_putc (b, ' ');
else else
{ {
if (strmatch (argv[i]->text, "<AA:BB:CC>")) if (strmatch (argv[i]->text, "<AA:BB:CC>"))
{ {
first = 1; first = 1;
buffer_putstr (b, argv[i]->arg); buffer_putstr (b, argv[i]->arg);
} }
} }
} }
buffer_putc (b, '\0'); buffer_putc (b, '\0');
@ -7910,7 +7910,7 @@ bgp_show_lcommunity (struct vty *vty, struct bgp *bgp, int argc,
static int static int
bgp_show_lcommunity_list (struct vty *vty, struct bgp *bgp, const char *lcom, bgp_show_lcommunity_list (struct vty *vty, struct bgp *bgp, const char *lcom,
afi_t afi, safi_t safi, u_char uj) afi_t afi, safi_t safi, u_char uj)
{ {
struct community_list *list; struct community_list *list;
@ -7918,7 +7918,7 @@ bgp_show_lcommunity_list (struct vty *vty, struct bgp *bgp, const char *lcom,
if (list == NULL) if (list == NULL)
{ {
vty_out (vty, "%% %s is not a valid large-community-list name%s", lcom, vty_out (vty, "%% %s is not a valid large-community-list name%s", lcom,
VTY_NEWLINE); VTY_NEWLINE);
return CMD_WARNING; return CMD_WARNING;
} }

View file

@ -853,7 +853,7 @@ struct route_map_rule_cmd route_match_community_cmd =
/* Match function for lcommunity match. */ /* Match function for lcommunity match. */
static route_map_result_t static route_map_result_t
route_match_lcommunity (void *rule, struct prefix *prefix, route_match_lcommunity (void *rule, struct prefix *prefix,
route_map_object_t type, void *object) route_map_object_t type, void *object)
{ {
struct community_list *list; struct community_list *list;
struct bgp_info *bgp_info; struct bgp_info *bgp_info;
@ -865,13 +865,13 @@ route_match_lcommunity (void *rule, struct prefix *prefix,
rcom = rule; rcom = rule;
list = community_list_lookup (bgp_clist, rcom->name, list = community_list_lookup (bgp_clist, rcom->name,
LARGE_COMMUNITY_LIST_MASTER); LARGE_COMMUNITY_LIST_MASTER);
if (! list) if (! list)
return RMAP_NOMATCH; return RMAP_NOMATCH;
if (bgp_info->attr->extra && if (bgp_info->attr->extra &&
lcommunity_list_match (bgp_info->attr->extra->lcommunity, list)) lcommunity_list_match (bgp_info->attr->extra->lcommunity, list))
return RMAP_MATCH; return RMAP_MATCH;
} }
return RMAP_NOMATCH; return RMAP_NOMATCH;
@ -1631,7 +1631,7 @@ struct rmap_lcom_set
/* For lcommunity set mechanism. */ /* For lcommunity set mechanism. */
static route_map_result_t static route_map_result_t
route_set_lcommunity (void *rule, struct prefix *prefix, route_set_lcommunity (void *rule, struct prefix *prefix,
route_map_object_t type, void *object) route_map_object_t type, void *object)
{ {
struct rmap_lcom_set *rcs; struct rmap_lcom_set *rcs;
struct bgp_info *binfo; struct bgp_info *binfo;
@ -1649,37 +1649,37 @@ route_set_lcommunity (void *rule, struct prefix *prefix,
/* "none" case. */ /* "none" case. */
if (rcs->none) if (rcs->none)
{ {
attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES)); attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES));
if (attr->extra) { if (attr->extra)
attr->extra->lcommunity = NULL; attr->extra->lcommunity = NULL;
}
/* See the longer comment down below. */ /* See the longer comment down below. */
if (old && old->refcnt == 0) if (old && old->refcnt == 0)
lcommunity_free(&old); lcommunity_free(&old);
return RMAP_OKAY; return RMAP_OKAY;
} }
if (rcs->additive && old) if (rcs->additive && old)
{ {
merge = lcommunity_merge (lcommunity_dup (old), rcs->lcom); merge = lcommunity_merge (lcommunity_dup (old), rcs->lcom);
/* HACK: if the old large-community is not intern'd, /* HACK: if the old large-community is not intern'd,
* we should free it here, or all reference to it may be lost. * we should free it here, or all reference to it may be lost.
* Really need to cleanup attribute caching sometime. * Really need to cleanup attribute caching sometime.
*/ */
if (old->refcnt == 0) if (old->refcnt == 0)
lcommunity_free (&old); lcommunity_free (&old);
new = lcommunity_uniq_sort (merge); new = lcommunity_uniq_sort (merge);
lcommunity_free (&merge); lcommunity_free (&merge);
} }
else else
new = lcommunity_dup (rcs->lcom); new = lcommunity_dup (rcs->lcom);
/* will be interned by caller if required */
if (attr->extra)
attr->extra->lcommunity = new;
/* will be interned by caller if required */
if (attr->extra) {
attr->extra->lcommunity = new;
}
attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES); attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES);
} }
@ -1703,19 +1703,19 @@ route_set_lcommunity_compile (const char *arg)
sp = strstr (arg, "additive"); sp = strstr (arg, "additive");
if (sp && sp > arg) if (sp && sp > arg)
{ {
/* "additive" keyworkd is included. */ /* "additive" keyworkd is included. */
additive = 1; additive = 1;
*(sp - 1) = '\0'; *(sp - 1) = '\0';
} }
lcom = lcommunity_str2com (arg); lcom = lcommunity_str2com (arg);
if (additive) if (additive)
*(sp - 1) = ' '; *(sp - 1) = ' ';
if (! lcom) if (! lcom)
return NULL; return NULL;
} }
rcs = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_com_set)); rcs = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct rmap_com_set));
@ -1752,7 +1752,7 @@ struct route_map_rule_cmd route_set_lcommunity_cmd =
/* For large community set mechanism. */ /* For large community set mechanism. */
static route_map_result_t static route_map_result_t
route_set_lcommunity_delete (void *rule, struct prefix *prefix, route_set_lcommunity_delete (void *rule, struct prefix *prefix,
route_map_object_t type, void *object) route_map_object_t type, void *object)
{ {
struct community_list *list; struct community_list *list;
struct lcommunity *merge; struct lcommunity *merge;
@ -1763,38 +1763,38 @@ route_set_lcommunity_delete (void *rule, struct prefix *prefix,
if (type == RMAP_BGP) if (type == RMAP_BGP)
{ {
if (! rule) if (! rule)
return RMAP_OKAY; return RMAP_OKAY;
binfo = object; binfo = object;
list = community_list_lookup (bgp_clist, rule, list = community_list_lookup (bgp_clist, rule,
LARGE_COMMUNITY_LIST_MASTER); LARGE_COMMUNITY_LIST_MASTER);
old = ((binfo->attr->extra) ? binfo->attr->extra->lcommunity : NULL); old = ((binfo->attr->extra) ? binfo->attr->extra->lcommunity : NULL);
if (list && old) if (list && old)
{ {
merge = lcommunity_list_match_delete (lcommunity_dup (old), list); merge = lcommunity_list_match_delete (lcommunity_dup (old), list);
new = lcommunity_uniq_sort (merge); new = lcommunity_uniq_sort (merge);
lcommunity_free (&merge); lcommunity_free (&merge);
/* HACK: if the old community is not intern'd, /* HACK: if the old community is not intern'd,
* we should free it here, or all reference to it may be lost. * we should free it here, or all reference to it may be lost.
* Really need to cleanup attribute caching sometime. * Really need to cleanup attribute caching sometime.
*/ */
if (old->refcnt == 0) if (old->refcnt == 0)
lcommunity_free (&old); lcommunity_free (&old);
if (new->size == 0) if (new->size == 0)
{ {
binfo->attr->extra->lcommunity = NULL; binfo->attr->extra->lcommunity = NULL;
binfo->attr->flag &= ~ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES); binfo->attr->flag &= ~ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES);
lcommunity_free (&new); lcommunity_free (&new);
} }
else else
{ {
binfo->attr->extra->lcommunity = new; binfo->attr->extra->lcommunity = new;
binfo->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES); binfo->attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LARGE_COMMUNITIES);
} }
} }
} }
return RMAP_OKAY; return RMAP_OKAY;
@ -3418,7 +3418,7 @@ DEFUN (match_lcommunity,
"Large Community-list name\n") "Large Community-list name\n")
{ {
return bgp_route_match_add (vty, "large-community", argv[2]->arg, return bgp_route_match_add (vty, "large-community", argv[2]->arg,
RMAP_EVENT_LLIST_ADDED); RMAP_EVENT_LLIST_ADDED);
} }
DEFUN (no_match_lcommunity, DEFUN (no_match_lcommunity,
@ -3432,7 +3432,7 @@ DEFUN (no_match_lcommunity,
"Large Community-list name\n") "Large Community-list name\n")
{ {
return bgp_route_match_delete (vty, "large-community", NULL, return bgp_route_match_delete (vty, "large-community", NULL,
RMAP_EVENT_LLIST_DELETED); RMAP_EVENT_LLIST_DELETED);
} }
DEFUN (match_ecommunity, DEFUN (match_ecommunity,
@ -3891,7 +3891,7 @@ DEFUN (set_lcommunity_none,
"No large community attribute\n") "No large community attribute\n")
{ {
return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index), return generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
"large-community", "none"); "large-community", "none");
} }
DEFUN (no_set_lcommunity, DEFUN (no_set_lcommunity,
@ -3903,7 +3903,7 @@ DEFUN (no_set_lcommunity,
"No community attribute\n") "No community attribute\n")
{ {
return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index), return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
"large-community", NULL); "large-community", NULL);
} }
DEFUN (no_set_lcommunity1, DEFUN (no_set_lcommunity1,
@ -3915,7 +3915,7 @@ DEFUN (no_set_lcommunity1,
"Large community in AA:BB:CC... format or additive\n") "Large community in AA:BB:CC... format or additive\n")
{ {
return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index), return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
"large-community", NULL); "large-community", NULL);
} }
DEFUN (set_lcommunity_delete, DEFUN (set_lcommunity_delete,
@ -3935,7 +3935,7 @@ DEFUN (set_lcommunity_delete,
strcpy (str + strlen (argv[2]->arg), " delete"); strcpy (str + strlen (argv[2]->arg), " delete");
generic_set_add (vty, VTY_GET_CONTEXT(route_map_index), generic_set_add (vty, VTY_GET_CONTEXT(route_map_index),
"large-comm-list", str); "large-comm-list", str);
XFREE (MTYPE_TMP, str); XFREE (MTYPE_TMP, str);
return CMD_SUCCESS; return CMD_SUCCESS;
@ -3953,7 +3953,7 @@ DEFUN (no_set_lcommunity_delete,
"Delete matching large communities\n") "Delete matching large communities\n")
{ {
return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index), return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index),
"large-comm-list", NULL); "large-comm-list", NULL);
} }
DEFUN (set_ecommunity_rt, DEFUN (set_ecommunity_rt,

View file

@ -6157,7 +6157,7 @@ DEFUN (show_bgp_memory,
VTY_NEWLINE); VTY_NEWLINE);
if ((count = mtype_stats_alloc (MTYPE_LCOMMUNITY))) if ((count = mtype_stats_alloc (MTYPE_LCOMMUNITY)))
vty_out (vty, "%ld BGP large-community entries, using %s of memory%s", vty_out (vty, "%ld BGP large-community entries, using %s of memory%s",
count, count,
mtype_memstr (memstrbuf, sizeof (memstrbuf), mtype_memstr (memstrbuf, sizeof (memstrbuf),
count * sizeof (struct lcommunity)), count * sizeof (struct lcommunity)),
VTY_NEWLINE); VTY_NEWLINE);
@ -8677,7 +8677,7 @@ lcommunity_show_all_iterator (struct hash_backet *backet, struct vty *vty)
lcom = (struct lcommunity *) backet->data; lcom = (struct lcommunity *) backet->data;
vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, lcom->refcnt, vty_out (vty, "[%p] (%ld) %s%s", (void *)backet, lcom->refcnt,
lcommunity_str (lcom), VTY_NEWLINE); lcommunity_str (lcom), VTY_NEWLINE);
} }
/* Show BGP's community internal data. */ /* Show BGP's community internal data. */
@ -8692,9 +8692,9 @@ DEFUN (show_ip_bgp_lcommunity_info,
vty_out (vty, "Address Refcnt Large-community%s", VTY_NEWLINE); vty_out (vty, "Address Refcnt Large-community%s", VTY_NEWLINE);
hash_iterate (lcommunity_hash (), hash_iterate (lcommunity_hash (),
(void (*) (struct hash_backet *, void *)) (void (*) (struct hash_backet *, void *))
lcommunity_show_all_iterator, lcommunity_show_all_iterator,
vty); vty);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
@ -11140,7 +11140,7 @@ DEFUN (show_ip_community_list_arg,
*/ */
static int static int
lcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv, lcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv,
int style, int reject_all_digit_name) int style, int reject_all_digit_name)
{ {
int ret; int ret;
int direct; int direct;
@ -11187,7 +11187,7 @@ lcommunity_list_set_vty (struct vty *vty, int argc, struct cmd_token **argv,
static int static int
lcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv, lcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv,
int style) int style)
{ {
int ret; int ret;
int direct = 0; int direct = 0;
@ -11201,9 +11201,9 @@ lcommunity_list_unset_vty (struct vty *vty, int argc, struct cmd_token **argv,
{ {
/* Check the list direct. */ /* Check the list direct. */
if (strncmp (argv[idx]->arg, "p", 1) == 0) if (strncmp (argv[idx]->arg, "p", 1) == 0)
direct = COMMUNITY_PERMIT; direct = COMMUNITY_PERMIT;
else else
direct = COMMUNITY_DENY; direct = COMMUNITY_DENY;
idx = 0; idx = 0;
argv_find (argv, argc, "LINE", &idx); argv_find (argv, argc, "LINE", &idx);
@ -11409,27 +11409,27 @@ lcommunity_list_show (struct vty *vty, struct community_list *list)
for (entry = list->head; entry; entry = entry->next) for (entry = list->head; entry; entry = entry->next)
{ {
if (entry == list->head) if (entry == list->head)
{ {
if (all_digit (list->name)) if (all_digit (list->name))
vty_out (vty, "Large community %s list %s%s", vty_out (vty, "Large community %s list %s%s",
entry->style == EXTCOMMUNITY_LIST_STANDARD ? entry->style == EXTCOMMUNITY_LIST_STANDARD ?
"standard" : "(expanded) access", "standard" : "(expanded) access",
list->name, VTY_NEWLINE); list->name, VTY_NEWLINE);
else else
vty_out (vty, "Named large community %s list %s%s", vty_out (vty, "Named large community %s list %s%s",
entry->style == EXTCOMMUNITY_LIST_STANDARD ? entry->style == EXTCOMMUNITY_LIST_STANDARD ?
"standard" : "expanded", "standard" : "expanded",
list->name, VTY_NEWLINE); list->name, VTY_NEWLINE);
} }
if (entry->any) if (entry->any)
vty_out (vty, " %s%s", vty_out (vty, " %s%s",
community_direct_str (entry->direct), VTY_NEWLINE); community_direct_str (entry->direct), VTY_NEWLINE);
else else
vty_out (vty, " %s %s%s", vty_out (vty, " %s %s%s",
community_direct_str (entry->direct), community_direct_str (entry->direct),
entry->style == EXTCOMMUNITY_LIST_STANDARD ? entry->style == EXTCOMMUNITY_LIST_STANDARD ?
entry->u.ecom->str : entry->config, entry->u.ecom->str : entry->config,
VTY_NEWLINE); VTY_NEWLINE);
} }
} }
@ -11796,20 +11796,20 @@ community_list_config_write (struct vty *vty)
for (list = cm->num.head; list; list = list->next) for (list = cm->num.head; list; list = list->next)
for (entry = list->head; entry; entry = entry->next) for (entry = list->head; entry; entry = entry->next)
{ {
vty_out (vty, "ip large-community-list %s %s %s%s", vty_out (vty, "ip large-community-list %s %s %s%s",
list->name, community_direct_str (entry->direct), list->name, community_direct_str (entry->direct),
community_list_config_str (entry), VTY_NEWLINE); community_list_config_str (entry), VTY_NEWLINE);
write++; write++;
} }
for (list = cm->str.head; list; list = list->next) for (list = cm->str.head; list; list = list->next)
for (entry = list->head; entry; entry = entry->next) for (entry = list->head; entry; entry = entry->next)
{ {
vty_out (vty, "ip large-community-list %s %s %s %s%s", vty_out (vty, "ip large-community-list %s %s %s %s%s",
entry->style == LARGE_COMMUNITY_LIST_STANDARD entry->style == LARGE_COMMUNITY_LIST_STANDARD
? "standard" : "expanded", ? "standard" : "expanded",
list->name, community_direct_str (entry->direct), list->name, community_direct_str (entry->direct),
community_list_config_str (entry), VTY_NEWLINE); community_list_config_str (entry), VTY_NEWLINE);
write++; write++;
} }
return write; return write;