Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ struct bpftunable_desc {
unsigned int id;
enum bpftunable_type type;
const char *name;
__u64 flags;
__u8 num_values;
};
```
Expand Down
5 changes: 4 additions & 1 deletion include/bpftune/bpftune.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ struct bpftunable_scenario {

#define BPFTUNE_MAX_VALUES 3

#define BPFTUNABLE_NAMESPACED 0x1 /* settable in non-global namespace? */
#define BPFTUNABLE_OPTIONAL 0x2 /* do not fail it tunable not found (e.g. ipv6 */

struct bpftunable_desc {
unsigned int id;
enum bpftunable_type type;
const char *name;
bool namespaced; /* settable in non-global namespace? */
__u64 flags;
__u8 num_values;
};

Expand Down
7 changes: 6 additions & 1 deletion src/libbpftune.c
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,11 @@ int bpftuner_tunables_init(struct bpftuner *tuner, unsigned int num_descs,
num_values = bpftune_sysctl_read(0, descs[i].name,
tuner->tunables[i].current_values);
if (num_values < 0) {
if (descs[i].flags & BPFTUNABLE_OPTIONAL) {
bpftune_log(LOG_DEBUG, "error reading optional tunable '%s': %s\n",
descs[i].name, strerror(-num_values));
continue;
}
bpftune_log(LOG_ERR, "error reading tunable '%s': %s\n",
descs[i].name, strerror(-num_values));
return num_values;
Expand Down Expand Up @@ -1052,7 +1057,7 @@ int bpftuner_tunable_sysctl_write(struct bpftuner *tuner, unsigned int tunable,
}
}

if (t->desc.namespaced) {
if (t->desc.flags & BPFTUNABLE_NAMESPACED) {
fd = bpftuner_netns_fd_from_cookie(tuner, netns_cookie);
if (fd < 0) {
bpftune_log(LOG_DEBUG, "could not get netns fd for cookie %ld\n",
Expand Down
25 changes: 15 additions & 10 deletions src/neigh_table_tuner.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,30 @@ struct neigh_table_tuner_bpf *skel;

static struct bpftunable_desc descs[] = {
{ NEIGH_TABLE_IPV4_GC_INTERVAL, BPFTUNABLE_SYSCTL,
"net.ipv4.neigh.default.gc_interval", false, 1 },
"net.ipv4.neigh.default.gc_interval", 0, 1 },
{ NEIGH_TABLE_IPV4_GC_STALE_TIME, BPFTUNABLE_SYSCTL,
"net.ipv4.neigh.default.gc_stale_time", true, 1, },
"net.ipv4.neigh.default.gc_stale_time", 0, 1, },
{ NEIGH_TABLE_IPV4_GC_THRESH1, BPFTUNABLE_SYSCTL,
"net.ipv4.neigh.default.gc_thresh1", false, 1, },
"net.ipv4.neigh.default.gc_thresh1", 0, 1, },
{ NEIGH_TABLE_IPV4_GC_THRESH2, BPFTUNABLE_SYSCTL,
"net.ipv4.neigh.default.gc_thresh2", false, 1, },
"net.ipv4.neigh.default.gc_thresh2", 0, 1, },
{ NEIGH_TABLE_IPV4_GC_THRESH3, BPFTUNABLE_SYSCTL,
"net.ipv4.neigh.default.gc_thresh3", false, 1, },
"net.ipv4.neigh.default.gc_thresh3", 0, 1, },
{ NEIGH_TABLE_IPV6_GC_INTERVAL, BPFTUNABLE_SYSCTL,
"net.ipv6.neigh.default.gc_interval", false, 1 },
"net.ipv6.neigh.default.gc_interval", BPFTUNABLE_OPTIONAL,
1 },
{ NEIGH_TABLE_IPV6_GC_STALE_TIME, BPFTUNABLE_SYSCTL,
"net.ipv6.neigh.default.gc_stale_time", true, 1, },
"net.ipv6.neigh.default.gc_stale_time", BPFTUNABLE_OPTIONAL,
1, },
{ NEIGH_TABLE_IPV6_GC_THRESH1, BPFTUNABLE_SYSCTL,
"net.ipv6.neigh.default.gc_thresh1", false, 1, },
"net.ipv6.neigh.default.gc_thresh1", BPFTUNABLE_OPTIONAL,
1, },
{ NEIGH_TABLE_IPV6_GC_THRESH2, BPFTUNABLE_SYSCTL,
"net.ipv6.neigh.default.gc_thresh2", false, 1, },
"net.ipv6.neigh.default.gc_thresh2", BPFTUNABLE_OPTIONAL,
1, },
{ NEIGH_TABLE_IPV6_GC_THRESH3, BPFTUNABLE_SYSCTL,
"net.ipv6.neigh.default.gc_thresh3", false, 1, },
"net.ipv6.neigh.default.gc_thresh3", BPFTUNABLE_OPTIONAL,
1, },
};

static struct bpftunable_scenario scenarios[] = {
Expand Down
4 changes: 2 additions & 2 deletions src/net_buffer_tuner.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ struct tcp_buffer_tuner_bpf *skel;

static struct bpftunable_desc descs[] = {
{ NETDEV_MAX_BACKLOG, BPFTUNABLE_SYSCTL, "net.core.netdev_max_backlog",
false, 1 },
0, 1 },
{ FLOW_LIMIT_CPU_BITMAP,
BPFTUNABLE_SYSCTL, "net.core.flow_limit_cpu_bitmap",
false, 1 },
0, 1 },
};

static struct bpftunable_scenario scenarios[] = {
Expand Down
2 changes: 1 addition & 1 deletion src/netns_tuner.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct netns_tuner_bpf *skel;

static struct bpftunable_desc descs[] = {
{
NETNS, BPFTUNABLE_OTHER, "Network namespace", true, 0 },
NETNS, BPFTUNABLE_OTHER, "Network namespace", BPFTUNABLE_NAMESPACED, 0 },
};

static struct bpftunable_scenario scenarios[] = {
Expand Down
3 changes: 2 additions & 1 deletion src/route_table_tuner.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ struct route_table_tuner_bpf *skel;

static struct bpftunable_desc descs[] = {
{ ROUTE_TABLE_IPV6_MAX_SIZE, BPFTUNABLE_SYSCTL,
"net.ipv6.route.max_size", true, 1 },
"net.ipv6.route.max_size",
BPFTUNABLE_NAMESPACED | BPFTUNABLE_OPTIONAL, 1 },
};

static struct bpftunable_scenario scenarios[] = {
Expand Down
2 changes: 1 addition & 1 deletion src/tcp_cong_tuner.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

static struct bpftunable_desc descs[] = {
{
TCP_CONG, BPFTUNABLE_OTHER, "TCP congestion control", false, 0 },
TCP_CONG, BPFTUNABLE_OTHER, "TCP congestion control", 0, 0 },
};

static struct bpftunable_scenario scenarios[] = {
Expand Down
3 changes: 2 additions & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ TUNER_TESTS = support_test log_test service_test inotify_test cap_test \
sysctl_test sysctl_legacy_test sysctl_netns_test \
netns_test netns_legacy_test \
backlog_test backlog_legacy_test \
neigh_table_test neigh_table_legacy_test \
neigh_table_test neigh_table_v4only_test \
neigh_table_legacy_test \
mem_pressure_test mem_pressure_legacy_test \
mem_exhaust_test mem_exhaust_legacy_test \
wmem_test wmem_legacy_test \
Expand Down
73 changes: 73 additions & 0 deletions test/neigh_table_v4only_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/bash
#
# SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
#
# Copyright (c) 2023, Oracle and/or its affiliates.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License v2 as published by the Free Software Foundation.
#
# 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, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 021110-1307, USA.
#

# run neigh table test when ipv6 is disabled

. ./test_lib.sh

LOGFILE=$TESTLOG_LAST

SLEEPTIME=1

for TUNER in neigh_table ; do

# gc_thresh3 is not namespaced...

for NS in global ; do
for TBL in arp_cache ; do

test_start "$0|neigh table test ($NS netns): does filling $TBL make it grow?"

test_setup "true"

sysctl -w net.ipv6.conf.all.disable_ipv6=1
if [[ $NS != "global" ]]; then
ip netns exec $NS sysctl -w net.ipv6.conf.all.disable_ipv6=1
fi
test_run_cmd_local "$BPFTUNE -s &" true

sleep $SETUPTIME

if [[ $NS != "global" ]]; then
PREFIX_CMD="ip netns exec $NETNS "
INTF=$VETH1
else
PREFIX_CMD=""
INTF=$VETH2
fi
$PREFIX_CMD ip ntable change name $TBL dev $INTF thresh3 128

for ((i=3; i < 255; i++ ))
do
ipaddr="192.168.168.${i}"
ih=$(printf '%x' $i)
macaddr="de:ad:be:ef:de:${ih}"
$PREFIX_CMD ip neigh replace $ipaddr lladdr $macaddr dev $INTF
done
grep "updated gc_thresh3 for $TBL table" $LOGFILE
test_pass
done
done
done

test_cleanup

test_exit
2 changes: 2 additions & 0 deletions test/test_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ test_setup_local()
ip netns list 2>/dev/null | grep $NETNS
FOUND=$?
set -e
sysctl -qw net.ipv6.conf.all.disable_ipv6=0
if [[ $FOUND -ne 0 ]]; then
ip netns pids $NETNS 2>/dev/null| xargs -r kill
ip netns del $NETNS 2>/dev/null|true
Expand Down Expand Up @@ -278,6 +279,7 @@ test_cleanup_local()
ip --all netns del ${NETNS_PREFIX}\*
ip link del $VETH2 2>/dev/null
ip link del bpftunelocal 2>/dev/null
sysctl -w net.ipv6.conf.all.disable_ipv6=0
set -e

if [[ ! -f /usr/lib64/bpftune/tcp_buffer_tuner.so ]]; then
Expand Down