From 0d32fbee6dd4f6f09f3a508b7df2585a8a710718 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 26 Oct 2020 08:46:57 -0400 Subject: [PATCH] lib, zebra: Add ability to read kernel notice of Offload Failed The linux kernel is getting RTM_F_OFFLOAD_FAILED for kernel routes that have failed to offload. Write the code to receive these notifications from the linux kernel and store that data for display about the routes. Signed-off-by: Donald Sharp --- lib/zclient.h | 7 +++++++ zebra/rt_netlink.c | 2 ++ zebra/zebra_vty.c | 5 ++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/zclient.h b/lib/zclient.h index 231fdad09b..3c80ba7efa 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -514,6 +514,13 @@ struct zapi_route { * offload situation. */ #define ZEBRA_FLAG_OFFLOADED 0x100 +/* + * This flag tells everyone that the route has + * failed offloading. + * This flag makes no sense unless you are in an asic + * offload situation. + */ +#define ZEBRA_FLAG_OFFLOAD_FAILED 0x200 /* The older XXX_MESSAGE flags live here */ uint32_t message; diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 4dc8c2a6eb..c0c1c4e7f2 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -672,6 +672,8 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id, flags |= ZEBRA_FLAG_TRAPPED; if (rtm->rtm_flags & RTM_F_OFFLOAD) flags |= ZEBRA_FLAG_OFFLOADED; + if (rtm->rtm_flags & RTM_F_OFFLOAD_FAILED) + flags |= ZEBRA_FLAG_OFFLOAD_FAILED; /* Route which inserted by Zebra. */ if (selfroute) { diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index ab7d2845e7..68487ea245 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -209,7 +209,7 @@ static char re_status_output_char(const struct route_entry *re, return 't'; if (zrouter.asic_offloaded - && !CHECK_FLAG(re->flags, ZEBRA_FLAG_OFFLOADED)) + && CHECK_FLAG(re->flags, ZEBRA_FLAG_OFFLOAD_FAILED)) return 'o'; if (star_p) @@ -870,6 +870,9 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn, if (CHECK_FLAG(re->flags, ZEBRA_FLAG_OFFLOADED)) json_object_boolean_true_add(json_route, "offloaded"); + if (CHECK_FLAG(re->flags, ZEBRA_FLAG_OFFLOAD_FAILED)) + json_object_boolean_false_add(json_route, "offloaded"); + if (re->tag) json_object_int_add(json_route, "tag", re->tag); -- 2.39.5