src/contrib/openbsd/strlcat.h
src/contrib/openbsd/strlcpy.c
src/contrib/openbsd/strlcpy.h
+src/contrib/os.h
src/contrib/qp-trie/trie.c
src/contrib/qp-trie/trie.h
src/contrib/semaphore.c
.sp
The utility has to be executed under root or with these capabilities:
CAP_NET_RAW, CAP_NET_ADMIN, CAP_SYS_ADMIN, and CAP_SYS_RESOURCE if maximum
-locked memory limit is too low.
+locked memory limit is too low on Linux < 5.11.
.sp
Sending USR1 signal to a running process triggers current statistics dump
to the standard output.
The utility has to be executed under root or with these capabilities:
CAP_NET_RAW, CAP_NET_ADMIN, CAP_SYS_ADMIN, and CAP_SYS_RESOURCE if maximum
-locked memory limit is too low.
+locked memory limit is too low on Linux < 5.11.
Sending USR1 signal to a running process triggers current statistics dump
to the standard output.
CapabilityBoundingSet=CAP_NET_RAW CAP_NET_ADMIN CAP_SYS_ADMIN CAP_SYS_RESOURCE
AmbientCapabilities=CAP_NET_RAW CAP_NET_ADMIN CAP_SYS_ADMIN CAP_SYS_RESOURCE
+ The `CAP_SYS_RESOURCE` is needed on Linux < 5.11.
+
Optimizations
-------------
contrib/mempattern.h \
contrib/net.c \
contrib/net.h \
+ contrib/os.h \
contrib/qp-trie/trie.c \
contrib/qp-trie/trie.h \
contrib/semaphore.c \
--- /dev/null
+/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <sys/utsname.h>
+
+inline static bool linux_at_least(unsigned version_first, unsigned version_second)
+{
+#if defined(__linux__)
+ struct utsname info;
+ unsigned first, second;
+ if (uname(&info) != 0 || sscanf(info.release, "%u.%u.", &first, &second) != 2) {
+ return false;
+ } else {
+ return first > version_first ||
+ (first = version_first && second >= version_second);
+ }
+#else
+ return false;
+#endif
+}
#include "knot/worker/pool.h"
#include "contrib/net.h"
#include "contrib/openbsd/strlcat.h"
+#include "contrib/os.h"
#include "contrib/sockaddr.h"
#include "contrib/trim.h"
}
#ifdef ENABLE_XDP
- if (lisxdp_val.code == KNOT_EOK) {
+ if (lisxdp_val.code == KNOT_EOK && !linux_at_least(5, 11)) {
struct rlimit min_limit = { RLIM_INFINITY, RLIM_INFINITY };
struct rlimit cur_limit = { 0 };
if (getrlimit(RLIMIT_MEMLOCK, &cur_limit) != 0 ||
#include "contrib/mempattern.h"
#include "contrib/openbsd/strlcat.h"
#include "contrib/openbsd/strlcpy.h"
+#include "contrib/os.h"
#include "contrib/sockaddr.h"
#include "contrib/ucw/mempool.h"
#include "utils/common/params.h"
thread_ctxs[i].thread_id = i;
}
- struct rlimit min_limit = { RLIM_INFINITY, RLIM_INFINITY }, cur_limit = { 0 };
- if (getrlimit(RLIMIT_MEMLOCK, &cur_limit) != 0 ||
- cur_limit.rlim_cur != min_limit.rlim_cur || cur_limit.rlim_max != min_limit.rlim_max) {
- int ret = setrlimit(RLIMIT_MEMLOCK, &min_limit);
- if (ret != 0) {
- printf("warning: unable to increase RLIMIT_MEMLOCK: %s\n", strerror(errno));
+ if (!linux_at_least(5, 11)) {
+ struct rlimit min_limit = { RLIM_INFINITY, RLIM_INFINITY }, cur_limit = { 0 };
+ if (getrlimit(RLIMIT_MEMLOCK, &cur_limit) != 0 ||
+ cur_limit.rlim_cur != min_limit.rlim_cur ||
+ cur_limit.rlim_max != min_limit.rlim_max) {
+ int ret = setrlimit(RLIMIT_MEMLOCK, &min_limit);
+ if (ret != 0) {
+ printf("warning: unable to increase RLIMIT_MEMLOCK: %s\n",
+ strerror(errno));
+ }
}
}
+
pthread_mutex_init(&global_stats.mutex, NULL);
struct sigaction stop_action = { .sa_handler = sigterm_handler };