summaryrefslogtreecommitdiff
path: root/zebra/if_netlink.c
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2020-04-15 15:16:11 +0200
committerPhilippe Guibert <philippe.guibert@6wind.com>2024-01-29 14:52:32 +0100
commit51cb6aee4b699d4f2fcf0f913a15cbbc6ff11598 (patch)
tree766bbe0a781462d7e79a01a9dd0bdd8afc919bb1 /zebra/if_netlink.c
parentf8755d7f866d4ae74d01b2ef9baa6829bdb99f63 (diff)
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 <philippe.guibert@6wind.com> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Diffstat (limited to 'zebra/if_netlink.c')
-rw-r--r--zebra/if_netlink.c13
1 files changed, 10 insertions, 3 deletions
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)