aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/device.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* device: use skb accessor functions where possibleJason A. Donenfeld2019-03-251-2/+2
| | | | Suggested-by: David Miller <davem@davemloft.net>
* global: the _bh variety of rcu helpers have been unifiedJason A. Donenfeld2019-03-171-3/+3
|
* peer: only synchronize_rcu_bh and traverse trie once when removing all peersJason A. Donenfeld2019-02-251-1/+0
|
* hashtables: decouple hashtable allocations from the main device allocationSultan Alsawaf2019-02-031-3/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The hashtable allocations are quite large, and cause the device allocation in the net framework to stall sometimes while it tries to find a contiguous region that can fit the device struct: [<0000000000000000>] __switch_to+0x94/0xb8 [<0000000000000000>] __alloc_pages_nodemask+0x764/0x7e8 [<0000000000000000>] kmalloc_order+0x20/0x40 [<0000000000000000>] __kmalloc+0x144/0x1a0 [<0000000000000000>] alloc_netdev_mqs+0x5c/0x368 [<0000000000000000>] rtnl_create_link+0x48/0x180 [<0000000000000000>] rtnl_newlink+0x410/0x708 [<0000000000000000>] rtnetlink_rcv_msg+0x190/0x1f8 [<0000000000000000>] netlink_rcv_skb+0x4c/0xf8 [<0000000000000000>] rtnetlink_rcv+0x30/0x40 [<0000000000000000>] netlink_unicast+0x18c/0x208 [<0000000000000000>] netlink_sendmsg+0x19c/0x348 [<0000000000000000>] sock_sendmsg+0x3c/0x58 [<0000000000000000>] ___sys_sendmsg+0x290/0x2b0 [<0000000000000000>] __sys_sendmsg+0x58/0xa0 [<0000000000000000>] SyS_sendmsg+0x10/0x20 [<0000000000000000>] el0_svc_naked+0x34/0x38 [<0000000000000000>] 0xffffffffffffffff To fix the allocation stalls, decouple the hashtable allocations from the device allocation and allocate the hashtables with kvmalloc's implicit __GFP_NORETRY so that the allocations fall back to vmalloc with little resistance. Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
* queueing: more reasonable allocator function conventionJason A. Donenfeld2019-02-031-1/+1
|
* global: update copyrightJason A. Donenfeld2019-01-071-1/+1
|
* device: do not clear keys on sleep for PM_AUTOSLEEPJason A. Donenfeld2018-10-271-4/+11
| | | | | | | | | | | This way other devices that use Android style wakelocks will also have the same semantics. We also move this logic into the handler so that it's slightly cleaner and gives us some opportunity to leave a normal comment. Suggested-by: Theodore Ts'o <tytso@mit.edu> Suggested-by: Andrew Lunn <andrew@lunn.ch> Suggested-by: Sultan Alsawaf <sultanxda@gmail.com>
* timers: it is always reasonable to remove a timerJason A. Donenfeld2018-10-271-2/+1
| | | | | | | | | | | | | | If struct timer_list has not been setup, it is zeroed, in which case timer_pending is false, so calling del_timer is safe. Calling del_timer is also safe on a timer that has already been del_timer'd. And calling del_timer is safe after a peer is dead, since the whole point of it being dead is that no more timers are created and all contexts eventually stop. Finally del_timer uses a lock, which means it's safe to call it concurrently. Therefore, we do not need any guards around calls to del_timer. While we're at it, we can get rid of the old lingering timers_enabled boolean which wasn't doing anything anyway anymore.
* send: consider dropped stage packets to be droppedJason A. Donenfeld2018-10-271-2/+4
| | | | Suggested-by: Andrew Lunn <andrew@lunn.ch>
* global: give if statements brackets and other cleanupsJason A. Donenfeld2018-10-091-2/+3
|
* device: use textual error labels alwaysJason A. Donenfeld2018-10-081-22/+23
| | | | Suggested-by: Jiri Pirko <jiri@resnulli.us>
* global: more nitsJason A. Donenfeld2018-10-081-4/+4
|
* global: rename struct wireguard_ to struct wg_Jason A. Donenfeld2018-10-081-14/+14
| | | | | | This required a bit of pruning of our christmas trees. Suggested-by: Jiri Pirko <jiri@resnulli.us>
* global: prefix functions used in callbacks with wg_Jason A. Donenfeld2018-10-081-20/+20
| | | | Suggested-by: Jiri Pirko <jiri@resnulli.us>
* global: prefix all functions with wg_Jason A. Donenfeld2018-10-021-36/+37
| | | | | | | | | | | | | I understand why this must be done, though I'm not so happy about having to do it. In some places, it puts us over 80 chars and we have to break lines up in further ugly ways. And in general, I think this makes things harder to read. Yet another thing we must do to please upstream. Maybe this can be replaced in the future by some kind of automatic module namespacing logic in the linker, or even combined with LTO and aggressive symbol stripping. Suggested-by: Andrew Lunn <andrew@lunn.ch>
* global: put SPDX identifier on its own lineJason A. Donenfeld2018-09-201-2/+2
| | | | | The kernel has very specific rules correlating file type with comment type, and also SPDX identifiers can't be merged with other comments.
* global: prefer sizeof(*pointer) when possibleJason A. Donenfeld2018-09-041-3/+2
| | | | Suggested-by: Sultan Alsawaf <sultanxda@gmail.com>
* global: satisfy check_patch.pl errorsJason A. Donenfeld2018-09-031-2/+3
|
* global: run through clang-formatJason A. Donenfeld2018-08-281-37/+58
| | | | | | | This is the worst commit in the whole repo, making the code much less readable, but so it goes with upstream maintainers. We are now woefully wrapped at 80 columns.
* send: switch handshake stamp to an atomicJason A. Donenfeld2018-08-041-1/+1
| | | | | | | | | | | Rather than abusing the handshake lock, we're much better off just using a boring atomic64 for this. It's simpler and performs better. Also, while we're at it, we set the handshake stamp both before and after the calculations, in case the calculations block for a really long time waiting for the RNG to initialize. Otherwise it's possible that when the RNG finally initializes, two handshakes are sent back to back, which isn't sensible.
* device: adjust commentJason A. Donenfeld2018-07-311-1/+1
| | | | Suggested-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
* device: destroy workqueue before freeing queueJason A. Donenfeld2018-07-181-1/+1
|
* device: print daddr not saddr in missing peer errorJason A. Donenfeld2018-07-041-1/+4
|
* global: use fast boottime instead of normal boottimeJason A. Donenfeld2018-06-231-1/+1
| | | | Generally if we're inaccurate by a few nanoseconds, it doesn't matter.
* global: use ktime boottime instead of jiffiesJason A. Donenfeld2018-06-231-1/+1
| | | | | | | | Since this is a network protocol, expirations need to be accounted for, even across system suspend. On real systems, this isn't a problem, since we're clearing all keys before suspend. But on Android, where we don't do that, this is something of a problem. So, we switch to using boottime instead of jiffies.
* device: do not assume dst is always validJason A. Donenfeld2018-05-311-1/+1
| | | | | | The new flow offloading feature at the moment does not set the dst. We have a patch pending to fix this upstream, but in the meantime, work around it here.
* device: remove allowedips before individual peersJason A. Donenfeld2018-05-181-1/+1
| | | | This avoids an O(n^2) traversal in favor of an O(n) one.
* send: account for route-based MTUJason A. Donenfeld2018-04-151-0/+5
| | | | | | | | | | It might be that a particular route has a different MTU than the interface, via `ip route add ... dev wg0 mtu 1281`, for example. In this case, it's important that we don't accidently pad beyond the end of the MTU. We accomplish that in this patch by carrying forward the MTU from the dst if it exists. We also add a unit test for this issue. Reported-by: Roman Mamedov <rm.wg@romanrm.net>
* device: let udev know what kind of device we areJason A. Donenfeld2018-01-301-0/+6
|
* global: year bumpJason A. Donenfeld2018-01-031-1/+1
|
* global: add SPDX tags to all filesGreg Kroah-Hartman2017-12-091-1/+4
| | | | | | | | | | | | | It's good to have SPDX identifiers in all files as the Linux kernel developers are working to add these identifiers to all files. Update all files with the correct SPDX license identifier based on the license text of the project or based on the license in the file itself. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Modified-by: Jason A. Donenfeld <Jason@zx2c4.com>
* device: clear last handshake timer on ifdownJason A. Donenfeld2017-11-291-0/+1
| | | | | | | Otherwise new handshakes might not occur immediately when the interface goes up and down. Also initialize peers to having a proper zeroed handshake jiffies.
* device: do not clear keys during sleep on AndroidJason A. Donenfeld2017-11-281-4/+4
| | | | | | This makes sense for the security model of laptops, but not for clicking phones on and off, where we actually want to be able to handle incoming packets.
* device: uninitialize socket first in destructionJason A. Donenfeld2017-11-171-2/+2
|
* socket: only free socket after successful creation of newJason A. Donenfeld2017-11-171-3/+3
| | | | | | | | | | | | | | When an interface is down, the socket port can change freely. A socket will be allocated when the interface comes up, and if a socket can't be allocated, the interface doesn't come up. However, a socket port can change while the interface is up. In this case, if a new socket with a new port cannot be allocated, it's important to keep the interface in a consistent state. The choices are either to bring down the interface or to preserve the old socket. This patch implements the latter. Reported-by: Marc-Antoine Perennou <keruspe@exherbo.org>
* allowedips: rename from routingtableJason A. Donenfeld2017-11-101-3/+3
| | | | Makes it more clear that this _not_ a routing table replacement.
* device: wait for all peers to be freed before destroyingJason A. Donenfeld2017-11-101-0/+1
|
* device: please lockdepJason A. Donenfeld2017-11-031-1/+1
|
* device: expand scope of destruct lockJason A. Donenfeld2017-10-311-2/+2
|
* device: only take reference if netns is differentJason A. Donenfeld2017-10-311-9/+50
| | | | | | If we take two references, the namespace and the device are never freed in the usual manner. We should thus only take a reference to another namespace when it is a different namespace from our own.
* global: style nitsJason A. Donenfeld2017-10-311-4/+8
|
* global: infuriating kernel iterator styleJason A. Donenfeld2017-10-311-4/+4
| | | | | | | | | | | | | | | | | One types: for (i = 0 ... So one should also type: for_each_obj (obj ... But the upstream kernel style guidelines are insane, and so we must instead do: for_each_obj(obj ... Ugly, but one must choose his battles wisely.
* peer: get rid of peer_for_each magicJason A. Donenfeld2017-10-311-6/+12
| | | | | | | | | Since the peer list is protected by the device_update_lock, and since items are removed from the peer list before putting their final reference, we don't actually need to take a reference when iterating. This allows us to simplify the macro considerably. Suggested-by: Johannes Berg <johannes@sipsolutions.net>
* global: accept decent check_patch.pl suggestionsJason A. Donenfeld2017-10-311-1/+2
|
* device: no need to take lock for integer comparisonJason A. Donenfeld2017-10-171-4/+3
|
* device: our use of queues means this check is worthlessJason A. Donenfeld2017-10-171-6/+0
|
* compat: move version logic to compat.h and out of main .cJason A. Donenfeld2017-10-111-6/+6
|
* routingtable: only use device's mutex, not a special rt oneJason A. Donenfeld2017-10-091-1/+1
|
* queueing: use ptr_ring instead of linked listsJason A. Donenfeld2017-10-051-6/+6
|
* global: add space around variable declarationsJason A. Donenfeld2017-10-031-1/+2
|