]> git.puffer.fish Git - mirror/frr.git/commitdiff
sockopt: add support for querying tcp round-trip-time
authorTimo Teräs <timo.teras@iki.fi>
Wed, 29 Apr 2015 06:43:03 +0000 (09:43 +0300)
committerDaniel Walton <dwalton@cumulusnetworks.com>
Thu, 26 May 2016 15:33:30 +0000 (15:33 +0000)
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit 6b2672f3c9493aef3495192e113f95a7db4b65bc)

lib/sockopt.c
lib/sockopt.h

index be22827f6e2bda2e6d0c0d89578e14a5f2fe7898..257271bc0b9a7ed4776bc4549a286935d938fce1 100644 (file)
@@ -518,6 +518,22 @@ sockopt_iphdrincl_swab_systoh (struct ip *iph)
   iph->ip_id = ntohs(iph->ip_id);
 }
 
+int
+sockopt_tcp_rtt (int sock)
+{
+#ifdef TCP_INFO
+  struct tcp_info ti;
+  socklen_t len = sizeof(ti);
+
+  if (getsockopt (sock, IPPROTO_TCP, TCP_INFO, &ti, &len) != 0)
+    return 0;
+
+  return ti.tcpi_rtt / 1000;
+#else
+  return 0;
+#endif
+}
+
 int
 sockopt_tcp_signature (int sock, union sockunion *su, const char *password)
 {
index aced6d489f916b3ec87cb47c16cfd95e74a49708..cb14efc7baef2254bcd4a65c0195321645f02895 100644 (file)
@@ -100,6 +100,7 @@ extern int getsockopt_ifindex (int, struct msghdr *);
 extern void sockopt_iphdrincl_swab_htosys (struct ip *iph);
 extern void sockopt_iphdrincl_swab_systoh (struct ip *iph);
 
+extern int sockopt_tcp_rtt (int);
 extern int sockopt_tcp_signature(int sock, union sockunion *su,
                                  const char *password);
 #endif /*_ZEBRA_SOCKOPT_H */