]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Notify "Peer De-configured" after entering 'no neighbor <neighbor> cmd' 5285/head
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Tue, 5 Nov 2019 12:33:31 +0000 (14:33 +0200)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Wed, 6 Nov 2019 18:38:02 +0000 (20:38 +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 17c93ffc38fb92bb4706239e883dd3c780aa4fed..3116e7cad0ae05cfcd3f6536f04b57cc45309e6a 100644 (file)
@@ -3146,14 +3146,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;
                }
@@ -3167,9 +3169,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);
+                       }
                }
        }
 
@@ -3201,6 +3206,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");
@@ -3222,9 +3228,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;
        }
@@ -3582,6 +3589,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 7621d7ef0f52a2f712e6463e3f32eef0940354aa..ffe0dc0e69437e9c14e83e6c9808159bcb071f3b 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 317f200b85cfb62c61adfa5e69e56e08d8f53bf8..e27018407f64c870f3dcbe153dde363e7746ca2f 100644 (file)
@@ -1638,9 +1638,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);