net: NetworkMonitor: set NETLINK_CAP_ACK on netlink socket
This allows the kernel to exclude the payload of the original
netlink message from a NLMSG_ERROR message. We use the sequence
number in nlmsghdr to keep track of replies, so we can safely
enable this (minor) optimization.
Change-Id: Ib02b36346fa20045ca4eb9f77c79688fd45c6525
diff --git a/ndn-cxx/net/impl/netlink-socket.cpp b/ndn-cxx/net/impl/netlink-socket.cpp
index 6c60e6b..cfc9e08 100644
--- a/ndn-cxx/net/impl/netlink-socket.cpp
+++ b/ndn-cxx/net/impl/netlink-socket.cpp
@@ -34,6 +34,9 @@
#ifndef SOL_NETLINK
#define SOL_NETLINK 270
#endif
+#ifndef NETLINK_CAP_ACK
+#define NETLINK_CAP_ACK 10
+#endif
#ifndef RTEXT_FILTER_SKIP_STATS
#define RTEXT_FILTER_SKIP_STATS (1 << 3)
#endif
@@ -99,6 +102,12 @@
m_pid = addr.nl_pid;
NDN_LOG_TRACE("our pid is " << m_pid);
+ // tell the kernel it doesn't need to include the original payload in ACK messages
+ if (::setsockopt(fd, SOL_NETLINK, NETLINK_CAP_ACK, &one, sizeof(one)) < 0) {
+ // not a fatal error
+ NDN_LOG_DEBUG("setting NETLINK_CAP_ACK failed: " << std::strerror(errno));
+ }
+
#ifdef NDN_CXX_HAVE_NETLINK_EXT_ACK
// enable extended ACK reporting
if (::setsockopt(fd, SOL_NETLINK, NETLINK_EXT_ACK, &one, sizeof(one)) < 0) {