[Toybox] [PATCH 3/3] Add support for mss, win and irtt to new netlink based display_routes
Eric Molitor
emolitor at molitor.org
Sun May 17 03:09:29 PDT 2020
---
toys/pending/route.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/toys/pending/route.c b/toys/pending/route.c
index 62fde509..4c673172 100644
--- a/toys/pending/route.c
+++ b/toys/pending/route.c
@@ -197,8 +197,13 @@ static void display_routes(void)
char netmask[32] = "0.0.0.0";
char flags[10] = "U";
uint32_t priority = 0;
+ uint32_t mss = 0;
+ uint32_t win = 0;
+ uint32_t irtt = 0;
char if_name[IF_NAMESIZE] = "-";
uint32_t route_netmask;
+ struct rtattr *metric;
+ uint32_t metric_len;
if (!(toys.optflags & FLAG_n)) strcpy(destip, "default");
if (!(toys.optflags & FLAG_n)) strcpy(gateip, "*");
@@ -233,7 +238,18 @@ static void display_routes(void)
break;
case RTA_METRICS:
- //todo: Implement mss, win, irtt
+ metric_len = RTA_PAYLOAD(route_attribute);
+ for (metric = RTA_DATA(route_attribute);
+ RTA_OK(metric, metric_len);
+ metric=RTA_NEXT(metric, metric_len)) {
+ if (metric->rta_type == RTAX_ADVMSS) {
+ mss = *(uint32_t *) RTA_DATA(metric);
+ } else if (metric->rta_type == RTAX_WINDOW) {
+ win = *(uint32_t *) RTA_DATA(metric);
+ } else if (metric->rta_type == RTAX_RTT) {
+ irtt = (*(uint32_t *) RTA_DATA(metric)) / 8;
+ }
+ }
break;
}
@@ -249,7 +265,7 @@ static void display_routes(void)
// IPv4 caching is disabled so hard coding Use to 0
xprintf("%-15.15s %-15.15s %-16s%-6s", destip, gateip, netmask, flags);
if (toys.optflags & FLAG_e) {
- xprintf("%5d %-5d %6d %s\n", 0, 0, 0, if_name);
+ xprintf("%5d %-5d %6d %s\n", mss, win, irtt, if_name);
} else xprintf("%-6d %-2d %7d %s\n", priority, 0, 0, if_name);
}
msg_hdr_ptr = NLMSG_NEXT(msg_hdr_ptr, msg_hdr_len);
--
2.25.1
More information about the Toybox
mailing list