On a router with ~10k+ connected devices ndp -an fails with ENOMEM because of some additional NDP records were added between sysctl() buffer size estimate and data fetch calls:
> ndp -an ndp: sysctl(PF_ROUTE, NET_RT_FLAGS): Cannot allocate memory
This patch allocates more space based on size estimate: 1/64 (~2%) of additional space, but not less that 4 m_rtmsg structures.