2021-10-19 10:43:28 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
#
|
|
|
|
# PASST - Plug A Simple Socket Transport
|
|
|
|
# for qemu/UNIX domain socket mode
|
|
|
|
#
|
|
|
|
# PASTA - Pack A Subtle Tap Abstraction
|
|
|
|
# for network namespace/tap device mode
|
|
|
|
#
|
|
|
|
# Copyright (c) 2021 Red Hat GmbH
|
|
|
|
# Author: Stefano Brivio <sbrivio@redhat.com>
|
|
|
|
|
2022-01-25 18:07:05 +00:00
|
|
|
RLIMIT_STACK_VAL := $(shell /bin/sh -c 'ulimit -s')
|
|
|
|
ifeq ($(RLIMIT_STACK_VAL),unlimited)
|
|
|
|
RLIMIT_STACK_VAL := 1024
|
|
|
|
endif
|
|
|
|
|
2022-09-26 10:43:45 +00:00
|
|
|
TARGET := $(shell $(CC) -dumpmachine)
|
2022-02-28 15:18:44 +00:00
|
|
|
# Get 'uname -m'-like architecture description for target
|
2022-09-26 10:43:45 +00:00
|
|
|
TARGET_ARCH := $(shell echo $(TARGET) | cut -f1 -d- | tr [A-Z] [a-z])
|
2022-09-23 09:56:30 +00:00
|
|
|
TARGET_ARCH := $(shell echo $(TARGET_ARCH) | sed 's/powerpc/ppc/')
|
2022-02-28 15:18:44 +00:00
|
|
|
|
2022-09-23 09:56:30 +00:00
|
|
|
AUDIT_ARCH := $(shell echo $(TARGET_ARCH) | tr [a-z] [A-Z] | sed 's/^ARM.*/ARM/')
|
2022-01-25 18:07:05 +00:00
|
|
|
AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/I[456]86/I386/')
|
|
|
|
AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/PPC64/PPC/')
|
|
|
|
AUDIT_ARCH := $(shell echo $(AUDIT_ARCH) | sed 's/PPCLE/PPC64LE/')
|
|
|
|
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
FLAGS := -Wall -Wextra -pedantic -std=c99 -D_XOPEN_SOURCE=700 -D_GNU_SOURCE
|
|
|
|
FLAGS += -D_FORTIFY_SOURCE=2 -O2 -pie -fPIE
|
|
|
|
FLAGS += -DPAGE_SIZE=$(shell getconf PAGE_SIZE)
|
|
|
|
FLAGS += -DNETNS_RUN_DIR=\"/run/netns\"
|
|
|
|
FLAGS += -DPASST_AUDIT_ARCH=AUDIT_ARCH_$(AUDIT_ARCH)
|
|
|
|
FLAGS += -DRLIMIT_STACK_VAL=$(RLIMIT_STACK_VAL)
|
|
|
|
FLAGS += -DARCH=\"$(TARGET_ARCH)\"
|
2020-07-13 20:55:46 +00:00
|
|
|
|
2022-06-14 05:12:21 +00:00
|
|
|
PASST_SRCS = arch.c arp.c checksum.c conf.c dhcp.c dhcpv6.c icmp.c igmp.c \
|
2022-09-24 07:53:15 +00:00
|
|
|
isolation.c lineread.c log.c mld.c ndp.c netlink.c packet.c passt.c \
|
|
|
|
pasta.c pcap.c siphash.c tap.c tcp.c tcp_splice.c udp.c util.c
|
2022-06-14 05:12:21 +00:00
|
|
|
QRAP_SRCS = qrap.c
|
|
|
|
SRCS = $(PASST_SRCS) $(QRAP_SRCS)
|
|
|
|
|
2022-06-14 05:12:22 +00:00
|
|
|
MANPAGES = passt.1 pasta.1 qrap.1
|
|
|
|
|
2022-06-14 05:12:21 +00:00
|
|
|
PASST_HEADERS = arch.h arp.h checksum.h conf.h dhcp.h dhcpv6.h icmp.h \
|
2022-09-12 12:24:03 +00:00
|
|
|
isolation.h lineread.h ndp.h netlink.h packet.h passt.h pasta.h \
|
2022-09-24 09:08:16 +00:00
|
|
|
pcap.h port_fwd.h siphash.h tap.h tcp.h tcp_splice.h udp.h util.h
|
2022-09-14 13:49:32 +00:00
|
|
|
HEADERS = $(PASST_HEADERS) seccomp.h
|
2022-06-14 05:12:21 +00:00
|
|
|
|
2022-09-28 18:36:57 +00:00
|
|
|
# On gcc 11 and 12, with -O2 and -flto, tcp_hash() and siphash_20b(), if
|
|
|
|
# inlined, seem to be hitting something similar to:
|
2021-10-19 15:28:18 +00:00
|
|
|
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78993
|
|
|
|
# from the pointer arithmetic used from the tcp_tap_handler() path to get the
|
|
|
|
# remote connection address.
|
Makefile: Hack for optimised-away store in ndp() before checksum calculation
With gcc 11 and 12, passing -flto, or -flto=auto, and -O2,
intra-procedural optimisation gets rid of a fundamental bit in ndp():
the store of hop_limit in the IPv6 header, before the checksum is
calculated, which on x86_64 looks like this:
ip6hr->hop_limit = IPPROTO_ICMPV6;
b8c0: c6 44 24 35 3a movb $0x3a,0x35(%rsp)
Here, hop_limit is temporarily set to the protocol number, to
conveniently get the IPv6 pseudo-header for ICMPv6 checksum
calculation in memory.
With LTO, the assignment just disappears from the binary.
This is rather visible as NDP messages get a wrong checksum, namely
the expected checksum plus 58, and they're ignored by the guest or
in the namespace, meaning we can't get any IPv6 routes, as reported
by Wenli Quan.
The issue affects a significant number of distribution builds,
including the ones for CentOS Stream 9, EPEL 9, Fedora >= 35,
Mageia Cauldron, and openSUSE Tumbleweed.
As a quick workaround, declare csum_unaligned() as "noipa" for gcc
11 and 12, with -flto and -O2. This disables inlining and cloning,
which causes the assignment to be compiled again.
Leave a TODO item: we should figure out if a gcc issue has already
been reported, and report one otherwise. There's no apparent
justification as to why the store could go away.
Reported-by: Wenli Quan <wquan@redhat.com>
Link: https://bugzilla.redhat.com/show_bug.cgi?id=2129713
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
2022-09-29 08:59:38 +00:00
|
|
|
#
|
|
|
|
# TODO: With the same combination, in ndp(), gcc optimises away the store of
|
|
|
|
# hop_limit in the IPv6 header (temporarily set to the protocol number for
|
|
|
|
# convenience, to mimic the ICMPv6 checksum pseudo-header) before the call to
|
|
|
|
# csum_unaligned(). Mark csum_unaligned() as "noipa" as a quick work-around,
|
|
|
|
# while we figure out if a corresponding gcc issue has already been reported.
|
2022-09-28 18:36:57 +00:00
|
|
|
ifeq (,$(filter-out 11 12, $(shell $(CC) -dumpversion)))
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
ifneq (,$(filter -flto%,$(FLAGS) $(CFLAGS)))
|
|
|
|
ifneq (,$(filter -O2,$(FLAGS) $(CFLAGS)))
|
|
|
|
FLAGS += -DTCP_HASH_NOINLINE
|
|
|
|
FLAGS += -DSIPHASH_20B_NOINLINE
|
Makefile: Hack for optimised-away store in ndp() before checksum calculation
With gcc 11 and 12, passing -flto, or -flto=auto, and -O2,
intra-procedural optimisation gets rid of a fundamental bit in ndp():
the store of hop_limit in the IPv6 header, before the checksum is
calculated, which on x86_64 looks like this:
ip6hr->hop_limit = IPPROTO_ICMPV6;
b8c0: c6 44 24 35 3a movb $0x3a,0x35(%rsp)
Here, hop_limit is temporarily set to the protocol number, to
conveniently get the IPv6 pseudo-header for ICMPv6 checksum
calculation in memory.
With LTO, the assignment just disappears from the binary.
This is rather visible as NDP messages get a wrong checksum, namely
the expected checksum plus 58, and they're ignored by the guest or
in the namespace, meaning we can't get any IPv6 routes, as reported
by Wenli Quan.
The issue affects a significant number of distribution builds,
including the ones for CentOS Stream 9, EPEL 9, Fedora >= 35,
Mageia Cauldron, and openSUSE Tumbleweed.
As a quick workaround, declare csum_unaligned() as "noipa" for gcc
11 and 12, with -flto and -O2. This disables inlining and cloning,
which causes the assignment to be compiled again.
Leave a TODO item: we should figure out if a gcc issue has already
been reported, and report one otherwise. There's no apparent
justification as to why the store could go away.
Reported-by: Wenli Quan <wquan@redhat.com>
Link: https://bugzilla.redhat.com/show_bug.cgi?id=2129713
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
2022-09-29 08:59:38 +00:00
|
|
|
FLAGS += -DCSUM_UNALIGNED_NO_IPA
|
2021-10-19 15:28:18 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2021-10-20 23:19:27 +00:00
|
|
|
C := \#include <linux/tcp.h>\nstruct tcp_info x = { .tcpi_snd_wnd = 0 };
|
|
|
|
ifeq ($(shell printf "$(C)" | $(CC) -S -xc - -o - >/dev/null 2>&1; echo $$?),0)
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
FLAGS += -DHAS_SND_WND
|
2021-10-20 23:19:27 +00:00
|
|
|
endif
|
|
|
|
|
2022-01-25 18:55:54 +00:00
|
|
|
C := \#include <linux/tcp.h>\nstruct tcp_info x = { .tcpi_bytes_acked = 0 };
|
|
|
|
ifeq ($(shell printf "$(C)" | $(CC) -S -xc - -o - >/dev/null 2>&1; echo $$?),0)
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
FLAGS += -DHAS_BYTES_ACKED
|
2022-01-25 18:55:54 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
C := \#include <linux/tcp.h>\nstruct tcp_info x = { .tcpi_min_rtt = 0 };
|
|
|
|
ifeq ($(shell printf "$(C)" | $(CC) -S -xc - -o - >/dev/null 2>&1; echo $$?),0)
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
FLAGS += -DHAS_MIN_RTT
|
2022-01-25 18:55:54 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
C := \#include <sys/random.h>\nint main(){int a=getrandom(0, 0, 0);}
|
|
|
|
ifeq ($(shell printf "$(C)" | $(CC) -S -xc - -o - >/dev/null 2>&1; echo $$?),0)
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
FLAGS += -DHAS_GETRANDOM
|
2022-01-25 18:55:54 +00:00
|
|
|
endif
|
|
|
|
|
2022-06-14 05:12:25 +00:00
|
|
|
ifeq ($(shell :|$(CC) -fstack-protector-strong -S -xc - -o - >/dev/null 2>&1; echo $$?),0)
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
FLAGS += -fstack-protector-strong
|
2022-03-15 17:14:53 +00:00
|
|
|
endif
|
|
|
|
|
2022-08-21 09:23:54 +00:00
|
|
|
prefix ?= /usr/local
|
|
|
|
exec_prefix ?= $(prefix)
|
|
|
|
bindir ?= $(exec_prefix)/bin
|
|
|
|
datarootdir ?= $(prefix)/share
|
|
|
|
docdir ?= $(datarootdir)/doc/passt
|
|
|
|
mandir ?= $(datarootdir)/man
|
|
|
|
man1dir ?= $(mandir)/man1
|
2021-08-19 18:23:04 +00:00
|
|
|
|
2022-09-23 09:56:30 +00:00
|
|
|
ifeq ($(TARGET_ARCH),x86_64)
|
2022-02-28 15:18:44 +00:00
|
|
|
BIN := passt passt.avx2 pasta pasta.avx2 qrap
|
|
|
|
else
|
|
|
|
BIN := passt pasta qrap
|
|
|
|
endif
|
2021-07-26 05:18:50 +00:00
|
|
|
|
2022-08-09 22:21:09 +00:00
|
|
|
all: $(BIN) $(MANPAGES) docs
|
2022-06-14 05:12:22 +00:00
|
|
|
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
static: FLAGS += -static -DGLIBC_NO_STATIC_NSS
|
2021-07-26 05:18:50 +00:00
|
|
|
static: clean all
|
|
|
|
|
2022-09-28 04:33:33 +00:00
|
|
|
seccomp.h: seccomp.sh $(PASST_SRCS) $(PASST_HEADERS)
|
|
|
|
@ EXTRA_SYSCALLS=$(EXTRA_SYSCALLS) ./seccomp.sh $(PASST_SRCS) $(PASST_HEADERS)
|
2021-10-13 20:25:03 +00:00
|
|
|
|
2022-09-14 13:49:32 +00:00
|
|
|
passt: $(PASST_SRCS) $(HEADERS)
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
$(CC) $(FLAGS) $(CFLAGS) $(PASST_SRCS) -o passt $(LDFLAGS)
|
2020-07-13 20:55:46 +00:00
|
|
|
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
passt.avx2: FLAGS += -Ofast -mavx2 -ftree-vectorize -funroll-loops
|
2022-09-14 13:49:32 +00:00
|
|
|
passt.avx2: $(PASST_SRCS) $(HEADERS)
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
$(CC) $(filter-out -O2,$(FLAGS) $(CFLAGS)) \
|
|
|
|
$(PASST_SRCS) -o passt.avx2 $(LDFLAGS)
|
2022-02-28 15:18:44 +00:00
|
|
|
|
|
|
|
passt.avx2: passt
|
|
|
|
|
2022-06-14 05:12:23 +00:00
|
|
|
pasta.avx2 pasta.1 pasta: pasta%: passt%
|
|
|
|
ln -s $< $@
|
passt: Add PASTA mode, major rework
PASTA (Pack A Subtle Tap Abstraction) provides quasi-native host
connectivity to an otherwise disconnected, unprivileged network
and user namespace, similarly to slirp4netns. Given that the
implementation is largely overlapping with PASST, no separate binary
is built: 'pasta' (and 'passt4netns' for clarity) both link to
'passt', and the mode of operation is selected depending on how the
binary is invoked. Usage example:
$ unshare -rUn
# echo $$
1871759
$ ./pasta 1871759 # From another terminal
# udhcpc -i pasta0 2>/dev/null
# ping -c1 pasta.pizza
PING pasta.pizza (64.190.62.111) 56(84) bytes of data.
64 bytes from 64.190.62.111 (64.190.62.111): icmp_seq=1 ttl=255 time=34.6 ms
--- pasta.pizza ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 34.575/34.575/34.575/0.000 ms
# ping -c1 spaghetti.pizza
PING spaghetti.pizza(2606:4700:3034::6815:147a (2606:4700:3034::6815:147a)) 56 data bytes
64 bytes from 2606:4700:3034::6815:147a (2606:4700:3034::6815:147a): icmp_seq=1 ttl=255 time=29.0 ms
--- spaghetti.pizza ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 28.967/28.967/28.967/0.000 ms
This entails a major rework, especially with regard to the storage of
tracked connections and to the semantics of epoll(7) references.
Indexing TCP and UDP bindings merely by socket proved to be
inflexible and unsuitable to handle different connection flows: pasta
also provides Layer-2 to Layer-2 socket mapping between init and a
separate namespace for local connections, using a pair of splice()
system calls for TCP, and a recvmmsg()/sendmmsg() pair for UDP local
bindings. For instance, building on the previous example:
# ip link set dev lo up
# iperf3 -s
$ iperf3 -c ::1 -Z -w 32M -l 1024k -P2 | tail -n4
[SUM] 0.00-10.00 sec 52.3 GBytes 44.9 Gbits/sec 283 sender
[SUM] 0.00-10.43 sec 52.3 GBytes 43.1 Gbits/sec receiver
iperf Done.
epoll(7) references now include a generic part in order to
demultiplex data to the relevant protocol handler, using 24
bits for the socket number, and an opaque portion reserved for
usage by the single protocol handlers, in order to track sockets
back to corresponding connections and bindings.
A number of fixes pertaining to TCP state machine and congestion
window handling are also included here.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
2021-07-17 06:34:53 +00:00
|
|
|
|
2022-06-14 05:12:21 +00:00
|
|
|
qrap: $(QRAP_SRCS) passt.h
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
$(CC) $(FLAGS) $(CFLAGS) $(QRAP_SRCS) -o qrap $(LDFLAGS)
|
2020-07-17 23:02:39 +00:00
|
|
|
|
2022-03-15 19:16:13 +00:00
|
|
|
valgrind: EXTRA_SYSCALLS="rt_sigprocmask rt_sigtimedwait rt_sigaction \
|
|
|
|
getpid gettid kill clock_gettime mmap munmap open \
|
2022-07-15 05:21:33 +00:00
|
|
|
unlink gettimeofday futex"
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
valgrind: FLAGS:=-g -O0 $(filter-out -O%,$(FLAGS))
|
2022-03-15 19:16:13 +00:00
|
|
|
valgrind: all
|
|
|
|
|
2020-07-13 20:55:46 +00:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
2022-06-14 05:12:24 +00:00
|
|
|
$(RM) $(BIN) *.o seccomp.h pasta.1 \
|
2022-07-06 07:29:02 +00:00
|
|
|
passt.tar passt.tar.gz *.deb *.rpm \
|
2022-08-09 22:21:09 +00:00
|
|
|
passt.pid README.plain.md
|
2021-08-19 18:23:04 +00:00
|
|
|
|
2022-08-09 22:21:09 +00:00
|
|
|
install: $(BIN) $(MANPAGES) docs
|
2022-08-21 09:23:54 +00:00
|
|
|
mkdir -p $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir)
|
|
|
|
cp -d $(BIN) $(DESTDIR)$(bindir)
|
|
|
|
cp -d $(MANPAGES) $(DESTDIR)$(man1dir)
|
|
|
|
mkdir -p $(DESTDIR)$(docdir)
|
|
|
|
cp -d README.plain.md $(DESTDIR)$(docdir)/README.md
|
|
|
|
cp -d doc/demo.sh $(DESTDIR)$(docdir)
|
2021-08-19 18:23:04 +00:00
|
|
|
|
|
|
|
uninstall:
|
2022-06-14 05:12:24 +00:00
|
|
|
$(RM) $(BIN:%=$(DESTDIR)$(prefix)/bin/%)
|
2022-08-21 09:23:54 +00:00
|
|
|
$(RM) $(MANPAGES:%=$(DESTDIR)$(man1dir)/%)
|
|
|
|
$(RM) $(DESTDIR)$(docdir)/README.md
|
|
|
|
$(RM) $(DESTDIR)$(docdir)/demo.sh
|
|
|
|
-rmdir $(DESTDIR)$(docdir)
|
2021-08-19 23:11:57 +00:00
|
|
|
|
2022-03-01 20:41:22 +00:00
|
|
|
pkgs: static
|
2022-02-28 15:18:44 +00:00
|
|
|
tar cf passt.tar -P --xform 's//\/usr\/bin\//' $(BIN)
|
2021-08-19 23:11:57 +00:00
|
|
|
tar rf passt.tar -P --xform 's//\/usr\/share\/man\/man1\//' \
|
2022-06-14 05:12:22 +00:00
|
|
|
$(MANPAGES)
|
2021-08-19 23:11:57 +00:00
|
|
|
gzip passt.tar
|
|
|
|
EMAIL="sbrivio@redhat.com" fakeroot alien --to-deb \
|
|
|
|
--description="User-mode networking for VMs and namespaces" \
|
|
|
|
-k --version=$(shell git rev-parse --short HEAD) \
|
|
|
|
passt.tar.gz
|
|
|
|
fakeroot alien --to-rpm --target=$(shell uname -m) \
|
|
|
|
--description="User-mode networking for VMs and namespaces" \
|
|
|
|
-k --version=g$(shell git rev-parse --short HEAD) passt.tar.gz
|
2021-10-19 22:05:11 +00:00
|
|
|
|
2022-08-09 22:21:09 +00:00
|
|
|
# TODO: This hack makes a "plain" Markdown version of README.md that can be
|
|
|
|
# reasonably shipped as documentation file, while the current README.md is
|
|
|
|
# definitely intended for web browser consumption. It should probably work the
|
|
|
|
# other way around: the web version should be obtained by adding HTML and
|
|
|
|
# JavaScript portions to a plain Markdown, instead. However, cgit needs to use
|
|
|
|
# a file in the git tree. Find a better way around this.
|
|
|
|
docs: README.md
|
|
|
|
@( \
|
|
|
|
skip=0; \
|
|
|
|
while read l; do \
|
|
|
|
case $$l in \
|
|
|
|
"## Demo") exit 0 ;; \
|
|
|
|
"<!"*) ;; \
|
|
|
|
"</"*) skip=1 ;; \
|
|
|
|
"<"*) skip=2 ;; \
|
|
|
|
esac; \
|
|
|
|
\
|
|
|
|
[ $$skip -eq 0 ] && echo "$$l"; \
|
|
|
|
[ $$skip -eq 1 ] && skip=0; \
|
|
|
|
done < README.md; \
|
|
|
|
) > README.plain.md
|
|
|
|
|
2021-10-19 22:05:11 +00:00
|
|
|
# Checkers currently disabled for clang-tidy:
|
|
|
|
# - llvmlibc-restrict-system-libc-headers
|
|
|
|
# TODO: this is Linux-only for the moment, nice to fix eventually
|
|
|
|
#
|
|
|
|
# - bugprone-macro-parentheses
|
|
|
|
# - google-readability-braces-around-statements
|
|
|
|
# - hicpp-braces-around-statements
|
|
|
|
# - readability-braces-around-statements
|
|
|
|
# Debatable whether that improves readability, right now it would look
|
|
|
|
# like a mess
|
|
|
|
#
|
|
|
|
# - readability-magic-numbers
|
|
|
|
# - cppcoreguidelines-avoid-magic-numbers
|
|
|
|
# TODO: in most cases they are justified, but probably not everywhere
|
|
|
|
#
|
|
|
|
# - clang-analyzer-valist.Uninitialized
|
|
|
|
# TODO: enable once https://bugs.llvm.org/show_bug.cgi?id=41311 is fixed
|
|
|
|
#
|
|
|
|
# - clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling
|
|
|
|
# Probably not doable to impement this without plain memcpy(), memset()
|
|
|
|
#
|
|
|
|
# - cppcoreguidelines-init-variables
|
|
|
|
# Dubious value, would kill readability
|
|
|
|
#
|
|
|
|
# - hicpp-signed-bitwise
|
|
|
|
# Those are needed for syscalls, epoll_wait flags, etc.
|
|
|
|
#
|
|
|
|
# - llvm-include-order
|
|
|
|
# TODO: not really important, but nice to fix eventually
|
|
|
|
#
|
|
|
|
# - readability-isolate-declaration
|
|
|
|
# Dubious value, would kill readability
|
|
|
|
#
|
|
|
|
# - bugprone-narrowing-conversions
|
|
|
|
# - cppcoreguidelines-narrowing-conversions
|
|
|
|
# TODO: nice to fix eventually
|
|
|
|
#
|
|
|
|
# - cppcoreguidelines-avoid-non-const-global-variables
|
|
|
|
# TODO: check, fix, and more in general constify wherever possible
|
|
|
|
#
|
2022-01-30 01:59:12 +00:00
|
|
|
# - altera-unroll-loops
|
|
|
|
# - altera-id-dependent-backward-branch
|
|
|
|
# TODO: check paths where it might make sense to improve performance
|
|
|
|
#
|
|
|
|
# - bugprone-easily-swappable-parameters
|
|
|
|
# Not much can be done about them other than being careful
|
|
|
|
#
|
|
|
|
# - readability-function-cognitive-complexity
|
|
|
|
# TODO: split reported functions
|
|
|
|
#
|
|
|
|
# - altera-struct-pack-align
|
|
|
|
# "Poor" alignment needed for structs reflecting message formats/headers
|
|
|
|
#
|
|
|
|
# - concurrency-mt-unsafe
|
|
|
|
# TODO: check again if multithreading is implemented
|
2022-09-26 10:43:42 +00:00
|
|
|
#
|
|
|
|
# - readability-identifier-length
|
|
|
|
# Complains about any identifier <3 characters, reasonable for
|
|
|
|
# globals, pointlessly verbose for locals and parameters.
|
2022-01-30 01:59:12 +00:00
|
|
|
|
2022-06-14 05:12:21 +00:00
|
|
|
clang-tidy: $(SRCS) $(HEADERS)
|
2021-10-19 22:05:11 +00:00
|
|
|
clang-tidy -checks=*,-modernize-*,\
|
|
|
|
-clang-analyzer-valist.Uninitialized,\
|
|
|
|
-cppcoreguidelines-init-variables,\
|
|
|
|
-bugprone-macro-parentheses,\
|
|
|
|
-google-readability-braces-around-statements,\
|
|
|
|
-hicpp-braces-around-statements,\
|
|
|
|
-readability-braces-around-statements,\
|
|
|
|
-readability-magic-numbers,\
|
|
|
|
-llvmlibc-restrict-system-libc-headers,\
|
|
|
|
-hicpp-signed-bitwise,\
|
|
|
|
-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,\
|
|
|
|
-llvm-include-order,\
|
|
|
|
-cppcoreguidelines-avoid-magic-numbers,\
|
|
|
|
-readability-isolate-declaration,\
|
|
|
|
-bugprone-narrowing-conversions,\
|
|
|
|
-cppcoreguidelines-narrowing-conversions,\
|
|
|
|
-cppcoreguidelines-avoid-non-const-global-variables,\
|
2022-01-30 01:59:12 +00:00
|
|
|
-altera-unroll-loops,-altera-id-dependent-backward-branch,\
|
|
|
|
-bugprone-easily-swappable-parameters,\
|
|
|
|
-readability-function-cognitive-complexity,\
|
|
|
|
-altera-struct-pack-align,\
|
2022-09-26 10:43:42 +00:00
|
|
|
-concurrency-mt-unsafe,\
|
|
|
|
-readability-identifier-length \
|
2022-03-27 11:41:48 +00:00
|
|
|
-config='{CheckOptions: [{key: bugprone-suspicious-string-compare.WarnOnImplicitComparison, value: "false"}]}' \
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
--warnings-as-errors=* $(SRCS) -- $(filter-out -pie,$(FLAGS) $(CFLAGS))
|
2021-10-21 07:41:13 +00:00
|
|
|
|
2022-09-26 10:43:46 +00:00
|
|
|
SYSTEM_INCLUDES := /usr/include $(wildcard /usr/include/$(TARGET))
|
2021-10-21 07:41:13 +00:00
|
|
|
ifeq ($(shell $(CC) -v 2>&1 | grep -c "gcc version"),1)
|
|
|
|
VER := $(shell $(CC) -dumpversion)
|
2022-09-26 10:43:43 +00:00
|
|
|
SYSTEM_INCLUDES += /usr/lib/gcc/$(TARGET)/$(VER)/include
|
2021-10-21 07:41:13 +00:00
|
|
|
endif
|
2022-06-14 05:12:21 +00:00
|
|
|
cppcheck: $(SRCS) $(HEADERS)
|
2021-10-21 07:41:13 +00:00
|
|
|
cppcheck --std=c99 --error-exitcode=1 --enable=all --force \
|
2022-09-26 10:43:44 +00:00
|
|
|
--inconclusive --library=posix --quiet \
|
2022-09-26 10:43:43 +00:00
|
|
|
$(SYSTEM_INCLUDES:%=-I%) \
|
|
|
|
$(SYSTEM_INCLUDES:%=--config-exclude=%) \
|
|
|
|
$(SYSTEM_INCLUDES:%=--suppress=*:%/*) \
|
|
|
|
$(SYSTEM_INCLUDES:%=--suppress=unmatchedSuppression:%/*) \
|
2022-09-28 04:33:18 +00:00
|
|
|
--inline-suppr \
|
2022-09-28 04:33:28 +00:00
|
|
|
--suppress=unusedStructMember \
|
Makefile: Allow define overrides by prepending, not appending, CFLAGS
If we append CFLAGS to the ones passed via command line (if any),
-D options we append will override -D options passed on command line
(if any).
For example, OpenSUSE build flags include -D_FORTIFY_SOURCE=3, and we
want to have -D_FORTIFY_SOURCE=2, if and only if not overridden. The
current behaviour implies we redefine _FORTIFY_SOURCE as 2, though.
Instead of appending CFLAGS, prepend them by adding all the default
build flags to another variable, a simply expanded one (defined with
:=), named FLAGS, and pass that *before* CFLAGS in targets, so that
defines from command line can override default flags.
Reported-by: Dario Faggioli <dfaggioli@suse.com>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Tested-by: Dario Faggioli <dfaggioli@suse.com>
2022-09-14 13:34:28 +00:00
|
|
|
$(filter -D%,$(FLAGS) $(CFLAGS)) \
|
2021-10-21 07:41:13 +00:00
|
|
|
.
|