Esempio n. 1
0
void ospf_adjust_sndbuflen_oisock (struct ospf * ospf, int buflen,struct ospf_interface *oi)
{
    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);
    }

    ret = setsockopt_so_sendbuf (oi->packet_fd, buflen);
    
    newbuflen = getsockopt_so_sendbuf (oi->packet_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__);
    }

}
Esempio n. 2
0
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
   * (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 < 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));
}