Skip to content

Commit

Permalink
Should be able to "no" the full text of any config line
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>

Ticket: CM-5816
  • Loading branch information
Daniel Walton committed Nov 23, 2015
1 parent 1a1f4ef commit 813d430
Show file tree
Hide file tree
Showing 19 changed files with 1,067 additions and 191 deletions.
12 changes: 12 additions & 0 deletions bgpd/bgp_bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,17 @@ DEFUN (no_neighbor_bfd,
return CMD_SUCCESS;
}

ALIAS (no_neighbor_bfd,
no_neighbor_bfd_val_cmd,
NO_NEIGHBOR_CMD2 "bfd " BFD_CMD_DETECT_MULT_RANGE BFD_CMD_MIN_RX_RANGE BFD_CMD_MIN_TX_RANGE,
NO_STR
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Disables BFD support\n"
"Detect Multiplier\n"
"Required min receive interval\n"
"Desired min transmit interval\n")

void
bgp_bfd_init(void)
{
Expand All @@ -505,4 +516,5 @@ bgp_bfd_init(void)
install_element (BGP_NODE, &neighbor_bfd_cmd);
install_element (BGP_NODE, &neighbor_bfd_param_cmd);
install_element (BGP_NODE, &no_neighbor_bfd_cmd);
install_element (BGP_NODE, &no_neighbor_bfd_val_cmd);
}
59 changes: 24 additions & 35 deletions bgpd/bgp_clist.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,16 +312,16 @@ community_list_entry_lookup (struct community_list *list, const void *arg,
switch (entry->style)
{
case COMMUNITY_LIST_STANDARD:
if (community_cmp (entry->u.com, arg))
if (entry->direct == direct && community_cmp (entry->u.com, arg))
return entry;
break;
case EXTCOMMUNITY_LIST_STANDARD:
if (ecommunity_cmp (entry->u.ecom, arg))
if (entry->direct == direct && ecommunity_cmp (entry->u.ecom, arg))
return entry;
break;
case COMMUNITY_LIST_EXPANDED:
case EXTCOMMUNITY_LIST_EXPANDED:
if (strcmp (entry->config, arg) == 0)
if (entry->direct == direct && strcmp (entry->config, arg) == 0)
return entry;
break;
default:
Expand Down Expand Up @@ -765,49 +765,43 @@ community_list_set (struct community_list_handler *ch,
return 0;
}

/* Unset community-list. When str is NULL, delete all of
community-list entry belongs to the specified name. */
/* Unset community-list */
int
community_list_unset (struct community_list_handler *ch,
const char *name, const char *str,
int direct, int style)
int direct, int style, int delete_all)
{
struct community_entry *entry = NULL;
struct community_list *list;
struct community *com = NULL;
regex_t *regex = NULL;

/* Lookup community list. */
list = community_list_lookup (ch, name, COMMUNITY_LIST_MASTER);
if (list == NULL)
return COMMUNITY_LIST_ERR_CANT_FIND_LIST;

/* Delete all of entry belongs to this community-list. */
if (!str)
if (delete_all)
{
community_list_delete (list);
route_map_notify_dependencies(name, RMAP_EVENT_CLIST_DELETED);
return 0;
}

if (style == COMMUNITY_LIST_STANDARD)
com = community_str2com (str);
else
regex = bgp_regcomp (str);

if (! com && ! regex)
return COMMUNITY_LIST_ERR_MALFORMED_VAL;
{
if (str)
com = community_str2com (str);
}

if (com)
entry = community_list_entry_lookup (list, com, direct);
{
entry = community_list_entry_lookup (list, com, direct);
community_free (com);
}
else
entry = community_list_entry_lookup (list, str, direct);

if (com)
community_free (com);
if (regex)
bgp_regex_free (regex);

if (!entry)
return COMMUNITY_LIST_ERR_CANT_FIND_LIST;

Expand Down Expand Up @@ -894,44 +888,39 @@ extcommunity_list_set (struct community_list_handler *ch,
int
extcommunity_list_unset (struct community_list_handler *ch,
const char *name, const char *str,
int direct, int style)
int direct, int style, int delete_all)
{
struct community_entry *entry = NULL;
struct community_list *list;
struct ecommunity *ecom = NULL;
regex_t *regex = NULL;

/* Lookup extcommunity list. */
list = community_list_lookup (ch, name, EXTCOMMUNITY_LIST_MASTER);
if (list == NULL)
return COMMUNITY_LIST_ERR_CANT_FIND_LIST;

/* Delete all of entry belongs to this extcommunity-list. */
if (!str)
if (delete_all)
{
community_list_delete (list);
route_map_notify_dependencies(name, RMAP_EVENT_ECLIST_DELETED);
return 0;
}

if (style == EXTCOMMUNITY_LIST_STANDARD)
ecom = ecommunity_str2com (str, 0, 1);
else
regex = bgp_regcomp (str);

if (! ecom && ! regex)
return COMMUNITY_LIST_ERR_MALFORMED_VAL;
{
if (str)
ecom = ecommunity_str2com (str, 0, 1);
}

if (ecom)
entry = community_list_entry_lookup (list, ecom, direct);
{
entry = community_list_entry_lookup (list, ecom, direct);
ecommunity_free (&ecom);
}
else
entry = community_list_entry_lookup (list, str, direct);

if (ecom)
ecommunity_free (&ecom);
if (regex)
bgp_regex_free (regex);

if (!entry)
return COMMUNITY_LIST_ERR_CANT_FIND_LIST;

Expand Down
4 changes: 2 additions & 2 deletions bgpd/bgp_clist.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ extern int community_list_set (struct community_list_handler *ch,
int style);
extern int community_list_unset (struct community_list_handler *ch,
const char *name, const char *str,
int direct, int style);
int direct, int style, int delete_all);
extern int extcommunity_list_set (struct community_list_handler *ch,
const char *name, const char *str,
int direct, int style);
extern int extcommunity_list_unset (struct community_list_handler *ch,
const char *name, const char *str,
int direct, int style);
int direct, int style, int delete_all);

extern struct community_list_master *
community_list_master_lookup (struct community_list_handler *, int);
Expand Down
6 changes: 6 additions & 0 deletions bgpd/bgp_ecommunity.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,12 @@ ecommunity_cmp (const void *arg1, const void *arg2)
{
const struct ecommunity *ecom1 = arg1;
const struct ecommunity *ecom2 = arg2;

if (ecom1 == NULL && ecom2 == NULL)
return 1;

if (ecom1 == NULL || ecom2 == NULL)
return 0;

return (ecom1->size == ecom2->size
&& memcmp (ecom1->val, ecom2->val, ecom1->size * ECOMMUNITY_SIZE) == 0);
Expand Down
10 changes: 10 additions & 0 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -12990,6 +12990,14 @@ ALIAS (bgp_damp_unset,
"Value to start suppressing a route\n"
"Maximum duration to suppress a stable route\n")

ALIAS (bgp_damp_unset,
bgp_damp_unset3_cmd,
"no bgp dampening <1-45>",
NO_STR
"BGP Specific commands\n"
"Enable route-flap dampening\n"
"Half-life time for the penalty\n")

DEFUN (show_ip_bgp_dampened_paths,
show_ip_bgp_dampened_paths_cmd,
"show ip bgp dampened-paths",
Expand Down Expand Up @@ -14030,11 +14038,13 @@ bgp_route_init (void)
install_element (BGP_NODE, &bgp_damp_set3_cmd);
install_element (BGP_NODE, &bgp_damp_unset_cmd);
install_element (BGP_NODE, &bgp_damp_unset2_cmd);
install_element (BGP_NODE, &bgp_damp_unset3_cmd);
install_element (BGP_IPV4_NODE, &bgp_damp_set_cmd);
install_element (BGP_IPV4_NODE, &bgp_damp_set2_cmd);
install_element (BGP_IPV4_NODE, &bgp_damp_set3_cmd);
install_element (BGP_IPV4_NODE, &bgp_damp_unset_cmd);
install_element (BGP_IPV4_NODE, &bgp_damp_unset2_cmd);
install_element (BGP_IPV4_NODE, &bgp_damp_unset3_cmd);
}

void
Expand Down
Loading

0 comments on commit 813d430

Please sign in to comment.