Re: Patch for Quagga port in 4.3

2008-05-21 Thread Raphael Mazelier

Claudio Jeker a écrit :

Could you try the following diff instead? This should fix the real cause
of the crashes.

  
Thanks for this quick patch. It works very well. I know that my previous 
patch was wrong.
In fact after spending a few hours more, I have made a bigger patch wich 
do almost the same.


I suppose that due to the change in route handling in 4.3, the message 
were send twice in RTM_VERSION 3 and 4.


I still have a problem on a box which have a vlan, interface :

ifconfig  vlan1
vlan1: flags=8843UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST mtu 1500
   lladdr 00:40:f4:8a:16:81
   vlan: 2 priority: 0 parent interface: rl0
   groups: vlan
   inet6 fe80::240:f4ff:fe8a:1681%vlan1 prefixlen 64 scopeid 0x5
   inet 192.168.20.1 netmask 0xff00 broadcast 255.255.255.0

Note the broadcast addr ? I have these behaviour since I upgrade to 4.3.
However the route are correct.
So I wrote this small patch wich test if the broadcast or dest addr are 
not the same as the mask.



$OpenBSD: patch-zebra_if_ioctl_c,v 1.0 2008/05/14 18:31:18 arf Exp $
--- zebra/if_ioctl.c.orig   Wed May 21 18:08:40 2008
+++ zebra/if_ioctl.cWed May 21 18:08:54 2008
@@ -258,18 +258,16 @@ if_getaddrs (void)
 dest_pnt = NULL;

 if (ifap-ifa_dstaddr 
- !IPV4_ADDR_SAME(addr-sin_addr,
- ((struct sockaddr_in *)
-   ifap-ifa_dstaddr)-sin_addr))
+ !IPV4_ADDR_SAME(addr-sin_addr, ((struct sockaddr_in *) 
ifap-ifa_dstaddr)-sin_addr)
+ !IPV4_ADDR_SAME(mask-sin_addr, ((struct sockaddr_in *) 
ifap-ifa_dstaddr)-sin_addr))

   {
 dest = (struct sockaddr_in *) ifap-ifa_dstaddr;
 dest_pnt = dest-sin_addr;
 flags = ZEBRA_IFA_PEER;
   }
- else if (ifap-ifa_broadaddr 
-  !IPV4_ADDR_SAME(addr-sin_addr,
-  ((struct sockaddr_in *)
-ifap-ifa_broadaddr)-sin_addr))
+ else if (ifap-ifa_broadaddr 
+  !IPV4_ADDR_SAME(addr-sin_addr, ((struct sockaddr_in *) 
ifap-ifa_broadaddr)-sin_addr)
+  !IPV4_ADDR_SAME(mask-sin_addr, ((struct sockaddr_in *) 
ifap-ifa_broadaddr)-sin_addr))

   {
 dest = (struct sockaddr_in *) ifap-ifa_broadaddr;
 dest_pnt = dest-sin_addr;
@@ -294,18 +292,16 @@ if_getaddrs (void)
 dest_pnt = NULL;

 if (ifap-ifa_dstaddr 
- !IPV6_ADDR_SAME(addr-sin6_addr,
- ((struct sockaddr_in6 *)
-   ifap-ifa_dstaddr)-sin6_addr))
+ !IPV6_ADDR_SAME(addr-sin6_addr, ((struct sockaddr_in6 
*) ifap-ifa_dstaddr)-sin6_addr)
+ !IPV6_ADDR_SAME(mask-sin6_addr, ((struct sockaddr_in6 
*) ifap-ifa_dstaddr)-sin6_addr))

   {
 dest = (struct sockaddr_in6 *) ifap-ifa_dstaddr;
 dest_pnt = dest-sin6_addr;
 flags = ZEBRA_IFA_PEER;
   }
- else if (ifap-ifa_broadaddr 
-  !IPV6_ADDR_SAME(addr-sin6_addr,
-  ((struct sockaddr_in6 *)
-ifap-ifa_broadaddr)-sin6_addr))
+ else if (ifap-ifa_broadaddr 
+ !IPV6_ADDR_SAME(addr-sin6_addr, ((struct sockaddr_in6 
*) ifap-ifa_broadaddr)-sin6_addr)
+ !IPV6_ADDR_SAME(mask-sin6_addr, ((struct sockaddr_in6 
*) ifap-ifa_broadaddr)-sin6_addr))

   {
 dest = (struct sockaddr_in6 *) ifap-ifa_broadaddr;
 dest_pnt = dest-sin6_addr;






Re: Patch for Quagga port in 4.3

2008-05-20 Thread Claudio Jeker
On Wed, May 14, 2008 at 06:36:36PM +0200, Raphael Mazelier wrote:
 In a previous post, I noticed that Quagga was broken in 4.3.
 After spending some hour to debug, I find were the stack overflow was.
 It's not clear if it was an openbsd bug (strange route in the kernel 
 interface),
 but it's clear for me that quagga don't make enought test before making  
 memcpy (still not a good idea).


