From de587d745e3b8b75cf92b2bff78af370adddb39f Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 7 Dec 2016 13:21:45 -0200 Subject: [PATCH] ospfd: set the OSPF socket's send buffer size only once This reverts commit b7fe4141, which introduced a logic where the OSPF send buffer size was dynamically updated to reflect the maximum MTU of the OSPF enabled interfaces (this was done to make ospfd work with interfaces configured for jumbo frames). Since commit a78d75b0, this is not necessary anymore because ospf_sock_init() now sets the OSPF send buffer size to a very high value (8MB). Also, the previous logic was broken because it didn't account for run-time interface MTU changes. Signed-off-by: Renato Westphal Signed-off-by: David Lamparter --- ospfd/ospf_interface.c | 5 ----- ospfd/ospf_network.c | 35 ----------------------------------- ospfd/ospf_network.h | 1 - ospfd/ospf_packet.c | 8 ++------ ospfd/ospfd.c | 4 ---- ospfd/ospfd.h | 1 - 6 files changed, 2 insertions(+), 52 deletions(-) diff --git a/ospfd/ospf_interface.c b/ospfd/ospf_interface.c index 2c8124b93d..8440765579 100644 --- a/ospfd/ospf_interface.c +++ b/ospfd/ospf_interface.c @@ -797,11 +797,6 @@ 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", __func__); ospf_if_stream_set (oi); OSPF_ISM_EVENT_SCHEDULE (oi, ISM_InterfaceUp); } diff --git a/ospfd/ospf_network.c b/ospfd/ospf_network.c index 088123ea24..f02fcd14ac 100644 --- a/ospfd/ospf_network.c +++ b/ospfd/ospf_network.c @@ -41,7 +41,6 @@ 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" @@ -258,37 +257,3 @@ ospf_sock_init (void) return ospf_sock; } - -void -ospf_adjust_sndbuflen (struct ospf * ospf, unsigned 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 - * (the MTU of a newly added interface). However, if the OS has - * truncated the actual buffer size to somewhat less size, try - * to detect it and update our records appropriately. The OS - * may allocate more buffer space, than requested, this isn't - * a error. - */ - ret = setsockopt_so_sendbuf (ospf->fd, buflen); - newbuflen = getsockopt_so_sendbuf (ospf->fd); - if (ret < 0 || newbuflen < 0 || newbuflen < (int) buflen) - zlog_warn ("%s: tried to set SO_SNDBUF to %u, but got %d", - __func__, buflen, newbuflen); - if (newbuflen >= 0) - ospf->maxsndbuflen = (unsigned int)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)); -} diff --git a/ospfd/ospf_network.h b/ospfd/ospf_network.h index 8257adb4af..bc01a84325 100644 --- a/ospfd/ospf_network.h +++ b/ospfd/ospf_network.h @@ -34,6 +34,5 @@ extern int ospf_if_drop_alldrouters (struct ospf *, struct prefix *, ifindex_t); extern int ospf_if_ipmulticast (struct ospf *, struct prefix *, ifindex_t); extern int ospf_sock_init (void); -extern void ospf_adjust_sndbuflen (struct ospf *, unsigned int); #endif /* _ZEBRA_OSPF_NETWORK_H */ diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index 72ce5586f6..f7d1d0fa7d 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -691,13 +691,9 @@ ospf_write (struct thread *thread) last_serviced_oi = oi; } pkt_count++; - /* convenience - max OSPF data per packet, - * and reliability - not more data, than our - * socket can accept - */ #ifdef WANT_OSPF_WRITE_FRAGMENT - maxdatasize = MIN (oi->ifp->mtu, ospf->maxsndbuflen) - - sizeof (struct ip); + /* convenience - max OSPF data per packet */ + maxdatasize = oi->ifp->mtu - sizeof (struct ip); #endif /* WANT_OSPF_WRITE_FRAGMENT */ /* Get one packet from queue. */ op = ospf_fifo_head (oi->obuf); diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 7156c1edac..1a7691c529 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -280,10 +280,6 @@ ospf_new (u_short instance) "a socket"); exit(1); } - new->maxsndbuflen = getsockopt_so_sendbuf (new->fd); - if (IS_DEBUG_OSPF (zebra, ZEBRA_INTERFACE)) - zlog_debug ("%s: starting with OSPF send buffer size %u", - __func__, new->maxsndbuflen); if ((new->ibuf = stream_new(OSPF_MAX_PACKET_SIZE+1)) == NULL) { zlog_err("ospf_new: fatal error: stream_new(%u) failed allocating ibuf", diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h index 93b5ab766a..41a7a30d85 100644 --- a/ospfd/ospfd.h +++ b/ospfd/ospfd.h @@ -252,7 +252,6 @@ struct ospf int write_oi_count; /* Num of packets sent per thread invocation */ struct thread *t_read; int fd; - unsigned int maxsndbuflen; struct stream *ibuf; struct list *oi_write_q;