[quagga-dev 10013] Re: Set macro NL_PKT_BUF_SIZE to 8192

Renato Westphal renatowestphal at gmail.com
Wed Nov 21 13:18:58 GMT 2012


2012/11/21 高鹏 <gpstrive at gmail.com>:
> Hi everyone,
>     Recently, I have met a trouble that next hop of the update message sent
> from bgpd is ::(all zero) which should be 2001::64/64 . At last , I found
> the reason that  buf[4096] or buf[NL_PKT_BUF_SIZE] in function
> netlink_parse_info(zebra/rt_netlink.c) was overflow.This
> result in zebra can't get the complete interfaces and addresses of the
> system.
>     I looked into the linux kernel v3.6 and discovered the following
> sections:
>
> """
>      /*
> 214  *  skb should fit one page. This choice is good for headerless malloc.
> 215  *  But we should limit to 8K so that userspace does not have to
> 216  *  use enormous buffer sizes on recvmsg() calls just to avoid
> 217  *  MSG_TRUNC when PAGE_SIZE is very large.
> 218  */
> 219 #if PAGE_SIZE < 8192UL
> 220 #define NLMSG_GOODSIZE  SKB_WITH_OVERHEAD(PAGE_SIZE)
> 221 #else
> 222 #define NLMSG_GOODSIZE  SKB_WITH_OVERHEAD(8192UL)
> 223 #endif
>
> """
>   PAGE_SIZE on my platform is 64KB, in addtion I had added so many virtual
> interfaces.
>   I changed buf[4096] to buf[8192], everything is normal.
>  So maybe we should be consistent with linux kernel.

Good catch... libmnl (minimalist netlink library) uses this: #define
MNL_SOCKET_BUFFER_SIZE (getpagesize() < 8192L ? getpagesize() : 8192L)

-- 
Renato Westphal




More information about the Quagga-dev mailing list