]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Notify "Peer De-configured" after entering 'no neighbor <neighbor> cmd'
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Tue, 5 Nov 2019 12:33:31 +0000 (14:33 +0200)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Wed, 20 Nov 2019 19:29:01 +0000 (21:29 +0200)
Before changes:

~# vtysh -c 'show ip bgp neighbors 192.168.0.2 json' | \
jq '."192.168.0.2".lastNotificationReason'
null

After changes:

~# vtysh -c 'show ip bgp neighbors 192.168.0.2 json' | \
jq '."192.168.0.2".lastNotificationReason'
"Cease/Peer Unconfigured"

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h

index 3b15a9c7a27dadf5eebd575a75e9e274ab0fe4f0..2c0538d0a93abed0487255988cf6c07888e3d17e 100644 (file)
@@ -3152,14 +3152,16 @@ DEFUN (no_neighbor,
                         * interface. */
                        if (peer->ifp)
                                bgp_zebra_terminate_radv(peer->bgp, peer);
+                       peer_notify_unconfig(peer);
                        peer_delete(peer);
                        return CMD_SUCCESS;
                }
 
                group = peer_group_lookup(bgp, argv[idx_peer]->arg);
-               if (group)
+               if (group) {
+                       peer_group_notify_unconfig(group);
                        peer_group_delete(group);
-               else {
+               else {
                        vty_out(vty, "%% Create the peer-group first\n");
                        return CMD_WARNING_CONFIG_FAILED;
                }
@@ -3173,9 +3175,12 @@ DEFUN (no_neighbor,
                        }
 
                        other = peer->doppelganger;
+                       peer_notify_unconfig(peer);
                        peer_delete(peer);
-                       if (other && other->status != Deleted)
+                       if (other && other->status != Deleted) {
+                               peer_notify_unconfig(other);
                                peer_delete(other);
+                       }
                }
        }
 
@@ -3207,6 +3212,7 @@ DEFUN (no_neighbor_interface_config,
                /* Request zebra to terminate IPv6 RAs on this interface. */
                if (peer->ifp)
                        bgp_zebra_terminate_radv(peer->bgp, peer);
+               peer_notify_unconfig(peer);
                peer_delete(peer);
        } else {
                vty_out(vty, "%% Create the bgp interface first\n");
@@ -3228,9 +3234,10 @@ DEFUN (no_neighbor_peer_group,
        struct peer_group *group;
 
        group = peer_group_lookup(bgp, argv[idx_word]->arg);
-       if (group)
+       if (group) {
+               peer_group_notify_unconfig(group);
                peer_group_delete(group);
-       else {
+       else {
                vty_out(vty, "%% Create the peer-group first\n");
                return CMD_WARNING_CONFIG_FAILED;
        }
@@ -3588,6 +3595,7 @@ DEFUN (no_neighbor_set_peer_group,
                return CMD_WARNING_CONFIG_FAILED;
        }
 
+       peer_notify_unconfig(peer);
        ret = peer_delete(peer);
 
        return bgp_vty_return(vty, ret);
index f0130c976865e800aceee4179c210a9d442c16b0..a557c9c7bc3d6aa1e2c11d51c67109f45139390d 100644 (file)
@@ -2553,6 +2553,30 @@ int peer_group_remote_as(struct bgp *bgp, const char *group_name, as_t *as,
        return 0;
 }
 
+int peer_notify_unconfig(struct peer *peer)
+{
+       if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
+               bgp_notify_send(peer, BGP_NOTIFY_CEASE,
+                               BGP_NOTIFY_CEASE_PEER_UNCONFIG);
+       return 0;
+}
+
+int peer_group_notify_unconfig(struct peer_group *group)
+{
+       struct peer *peer, *other;
+       struct listnode *node, *nnode;
+
+       for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) {
+               other = peer->doppelganger;
+               if (other && other->status != Deleted) {
+                       other->group = NULL;
+                       peer_notify_unconfig(other);
+               } else
+                       peer_notify_unconfig(peer);
+       }
+       return 0;
+}
+
 int peer_group_delete(struct peer_group *group)
 {
        struct bgp *bgp;
index 865f5a2b68fb868f2cc8f40c45a0a413b477623a..273fef43c2ccba36293956294457ccd6523799c4 100644 (file)
@@ -1618,9 +1618,11 @@ extern int peer_remote_as(struct bgp *, union sockunion *, const char *, as_t *,
                          int, afi_t, safi_t);
 extern int peer_group_remote_as(struct bgp *, const char *, as_t *, int);
 extern int peer_delete(struct peer *peer);
+extern int peer_notify_unconfig(struct peer *peer);
 extern int peer_group_delete(struct peer_group *);
 extern int peer_group_remote_as_delete(struct peer_group *);
 extern int peer_group_listen_range_add(struct peer_group *, struct prefix *);
+extern int peer_group_notify_unconfig(struct peer_group *group);
 
 extern int peer_activate(struct peer *, afi_t, safi_t);
 extern int peer_deactivate(struct peer *, afi_t, safi_t);