bpgd: resolve more neighbor peer-group issues

Found in testing that in a certain sequence, a neighbor's peer-group
membership would be lost.  This fix resolves that issue. Additionally
found that "no neighbor swp1 remote-as 2" would sometimes leave the
config with "neighbor swp1 remote-as 0" rather than removing from the
config. That one is also resolved.

Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
This commit is contained in:
Don Slice 2019-03-02 19:40:17 +00:00
parent 700e9faa28
commit 390485fdc9
2 changed files with 12 additions and 7 deletions

View File

@ -2841,18 +2841,23 @@ static int peer_remote_as_vty(struct vty *vty, const char *peer_str,
as = strtoul(as_str, NULL, 10);
}
/* If peer is peer group, call proper function. */
/* If peer is peer group or interface peer, call proper function. */
ret = str2sockunion(peer_str, &su);
if (ret < 0) {
/* Check for peer by interface */
struct peer *peer;
/* Check if existing interface peer */
peer = peer_lookup_by_conf_if(bgp, peer_str);
ret = peer_remote_as(bgp, NULL, peer_str, &as, as_type, afi,
safi);
if (ret < 0) {
/* if not interface peer, check peer-group settings */
if (ret < 0 && !peer) {
ret = peer_group_remote_as(bgp, peer_str, &as, as_type);
if (ret < 0) {
vty_out(vty,
"%% Create the peer-group or interface first or specify \"interface\" keyword\n");
vty_out(vty, "%% if using an unnumbered interface neighbor\n");
"%% Create the peer-group or interface first\n");
return CMD_WARNING_CONFIG_FAILED;
}
return CMD_SUCCESS;
@ -3251,7 +3256,7 @@ DEFUN (no_neighbor_interface_peer_group_remote_as,
/* look up for neighbor by interface name config. */
peer = peer_lookup_by_conf_if(bgp, argv[idx_word]->arg);
if (peer) {
peer_as_change(peer, 0, AS_SPECIFIED);
peer_as_change(peer, 0, AS_UNSPECIFIED);
return CMD_SUCCESS;
}

View File

@ -2722,7 +2722,7 @@ int peer_group_bind(struct bgp *bgp, union sockunion *su, struct peer *peer,
peer->sort = group->conf->sort;
}
if (!group->conf->as) {
if (!group->conf->as && peer_sort(peer)) {
if (peer_sort(group->conf) != BGP_PEER_INTERNAL
&& peer_sort(group->conf) != peer_sort(peer)) {
if (as)