diff --git a/lib/route_types.pl b/lib/route_types.pl index e007de4d69..39af8d0d56 100755 --- a/lib/route_types.pl +++ b/lib/route_types.pl @@ -121,7 +121,10 @@ sub codelist { } $str =~ s/ $//; push @lines, $str . "\\n\" \\\n"; - push @lines, " \" > - selected route, * - FIB route, q - queued, r - rejected, b - backup\\n\\n\""; + push @lines, " \" > - selected route, * - FIB route, q - queued, r - rejected, b - backup\\n\""; + push @lines, " \" t - trapped, o - offload failure\\n\""; + + return join("", @lines); } diff --git a/lib/zclient.h b/lib/zclient.h index f99b3ad743..050877f27a 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -480,6 +480,20 @@ struct zapi_route { * route entry. This mainly is used for backup static routes. */ #define ZEBRA_FLAG_RR_USE_DISTANCE 0x40 +/* + * This flag tells everyone that the route was intentionally + * not offloaded and the route will be sent to the cpu for + * forwarding. This flag makes no sense unless you are in + * an asic offload situation + */ +#define ZEBRA_FLAG_TRAPPED 0x80 +/* + * This flag tells everyone that the route has been + * successfully offloaded to an asic for forwarding. + * This flag makes no sense unless you are in an asic + * offload situation. + */ +#define ZEBRA_FLAG_OFFLOADED 0x100 /* The older XXX_MESSAGE flags live here */ uint32_t message; diff --git a/tests/topotests/lib/topotest.py b/tests/topotests/lib/topotest.py index e34d1cf0be..c3f3730b2a 100644 --- a/tests/topotests/lib/topotest.py +++ b/tests/topotests/lib/topotest.py @@ -628,7 +628,7 @@ def ip4_route_zebra(node, vrf_name=None): lines = output.splitlines() header_found = False while lines and (not lines[0].strip() or not header_found): - if "> - selected route" in lines[0]: + if "o - offload failure" in lines[0]: header_found = True lines = lines[1:] return "\n".join(lines) @@ -654,7 +654,7 @@ def ip6_route_zebra(node, vrf_name=None): lines = output.splitlines() header_found = False while lines and (not lines[0].strip() or not header_found): - if "> - selected route" in lines[0]: + if "o - offload failure" in lines[0]: header_found = True lines = lines[1:] diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 50b1a62d86..c4fe808071 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -643,6 +643,11 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id, return 0; } + if (rtm->rtm_flags & RTM_F_TRAP) + flags |= ZEBRA_FLAG_TRAPPED; + if (rtm->rtm_flags & RTM_F_OFFLOAD) + flags |= ZEBRA_FLAG_OFFLOADED; + /* Route which inserted by Zebra. */ if (selfroute) { flags |= ZEBRA_FLAG_SELFROUTE; diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 3c360901b3..28c33a70fe 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -192,6 +192,14 @@ static char re_status_output_char(const struct route_entry *re, star_p = true; } + if (zrouter.asic_offloaded + && CHECK_FLAG(re->flags, ZEBRA_FLAG_TRAPPED)) + return 't'; + + if (zrouter.asic_offloaded + && !CHECK_FLAG(re->flags, ZEBRA_FLAG_OFFLOADED)) + return 'o'; + if (star_p) return '*'; else @@ -862,6 +870,12 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn, if (CHECK_FLAG(re->status, ROUTE_ENTRY_QUEUED)) json_object_boolean_true_add(json_route, "queued"); + if (CHECK_FLAG(re->flags, ZEBRA_FLAG_TRAPPED)) + json_object_boolean_true_add(json_route, "trapped"); + + if (CHECK_FLAG(re->flags, ZEBRA_FLAG_OFFLOADED)) + json_object_boolean_true_add(json_route, "offloaded"); + if (re->tag) json_object_int_add(json_route, "tag", re->tag);