Skip to content

Commit

Permalink
QUIC: configure cleanup.
Browse files Browse the repository at this point in the history
Renamed and removed some macros.
  • Loading branch information
mdocguard committed Dec 9, 2021
1 parent 3ab900c commit d06f602
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 45 deletions.
2 changes: 1 addition & 1 deletion auto/modules
Original file line number Diff line number Diff line change
Expand Up @@ -1365,7 +1365,7 @@ if [ $USE_OPENSSL_QUIC = YES ]; then

. auto/module

if [ $NGX_QUIC_BPF$BPF_FOUND$SO_COOKIE_FOUND = YESYESYES ]; then
if [ $QUIC_BPF = YES -a $SO_COOKIE_FOUND = YES ]; then
ngx_module_type=CORE
ngx_module_name=ngx_quic_bpf_module
ngx_module_incs=
Expand Down
5 changes: 2 additions & 3 deletions auto/options
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ USE_THREADS=NO

NGX_FILE_AIO=NO

NGX_QUIC_BPF=YES
QUIC_BPF=NO

HTTP=YES

Expand Down Expand Up @@ -170,7 +170,6 @@ USE_GEOIP=NO
NGX_GOOGLE_PERFTOOLS=NO
NGX_CPP_TEST=NO

BPF_FOUND=NO
SO_COOKIE_FOUND=NO

NGX_LIBATOMIC=NO
Expand Down Expand Up @@ -218,7 +217,7 @@ do

--with-file-aio) NGX_FILE_AIO=YES ;;

--without-quic_bpf_module) NGX_QUIC_BPF=NO ;;
--without-quic_bpf_module) QUIC_BPF=NONE ;;

--with-ipv6)
NGX_POST_CONF_MSG="$NGX_POST_CONF_MSG
Expand Down
70 changes: 29 additions & 41 deletions auto/os/linux
Original file line number Diff line number Diff line change
Expand Up @@ -235,33 +235,45 @@ ngx_include="sys/vfs.h"; . auto/include
CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"


# (E)BPF
# BPF sockhash

ngx_feature="BPF support"
ngx_feature="BPF sockhash"
ngx_feature_name="NGX_HAVE_BPF"
ngx_feature_run=no
ngx_feature_incs="#include <linux/bpf.h>
#include <sys/syscall.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="
union bpf_attr attr = { 0 };
/* only declare BPF support if all required features found */
attr.map_flags = 0;
attr.map_type = BPF_MAP_TYPE_SOCKHASH;
syscall(__NR_bpf, 0, &attr, 0);"
ngx_feature_test="union bpf_attr attr = { 0 };

attr.map_flags = 0;
attr.map_type = BPF_MAP_TYPE_SOCKHASH;

syscall(__NR_bpf, 0, &attr, 0);"
. auto/feature

if [ $ngx_found = yes ]; then
BPF_FOUND=YES

CORE_SRCS="$CORE_SRCS src/core/ngx_bpf.c"
CORE_DEPS="$CORE_DEPS src/core/ngx_bpf.h"
fi

# quic bpf module uses sockhash to select socket from reuseport group,
# support appeared in Linux 5.7:
#
# commit: 9fed9000c5c6cacfcaaa48aff74818072ae294cc
# bpf: Allow selecting reuseport socket from a SOCKMAP/SOCKHASH

if [ $QUIC_BPF != NONE ]; then
echo $ngx_n "checking for BPF sockhash support in kernel ...$ngx_c"
if [ $version -lt 329472 ]; then
echo " not found (at least 5.7 is required)"
QUIC_BPF=NO
else
echo " found"
QUIC_BPF=YES
fi
fi
fi

# SO_COOKIE socket option

ngx_feature="SO_COOKIE"
ngx_feature_name="NGX_HAVE_SO_COOKIE"
Expand All @@ -271,17 +283,16 @@ ngx_feature_incs="#include <sys/socket.h>
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="socklen_t optlen = sizeof(uint64_t);
uint64_t cookie;
getsockopt(0, SOL_SOCKET, SO_COOKIE, &cookie, &optlen)"
uint64_t cookie;
getsockopt(0, SOL_SOCKET, SO_COOKIE, &cookie, &optlen)"
. auto/feature

if [ $ngx_found = yes ]; then
SO_COOKIE_FOUND=YES
have=NGX_HAVE_SO_COOKIE . auto/have
fi


# UDP_SEGMENT socket option is used for segmentation offloading
# UDP segmentation offloading

ngx_feature="UDP_SEGMENT"
ngx_feature_name="NGX_HAVE_UDP_SEGMENT"
Expand All @@ -292,29 +303,6 @@ ngx_feature_incs="#include <sys/socket.h>
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="socklen_t optlen = sizeof(int);
int val;
getsockopt(0, SOL_UDP, UDP_SEGMENT, &val, &optlen)"
int val;
getsockopt(0, SOL_UDP, UDP_SEGMENT, &val, &optlen)"
. auto/feature

if [ $ngx_found = yes ]; then
UDP_SEGMENT_FOUND=YES
have=NGX_HAVE_UDP_SEGMENT . auto/have
fi


# ngx_quic_bpf module uses sockhash to select socket from reuseport group,
# support appeared in Linux-5.7:
#
# commit: 9fed9000c5c6cacfcaaa48aff74818072ae294cc
# bpf: Allow selecting reuseport socket from a SOCKMAP/SOCKHASH
#
if [ $NGX_QUIC_BPF$BPF_FOUND = YESYES ]; then
echo $ngx_n "checking for kernel with reuseport/BPF support...$ngx_c"
if [ $version -lt 329472 ]; then
echo " not found (at least 5.7 is required)"
NGX_QUIC_BPF=NO
else
echo " found"
fi
fi

0 comments on commit d06f602

Please sign in to comment.