From 51cb6aee4b699d4f2fcf0f913a15cbbc6ff11598 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Wed, 15 Apr 2020 15:16:11 +0200 Subject: [PATCH 1/3] zebra: fix speed set to UINT32_MAX get_iflink_speed() returns UINT32_MAX when the speeds is unknown. Routing daemons (at least ospfd) interprets it as the high value. Return errors in get_iflink_speed() to avoid the confusion. Signed-off-by: Philippe Guibert Signed-off-by: Louis Scalbert --- zebra/if_netlink.c | 13 ++++++++++--- zebra/interface.c | 6 +++--- zebra/interface.h | 3 +++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index 551ef6533ed5..5f096e3039b1 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 6e33d7ec7d11..6624eb259165 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 fc6850e80ed5..7d633f32d2ea 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; From e3c62b2aeb869002051d06b2a76eaf539f96b176 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Wed, 22 Apr 2020 13:33:20 +0200 Subject: [PATCH 2/3] doc, yang, zebra: allow bandwidth up to 1 terabit/sec Allow bandwidth up to 1000000 Mb/s (ie. 1 Tb/s) and document it. Signed-off-by: Philippe Guibert Signed-off-by: Louis Scalbert --- doc/user/zebra.rst | 5 ++--- yang/frr-zebra.yang | 2 +- zebra/zebra_cli.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/user/zebra.rst b/doc/user/zebra.rst index 9199404f3e4a..a80580ec71cb 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/yang/frr-zebra.yang b/yang/frr-zebra.yang index 564617103b98..c338a23af08a 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/zebra_cli.c b/zebra/zebra_cli.c index 296f03ae892e..a00698e8c7bd 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") From 42c1652dcb744d41178df1f5acad1e0d10cdf42b Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Wed, 29 Apr 2020 10:05:19 +0200 Subject: [PATCH 3/3] lib,ospf6d: fix reference bandwidth description Fix reference bandwidth description. It is Kbps, not Mbps. Signed-off-by: Philippe Guibert Signed-off-by: Louis Scalbert --- lib/libospf.h | 2 +- ospf6d/ospf6_interface.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libospf.h b/lib/libospf.h index 9a643256c23d..45e7fb187069 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 2b42af390a0c..46a7c90dc74b 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