summaryrefslogtreecommitdiff
path: root/src/platform/nm-netlink.c
Commit message (Collapse)AuthorAgeFilesLines
* platform: move genl_ctrl_resolve to nm-netlink.cJavier Arteaga2018-03-301-0/+68
| | | | | | | Move genl_ctrl_resolve out of the wifi code so it can be reused by other interfaces based on genetlink. https://mail.gnome.org/archives/networkmanager-list/2018-March/msg00044.html
* platform: print error message from netlink extended ackBeniamino Galvani2018-03-091-0/+20
| | | | | | | | | | | | | | 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. Examples: platform-linux: netlink: recvmsg: error message from kernel: Network is unreachable (101) "Nexthop has invalid gateway" for request 12 platform-linux: netlink: recvmsg: error message from kernel: Invalid argument (22) "Local address cannot be multicast" for request 21 [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2d4bc93368f5a0ddb57c8c885cdad9c9b7a10ed5
* platform: cleanup error handling in event_handler_recvmsgs()Thomas Haller2018-02-211-4/+4
| | | | | | Now that we cleaned up nl_recv(), we have full control over which error variables are returned when. We no longer need to check "errno" directly, and we no longer need the NLE_USER_* workaround.
* netlink: various cleanups and use cleanup attributeThomas Haller2018-02-211-27/+28
| | | | | | | | | | - adjust some coding style (space after function name). - ensure to use g_free(), as we no longer use malloc but the g_malloc aliases. Nowadays, glib's malloc is identical to malloc from the standard library and so this is no issue in practice. Still it's bad style to mix g_malloc() with free(). - use cleanup attribute for memory handling.
* netlink: use slice allocator for "struct nl_msg"Thomas Haller2018-02-211-61/+38
|
* netlink: use glib allocator functions for nlmsg_alloc*()Thomas Haller2018-02-211-66/+21
| | | | | | | | | Glib is not out of memory safe, meaning it always aborts the program when an allocation fails. It is not possible to meaningfully handle out of memory when using glib. Replace all allocation functions for netlink message with their glib counter part and remove the NULL checks.
* netlink: simplify netlink callback handlingThomas Haller2018-02-211-184/+44
| | | | | | | | | | | | | | | | With libnl3, each socket has it's own callback structure. One would often take that callback structure, clone it, modify it and invoke a receive operation with it. We don't need this complexity. We got rid of all default handlers, hence, by default all callbacks are unset. The only callbacks that are set, are those that we specify immediately before invoking the receive operation. Just pass the callback structure at that point. Also, no more ref-counting, and cloning of the callback structure. It is so simple, just stack allocate one if you need it.
* netlink: drop redundant nl_recvmsgs_report() functionThomas Haller2018-02-211-13/+2
| | | | | | The only difference between nl_recvmsgs_report() and nl_recvmsgs() is the return value on success. libnl3 couldn't change that for backward compatibility reasons. We can merge them.
* netlink: drop unused callback typesThomas Haller2018-02-211-62/+17
|
* netlink: remove unused callback hooksThomas Haller2018-02-211-53/+9
|
* netlink: refactor error numbers from netlinkThomas Haller2018-02-211-34/+68
| | | | | | | | | | | | | | | | | | | Originally, these were error numbers from libnl3. These error numbers are separate from errno, which is unfortunate, because sometimes we care about the native errno returned from kernel. Now, refactor them so that the error numbers are in the shared realm of errno, but failures from kernel or underlying API are still returned via their native errno. - NLE_INVAL doesn't exist anymore. Passing invalid arguments to a function is commonly a bug. g_return_*(NLE_BUG) is the right answer to that. - NLE_NOMEM and NLE_AGAIN is replaced by their errno counterparts. - drop several error numbers. If nobody cares about these numbers, there is no reason to have a specific error number for them. NLE_UNSPEC is sufficient.
* netlink: drop libnl3 dependencyThomas Haller2018-02-211-3/+1453
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* netlink: move nl_nlmsghdr_to_str() to netlink headerThomas Haller2018-02-211-0/+104
|
* platform: move genl functions to nm-netlink.cThomas Haller2018-01-151-0/+97
| | | | | So they can be reused outside of wifi, like for implementing wireguard support.
* platform: add nm-netlink.h for netlink related helper functionsThomas Haller2018-01-151-0/+25
Especially useful, because we don't link against libnl-genl-3.so but re-implement generic netlink support. Such code should go there so it can be used by various components.