Skip to content

Commit

Permalink
zebra: use SO_RCVBUFFORCE for netlink socket
Browse files Browse the repository at this point in the history
so net.core.rmem_max must not be adjusted. Requires
linux kernel >= 2.6.14, falls back to SO_RCVBUF on error

Signed-off-by: Ulrich Weber <[email protected]>
Signed-off-by: David Lamparter <[email protected]>
  • Loading branch information
Ulrich Weber authored and eqvinox committed Feb 23, 2013
1 parent 66b63aa commit f1ef81b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/zebra.8
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ handle flood of netlink messages from kernel. If you ever see "recvmsg overrun"
messages in zebra log, you are in trouble.

Solution is to increase receive buffer of netlink socket. Note that kernel
doesn't allow to increase it over maximum value defined in
< 2.6.14 doesn't allow to increase it over maximum value defined in
\fI/proc/sys/net/core/rmem_max\fR. If you want to do it, you have to increase
maximum before starting zebra.

Expand Down
14 changes: 13 additions & 1 deletion zebra/rt_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ set_ifindex(struct interface *ifp, unsigned int ifi_index)
ifp->ifindex = ifi_index;
}

#ifndef SO_RCVBUFFORCE
#define SO_RCVBUFFORCE (33)
#endif

static int
netlink_recvbuf (struct nlsock *nl, uint32_t newsize)
{
Expand All @@ -117,8 +121,16 @@ netlink_recvbuf (struct nlsock *nl, uint32_t newsize)
return -1;
}

ret = setsockopt(nl->sock, SOL_SOCKET, SO_RCVBUF, &nl_rcvbufsize,
/* Try force option (linux >= 2.6.14) and fall back to normal set */
if ( zserv_privs.change (ZPRIVS_RAISE) )
zlog_err ("routing_socket: Can't raise privileges");
ret = setsockopt(nl->sock, SOL_SOCKET, SO_RCVBUFFORCE, &nl_rcvbufsize,
sizeof(nl_rcvbufsize));
if ( zserv_privs.change (ZPRIVS_LOWER) )
zlog_err ("routing_socket: Can't lower privileges");
if (ret < 0)
ret = setsockopt(nl->sock, SOL_SOCKET, SO_RCVBUF, &nl_rcvbufsize,
sizeof(nl_rcvbufsize));
if (ret < 0)
{
zlog (NULL, LOG_ERR, "Can't set %s receive buffer size: %s", nl->name,
Expand Down

0 comments on commit f1ef81b

Please sign in to comment.