diff options
author | Ulrich Weber <ulrich.weber@Sophos.com> | 2013-01-22 10:39:18 +0000 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2013-02-23 18:19:24 +0100 |
commit | f1ef81b2476ea533ac3d2129aa0e89653c427323 (patch) | |
tree | 107bc07162b377b16af43d59cca4ce1a82a747f0 /zebra | |
parent | 66b63aa036c75737c3a8cea9693eff4dec84f903 (diff) |
zebra: use SO_RCVBUFFORCE for netlink socket
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 <ulrich.weber@sophos.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'zebra')
-rw-r--r-- | zebra/rt_netlink.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index fa446a56..bab17037 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -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) { @@ -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, |