mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-20 08:41:19 -08:00
Copy upstream/drivers/net/wireguard into src and rename only the user-visible identifiers: the module (and thus the rtnl link kind and device type, which come from KBUILD_MODNAME) is now tswg, and the genetlink family is "tswg". The uapi header moves to src/include/uapi/linux/tswg.h so it can't collide with the kernel's. Internal wg_ symbols keep their names to keep upstream merges easy; they aren't exported, so tswg.ko can coexist with wireguard.ko. Add an out-of-tree Kbuild and top-level Makefile, plus scripts/ubuntu-headers.sh, which fetches and unpacks an Ubuntu kernel's headers so we can build for the natlab Ubuntu guest without installing anything. This still only builds against 7.4-era kernels; compat shims follow. Updates #426 Signed-off-by: Brad Fitzpatrick <[email protected]> Change-Id: Ia36ef82a53efbbcdb301ed069785162372efda55
79 lines
1.6 KiB
C
79 lines
1.6 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (C) 2015-2019 Jason A. Donenfeld <[email protected]>. All Rights Reserved.
|
|
*/
|
|
|
|
#include "version.h"
|
|
#include "device.h"
|
|
#include "noise.h"
|
|
#include "queueing.h"
|
|
#include "ratelimiter.h"
|
|
#include "netlink.h"
|
|
|
|
#include <uapi/linux/tswg.h>
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/module.h>
|
|
#include <net/genetlink.h>
|
|
#include <net/rtnetlink.h>
|
|
|
|
static int __init wg_mod_init(void)
|
|
{
|
|
int ret;
|
|
|
|
ret = wg_allowedips_slab_init();
|
|
if (ret < 0)
|
|
goto err_allowedips;
|
|
|
|
#ifdef DEBUG
|
|
ret = -ENOTRECOVERABLE;
|
|
if (!wg_allowedips_selftest() || !wg_packet_counter_selftest() ||
|
|
!wg_ratelimiter_selftest())
|
|
goto err_peer;
|
|
#endif
|
|
wg_noise_init();
|
|
|
|
ret = wg_peer_init();
|
|
if (ret < 0)
|
|
goto err_peer;
|
|
|
|
ret = wg_device_init();
|
|
if (ret < 0)
|
|
goto err_device;
|
|
|
|
ret = wg_genetlink_init();
|
|
if (ret < 0)
|
|
goto err_netlink;
|
|
|
|
pr_info("tswg " TSWG_VERSION " (Tailscale fork of WireGuard " WIREGUARD_VERSION ") loaded.\n");
|
|
pr_info("Copyright (C) 2015-2019 Jason A. Donenfeld <[email protected]>. All Rights Reserved.\n");
|
|
|
|
return 0;
|
|
|
|
err_netlink:
|
|
wg_device_uninit();
|
|
err_device:
|
|
wg_peer_uninit();
|
|
err_peer:
|
|
wg_allowedips_slab_uninit();
|
|
err_allowedips:
|
|
return ret;
|
|
}
|
|
|
|
static void __exit wg_mod_exit(void)
|
|
{
|
|
wg_genetlink_uninit();
|
|
wg_device_uninit();
|
|
wg_peer_uninit();
|
|
wg_allowedips_slab_uninit();
|
|
}
|
|
|
|
module_init(wg_mod_init);
|
|
module_exit(wg_mod_exit);
|
|
MODULE_LICENSE("GPL v2");
|
|
MODULE_DESCRIPTION("Tailscale fork of the WireGuard secure network tunnel");
|
|
MODULE_AUTHOR("Jason A. Donenfeld <[email protected]>");
|
|
MODULE_VERSION(TSWG_VERSION);
|
|
MODULE_ALIAS_RTNL_LINK(KBUILD_MODNAME);
|
|
MODULE_ALIAS_GENL_FAMILY(WG_GENL_NAME);
|