Subject: Re: 070812 -current routed broken ?
To: None <current-users@NetBSD.org>
From: David Young <dyoung@pobox.com>
List: current-users
Date: 08/12/2007 20:12:54
--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Mon, Aug 13, 2007 at 02:11:20AM +0200, Frank Kardel wrote:
> Hi !
>
> I found the the current state of kernel<->routed is in bad shape.
> A routed on 070812 -current will enter an endless loop because a msglen
> parameter from sysctl data is 0. Something seems to have changed there
> where routed
> wasn't expecting it. Anyone seeing the same thing ?
It looks to me like sbin/routed/if.c:ifinit() will sometimes overwrite
the ifam_len member of the next message while it processes the first:
sdl = (struct sockaddr_dl *)(ifm + 1);
sdl->sdl_data[sdl->sdl_nlen] = 0;
strncpy(ifs0.int_name, sdl->sdl_data,
MIN(sizeof(ifs0.int_name), sdl->sdl_nlen));
continue;
I have attached a patch for you to try.
I don't know why you did not see this before. Perhaps a sockaddr_dl
copied from the kernel fits its contents tighter than before? There could
be a new bug in the kernel, of course.
Dave
--
David Young OJC Technologies
dyoung@ojctech.com Urbana, IL * (217) 278-3933 ext 24
--OXfL5xGRrasGEqWY
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ifinit.patch"
? .if.c.swp
Index: if.c
===================================================================
RCS file: /cvsroot/src/sbin/routed/if.c,v
retrieving revision 1.25
diff -p -u -u -p -r1.25 if.c
--- if.c 17 Mar 2006 16:58:09 -0000 1.25
+++ if.c 13 Aug 2007 01:12:35 -0000
@@ -749,7 +749,7 @@ ifinit(void)
continue; /* just ignore compat message */
#endif
if (ifam->ifam_type == RTM_IFINFO) {
- struct sockaddr_dl *sdl;
+ const struct sockaddr_dl *sdl;
ifm = (struct if_msghdr *)ifam;
/* make prototype structure for the IP aliases
@@ -769,10 +769,10 @@ ifinit(void)
#ifdef sgi
ifs0.int_data.odrops = ifm->ifm_data.ifi_odrops;
#endif
- sdl = (struct sockaddr_dl *)(ifm + 1);
- sdl->sdl_data[sdl->sdl_nlen] = 0;
- strncpy(ifs0.int_name, sdl->sdl_data,
- MIN(sizeof(ifs0.int_name), sdl->sdl_nlen));
+ sdl = (const struct sockaddr_dl *)(ifm + 1);
+ /* NUL-termination by memset, above. */
+ memcpy(ifs0.int_name, sdl->sdl_data,
+ MIN(sizeof(ifs0.int_name) - 1, sdl->sdl_nlen));
continue;
}
if (ifam->ifam_type != RTM_NEWADDR) {
--OXfL5xGRrasGEqWY--