]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Add a warning for the operator that keepalive was changed 14288/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 29 Aug 2023 12:11:52 +0000 (15:11 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Tue, 29 Aug 2023 12:14:07 +0000 (15:14 +0300)
```
donatas-pc(config-router)# timers bgp 8 12
% keeplive value 8 is larger than 1/3 of the holdtime, setting to 4
donatas-pc(config-router)# do sh run | include timers bgp
 timers bgp 4 12
donatas-pc(config-router)#
```

Closes https://github.com/FRRouting/frr/issues/14287

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

index 445dea92d5aa6457bd917227dd22a8fbdd0f3806..daa8507e3912b76f3feef5cc42f5be144cbd5aa8 100644 (file)
@@ -590,7 +590,7 @@ int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name,
        int ret = bgp_get(bgp, as, name, inst_type, as_pretty, asnotation);
 
        if (ret == BGP_CREATED) {
-               bgp_timers_set(*bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME,
+               bgp_timers_set(NULL, *bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME,
                               DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN);
 
                if (DFLT_BGP_IMPORT_CHECK)
@@ -2661,7 +2661,7 @@ DEFUN (bgp_timers,
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       bgp_timers_set(bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY,
+       bgp_timers_set(vty, bgp, keepalive, holdtime, DFLT_BGP_CONNECT_RETRY,
                       BGP_DEFAULT_DELAYOPEN);
 
        return CMD_SUCCESS;
@@ -2677,7 +2677,7 @@ DEFUN (no_bgp_timers,
        "Holdtime\n")
 {
        VTY_DECLVAR_CONTEXT(bgp, bgp);
-       bgp_timers_set(bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME,
+       bgp_timers_set(vty, bgp, DFLT_BGP_KEEPALIVE, DFLT_BGP_HOLDTIME,
                       DFLT_BGP_CONNECT_RETRY, BGP_DEFAULT_DELAYOPEN);
 
        return CMD_SUCCESS;
index 730c96cdda6630d2af34506aaeef5e5556f64943..60b394b6971f5065cdc55d3006362293018365a3 100644 (file)
@@ -519,11 +519,22 @@ void bgp_cluster_id_unset(struct bgp *bgp)
 }
 
 /* BGP timer configuration.  */
-void bgp_timers_set(struct bgp *bgp, uint32_t keepalive, uint32_t holdtime,
-                   uint32_t connect_retry, uint32_t delayopen)
+void bgp_timers_set(struct vty *vty, struct bgp *bgp, uint32_t keepalive,
+                   uint32_t holdtime, uint32_t connect_retry,
+                   uint32_t delayopen)
 {
-       bgp->default_keepalive =
-               (keepalive < holdtime / 3 ? keepalive : holdtime / 3);
+       uint32_t default_keepalive = holdtime / 3;
+
+       if (keepalive > default_keepalive) {
+               if (vty)
+                       vty_out(vty,
+                               "%% keepalive value %u is larger than 1/3 of the holdtime, setting to %u\n",
+                               keepalive, default_keepalive);
+       } else {
+               default_keepalive = keepalive;
+       }
+
+       bgp->default_keepalive = default_keepalive;
        bgp->default_holdtime = holdtime;
        bgp->default_connect_retry = connect_retry;
        bgp->default_delayopen = delayopen;
index 51e0cb3802a9542f3e72fcfe09532bee0f36e6bc..6aa659adea7d798c9bc07b73b36eec17d09a70cb 100644 (file)
@@ -2254,8 +2254,9 @@ extern void bgp_confederation_peers_add(struct bgp *bgp, as_t as,
                                        const char *as_str);
 extern void bgp_confederation_peers_remove(struct bgp *bgp, as_t as);
 
-extern void bgp_timers_set(struct bgp *, uint32_t keepalive, uint32_t holdtime,
-                          uint32_t connect_retry, uint32_t delayopen);
+extern void bgp_timers_set(struct vty *vty, struct bgp *, uint32_t keepalive,
+                          uint32_t holdtime, uint32_t connect_retry,
+                          uint32_t delayopen);
 extern void bgp_timers_unset(struct bgp *);
 
 extern void bgp_default_local_preference_set(struct bgp *bgp,