Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 04 Oct 2002 19:55:15 +0300
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        "Vladimir B. Grebenschikov" <vova@sw.ru>
Cc:        sumikawa@FreeBSD.org, freebsd-net@FreeBSD.org
Subject:   Re: zebra interface flags problem on 4.7-RC2 (IFF_PROMISC)
Message-ID:  <3D9DC7F3.7B966349@FreeBSD.org>
References:  <1033739506.1060.16.camel@vbook.express.ru>  <20021004140644.GB61661@vega.vega.com> <1033741307.1060.22.camel@vbook.express.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------4E39E42B7C27B4B2B6476BD6
Content-Type: text/plain; charset=koi8-r
Content-Transfer-Encoding: 8bit

Closer look at zebra's code revealed that my initial guess was
entirely correct. The problem is that it doesn't bother to zero out
ifreq structure allocated on stack, which leads to this misbehaviour.

Attached patch should fix the problem - unfortunately due to code
freeze I can't commit it immediately.

-Maxim

"Vladimir B. Grebenschikov" wrote:
> 
> χ Fri, 04.10.2002, Χ 18:06, Maxim Sobolev ΞΑΠΙΣΑΜ:
> > On Fri, Oct 04, 2002 at 05:51:46PM +0400, Vladimir B.  Grebenschikov wrote:
> > >
> > > Hi
> > >
> > > I have tried to install fresh zebra (from ports) on 4.7-RC2
> > >
> > > have a problem - zebra turns on promiscuity mode on interface,
> > > it is completely unacceptable when interface connected to HUB (not
> > > switch) - router begins resend all packets.
> > >
> > > # ifconfig fxp1
> > > fxp1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
> > >         inet 193.125.143.129 netmask 0xffffff00 broadcast
> > > 193.125.143.255
> > >         ether 00:a0:c9:41:a3:a3
> > >         media: Ethernet autoselect (10baseT/UTP)
> > >         status: active
> > > # zebra -d
> > > 2002/10/04 16:33:42 ZEBRA: can't get ip6forwarding value
> > > # ifconfig fxp1
> > > fxp1: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu
> > > 1500
> > >         inet 193.125.143.129 netmask 0xffffff00 broadcast
> > > 193.125.143.255
> > >         ether 00:a0:c9:41:a3:a3
> > >         media: Ethernet autoselect (10baseT/UTP)
> > >         status: active
> > >
> > >
> > > Nothing special in zebra config, just installed 4.7-RC2, just upgraded
> > > zebra.
> > >
> > > I am not sure is it Zebra-related or FreeBSD-related problem
> > > digging into zebra code do not show any abnormal interface flags
> > > installed.
> >
> > This is probably a bug in zebra - I guess that it's doesn't clear
> > 'struct ifreq' properly before SIOCSIFFLAGS ioctl(2).
> 
> Zebra explicitly sets flags like this:
> ioctl.c:  ifreq.ifr_flags = ifp->flags;
> ioctl.c:  ifreq.ifr_flags |= flags;
> 
> and I have tried to change code:
> 
> ioctl.c:  ifreq.ifr_flags = ifp->flags;
> ioctl.c:  ifreq.ifr_flags |= flags;
> ioctl.c:  ifreq.ifr_flags &= ~(IFF_PROMISC);
> 
> - does not help.
> 
> > -Maxim
> >
> > >
> > > May be problem related to following commit:
> > >
> > > date: 2002/08/30 14:23:38;  author: sobomax;  state: Exp;  lines: +25 -4
> > > MFC: user-setable promisc mode. The code is slightly diffrent (and
> > > uglier)
> > > than in HEAD, because we have had to preserve kernel ABI, so that
> > > increasing
> > > if_flags to 32 bits was not an option.
> > >
> > >
> > > --
> > > Vladimir B. Grebenschikov
> > > vova@sw.ru, SWsoft, Inc.
> >
> > To Unsubscribe: send mail to majordomo@FreeBSD.org
> > with "unsubscribe freebsd-net" in the body of the message
> >
> --
> Vladimir B. Grebenschikov
> vova@sw.ru, SWsoft, Inc.
--------------4E39E42B7C27B4B2B6476BD6
Content-Type: text/plain; charset=koi8-r;
 name="diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="diff"

Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/net/zebra/Makefile,v
retrieving revision 1.64
diff -d -u -r1.64 Makefile
--- Makefile	13 Sep 2002 07:57:25 -0000	1.64
+++ Makefile	4 Oct 2002 16:50:07 -0000
@@ -7,6 +7,7 @@
 
 PORTNAME=	zebra
 PORTVERSION=	0.93b
+PORTREVISION=	1
 CATEGORIES=	net ipv6
 MASTER_SITES=	ftp://ftp.zebra.org/pub/zebra/ \
 		ftp://ftp.ripe.net/mirrors/sites/ftp.zebra.org/pub/zebra/ \
Index: files/patch-ioctl.c
===================================================================
RCS file: /home/ncvs/ports/net/zebra/files/patch-ioctl.c,v
retrieving revision 1.1
diff -d -u -r1.1 patch-ioctl.c
--- files/patch-ioctl.c	12 Dec 2001 18:08:55 -0000	1.1
+++ files/patch-ioctl.c	4 Oct 2002 16:50:07 -0000
@@ -1,6 +1,25 @@
---- zebra/ioctl.c.orig	Wed Dec 12 18:02:16 2001
-+++ zebra/ioctl.c	Wed Dec 12 18:02:30 2001
-@@ -478,6 +478,9 @@
+
+$FreeBSD$
+
+--- zebra/ioctl.c.orig	Tue Oct 23 11:31:29 2001
++++ zebra/ioctl.c	Fri Oct  4 19:45:04 2002
+@@ -349,6 +349,7 @@
+   int ret;
+   struct ifreq ifreq;
+ 
++  bzero(&ifreq, sizeof(struct ifreq));
+   ifreq_set_name (&ifreq, ifp);
+ 
+   ifreq.ifr_flags = ifp->flags;
+@@ -371,6 +372,7 @@
+   int ret;
+   struct ifreq ifreq;
+ 
++  bzero(&ifreq, sizeof(struct ifreq));
+   ifreq_set_name (&ifreq, ifp);
+ 
+   ifreq.ifr_flags = ifp->flags;
+@@ -473,6 +475,9 @@
    mask.sin6_len = sizeof (struct sockaddr_in6);
  #endif
    memcpy (&addreq.ifra_prefixmask, &mask, sizeof (struct sockaddr_in6));
@@ -8,5 +27,5 @@
 +  addreq.ifra_lifetime.ia6t_vltime = 0xffffffff;
 +  addreq.ifra_lifetime.ia6t_pltime = 0xffffffff;
    
-   ret = if_ioctl_ipv6 (SIOCAIFADDR_IN6, (caddr_t) &addreq);
-   if (ret < 0)
+   addreq.ifra_lifetime.ia6t_pltime = ND6_INFINITE_LIFETIME; 
+   addreq.ifra_lifetime.ia6t_vltime = ND6_INFINITE_LIFETIME; 

--------------4E39E42B7C27B4B2B6476BD6--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D9DC7F3.7B966349>