summaryrefslogtreecommitdiffstats
path: root/ospf6d/ospf6_network.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2016-12-07 16:21:46 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2016-12-08 12:50:25 +0100
commit6228a3b8743ea2a6589070de926588e2ceb0f27f (patch)
tree1d4f333086f14d333c2aae31b1c01a27e55e8b0b /ospf6d/ospf6_network.c
parentospfd: set the OSPF socket's send buffer size only once (diff)
downloadfrr-6228a3b8743ea2a6589070de926588e2ceb0f27f.tar.xz
frr-6228a3b8743ea2a6589070de926588e2ceb0f27f.zip
*: always set SO_SNDBUF and SO_RCVBUF using a best effort approach
If we fail to set any socket's buffer size, try again with a smaller value and keep going until it succeeds. This is better than just giving up or, even worse, abort the creation of a socket (ospf6d and ripd). Fix broken ospf6d on FreeBSD. Signed-off-by: Renato Westphal <renato@opensourcerouting.org> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'ospf6d/ospf6_network.c')
-rw-r--r--ospf6d/ospf6_network.c38
1 files changed, 2 insertions, 36 deletions
diff --git a/ospf6d/ospf6_network.c b/ospf6d/ospf6_network.c
index 0d730c596..0217d6603 100644
--- a/ospf6d/ospf6_network.c
+++ b/ospf6d/ospf6_network.c
@@ -118,8 +118,6 @@ ospf6_sso (ifindex_t ifindex, struct in6_addr *group, int option)
struct ipv6_mreq mreq6;
int ret;
int bufsize = (8 * 1024 * 1024);
- int optval;
- socklen_t optlen = sizeof(optval);
assert (ifindex);
mreq6.ipv6mr_interface = ifindex;
@@ -134,40 +132,8 @@ ospf6_sso (ifindex_t ifindex, struct in6_addr *group, int option)
return ret;
}
- if ((ret = setsockopt (ospf6_sock, SOL_SOCKET, SO_SNDBUF,
- &bufsize, sizeof (bufsize))) < 0)
- {
- zlog_err ("Couldn't increase raw wbuf size: %s\n", safe_strerror(errno));
- return ret;
- }
-
- if ((ret = getsockopt (ospf6_sock, SOL_SOCKET, SO_SNDBUF,
- &optval, &optlen)) < 0)
- {
- zlog_err ("getsockopt of SO_SNDBUF failed with error %s\n", safe_strerror(errno));
- return ret;
- }
- else if (optval < bufsize)
- {
- zlog_err ("Unable to SO_SNDBUF to %d, set to %d\n", bufsize, optval);
- }
-
- if ((ret = setsockopt (ospf6_sock, SOL_SOCKET, SO_RCVBUF,
- &bufsize, sizeof (bufsize))) < 0)
- {
- zlog_err ("Couldn't increase raw rbuf size: %s\n", safe_strerror(errno));
- }
-
- if ((ret = getsockopt (ospf6_sock, SOL_SOCKET, SO_RCVBUF,
- &optval, &optlen)) < 0)
- {
- zlog_err ("getsockopt of SO_RCVBUF failed with error %s\n", safe_strerror(errno));
- return ret;
- }
- else if (optval < bufsize)
- {
- zlog_err ("Unable to SO_RCVBUF to %d, set to %d\n", bufsize, optval);
- }
+ setsockopt_so_sendbuf (ospf6_sock, bufsize);
+ setsockopt_so_recvbuf (ospf6_sock, bufsize);
return 0;
}