Commit 04e8cc38 authored by Joanne Hugé's avatar Joanne Hugé

Compile extended ack reporting only for kernel >= 4.12

parent c6c00908
......@@ -39,6 +39,7 @@ THE SOFTWARE.
#include <sys/socket.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/version.h>
#include <net/if_arp.h>
/* From <linux/if_bridge.h> */
......@@ -73,6 +74,10 @@ THE SOFTWARE.
memcpy(d, RTA_DATA(rta), 16); \
} while(0)
/* extended ACK reporting was introduced in Linux by commit
2d4bc93368f5a0ddb57c8c885cdad9c9b7a10ed5 first released as 4.12 */
#define EXTENDED_ACK_REPORTING (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0))
int export_table = -1, import_tables[MAX_IMPORT_TABLES], import_table_count = 0;
struct sysctl_setting {
......@@ -319,10 +324,12 @@ netlink_socket(struct netlink *nl, uint32_t groups)
}
}
#if EXTENDED_ACK_REPORTING
rc = setsockopt(nl->sock, SOL_NETLINK, NETLINK_EXT_ACK,
&one, sizeof(one));
if(rc < 0)
perror("Warning: couldn't enable netlink extended acks");
#endif
rc = bind(nl->sock, (struct sockaddr *)&nl->sockaddr, nl->socklen);
if(rc < 0)
......@@ -354,6 +361,7 @@ netlink_socket(struct netlink *nl, uint32_t groups)
static int netlink_get_extack(struct nlmsghdr *nh, int len, int done)
{
#if EXTENDED_ACK_REPORTING
const char *msg = NULL;
struct nlattr *nla;
......@@ -378,6 +386,7 @@ static int netlink_get_extack(struct nlmsghdr *nh, int len, int done)
if(msg && *msg != '\0')
kdebugf(" extack: '%s' ", msg);
#endif
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment