Skip to content

Commit

Permalink
added wireguard, tag:0.0.20191219,
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Murav'jov committed Feb 29, 2020
1 parent a097153 commit c2e547f
Show file tree
Hide file tree
Showing 166 changed files with 60,641 additions and 0 deletions.
1 change: 1 addition & 0 deletions net/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ config INET
Short answer: say Y.

if INET
source "net/wireguard/Kconfig"
source "net/ipv4/Kconfig"
source "net/ipv6/Kconfig"
source "net/netlabel/Kconfig"
Expand Down
1 change: 1 addition & 0 deletions net/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ obj-$(CONFIG_NET) += $(tmp-y)
obj-$(CONFIG_LLC) += llc/
obj-$(CONFIG_NET) += ethernet/ 802/ sched/ netlink/ bpf/
obj-$(CONFIG_NETFILTER) += netfilter/
obj-$(CONFIG_WIREGUARD) += wireguard/
obj-$(CONFIG_INET) += ipv4/
obj-$(CONFIG_TLS) += tls/
obj-$(CONFIG_XFRM) += xfrm/
Expand Down
15 changes: 15 additions & 0 deletions net/wireguard/Kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.

ccflags-y := -O3 -fvisibility=hidden
ccflags-$(CONFIG_WIREGUARD_DEBUG) += -DDEBUG -g
ccflags-y += -D'pr_fmt(fmt)=KBUILD_MODNAME ": " fmt'
ccflags-y += -Wframe-larger-than=2048

wireguard-y := main.o noise.o device.o peer.o timers.o queueing.o send.o receive.o socket.o peerlookup.o allowedips.o ratelimiter.o cookie.o netlink.o

include $(src)/crypto/Kbuild.include
include $(src)/compat/Kbuild.include

obj-$(if $(KBUILD_EXTMOD),m,$(CONFIG_WIREGUARD)) := wireguard.o
33 changes: 33 additions & 0 deletions net/wireguard/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
config WIREGUARD
tristate "IP: WireGuard secure network tunnel"
depends on NET && INET
depends on IPV6 || !IPV6
select NET_UDP_TUNNEL
select DST_CACHE
select CRYPTO
select CRYPTO_ALGAPI
select VFP
select VFPv3 if CPU_V7
select NEON if CPU_V7
select KERNEL_MODE_NEON if CPU_V7
default m
help
WireGuard is a secure, fast, and easy to use replacement for IPsec
that uses modern cryptography and clever networking tricks. It's
designed to be fairly general purpose and abstract enough to fit most
use cases, while at the same time remaining extremely simple to
configure. See www.wireguard.com for more info.

It's safe to say Y or M here, as the driver is very lightweight and
is only in use when an administrator chooses to add an interface.

config WIREGUARD_DEBUG
bool "Debugging checks and verbose messages"
depends on WIREGUARD
help
This will write log messages for handshake and other events
that occur for a WireGuard interface. It will also perform some
extra validation checks and unit tests at various points. This is
only useful for debugging.

Say N here unless you know what you're doing.
81 changes: 81 additions & 0 deletions net/wireguard/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.

KERNELRELEASE ?= $(shell uname -r)
KERNELDIR ?= /lib/modules/$(KERNELRELEASE)/build
PREFIX ?= /usr
DESTDIR ?=
SRCDIR ?= $(PREFIX)/src
DKMSDIR ?= $(SRCDIR)/wireguard
DEPMOD ?= depmod

PWD := $(shell pwd)

all: module tools
debug: module-debug tools-debug

ifneq ($(V),1)
MAKEFLAGS += --no-print-directory
endif

version.h:
@export GIT_CEILING_DIRECTORIES="$$(readlink -f ../..)" && \
ver="#define WIREGUARD_VERSION \"$$(git describe --dirty 2>/dev/null)\"" && \
[ "$$(cat version.h 2>/dev/null)" != "$$ver" ] && \
echo "$$ver" > version.h && \
git update-index --assume-unchanged version.h || true

dkms.conf:
@export GIT_CEILING_DIRECTORIES="$$(readlink -f ../..)" && \
ver="$$(git describe --dirty 2>/dev/null)" && \
. ./dkms.conf && \
[ "$$PACKAGE_VERSION" != "$$ver" ] && \
sed -i "s/PACKAGE_VERSION=.*/PACKAGE_VERSION=\"$$ver\"/" dkms.conf && \
git update-index --assume-unchanged dkms.conf || true

module: version.h
@$(MAKE) -C $(KERNELDIR) M=$(PWD) modules

module-debug: version.h
@$(MAKE) -C $(KERNELDIR) M=$(PWD) V=1 CONFIG_WIREGUARD_DEBUG=y modules

clean:
@$(MAKE) -C $(KERNELDIR) M=$(PWD) clean
@$(MAKE) -C tools clean

module-install:
@$(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
$(DEPMOD) -a $(KERNELRELEASE)

install: module-install tools-install

rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))
DKMS_SOURCES := version.h Makefile Kbuild Kconfig dkms.conf $(filter-out version.h wireguard.mod.c tools/% tests/%,$(call rwildcard,,*.c *.h *.S *.pl *.include))
dkms-install: $(DKMS_SOURCES)
@$(foreach f,$(DKMS_SOURCES),install -v -m0644 -D $(f) $(DESTDIR)$(DKMSDIR)/$(f);)

tools:
@$(MAKE) -C tools

tools-debug:
@$(MAKE) -C tools V=1 DEBUG_TOOLS=y

tools-install:
@$(MAKE) -C tools install

style:
$(KERNELDIR)/scripts/checkpatch.pl -f --max-line-length=4000 --codespell --color=always $(filter-out wireguard.mod.c,$(wildcard *.c)) $(wildcard *.h) $(wildcard selftest/*.c)

check: clean
scan-build --html-title=WireGuard -maxloop 100 --view --keep-going $(MAKE) module tools CONFIG_WIREGUARD_DEBUG=y C=2 CF="-D__CHECK_ENDIAN__"

coccicheck: clean
@$(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_WIREGUARD_DEBUG=y coccicheck MODE=report

cloc:
@cloc --skip-uniqueness --by-file --extract-with="$$(readlink -f ../contrib/kernel-tree/filter-compat-defines.sh) >FILE< > \$$(basename >FILE<)" $(filter-out wireguard.mod.c,$(wildcard *.c)) $(wildcard *.h)

-include tests/debug.mk

.PHONY: all module module-debug module-install tools tools-install install dkms-install clean core-cloc check style version.h dkms.conf

0 comments on commit c2e547f

Please sign in to comment.