summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
authorSergey V. Lobanov <sergey@lobanov.in>2021-12-20 18:00:32 +0300
committerSergey V. Lobanov <sergey@lobanov.in>2021-12-20 18:00:32 +0300
commit5249bf6428e70aa489aa9b8c44b16935c391a7fe (patch)
tree8234db2351aca96b5c957ad99d47fdea37697a20 /accel-pppd
parent385c4038c451f5c181136070846cab0664dae43a (diff)
downloadaccel-ppp-5249bf6428e70aa489aa9b8c44b16935c391a7fe.tar.gz
accel-ppp-5249bf6428e70aa489aa9b8c44b16935c391a7fe.zip
T55: add netlink buffer size configuration parameters
Netlink buffers may overflow so it might be useful to increase send and receive netlink buffer sizes. Two parameters to [common] configuration section added: nl-rcv-buffer, nl-snd-buffer. It is required to set (sysctl) net.core.wmem_max>=nl-snd-buffer and net.core.rmem_max>=nl-rcv-buffer before running accel-pppd To check current netlink buffer size and related info use the following command: % ss -f netlink -m 0 0 rtnl:kernel * skmem:(r0,rb212992,t0,tb212992,f0,w0,o0,bl0,d0) 0 0 rtnl:-1140221812 * skmem:(r0,rb2048000,t0,tb80000,f0,w0,o0,bl0,d0) 0 0 rtnl:accel-pppd/14285 * skmem:(r0,rb2048000,t0,tb65536,f0,w0,o0,bl0,d0) ... (Please check man ss to get the meaning for r,rb,t,tb,f,w,o,bl and d params) In the ss output you will see the values doubled from configured. First accel-pppd netlink socket will use default values (rcv=1048576, snd=32768) regardless of configured nl-rcv-buffer and nl-snd-buffer values. Signed-off-by: Sergey V. Lobanov <sergey@lobanov.in>
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/accel-ppp.conf2
-rw-r--r--accel-pppd/accel-ppp.conf.56
-rw-r--r--accel-pppd/libnetlink/libnetlink.c21
-rw-r--r--accel-pppd/net.c11
4 files changed, 35 insertions, 5 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf
index 8ea405bc..8b437cfa 100644
--- a/accel-pppd/accel-ppp.conf
+++ b/accel-pppd/accel-ppp.conf
@@ -43,6 +43,8 @@ thread-count=4
#max-sessions=1000
#max-starting=0
#check-ip=0
+#nl-snd-buffer=32768
+#nl-rcv-buffer=1048576
[ppp]
verbose=1
diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5
index 51612ca9..8337ad7a 100644
--- a/accel-pppd/accel-ppp.conf.5
+++ b/accel-pppd/accel-ppp.conf.5
@@ -131,6 +131,12 @@ Specifies maximum concurrent session attempts which server may processed (defaul
.TP
.BI "check-ip=" 0|1
Specifies whether accel-ppp should check if IP already assigned to other client interface (default 0).
+.TP
+.BI "nl-snd-buffer=" n
+Specifies netlink maximum send buffer size (SO_SNDBUF option) (default 32768).
+.TP
+.BI "nl-rcv-buffer=" n
+Specifies netlink maximum receive buffer size (SO_RCVBUF option) (default 1048576).
.SH [ppp]
.br
PPP module configuration.
diff --git a/accel-pppd/libnetlink/libnetlink.c b/accel-pppd/libnetlink/libnetlink.c
index 0ab83a3c..a0ea103e 100644
--- a/accel-pppd/libnetlink/libnetlink.c
+++ b/accel-pppd/libnetlink/libnetlink.c
@@ -28,7 +28,8 @@
#define __export __attribute__((visibility("default")))
-int rcvbuf = 1024 * 1024;
+extern int conf_nl_rcvbuf;
+extern int conf_nl_sndbuf;
void __export rtnl_close(struct rtnl_handle *rth)
{
@@ -52,12 +53,22 @@ int __export rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions,
return -1;
}
- if (setsockopt(rth->fd,SOL_SOCKET,SO_SNDBUF,&sndbuf,sizeof(sndbuf)) < 0) {
- log_debug("libnetlink: ""SO_SNDBUF: %s\n", strerror(errno));
- return -1;
+ if (conf_nl_sndbuf > 0) {
+ if (setsockopt(rth->fd,SOL_SOCKET,SO_SNDBUF,&conf_nl_sndbuf,sizeof(conf_nl_sndbuf)) < 0) {
+ log_debug("libnetlink: ""SO_SNDBUF: %s\n", strerror(errno));
+ log_debug("libnetlink: unable to set custom sndbuf. Default value %d will be used", sndbuf);
+ conf_nl_sndbuf = -1;
+ }
+ }
+
+ if (conf_nl_sndbuf <= 0) {
+ if (setsockopt(rth->fd,SOL_SOCKET,SO_SNDBUF,&sndbuf,sizeof(sndbuf)) < 0) {
+ log_debug("libnetlink: ""SO_SNDBUF: %s\n", strerror(errno));
+ return -1;
+ }
}
- if (setsockopt(rth->fd,SOL_SOCKET,SO_RCVBUF,&rcvbuf,sizeof(rcvbuf)) < 0) {
+ if (setsockopt(rth->fd,SOL_SOCKET,SO_RCVBUF,&conf_nl_rcvbuf,sizeof(conf_nl_rcvbuf)) < 0) {
log_debug("libnetlink: ""SO_RCVBUF: %s\n", strerror(errno));
return -1;
}
diff --git a/accel-pppd/net.c b/accel-pppd/net.c
index 26373fc1..c619deed 100644
--- a/accel-pppd/net.c
+++ b/accel-pppd/net.c
@@ -45,6 +45,9 @@ __export __thread struct ap_net *net;
__export struct ap_net *def_net;
static int def_ns_fd;
+__export int conf_nl_rcvbuf = 1024 * 1024;
+__export int conf_nl_sndbuf = -1;
+
static int def_socket(int domain, int type, int proto)
{
return socket(domain, type, proto);
@@ -432,6 +435,14 @@ static void __init init()
{
const char *opt;
+ opt = conf_get_opt("common", "nl-rcv-buffer");
+ if (opt)
+ conf_nl_rcvbuf = atoi(opt);
+
+ opt = conf_get_opt("common", "nl-snd-buffer");
+ if (opt)
+ conf_nl_sndbuf = atoi(opt);
+
opt = conf_get_opt("common", "netns-run-dir");
if (opt)
conf_netns_run_dir = opt;