]> git.puffer.fish Git - matthieu/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:27:32 +0000 (21:27 +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 141d5cf306d04d706b1970b593b92d680fa931db..e96d2405b252dfe0ea37fba95fb4ee5c44b19cf1 100644 (file)
@@ -3173,14 +3173,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;
                }
@@ -3194,9 +3196,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);
+                       }
                }
        }
 
@@ -3228,6 +3233,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");
@@ -3249,9 +3255,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;
        }
@@ -3609,6 +3616,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 4d780e6f779b10e0c7635de1d001faa569a033e5..8f5d8738413040b5c43577599d9170360eb3b077 100644 (file)
@@ -2562,6 +2562,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 e4f4dc0b5350006d20b4dababe0e10c5eb8b77c8..0625ea13aa65fcd5a57a95033c5ccca153e9bbcd 100644 (file)
@@ -1634,9 +1634,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);