[quagga-dev 1420] Re: [Zebra-pj-commit] "quagga/lib ChangeLog sockopt.c sockopt.h"

Paul Jakma paul at clubi.ie
Thu Aug 19 15:52:00 BST 2004

On Thu, 19 Aug 2004, Greg Troxel wrote:

>  #define SOPT_SIZE_CMSG_PKTINFO_IPV6() (sizeof (struct in6_pktinfo));
> I don't mean to imply that you caused any problems with this, but 
> there seems to be an underlying problem in ospfd where this is 
> used:


>    char buff [sizeof (*cmsg) + SOPT_SIZE_CMSG_PKTINFO_IPV4()];
>    msgh.msg_control = (caddr_t) buff;
>    msgh.msg_controllen = sizeof (buff);
> The macro in sockopt.h returns the actual size, but the CMSG_SPACE 
> padding is not done (see /usr/include/sys/socket.h on netbsd, 
> assuming this is the same on linux but not sure).

Quite possible. My goal was simply to shift useage to a central place 
with minimum of fuss. The above was the most common way to allocate 
the cmsg buffer, so doing it so allowed me to remain bug compatible.

> In contrast, I fixed zebra/rtadvd.c:
>  msg.msg_controllen = CMSG_SPACE(sizeof(struct in6_pktinfo));

I'd rather have SOPT_SIZE_CMSG_PKTINFO_IPV6() and have 

For IPv6 it doesnt matter, cause thankfully v6 APIs are more 
consistent. But for v4, I'd prefer code not to have anything more 
than a vague notion of "i want to retrieve the ifindex", and we migth 
as well extend to v6.

This probably implies wrapping up controll message access completely.

> cmsghdr is 12 bytes, so on sparc and sparc64 it gets aligned to 16.
> So I would expect this not to work on NetBSD/sparc64, yet it seems to.


Paul Jakma	paul at clubi.ie	paul at jakma.org	Key ID: 64A2FF6A
evil hackers from Serbia.

More information about the Quagga-dev mailing list