mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-04-29 02:37:00 +00:00
Bug #362 is fixed now.
This commit is contained in:
parent
1ba27564f3
commit
b7fe414112
@ -1,3 +1,8 @@
|
||||
2007-08-21 Denis Ovsienko
|
||||
|
||||
* sockopt.[ch]: (setsockopt_so_sendbuf, getsockopt_so_sendbuf):
|
||||
new functions to adjust ospfd working socket.
|
||||
|
||||
2007-08-13 Denis Ovsienko
|
||||
|
||||
* zebra.h: introduce ZEBRA_ERR_KERNEL and ZEBRA_ERR_NOERROR
|
||||
|
@ -36,6 +36,35 @@ setsockopt_so_recvbuf (int sock, int size)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
setsockopt_so_sendbuf (const int sock, int size)
|
||||
{
|
||||
int ret = setsockopt (sock, SOL_SOCKET, SO_SNDBUF,
|
||||
(char *)&size, sizeof (int));
|
||||
|
||||
if (ret < 0)
|
||||
zlog_err ("fd %d: can't setsockopt SO_SNDBUF to %d: %s",
|
||||
sock, size, safe_strerror (errno));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
getsockopt_so_sendbuf (const int sock)
|
||||
{
|
||||
u_int32_t optval;
|
||||
socklen_t optlen = sizeof (optval);
|
||||
int ret = getsockopt (sock, SOL_SOCKET, SO_SNDBUF,
|
||||
(char *)&optval, &optlen);
|
||||
if (ret < 0)
|
||||
{
|
||||
zlog_err ("fd %d: can't getsockopt SO_SNDBUF: %d (%s)",
|
||||
sock, errno, safe_strerror (errno));
|
||||
return ret;
|
||||
}
|
||||
return optval;
|
||||
}
|
||||
|
||||
static void *
|
||||
getsockopt_cmsg_data (struct msghdr *msgh, int level, int type)
|
||||
{
|
||||
|
@ -23,6 +23,8 @@
|
||||
#define _ZEBRA_SOCKOPT_H
|
||||
|
||||
extern int setsockopt_so_recvbuf (int sock, int size);
|
||||
extern int setsockopt_so_sendbuf (const int sock, int size);
|
||||
extern int getsockopt_so_sendbuf (const int sock);
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
extern int setsockopt_ipv6_pktinfo (int, int);
|
||||
|
@ -1,3 +1,16 @@
|
||||
2007-08-21 Denis Ovsienko
|
||||
|
||||
* ospfd.h: Extend struct ospf with maxsndbuflen field and
|
||||
define its default value.
|
||||
* ospfd.c: (ospf_new) init maxsndbuflen
|
||||
* ospf_interface.c: (ospf_if_up) Call ospf_adjust_sndbuflen()
|
||||
for each regular interface being brought up.
|
||||
* ospf_network.[ch]: (ospf_adjust_sndbuflen) New function
|
||||
makes sure ospf socket sending buffer is large enough
|
||||
to cover the biggest interface MTU we have seen ever.
|
||||
* ospf_packet.c: (ospf_write) Use maxsndbuflen to decide on
|
||||
the biggest amount of data we are going to send at once.
|
||||
|
||||
2007-08-07 Paul Jakma <paul.jakma@sun.com>
|
||||
|
||||
* ospf_spf.c: (ospf_spf_next) Finish off the explanatory
|
||||
|
@ -781,6 +781,11 @@ ospf_if_up (struct ospf_interface *oi)
|
||||
OSPF_ISM_EVENT_SCHEDULE (oi, ISM_LoopInd);
|
||||
else
|
||||
{
|
||||
struct ospf *ospf = ospf_lookup ();
|
||||
if (ospf != NULL)
|
||||
ospf_adjust_sndbuflen (ospf, oi->ifp->mtu);
|
||||
else
|
||||
zlog_warn ("%s: ospf_lookup() returned NULL");
|
||||
ospf_if_stream_set (oi);
|
||||
OSPF_ISM_EVENT_SCHEDULE (oi, ISM_InterfaceUp);
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ extern struct zebra_privs_t ospfd_privs;
|
||||
#include "ospfd/ospf_lsdb.h"
|
||||
#include "ospfd/ospf_neighbor.h"
|
||||
#include "ospfd/ospf_packet.h"
|
||||
#include "ospfd/ospf_dump.h"
|
||||
|
||||
|
||||
|
||||
@ -233,3 +234,37 @@ ospf_sock_init (void)
|
||||
|
||||
return ospf_sock;
|
||||
}
|
||||
|
||||
void
|
||||
ospf_adjust_sndbuflen (struct ospf * ospf, int buflen)
|
||||
{
|
||||
int ret, newbuflen;
|
||||
/* Check if any work has to be done at all. */
|
||||
if (ospf->maxsndbuflen >= buflen)
|
||||
return;
|
||||
if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE))
|
||||
zlog_debug ("%s: adjusting OSPF send buffer size to %d",
|
||||
__func__, buflen);
|
||||
if (ospfd_privs.change (ZPRIVS_RAISE))
|
||||
zlog_err ("%s: could not raise privs, %s", __func__,
|
||||
safe_strerror (errno));
|
||||
/* Now we try to set SO_SNDBUF to what our caller has requested
|
||||
* (OSPF_SNDBUFLEN_DEFAULT initially, which seems to be a sane
|
||||
* default; or the MTU of a newly added interface). However,
|
||||
* if the OS has truncated the actual buffer size to somewhat
|
||||
* less or bigger size, try to detect it and update our records
|
||||
* appropriately.
|
||||
*/
|
||||
ret = setsockopt_so_sendbuf (ospf->fd, buflen);
|
||||
newbuflen = getsockopt_so_sendbuf (ospf->fd);
|
||||
if (ret < 0 || newbuflen != buflen)
|
||||
zlog_warn ("%s: tried to set SO_SNDBUF to %d, but got %d",
|
||||
__func__, buflen, newbuflen);
|
||||
if (newbuflen >= 0)
|
||||
ospf->maxsndbuflen = newbuflen;
|
||||
else
|
||||
zlog_warn ("%s: failed to get SO_SNDBUF", __func__);
|
||||
if (ospfd_privs.change (ZPRIVS_LOWER))
|
||||
zlog_err ("%s: could not lower privs, %s", __func__,
|
||||
safe_strerror (errno));
|
||||
}
|
||||
|
@ -34,5 +34,6 @@ extern int ospf_if_drop_alldrouters (struct ospf *, struct prefix *,
|
||||
unsigned int);
|
||||
extern int ospf_if_ipmulticast (struct ospf *, struct prefix *, unsigned int);
|
||||
extern int ospf_sock_init (void);
|
||||
extern void ospf_adjust_sndbuflen (struct ospf *, int);
|
||||
|
||||
#endif /* _ZEBRA_OSPF_NETWORK_H */
|
||||
|
@ -602,8 +602,12 @@ ospf_write (struct thread *thread)
|
||||
ipid = (time(NULL) & 0xffff);
|
||||
#endif /* WANT_OSPF_WRITE_FRAGMENT */
|
||||
|
||||
/* convenience - max OSPF data per packet */
|
||||
maxdatasize = oi->ifp->mtu - sizeof (struct ip);
|
||||
/* convenience - max OSPF data per packet,
|
||||
* and reliability - not more data, than our
|
||||
* socket can accept
|
||||
*/
|
||||
maxdatasize = MIN (oi->ifp->mtu, ospf->maxsndbuflen) -
|
||||
sizeof (struct ip);
|
||||
|
||||
/* Get one packet from queue. */
|
||||
op = ospf_fifo_head (oi->obuf);
|
||||
|
@ -212,6 +212,8 @@ ospf_new (void)
|
||||
"a socket");
|
||||
exit(1);
|
||||
}
|
||||
new->maxsndbuflen = 0;
|
||||
ospf_adjust_sndbuflen (new, OSPF_SNDBUFLEN_DEFAULT);
|
||||
if ((new->ibuf = stream_new(OSPF_MAX_PACKET_SIZE+1)) == NULL)
|
||||
{
|
||||
zlog_err("ospf_new: fatal error: stream_new(%u) failed allocating ibuf",
|
||||
|
@ -129,6 +129,9 @@
|
||||
#define OSPF_LS_REFRESH_SHIFT (60 * 15)
|
||||
#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. */
|
||||
struct ospf_master
|
||||
{
|
||||
@ -266,6 +269,7 @@ struct ospf
|
||||
struct thread *t_write;
|
||||
struct thread *t_read;
|
||||
int fd;
|
||||
int maxsndbuflen;
|
||||
struct stream *ibuf;
|
||||
struct list *oi_write_q;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user