netlink: drop libnl3 dependency

From libnl3, we only used the helper function to parse/generate netlink
messages and the socket functions to send/receive messages. We don't
need an external dependency to do that, it is simple enough.

Drop the libnl3 dependency, and replace all missing code by directly
copying it from libnl3 sources. At this point, I mostly tried to
import the required bits to make it working with few modifications.

Note that this increases the binary size of NetworkManager by 4736 bytes
for contrib/rpm build on x86_64. In the future, we can simplify the code
further.

A few modifications from libnl3 are:

- netlink errors NLE_* are now in the domain or regular errno.
  The distinction of having to bother with two kinds of error
  number domains was annoying.

- parts of the callback handling is copied partially and unused parts
  are dropped. Especially, the verbose/debug handlers are not used.
  In following commits, the callback handling will be significantly
  simplified.

- the complex handling of seleting ports was simplified. We now always
  let kernel choose the right port automatically.
This commit is contained in:
Thomas Haller
2018-02-15 16:54:30 +01:00
parent ffbad3d0e8
commit 3fab322a20
12 changed files with 1934 additions and 60 deletions

View File

@@ -21,6 +21,7 @@
#include "nm-linux-platform.h"
#include <poll.h>
#include <endian.h>
#include <errno.h>
#include <unistd.h>
@@ -3951,7 +3952,7 @@ _nlh_seq_next_get (NMLinuxPlatformPrivate *priv)
* @response_type:
* @response_out_data:
*
* Returns: 0 on success or a negative errno. Beware, it's an errno, not nlerror.
* Returns: 0 on success or a negative errno.
*/
static int
_nl_send_nlmsghdr (NMPlatform *platform,
@@ -6514,6 +6515,9 @@ continue_reading:
n = -_NLE_MSG_TRUNC;
break;
}
case -ENOBUFS:
n = -_NLE_NM_NOBUFS;
break;
case -NLE_NOMEM:
if (errno == ENOBUFS) {
/* we are very much interested in a overrun of the receive buffer.