2004-01-08 Greg Troxel <gdt@fnord.ir.bbn.com>

* kernel_socket.c (kernel_read): Use sockaddr_storage in buffer
        for reading kernel messages to ensure enough space (necessary on
        Solaris due to sockaddr_dl being large).  Thanks to Sowmini
        Varadhan for help with this change.
This commit is contained in:
gdt 2004-01-08 15:44:29 +00:00
parent 9ccabd1cdb
commit b27900b7c0
2 changed files with 21 additions and 9 deletions

View File

@ -1,3 +1,10 @@
2004-01-08 Greg Troxel <gdt@fnord.ir.bbn.com>
* kernel_socket.c (kernel_read): Use sockaddr_storage in buffer
for reading kernel messages to ensure enough space (necessary on
Solaris due to sockaddr_dl being large). Thanks to Sowmini
Varadhan for help with this change.
2004-01-06 Greg Troxel <gdt@t1.ir.bbn.com> 2004-01-06 Greg Troxel <gdt@t1.ir.bbn.com>
* rtadv.c (rtadv_send_packet): Change perror to zlog_err. * rtadv.c (rtadv_send_packet): Change perror to zlog_err.

View File

@ -849,10 +849,12 @@ kernel_read (struct thread *thread)
/* /*
* This must be big enough for any message the kernel might send. * This must be big enough for any message the kernel might send.
* The code previously used RTAX_MAX struct sockaddrs in all cases, * Rather than determining how many sockaddrs of what size might be
* but now that sockaddrs are variable size, this doesn't work * in each particular message, just use RTAX_MAX of sockaddr_storage
* (Solaris has 244 bytes of sdl_data!). For now, add a struct * for each. Note that the sockaddrs must be after each message
* sockaddr_dl to the case where it is used. * definition, or rather after whichever happens to be the largest,
* since the buffer needs to be big enough for a message and the
* sockaddrs together.
*/ */
union union
{ {
@ -860,22 +862,21 @@ kernel_read (struct thread *thread)
struct struct
{ {
struct rt_msghdr rtm; struct rt_msghdr rtm;
struct sockaddr addr[RTAX_MAX]; struct sockaddr_storage addr[RTAX_MAX];
} r; } r;
/* Interface information. */ /* Interface information. */
struct struct
{ {
struct if_msghdr ifm; struct if_msghdr ifm;
struct sockaddr_dl; struct sockaddr_storage addr[RTAX_MAX];
struct sockaddr addr[RTAX_MAX-1];
} im; } im;
/* Interface address information. */ /* Interface address information. */
struct struct
{ {
struct ifa_msghdr ifa; struct ifa_msghdr ifa;
struct sockaddr addr[RTAX_MAX]; struct sockaddr_storage addr[RTAX_MAX];
} ia; } ia;
#ifdef RTM_IFANNOUNCE #ifdef RTM_IFANNOUNCE
@ -883,7 +884,7 @@ kernel_read (struct thread *thread)
struct struct
{ {
struct if_announcemsghdr ifan; struct if_announcemsghdr ifan;
struct sockaddr addr[RTAX_MAX]; struct sockaddr_storage addr[RTAX_MAX];
} ian; } ian;
#endif /* RTM_IFANNOUNCE */ #endif /* RTM_IFANNOUNCE */
@ -908,6 +909,10 @@ kernel_read (struct thread *thread)
rtm = &buf.r.rtm; rtm = &buf.r.rtm;
/*
* Ensure that we didn't drop any data, so that processing routines
* can assume they have the whole message.
*/
if (rtm->rtm_msglen != nbytes) if (rtm->rtm_msglen != nbytes)
{ {
zlog_warn ("kernel_read: rtm->rtm_msglen %d, nbytes %d, type %d\n", zlog_warn ("kernel_read: rtm->rtm_msglen %d, nbytes %d, type %d\n",