+ fix minor regression in OSPF sending buffer adjustment logic

This commit is contained in:
Denis Ovsienko 2007-09-18 09:01:13 +00:00
parent 96934e6ac6
commit f102e75f61
4 changed files with 18 additions and 11 deletions

View file

@ -1,3 +1,10 @@
2007-09-18 Denis Ovsienko
* ospf_network.c: (ospf_adjust_sndbuflen) Don't complain
about getting more buffer space, than requested.
* ospfd.[ch]: (ospf_new) Abandon OSPF_SNDBUFLEN_DEFAULT
and consider OS's initial buffer size instead.
2007-08-21 Denis Ovsienko 2007-08-21 Denis Ovsienko
* ospfd.h: Extend struct ospf with maxsndbuflen field and * ospfd.h: Extend struct ospf with maxsndbuflen field and

View file

@ -249,15 +249,15 @@ ospf_adjust_sndbuflen (struct ospf * ospf, int buflen)
zlog_err ("%s: could not raise privs, %s", __func__, zlog_err ("%s: could not raise privs, %s", __func__,
safe_strerror (errno)); safe_strerror (errno));
/* Now we try to set SO_SNDBUF to what our caller has requested /* Now we try to set SO_SNDBUF to what our caller has requested
* (OSPF_SNDBUFLEN_DEFAULT initially, which seems to be a sane * (the MTU of a newly added interface). However, if the OS has
* default; or the MTU of a newly added interface). However, * truncated the actual buffer size to somewhat less size, try
* if the OS has truncated the actual buffer size to somewhat * to detect it and update our records appropriately. The OS
* less or bigger size, try to detect it and update our records * may allocate more buffer space, than requested, this isn't
* appropriately. * a error.
*/ */
ret = setsockopt_so_sendbuf (ospf->fd, buflen); ret = setsockopt_so_sendbuf (ospf->fd, buflen);
newbuflen = getsockopt_so_sendbuf (ospf->fd); newbuflen = getsockopt_so_sendbuf (ospf->fd);
if (ret < 0 || newbuflen != buflen) if (ret < 0 || newbuflen < buflen)
zlog_warn ("%s: tried to set SO_SNDBUF to %d, but got %d", zlog_warn ("%s: tried to set SO_SNDBUF to %d, but got %d",
__func__, buflen, newbuflen); __func__, buflen, newbuflen);
if (newbuflen >= 0) if (newbuflen >= 0)

View file

@ -33,6 +33,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "sockunion.h" /* for inet_aton () */ #include "sockunion.h" /* for inet_aton () */
#include "zclient.h" #include "zclient.h"
#include "plist.h" #include "plist.h"
#include "sockopt.h"
#include "ospfd/ospfd.h" #include "ospfd/ospfd.h"
#include "ospfd/ospf_network.h" #include "ospfd/ospf_network.h"
@ -212,8 +213,10 @@ ospf_new (void)
"a socket"); "a socket");
exit(1); exit(1);
} }
new->maxsndbuflen = 0; new->maxsndbuflen = getsockopt_so_sendbuf (new->fd);
ospf_adjust_sndbuflen (new, OSPF_SNDBUFLEN_DEFAULT); if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
zlog_debug ("%s: starting with OSPF send buffer size %d",
__func__, new->maxsndbuflen);
if ((new->ibuf = stream_new(OSPF_MAX_PACKET_SIZE+1)) == NULL) if ((new->ibuf = stream_new(OSPF_MAX_PACKET_SIZE+1)) == NULL)
{ {
zlog_err("ospf_new: fatal error: stream_new(%u) failed allocating ibuf", zlog_err("ospf_new: fatal error: stream_new(%u) failed allocating ibuf",

View file

@ -129,9 +129,6 @@
#define OSPF_LS_REFRESH_SHIFT (60 * 15) #define OSPF_LS_REFRESH_SHIFT (60 * 15)
#define OSPF_LS_REFRESH_JITTER 60 #define OSPF_LS_REFRESH_JITTER 60
/* Initial send buffer size for ospfd raw sending socket. */
#define OSPF_SNDBUFLEN_DEFAULT 1024
/* OSPF master for system wide configuration and variables. */ /* OSPF master for system wide configuration and variables. */
struct ospf_master struct ospf_master
{ {