NetBSD Problem Report #40036
From tsutsui@ceres.dti.ne.jp Wed Nov 26 14:50:48 2008
Return-Path: <tsutsui@ceres.dti.ne.jp>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id 1A4C763B8BD
for <gnats-bugs@gnats.NetBSD.org>; Wed, 26 Nov 2008 14:50:48 +0000 (UTC)
Message-Id: <200811261420.mAQEKQ2l013168@mirage.ceres.dti.ne.jp>
Date: Wed, 26 Nov 2008 23:20:26 +0900 (JST)
From: tsutsui@ceres.dti.ne.jp
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@gnats.NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: rc.d/network doesn't check IPv6 properly with new ifconfig(8)
X-Send-Pr-Version: 3.95
>Number: 40036
>Category: bin
>Synopsis: rc.d/network doesn't check IPv6 properly with new ifconfig(8)
>Confidential: no
>Severity: non-critical
>Priority: high
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Nov 26 14:55:00 +0000 2008
>Closed-Date: Sun Dec 07 07:20:48 +0000 2008
>Last-Modified: Sun Dec 07 07:20:48 +0000 2008
>Originator: Izumi Tsutsui
>Release: NetBSD 5.0_BETA
>Organization:
>Environment:
System: NetBSD 5.0_BETA from NetBSD-daily/netbsd-5/200811190002Z
Architecture: sun2
Machine: m68000
>Description:
/etc/rc.d/network has the following line to check if kernel has IPv6 support:
---
if /sbin/ifconfig lo0 inet6 >/dev/null 2>&1; then
# We have IPv6 support in kernel.
---
But recently revised ifconfig(8) doesn't return error on that test
even if a kernel doesn't have inet6 support:
---
# sysctl -a | grep inet6
# ifconfig lo0 inet6 > /dev/null 2>&1 && echo true
true
#
---
so rc.d/network causes a lot of errors on boot:
---
:
Starting network.
/etc/rc: WARNING: $hostname not set.
usage: ifconfig [-h] [-m] [-v] [-z] [-L] interface
[ af [ address [ dest_addr ] ] [ netmask mask ] [ prefixlen n ]
[ alias | -alias ] ]
[ up ] [ down ] [ metric n ] [ mtu n ]
[ vlan n vlanif i ]
[ [ af ] tunnel src_addr dest_addr ] [ deletetunnel ]
[ media type ] [ mediaopt opts ] [ -mediaopt opts ] [ instance minst ]
[ nwid network_id ] [ nwkey network_key | -nwkey ]
[ list scan ]
[ powersave | -powersave ] [ powersavesleep duration ]
[ hidessid | -hidessid ] [ apbridge | -apbridge ]
[ agrport i ] [ -agrport i ]
[ anycast | -anycast ] [ deprecated | -deprecated ]
[ tentative | -tentative ] [ pltime n ] [ vltime n ] [ eui64 ]
[ advbase n ] [ advskew n ] [ carpdev iface ] [ pass passphrase ] [ state state ] [ vhid n ]
[ arp | -arp ]
[ preference n ]
[ link0 | -link0 ] [ link1 | -link1 ] [ link2 | -link2 ]
ifconfig -a [-b] [-d] [-h] [-m] [-u] [-v] [-z] [ af ]
ifconfig -l [-b] [-d] [-s] [-u]
ifconfig -C
ifconfig interface create
ifconfig interface destroy
route: writing to routing socket: Network is unreachable
route: writing to routing socket: not in table
route: writing to routing socket: not in table
route: writing to routing socket: not in table
route: writing to routing socket: not in table
route: writing to routing socket: not in table
route: writing to routing socket: not in table
route: writing to routing socket: not in table
route: writing to routing socket: not in table
route: writing to routing socket: not in table
route: writing to routing socket: not in table
route: writing to routing socket: not in table
route: writing to routing socket: not in table
sysctl: second level name 'inet6' in 'net.inet6.ip6.forwarding' is invalid
sysctl: second level name 'inet6' in 'net.inet6.ip6.accept_rtadv' is invalid
IPv6 mode: host
Configuring network interfaces: ie0.
Adding interface aliases:.
usage: sleep seconds
Building databases: dev, utmp, utmpx done
:
---
>How-To-Repeat:
Build kernel without options INET6 and boot it to multiuser,
or try the above commands.
>Fix:
Fix ifconfig(8) as the previous behavior, or
fix rc.d/network to use sysctl(8) for inet6 check?
---
Izumi Tsutsui
>Release-Note:
>Audit-Trail:
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org, tsutsui@ceres.dti.ne.jp
Subject: Re: bin/40036: rc.d/network doesn't check IPv6 properly with new ifconfig(8)
Date: Thu, 27 Nov 2008 22:46:30 +0900
> >Synopsis: rc.d/network doesn't check IPv6 properly with new ifconfig(8)
:
> # sysctl -a | grep inet6
> # ifconfig lo0 inet6 > /dev/null 2>&1 && echo true
> true
> #
- ifconfig(8) on i386 and news68k 5.0_BETA don't has this problem
- old ifconfig(8) binary (around 20080501) on sun2 also works
(i.e. returns error) properly
It looks sun2 specific, so I'll check what happens there.
---
Izumi Tsutsui
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org, tsutsui@ceres.dti.ne.jp
Subject: Re: bin/40036: rc.d/network doesn't check IPv6 properly with new ifconfig(8)
Date: Fri, 28 Nov 2008 01:27:08 +0900
> It looks sun2 specific, so I'll check what happens there.
"cc -O1 -fno-loop-optimize" fixes the problem, but
the attached changes also fixes it.
I'm not sure if it's a gcc optimization bug (on m68000 or m68k+softfloat)
or a source bug, but is it okay to commit this diff for workaround?
---
Index: ifconfig.c
===================================================================
RCS file: /cvsroot/src/sbin/ifconfig/ifconfig.c,v
retrieving revision 1.213
diff -u -r1.213 ifconfig.c
--- ifconfig.c 1 Aug 2008 22:29:13 -0000 1.213
+++ ifconfig.c 27 Nov 2008 16:19:01 -0000
@@ -693,14 +693,13 @@
{
int i;
const struct afswtch *afp;
- struct kwinst kw = {.k_type = KW_T_INT};
SIMPLEQ_FOREACH(afp, &aflist, af_next) {
- kw.k_word = afp->af_name;
- kw.k_int = afp->af_af;
for (i = 0; i < __arraycount(familykw); i++) {
if (familykw[i].k_word == NULL) {
- familykw[i] = kw;
+ familykw[i].k_type = KW_T_INT;
+ familykw[i].k_word = afp->af_name;
+ familykw[i].k_int = afp->af_af;
break;
}
}
---
From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, tsutsui@ceres.dti.ne.jp
Subject: Re: bin/40036: rc.d/network doesn't check IPv6 properly with new
ifconfig(8)
Date: Fri, 28 Nov 2008 00:09:04 +0000
On Thu, Nov 27, 2008 at 04:30:03PM +0000, Izumi Tsutsui wrote:
> "cc -O1 -fno-loop-optimize" fixes the problem, but
> the attached changes also fixes it.
>
> I'm not sure if it's a gcc optimization bug (on m68000 or m68k+softfloat)
> or a source bug, but is it okay to commit this diff for workaround?
That would be a gcc bug.
> - struct kwinst kw = {.k_type = KW_T_INT};
However, this initializes all the fields of struct kwinst (there are
quite a few) and the new code without kw does not. It probably doesn't
matter, as familykw[] is file-static, but maybe it's better to be
cautious.
(Does making kw volatile cause the problem to go away?)
--
David A. Holland
dholland@netbsd.org
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: dholland-bugs@netbsd.org
Cc: gnats-bugs@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,
tsutsui@ceres.dti.ne.jp
Subject: Re: bin/40036: rc.d/network doesn't check IPv6 properly with newifconfig(8)
Date: Fri, 28 Nov 2008 19:39:08 +0900
> > "cc -O1 -fno-loop-optimize" fixes the problem, but
> > the attached changes also fixes it.
> >
> > I'm not sure if it's a gcc optimization bug (on m68000 or m68k+softfloat)
> > or a source bug, but is it okay to commit this diff for workaround?
>
> That would be a gcc bug.
It turns out that the similar bug could occur even on i386
if -O1 is specified (but not with -O2):
---
% uname -mrs
NetBSD 5.0_BETA i386
% gcc --version
gcc (GCC) 4.1.3 20080704 prerelease (NetBSD nb1 20080202)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
% cat test.c
#include <inttypes.h>
#include <stdio.h>
struct kwinst {
int k_type;
const char *k_word;
union kwval {
int64_t u_sint;
char *u_str;
} k_u;
#define k_int k_u.u_sint
};
struct kwinst fkw[10];
int num[] = { 11, 22, 33, 44 };
char *name[] = {"aaaaaa","bbbbbb","cccccc","dddddd"};
main()
{
int a, i;
struct kwinst kw = {.k_type = 1};
for (a = 0; a < 4; a++) {
kw.k_int = num[a];
kw.k_word = name[a];
for (i = 0; i < 10; i++) {
if (fkw[i].k_word == NULL) {
fkw[i] = kw;
break;
}
}
printf("a=%d: kw.k_word=%s kw.k_int=%d, "
"fkw[%d].k_word=%s fkw[%d].k_int=%d\n", a,
kw.k_word, (int)kw.k_int,
i, fkw[i].k_word, i, (int)fkw[i].k_int);
}
}
% cc -O test.c
% ./a.out
a=0: kw.k_word=aaaaaa kw.k_int=11, fkw[0].k_word=(null) fkw[0].k_int=11
a=1: kw.k_word=bbbbbb kw.k_int=22, fkw[0].k_word=aaaaaa fkw[0].k_int=22
a=2: kw.k_word=cccccc kw.k_int=33, fkw[1].k_word=bbbbbb fkw[1].k_int=33
a=3: kw.k_word=dddddd kw.k_int=44, fkw[2].k_word=cccccc fkw[2].k_int=44
% cc -O -fno-loop-optimize test.c
% ./a.out
a=0: kw.k_word=aaaaaa kw.k_int=11, fkw[0].k_word=aaaaaa fkw[0].k_int=11
a=1: kw.k_word=bbbbbb kw.k_int=22, fkw[1].k_word=bbbbbb fkw[1].k_int=22
a=2: kw.k_word=cccccc kw.k_int=33, fkw[2].k_word=cccccc fkw[2].k_int=33
a=3: kw.k_word=dddddd kw.k_int=44, fkw[3].k_word=dddddd fkw[3].k_int=44
% cc -O2 test.c
% ./a.out
a=0: kw.k_word=aaaaaa kw.k_int=11, fkw[0].k_word=aaaaaa fkw[0].k_int=11
a=1: kw.k_word=bbbbbb kw.k_int=22, fkw[1].k_word=bbbbbb fkw[1].k_int=22
a=2: kw.k_word=cccccc kw.k_int=33, fkw[2].k_word=cccccc fkw[2].k_int=33
a=3: kw.k_word=dddddd kw.k_int=44, fkw[3].k_word=dddddd fkw[3].k_int=44
%
---
> > - struct kwinst kw = {.k_type = KW_T_INT};
>
> However, this initializes all the fields of struct kwinst (there are
> quite a few) and the new code without kw does not. It probably doesn't
> matter, as familykw[] is file-static,
I assumed it in the patch.
> but maybe it's better to be
> cautious.
>
> (Does making kw volatile cause the problem to go away?)
Yes, but it looks weird for workaround.
Maybe we have the following options:
1) add COPTS.ifconfig.c+= -fno-loop-optimize in src/sbin/ifconfig/Makefile
.if ${MACHINE_ARCH} == "m68000"
2) add COPTS.ifconfig.c+= -fno-loop-optimize in src/sbin/ifconfig/Makefile
by default
3) use DBG?= -O1 -fno-loop-optimize in src/share/mk/sys.mk for m68000
4) put workaround changes into ifconfig.c
5) fix gcc (best but probably unlikely)
Opinions?
---
Izumi Tsutsui
From: Martin Husemann <martin@duskware.de>
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Cc: gnats-bugs@netbsd.org
Subject: Re: bin/40036: rc.d/network doesn't check IPv6 properly with newifconfig(8)
Date: Fri, 28 Nov 2008 12:45:18 +0100
On Fri, Nov 28, 2008 at 07:39:08PM +0900, Izumi Tsutsui wrote:
> 1) add COPTS.ifconfig.c+= -fno-loop-optimize in src/sbin/ifconfig/Makefile
> .if ${MACHINE_ARCH} == "m68000"
This is what I'd prefer (and note it in doc/HACKS).
> 5) fix gcc (best but probably unlikely)
Please file a toolchain PR for it anyway.
Martin
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: martin@duskware.de
Cc: gnats-bugs@NetBSD.org, tsutsui@ceres.dti.ne.jp
Subject: Re: bin/40036: rc.d/network doesn't check IPv6 properly with newifconfig(8)
Date: Sat, 29 Nov 2008 23:56:51 +0900
martin@duskware.de wrote:
> > 5) fix gcc (best but probably unlikely)
> Please file a toolchain PR for it anyway.
Done, PR toolchain/40066.
---
Izumi Tsutsui
From: Izumi Tsutsui <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/40036 CVS commit: src/sbin/ifconfig
Date: Sat, 29 Nov 2008 15:28:49 +0000 (UTC)
Module Name: src
Committed By: tsutsui
Date: Sat Nov 29 15:28:49 UTC 2008
Modified Files:
src/sbin/ifconfig: Makefile
Log Message:
Specify -fno-loop-optimize on m68000 as workaround for gcc -O1 codegen bug
mentioned in PR bin/40036 and PR toolchain/40066.
To generate a diff of this commit:
cvs rdiff -r1.38 -r1.39 src/sbin/ifconfig/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: Soren Jacobsen <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/40036 CVS commit: [netbsd-5] src/sbin/ifconfig
Date: Sat, 6 Dec 2008 21:25:44 +0000 (UTC)
Module Name: src
Committed By: snj
Date: Sat Dec 6 21:25:44 UTC 2008
Modified Files:
src/sbin/ifconfig [netbsd-5]: Makefile
Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #164):
sbin/ifconfig/Makefile: revision 1.39
Specify -fno-loop-optimize on m68000 as workaround for gcc -O1 codegen bug
mentioned in PR bin/40036 and PR toolchain/40066.
To generate a diff of this commit:
cvs rdiff -r1.38 -r1.38.2.1 src/sbin/ifconfig/Makefile
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Sun, 07 Dec 2008 16:20:48 +0900
State-Changed-Why:
Workarounded and pulled up to netbsd-5.
The real fix will be followed by PR toolchain/40066.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.