From owner-freebsd-net Fri Oct 4 9:53:24 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D569937B407; Fri, 4 Oct 2002 09:53:14 -0700 (PDT) Received: from baraca.united.net.ua (ns.united.net.ua [193.111.8.193]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1A0B743E6A; Fri, 4 Oct 2002 09:53:13 -0700 (PDT) (envelope-from sobomax@FreeBSD.org) Received: from vega.vega.com (xDSL-2-2.united.net.ua [193.111.9.226]) by baraca.united.net.ua (8.11.6/8.11.6) with ESMTP id g94Gr5p39555; Fri, 4 Oct 2002 19:53:07 +0300 (EEST) (envelope-from sobomax@FreeBSD.org) Received: from FreeBSD.org (big_brother.vega.com [192.168.1.1]) by vega.vega.com (8.12.6/8.12.5) with ESMTP id g94Gr2Ts062472; Fri, 4 Oct 2002 19:53:02 +0300 (EEST) (envelope-from sobomax@FreeBSD.org) Message-ID: <3D9DC7F3.7B966349@FreeBSD.org> Date: Fri, 04 Oct 2002 19:55:15 +0300 From: Maxim Sobolev Organization: Vega International Capital X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U) X-Accept-Language: en,uk,ru MIME-Version: 1.0 To: "Vladimir B. Grebenschikov" Cc: sumikawa@FreeBSD.org, freebsd-net@FreeBSD.org Subject: Re: zebra interface flags problem on 4.7-RC2 (IFF_PROMISC) References: <1033739506.1060.16.camel@vbook.express.ru> <20021004140644.GB61661@vega.vega.com> <1033741307.1060.22.camel@vbook.express.ru> Content-Type: multipart/mixed; boundary="------------4E39E42B7C27B4B2B6476BD6" Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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 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 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