Could you try the following diff instead? This should fix the real cause
of the crashes.

-- 
:wq Claudio

Index: Makefile
===
RCS file: /cvs/ports/net/quagga/Makefile,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile
--- Makefile15 Sep 2007 22:36:58 -  1.10
+++ Makefile10 Oct 2007 08:20:29 -
@@ -3,6 +3,7 @@
 COMMENT=   multi-threaded routing daemon
 
 DISTNAME=  quagga-0.99.9
+PKGNAME=   ${DISTNAME}p0
 SHARED_LIBS=ospf   0.0 \
 zebra  0.0
 CATEGORIES=net
Index: patches/patch-zebra_kernel_socket_c
===
RCS file: /cvs/ports/net/quagga/patches/patch-zebra_kernel_socket_c,v
retrieving revision 1.3
diff -u -p -r1.3 patch-zebra_kernel_socket_c
--- patches/patch-zebra_kernel_socket_c 12 Sep 2007 20:31:18 -  1.3
+++ patches/patch-zebra_kernel_socket_c 9 Oct 2007 21:55:04 -
@@ -1,6 +1,6 @@
 $OpenBSD: patch-zebra_kernel_socket_c,v 1.3 2007/09/12 20:31:18 rui Exp $
 zebra/kernel_socket.c.orig Wed Aug 22 17:22:57 2007
-+++ zebra/kernel_socket.c  Tue Sep 11 16:52:21 2007
+--- zebra/kernel_socket.c.orig Wed Aug 22 18:22:57 2007
 zebra/kernel_socket.c  Tue Oct  9 23:54:58 2007
 @@ -136,7 +136,7 @@ struct message rtm_type_str[] =
{RTM_REDIRECT, RTM_REDIRECT},
{RTM_MISS, RTM_MISS},
@@ -10,3 +10,14 @@ $OpenBSD: patch-zebra_kernel_socket_c,v 
{RTM_OLDADD,   RTM_OLDADD},
  #endif /* RTM_OLDADD */
  #ifdef RTM_OLDDEL
+@@ -705,9 +705,7 @@ rtm_read_mesg (struct rt_msghdr *rtm,
+ 
+   /* rt_msghdr version check. */
+   if (rtm-rtm_version != RTM_VERSION) 
+-  zlog (NULL, LOG_WARNING,
+-Routing message version different %d should be %d.
+-This may cause problem\n, rtm-rtm_version, RTM_VERSION);
++  return 0;
+   
+   /* Be sure structure is cleared */
+   memset (dest, 0, sizeof (union sockunion));



Patch for Quagga port in 4.3

2008-05-14 Thread Raphael Mazelier

In a previous post, I noticed that Quagga was broken in 4.3.
After spending some hour to debug, I find were the stack overflow was.
It's not clear if it was an openbsd bug (strange route in the kernel 
interface),
but it's clear for me that quagga don't make enought test before making  
memcpy (still not a good idea).


I propose the following new patch file patch-zebra_kernel_socket_c

--- zebra/kernel_socket.c.orig  Wed Aug 22 18:22:57 2007
+++ zebra/kernel_socket.c   Wed May 14 18:14:47 2008
@@ -98,7 +98,8 @@ extern struct zebra_t zebrad;
{ \
  void *pdest = (DEST); \
  int len = SAROUNDUP ((PNT)); \
-  if ((DEST) != NULL) \
+  if ( ((DEST) != NULL)  \
+   (len = sizeof (union sockunion))) \
memcpy (pdest, (PNT), len); \
  (PNT) += len; \
}
@@ -136,7 +137,7 @@ struct message rtm_type_str[] =
  {RTM_REDIRECT, RTM_REDIRECT},
  {RTM_MISS, RTM_MISS},
  {RTM_LOCK, RTM_LOCK},
-#ifdef OLDADD
+#ifdef RTM_OLDADD
  {RTM_OLDADD,   RTM_OLDADD},
#endif /* RTM_OLDADD */
#ifdef RTM_OLDDEL

It work for me, but I don't know if it was the right solution.
I also commit a bug repport on the quagga bugzilla and I will wait for 
comment, because I think it's real bug, and must be committed upstream.


--
Raphael MAZELIER