mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-03 00:00:24 -04:00
kernel-netlink: Also set the receive buffer size on event sockets
This was weirdly overlooked and could cause issues e.g. on hosts with lots of route changes.
This commit is contained in:
parent
714c939018
commit
5971fc36c9
@ -653,6 +653,29 @@ u_int netlink_get_buflen()
|
|||||||
return buflen;
|
return buflen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the configured receive buffer size on the given socket.
|
||||||
|
*/
|
||||||
|
static void set_rcvbuf_size(int socket)
|
||||||
|
{
|
||||||
|
int rcvbuf_size = 0;
|
||||||
|
|
||||||
|
rcvbuf_size = lib->settings->get_int(lib->settings,
|
||||||
|
"%s.plugins.kernel-netlink.receive_buffer_size",
|
||||||
|
NETLINK_RCVBUF_DEFAULT, lib->ns);
|
||||||
|
if (rcvbuf_size)
|
||||||
|
{
|
||||||
|
if (setsockopt(socket, SOL_SOCKET, SO_RCVBUFFORCE, &rcvbuf_size,
|
||||||
|
sizeof(rcvbuf_size)) == -1 &&
|
||||||
|
setsockopt(socket, SOL_SOCKET, SO_RCVBUF, &rcvbuf_size,
|
||||||
|
sizeof(rcvbuf_size)) == -1)
|
||||||
|
{
|
||||||
|
DBG1(DBG_KNL, "failed to set receive buffer size to %d: %s",
|
||||||
|
rcvbuf_size, strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Described in header
|
* Described in header
|
||||||
*/
|
*/
|
||||||
@ -663,7 +686,7 @@ netlink_socket_t *netlink_socket_create(int protocol, enum_name_t *names,
|
|||||||
struct sockaddr_nl addr = {
|
struct sockaddr_nl addr = {
|
||||||
.nl_family = AF_NETLINK,
|
.nl_family = AF_NETLINK,
|
||||||
};
|
};
|
||||||
int on = 1, rcvbuf_size = 0;
|
int on = 1;
|
||||||
|
|
||||||
INIT(this,
|
INIT(this,
|
||||||
.public = {
|
.public = {
|
||||||
@ -711,20 +734,8 @@ netlink_socket_t *netlink_socket_create(int protocol, enum_name_t *names,
|
|||||||
ignore_result(setsockopt(this->socket, SOL_NETLINK, NETLINK_EXT_ACK, &on,
|
ignore_result(setsockopt(this->socket, SOL_NETLINK, NETLINK_EXT_ACK, &on,
|
||||||
sizeof(on)));
|
sizeof(on)));
|
||||||
|
|
||||||
rcvbuf_size = lib->settings->get_int(lib->settings,
|
set_rcvbuf_size(this->socket);
|
||||||
"%s.plugins.kernel-netlink.receive_buffer_size",
|
|
||||||
NETLINK_RCVBUF_DEFAULT, lib->ns);
|
|
||||||
if (rcvbuf_size)
|
|
||||||
{
|
|
||||||
if (setsockopt(this->socket, SOL_SOCKET, SO_RCVBUFFORCE, &rcvbuf_size,
|
|
||||||
sizeof(rcvbuf_size)) == -1 &&
|
|
||||||
setsockopt(this->socket, SOL_SOCKET, SO_RCVBUF, &rcvbuf_size,
|
|
||||||
sizeof(rcvbuf_size)) == -1)
|
|
||||||
{
|
|
||||||
DBG1(DBG_KNL, "failed to set receive buffer size to %d: %s",
|
|
||||||
rcvbuf_size, strerror(errno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this->parallel)
|
if (this->parallel)
|
||||||
{
|
{
|
||||||
lib->watcher->add(lib->watcher, this->socket, WATCHER_READ, watch, this);
|
lib->watcher->add(lib->watcher, this->socket, WATCHER_READ, watch, this);
|
||||||
@ -806,6 +817,8 @@ netlink_event_socket_t *netlink_event_socket_create(int protocol, uint32_t group
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_rcvbuf_size(this->socket);
|
||||||
|
|
||||||
if (bind(this->socket, (struct sockaddr*)&addr, sizeof(addr)))
|
if (bind(this->socket, (struct sockaddr*)&addr, sizeof(addr)))
|
||||||
{
|
{
|
||||||
DBG1(DBG_KNL, "unable to bind netlink event socket: %s (%d)",
|
DBG1(DBG_KNL, "unable to bind netlink event socket: %s (%d)",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user