diff options
-rw-r--r-- | accel-pppd/accel-ppp.conf | 2 | ||||
-rw-r--r-- | accel-pppd/accel-ppp.conf.5 | 6 | ||||
-rw-r--r-- | accel-pppd/libnetlink/libnetlink.c | 21 | ||||
-rw-r--r-- | accel-pppd/net.c | 11 |
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; |