summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDonald Sharp <donaldsharp72@gmail.com>2024-02-02 12:51:35 -0500
committerGitHub <noreply@github.com>2024-02-02 12:51:35 -0500
commit3d57f0439533f415b0ab1c95e5fed15e099a32c3 (patch)
treea6b7a68a2b17eb3c4f3aded966cba85c83ed6b54
parent080054686fbfb30272106c5a18cf0f984cfb818f (diff)
parent42c1652dcb744d41178df1f5acad1e0d10cdf42b (diff)
Merge pull request #10151 from pguibert6WIND/ensure_routing_protocols_good_bw
zebra: avoid having speed set to UINT32_MAX
-rw-r--r--doc/user/zebra.rst5
-rw-r--r--lib/libospf.h2
-rw-r--r--ospf6d/ospf6_interface.h2
-rw-r--r--yang/frr-zebra.yang2
-rw-r--r--zebra/if_netlink.c13
-rw-r--r--zebra/interface.c6
-rw-r--r--zebra/interface.h3
-rw-r--r--zebra/zebra_cli.c2
8 files changed, 22 insertions, 13 deletions
diff --git a/doc/user/zebra.rst b/doc/user/zebra.rst
index 9199404f3e..a80580ec71 100644
--- a/doc/user/zebra.rst
+++ b/doc/user/zebra.rst
@@ -184,10 +184,9 @@ Standard Commands
Enable or disable multicast flag for the interface.
-.. clicmd:: bandwidth (1-10000000)
+.. clicmd:: bandwidth (1-1000000)
-
- Set bandwidth value of the interface in kilobits/sec. This is for
+ Set bandwidth value of the interface in Megabits/sec. This is for
calculating OSPF cost. This command does not affect the actual device
configuration.
diff --git a/lib/libospf.h b/lib/libospf.h
index 9a643256c2..45e7fb1870 100644
--- a/lib/libospf.h
+++ b/lib/libospf.h
@@ -61,7 +61,7 @@ extern "C" {
#define OSPF_TRANSMIT_DELAY_DEFAULT 1
#define OSPF_DEFAULT_BANDWIDTH 10000 /* Mbps */
-#define OSPF_DEFAULT_REF_BANDWIDTH 100000 /* Mbps */
+#define OSPF_DEFAULT_REF_BANDWIDTH 100000 /* Kbps */
#define OSPF_POLL_INTERVAL_DEFAULT 60
#define OSPF_NEIGHBOR_PRIORITY_DEFAULT 0
diff --git a/ospf6d/ospf6_interface.h b/ospf6d/ospf6_interface.h
index 2b42af390a..46a7c90dc7 100644
--- a/ospf6d/ospf6_interface.h
+++ b/ospf6d/ospf6_interface.h
@@ -231,7 +231,7 @@ extern const char *const ospf6_interface_state_str[];
#define OSPF6_INTERFACE_TRANSDELAY 1
#define OSPF6_INTERFACE_INSTANCE_ID 0
#define OSPF6_INTERFACE_BANDWIDTH 10000 /* Mbps */
-#define OSPF6_REFERENCE_BANDWIDTH 100000 /* Mbps */
+#define OSPF6_REFERENCE_BANDWIDTH 100000 /* Kbps */
#define OSPF6_INTERFACE_SSO_RETRY_INT 1
#define OSPF6_INTERFACE_SSO_RETRY_MAX 5
diff --git a/yang/frr-zebra.yang b/yang/frr-zebra.yang
index 564617103b..c338a23af0 100644
--- a/yang/frr-zebra.yang
+++ b/yang/frr-zebra.yang
@@ -2050,7 +2050,7 @@ module frr-zebra {
leaf bandwidth {
type uint32 {
- range "1..100000";
+ range "1..1000000";
}
units "megabits/sec";
description
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c
index 551ef6533e..5f096e3039 100644
--- a/zebra/if_netlink.c
+++ b/zebra/if_netlink.c
@@ -261,6 +261,7 @@ static uint32_t get_iflink_speed(struct interface *interface, int *error)
int sd;
int rc;
const char *ifname = interface->name;
+ uint32_t ret;
if (error)
*error = 0;
@@ -285,7 +286,7 @@ static uint32_t get_iflink_speed(struct interface *interface, int *error)
ifname, errno, safe_strerror(errno));
/* no vrf socket creation may probably mean vrf issue */
if (error)
- *error = -1;
+ *error = INTERFACE_SPEED_ERROR_READ;
return 0;
}
/* Get the current link state for the interface */
@@ -299,14 +300,20 @@ static uint32_t get_iflink_speed(struct interface *interface, int *error)
ifname, errno, safe_strerror(errno));
/* no device means interface unreachable */
if (errno == ENODEV && error)
- *error = -1;
+ *error = INTERFACE_SPEED_ERROR_READ;
ecmd.speed_hi = 0;
ecmd.speed = 0;
}
close(sd);
- return ((uint32_t)ecmd.speed_hi << 16) | ecmd.speed;
+ ret = ((uint32_t)ecmd.speed_hi << 16) | ecmd.speed;
+ if (ret == UINT32_MAX) {
+ if (error)
+ *error = INTERFACE_SPEED_ERROR_UNKNOWN;
+ ret = 0;
+ }
+ return ret;
}
uint32_t kernel_get_speed(struct interface *ifp, int *error)
diff --git a/zebra/interface.c b/zebra/interface.c
index 6e33d7ec7d..6624eb2591 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -62,7 +62,7 @@ static void if_zebra_speed_update(struct event *thread)
* interfaces not available.
* note that loopback & virtual interfaces can return 0 as speed
*/
- if (error < 0)
+ if (error == INTERFACE_SPEED_ERROR_READ)
return;
if (new_speed != ifp->speed) {
@@ -73,7 +73,7 @@ static void if_zebra_speed_update(struct event *thread)
changed = true;
}
- if (changed || new_speed == UINT32_MAX) {
+ if (changed || error == INTERFACE_SPEED_ERROR_UNKNOWN) {
#define SPEED_UPDATE_SLEEP_TIME 5
#define SPEED_UPDATE_COUNT_MAX (4 * 60 / SPEED_UPDATE_SLEEP_TIME)
/*
@@ -88,7 +88,7 @@ static void if_zebra_speed_update(struct event *thread)
* to not update the system to keep track of that. This
* is far simpler to just stop trying after 4 minutes
*/
- if (new_speed == UINT32_MAX &&
+ if (error == INTERFACE_SPEED_ERROR_UNKNOWN &&
zif->speed_update_count == SPEED_UPDATE_COUNT_MAX)
return;
diff --git a/zebra/interface.h b/zebra/interface.h
index fc6850e80e..7d633f32d2 100644
--- a/zebra/interface.h
+++ b/zebra/interface.h
@@ -201,6 +201,9 @@ struct zebra_if {
ifindex_t link_ifindex;
struct interface *link;
+#define INTERFACE_SPEED_ERROR_READ -1
+#define INTERFACE_SPEED_ERROR_UNKNOWN -2
+
uint8_t speed_update_count;
struct event *speed_update;
diff --git a/zebra/zebra_cli.c b/zebra/zebra_cli.c
index 76b2df157e..8fedcfedc0 100644
--- a/zebra/zebra_cli.c
+++ b/zebra/zebra_cli.c
@@ -194,7 +194,7 @@ static void lib_interface_zebra_enabled_cli_write(struct vty *vty,
DEFPY_YANG (bandwidth_if,
bandwidth_if_cmd,
- "[no] bandwidth ![(1-100000)]$bw",
+ "[no] bandwidth ![(1-1000000)]$bw",
NO_STR
"Set bandwidth informational parameter\n"
"Bandwidth in megabits\n")