]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Add `clear bgp capabilities` command to resend some dynamic capabilities
authorDonatas Abraitis <donatas@opensourcerouting.org>
Fri, 6 Oct 2023 14:41:18 +0000 (17:41 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Fri, 20 Oct 2023 06:36:33 +0000 (09:36 +0300)
For instance, it's not possible to resend FQDN capability without resetting
the session, so let's create some more elegant way to do that.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h

index fca9e2ad8e3c926d2d4548115beb44324be20108..bce4be97259af431c9314fdfa3feef2b63bcfc53 100644 (file)
@@ -10572,7 +10572,7 @@ static int bgp_clear_prefix(struct vty *vty, const char *view_name,
 /* one clear bgp command to rule them all */
 DEFUN (clear_ip_bgp_all,
        clear_ip_bgp_all_cmd,
-       "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D$neighbor|X:X::X:X$neighbor|WORD$neighbor|ASNUM|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out|message-stats>]",
+       "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D$neighbor|X:X::X:X$neighbor|WORD$neighbor|ASNUM|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out|message-stats|capabilities>]",
        CLEAR_STR
        IP_STR
        BGP_STR
@@ -10595,7 +10595,8 @@ DEFUN (clear_ip_bgp_all,
        BGP_SOFT_IN_STR
        "Push out prefix-list ORF and do inbound soft reconfig\n"
        BGP_SOFT_OUT_STR
-       "Reset message statistics\n")
+       "Reset message statistics\n"
+       "Resend capabilities\n")
 {
        char *vrf = NULL;
 
@@ -10652,7 +10653,7 @@ DEFUN (clear_ip_bgp_all,
                clr_sort = clear_external;
        }
 
-       /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats>] */
+       /* [<soft [<in|out>]|in [prefix-filter]|out|message-stats|capabilities>] */
        if (argv_find(argv, argc, "soft", &idx)) {
                if (argv_find(argv, argc, "in", &idx)
                    || argv_find(argv, argc, "out", &idx))
@@ -10669,6 +10670,8 @@ DEFUN (clear_ip_bgp_all,
                clr_type = BGP_CLEAR_SOFT_OUT;
        } else if (argv_find(argv, argc, "message-stats", &idx)) {
                clr_type = BGP_CLEAR_MESSAGE_STATS;
+       } else if (argv_find(argv, argc, "capabilities", &idx)) {
+               clr_type = BGP_CLEAR_CAPABILITIES;
        } else
                clr_type = BGP_CLEAR_SOFT_NONE;
 
index 04c06b94d8ac41536a32bc9d2023806bd93e7a58..0a01d719687f8a5017801206f6e03a5e39e7fcf0 100644 (file)
@@ -8046,6 +8046,16 @@ static void peer_reset_message_stats(struct peer *peer)
        }
 }
 
+/* Helper function to resend some BGP capabilities that are uncontrolled.
+ * For instance, FQDN capability, that can't be turned off, but let's say
+ * we changed the hostname, we need to resend it.
+ */
+static void peer_clear_capabilities(struct peer *peer, afi_t afi, safi_t safi)
+{
+       bgp_capability_send(peer, afi, safi, CAPABILITY_CODE_FQDN,
+                           CAPABILITY_ACTION_SET);
+}
+
 /*
  * If peer clear is invoked in a loop for all peers on the BGP instance,
  * it may end up freeing the doppelganger, and if this was the next node
@@ -8154,6 +8164,9 @@ int peer_clear_soft(struct peer *peer, afi_t afi, safi_t safi,
        if (stype == BGP_CLEAR_MESSAGE_STATS)
                peer_reset_message_stats(peer);
 
+       if (stype == BGP_CLEAR_CAPABILITIES)
+               peer_clear_capabilities(peer, afi, safi);
+
        return 0;
 }
 
index bc2008b78ba279410d55d1ebc03ab64392b1f7a8..22082aa52e080a788e346ed399fdc31d0b198722 100644 (file)
@@ -2073,7 +2073,8 @@ enum bgp_clear_type {
        BGP_CLEAR_SOFT_IN,
        BGP_CLEAR_SOFT_BOTH,
        BGP_CLEAR_SOFT_IN_ORF_PREFIX,
-       BGP_CLEAR_MESSAGE_STATS
+       BGP_CLEAR_MESSAGE_STATS,
+       BGP_CLEAR_CAPABILITIES,
 };
 
 /* Macros. */