summaryrefslogtreecommitdiff
path: root/src/platform/nm-netlink.c
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2018-03-08 17:01:35 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2018-03-08 17:49:18 +0100
commit5e27a30e1d7b64f056d666463aa6c6894531462d (patch)
tree530ce6634fd7545b7bf2ebe15889f305e6a246c1 /src/platform/nm-netlink.c
parent39fde61a5a160ac8be644290226d3cff94c4b342 (diff)
downloadNetworkManager-bg/extack.tar.gz
platform: print error message from netlink extended ackbg/extack
From v4.12 the kernel appends some attributes to netlink acks containing a textual description of the error and other fields (see commit [1]). Parse those attributes and print the error message. Example: platform-linux: netlink: recvmsg: error message from kernel: Network is unreachable (101) "Nexthop has invalid gateway" for request 12 [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2d4bc93368f5a0ddb57c8c885cdad9c9b7a10ed5
Diffstat (limited to 'src/platform/nm-netlink.c')
-rw-r--r--src/platform/nm-netlink.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/platform/nm-netlink.c b/src/platform/nm-netlink.c
index 7d794f7737..0baaaf0b47 100644
--- a/src/platform/nm-netlink.c
+++ b/src/platform/nm-netlink.c
@@ -38,6 +38,10 @@
#define NL_MSG_PEEK_EXPLICIT (1<<4)
#define NL_NO_AUTO_ACK (1<<5)
+#ifndef NETLINK_EXT_ACK
+#define NETLINK_EXT_ACK 11
+#endif
+
#define NL_MSG_CRED_PRESENT 1
struct nl_msg {
@@ -933,6 +937,22 @@ nl_socket_add_memberships (struct nl_sock *sk, int group, ...)
return 0;
}
+int
+nl_socket_set_ext_ack (struct nl_sock *sk, gboolean enable)
+{
+ int err;
+
+ if (sk->s_fd == -1)
+ return -NLE_BAD_SOCK;
+
+ enable = !!enable;
+ err = setsockopt (sk->s_fd, SOL_NETLINK, NETLINK_EXT_ACK, &enable, sizeof (enable));
+ if (err < 0)
+ return -nl_syserr2nlerr (errno);
+
+ return 0;
+}
+
void nl_socket_disable_msg_peek (struct nl_sock *sk)
{
sk->s_flags |= NL_MSG_PEEK_EXPLICIT;