š
š
03.11.2015, 01:29, "Ondrej Zajicek" <santiago@crfreenet.org>:

On Tue, Nov 03, 2015 at 12:15:01AM +0300, Alexander V. Chernikov wrote:

ššššHi,
šššš*
ššššCurrently, if the number of your established BGP sessions is larger than
ššššFD_SETSIZE limit, then you will get 100% cpu usage on select() (returning
ššššEINVAL for nfds) after trying to include the first fd>=FD_SETSIZE.
ššššProbably, the better way of handling this would be by explicitly rejecting
ššššactive/passive sockets setup with proper error message so user could
ššššrebuild bird with appropriate limit without spending time on diagnosing
šššš100% cpu usage issue.


Hi

Thanks for the patch, that makes perfect sense. Will be merged ASAP.

Great, thank you :)


BTW, is it possible to change the limit by just redefining it and
rebuilding BIRD? Aren't there any problems on the kernel side?

Well, it depends. For FreeBSD setting FD_SETSIZE manually before sys header inclusion "just works" (and this is documented in select(2)).
The same would probably also work for Linux (not 100% sure about FORTIFY_SOURCE version).
It looks like people simply tend to switch to other primitives instead of fighting with FD_SETSIZE ( https://sourceware.org/bugzilla/show_bug.cgi?id=10352šis a good example).
Not sure if bird needs os-dependent stuff like eventports/epoll/kqueue variant and own libev[ent], but having poll() as compile-time option might also be an option.
(Not insisting on anything, select() is fine for our workload, just discussing).
š


Just some minor comment:
š

šdiff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
ššššif (sk_setup(t) < 0)
šššš{
šššššš/* FIXME: Call err_hook instead ? */
š@@ -1404,6 +1415,12 @@ sk_open(sock *s)
ššššif (fd < 0)
ššššššERR("socket");

š+ if (fd >= FD_SETSIZE)
š+ {
š+ log(L_ERR "Socket setup failed due to FD_SETSIZE limit (%d)", FD_SETSIZE);
š+ ERR2("FD_SETSIZE limit reached");
š+ }


It is unnecessary to do log() here, ERR2() stores the error message in the
socket and later it will be logged by the caller using sk_log_error().

Yes, the only reason I wrote log() was to print bundled FD_SETSIZE value.
Probably for the first time it will always be 1024, so that's fine :)

š

--
Elen sila lumenn' omentielvo


Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."