NetBSD Problem Report #34517
From gson@gson.org Wed Sep 13 14:05:03 2006
Return-Path: <gson@gson.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
by narn.NetBSD.org (Postfix) with ESMTP id D115D63B84D
for <gnats-bugs@gnats.NetBSD.org>; Wed, 13 Sep 2006 14:05:02 +0000 (UTC)
Message-Id: <20060913124529.64E7075E29@guava.gson.org>
Date: Wed, 13 Sep 2006 15:45:29 +0300 (EEST)
From: gson@gson.org (Andreas Gustafsson)
Reply-To: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Subject: re(4) drops all traffic in promiscuous mode
X-Send-Pr-Version: 3.95
>Number: 34517
>Category: kern
>Synopsis: re(4) drops all traffic in promiscuous mode
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Sep 13 14:10:00 +0000 2006
>Closed-Date: Wed Nov 29 14:14:13 +0000 2006
>Last-Modified: Wed Nov 29 14:15:01 +0000 2006
>Originator: Andreas Gustafsson
>Release: NetBSD 3.99.24
>Organization:
>Environment:
System: NetBSD guava.gson.org 3.99.24 NetBSD 3.99.24 (GENERIC) #0: Fri Aug 4 13:14:16 EEST 2006 root@guru.araneus.fi:/usr/build/1005/obj/sys/arch/i386/compile/GENERIC i386
Architecture: i386
Machine: i386
>Description:
When a re(4) Ethernet interface is put into promiscuous mode by
tcpdump, it stops passing traffic.
>How-To-Repeat:
In one terminal window, ping another machine connected through a re(4)
interface.
In another terminal window, attempt to monitor the ping traffic using
tcpdump (without specifying the -p option)
Observe how tcpdump shows the outgoing ping packets, but no incoming
ones. Also, observe how ping shows no packets being received while
tcpdump is running.
Here is some sample output from ping (tcpdump was started
at 7 seconds, and interrupted after 25 seconds):
guava ~ $ ping -n 10.0.1.254
PING 10.0.1.254 (10.0.1.254): 56 data bytes
64 bytes from 10.0.1.254: icmp_seq=0 ttl=255 time=2.310 ms
64 bytes from 10.0.1.254: icmp_seq=1 ttl=255 time=2.331 ms
64 bytes from 10.0.1.254: icmp_seq=2 ttl=255 time=2.335 ms
64 bytes from 10.0.1.254: icmp_seq=3 ttl=255 time=2.355 ms
64 bytes from 10.0.1.254: icmp_seq=4 ttl=255 time=2.360 ms
64 bytes from 10.0.1.254: icmp_seq=5 ttl=255 time=2.972 ms
64 bytes from 10.0.1.254: icmp_seq=6 ttl=255 time=2.425 ms
64 bytes from 10.0.1.254: icmp_seq=7 ttl=255 time=2.377 ms
64 bytes from 10.0.1.254: icmp_seq=25 ttl=255 time=2.320 ms
64 bytes from 10.0.1.254: icmp_seq=26 ttl=255 time=2.273 ms
64 bytes from 10.0.1.254: icmp_seq=27 ttl=255 time=2.277 ms
64 bytes from 10.0.1.254: icmp_seq=28 ttl=255 time=3.098 ms
64 bytes from 10.0.1.254: icmp_seq=29 ttl=255 time=3.612 ms
^C
----10.0.1.254 PING Statistics----
30 packets transmitted, 13 packets received, 56.7% packet loss
round-trip min/avg/max/stddev = 2.273/2.542/3.612/0.416 ms
And here is the corresponding output from tcpdump:
guava /u/gson # tcpdump -n -i re0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on re0, link-type EN10MB (Ethernet), capture size 96 bytes
10:14:49.415676 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 8
10:14:50.415690 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 9
10:14:51.415702 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 10
10:14:52.415711 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 11
10:14:53.415737 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 12
10:14:54.415740 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 13
10:14:55.415753 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 14
10:14:56.415775 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 15
10:14:57.415787 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 16
10:14:58.415803 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 17
10:14:59.415817 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 18
10:15:00.415830 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 19
10:15:01.415821 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 20
10:15:02.415620 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 21
10:15:03.415137 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 22
^C
15 packets captured
16 packets received by filter
0 packets dropped by kernel
Here is the relevant dmesg output:
re0 at pci0 dev 11 function 0: RealTek 8169S Single-chip Gigabit Ethernet
re0: interrupting at irq 9
re0: Ethernet address 00:50:fc:fe:81:9a
re0: using 256 tx descriptors
rgephy0 at re0 phy 7: RTL8169S/8110S 1000BASE-T media interface, rev. 0
rgephy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT, 1000baseT-FDX, auto
>Fix:
None provided.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback
State-Changed-By: tsutsui@netbsd.org
State-Changed-When: Sat, 25 Nov 2006 23:17:58 +0900
State-Changed-Why:
Is there still this problem on -current? It works for me:
# tcpdump -n -i re0 >& /dev/null &
[1] 4043
# ifconfig re0
re0: flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
capabilities=3f80<TSO4,IP4CSUM_Rx,IP4CSUM_Tx,TCP4CSUM_Rx,TCP4CSUM_Tx,UDP4CSUM_Rx,UDP4CSUM_Tx>
enabled=3f00<IP4CSUM_Rx,IP4CSUM_Tx,TCP4CSUM_Rx,TCP4CSUM_Tx,UDP4CSUM_Rx,UDP4CSUM_Tx>
address: 00:e0:4c:77:73:6d
media: Ethernet autoselect (1000baseT full-duplex)
status: active
inet 192.168.20.1 netmask 0xffffff00 broadcast 192.168.20.255
inet6 fe80::2e0:4cff:fe77:736d%re0 prefixlen 64 scopeid 0x1
# ping -n 192.168.20.17
PING 192.168.20.17 (192.168.20.17): 56 data bytes
64 bytes from 192.168.20.17: icmp_seq=0 ttl=255 time=0.590 ms
64 bytes from 192.168.20.17: icmp_seq=1 ttl=255 time=0.484 ms
64 bytes from 192.168.20.17: icmp_seq=2 ttl=255 time=0.419 ms
64 bytes from 192.168.20.17: icmp_seq=3 ttl=255 time=0.476 ms
^C
----192.168.20.17 PING Statistics----
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.419/0.492/0.590/0.071 ms
#
From: gson@gson.org (Andreas Gustafsson)
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: kern/34517 (re(4) drops all traffic in promiscuous mode)
Date: Sun, 26 Nov 2006 22:20:48 +0200
tsutsui@NetBSD.org wrote:
> State-Changed-From-To: open->feedback
> State-Changed-Why:
> Is there still this problem on -current? It works for me:
I tried a kernel built from yesterday's -current sources. It now
works better but still not well: packets are still dropped, but now
only for the first few seconds after tcpdump is started. After that,
traffic starts flowing again.
In my latest test, I started a tcpdump about two seconds after
starting a ping; note how packets 2 through 4 are missing from the
the ping output:
$ ping -n 10.0.1.254
PING 10.0.1.254 (10.0.1.254): 56 data bytes
64 bytes from 10.0.1.254: icmp_seq=0 ttl=255 time=3.215 ms
64 bytes from 10.0.1.254: icmp_seq=1 ttl=255 time=3.250 ms
64 bytes from 10.0.1.254: icmp_seq=5 ttl=255 time=3.245 ms
64 bytes from 10.0.1.254: icmp_seq=6 ttl=255 time=3.251 ms
64 bytes from 10.0.1.254: icmp_seq=7 ttl=255 time=3.272 ms
In the output from tcpdump itself, you see the requests but not
the responses:
$ sudo tcpdump -n -i re0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on re0, link-type EN10MB (Ethernet), capture size 96 bytes
22:03:03.805794 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 2
22:03:04.805817 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 3
22:03:05.805805 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 4
22:03:06.805818 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 5
22:03:06.808886 IP 10.0.1.254 > 10.0.1.1: icmp 64: echo reply seq 5
22:03:07.805841 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 6
22:03:07.808915 IP 10.0.1.254 > 10.0.1.1: icmp 64: echo reply seq 6
22:03:08.805851 IP 10.0.1.1 > 10.0.1.254: icmp 64: echo request seq 7
22:03:08.808945 IP 10.0.1.254 > 10.0.1.1: icmp 64: echo reply seq 7
Here's the output from "ifconfig re0":
$ ifconfig re0
re0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
capabilities=3f80<TSO4,IP4CSUM_Rx,IP4CSUM_Tx,TCP4CSUM_Rx,TCP4CSUM_Tx,UDP4CSUM_Rx,UDP4CSUM_Tx>
enabled=0
address: 00:50:fc:fe:81:9a
media: Ethernet autoselect (100baseTX full-duplex)
status: active
inet 10.0.1.1 netmask 0xffffff00 broadcast 10.0.1.255
inet6 fe80::250:fcff:fefe:819a%re0 prefixlen 64 scopeid 0x2
--
Andreas Gustafsson, gson@gson.org
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
netbsd-bugs@NetBSD.org, gson@gson.org, tsutsui@ceres.dti.ne.jp
Subject: Re: kern/34517 (re(4) drops all traffic in promiscuous mode)
Date: Mon, 27 Nov 2006 18:32:56 +0900
gson@gson.org wrote:
> I tried a kernel built from yesterday's -current sources. It now
> works better but still not well: packets are still dropped, but now
> only for the first few seconds after tcpdump is started. After that,
> traffic starts flowing again.
In re_init(), mii_mediachg() is called and it seems to take
a few seconds till PHY is settled.
(you could see it by link LEDs)
I'm not sure if such mii_mediachg() is always required on
initialization, but how about the attached patch?
(values in rgephy.c are taken from Realtek's driver)
---
Izumi Tsutsui
Index: dev/ic/rtl8169.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/rtl8169.c,v
retrieving revision 1.71
diff -u -u -r1.71 rtl8169.c
--- dev/ic/rtl8169.c 25 Nov 2006 02:42:18 -0000 1.71
+++ dev/ic/rtl8169.c 27 Nov 2006 09:14:48 -0000
@@ -1955,8 +1955,6 @@
if (sc->re_testmode)
return 0;
- mii_mediachg(&sc->mii);
-
CSR_WRITE_1(sc, RTK_CFG1, RTK_CFG1_DRVLOAD | RTK_CFG1_FULLDUPLEX);
ifp->if_flags |= IFF_RUNNING;
Index: dev/mii/rgephy.c
===================================================================
RCS file: /cvsroot/src/sys/dev/mii/rgephy.c,v
retrieving revision 1.12
diff -u -u -r1.12 rgephy.c
--- dev/mii/rgephy.c 16 Nov 2006 21:24:07 -0000 1.12
+++ dev/mii/rgephy.c 27 Nov 2006 09:14:48 -0000
@@ -551,10 +551,8 @@
/* Reset capabilities */
/* Step1: write our capability */
PHY_WRITE(sc, 0x04,0x01e1); /* 10/100 capability */
- PHY_WRITE(sc, 0x09,0x0200); /* 1000 capability */
+ PHY_WRITE(sc, 0x09,0x0300); /* 1000 capability */
-#ifdef jrs_notyet
/* Step2: Restart NWay */
PHY_WRITE(sc, 0x00, 0x1200); // NWay enable and Restart NWay
-#endif
}
From: gson@gson.org (Andreas Gustafsson)
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Cc: gnats-bugs@NetBSD.org
Subject: Re: kern/34517 (re(4) drops all traffic in promiscuous mode)
Date: Tue, 28 Nov 2006 19:56:13 +0200
Izumi Tsutsui wrote:
> In re_init(), mii_mediachg() is called and it seems to take
> a few seconds till PHY is settled.
> (you could see it by link LEDs)
>
> I'm not sure if such mii_mediachg() is always required on
> initialization, but how about the attached patch?
With the patch, the problem is gone - traffic flows normally across
the switch to promiscuous mode. I also verified that the interface is
in fact receiving traffic promiscuously when requested.
--
Andreas Gustafsson, gson@gson.org
State-Changed-From-To: feedback->closed
State-Changed-By: tsutsui@netbsd.org
State-Changed-When: Wed, 29 Nov 2006 23:14:13 +0900
State-Changed-Why:
Fix committed.
From: Izumi Tsutsui <tsutsui@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc:
Subject: PR/34517 CVS commit: src/sys/dev/ic
Date: Wed, 29 Nov 2006 14:13:15 +0000 (UTC)
Module Name: src
Committed By: tsutsui
Date: Wed Nov 29 14:13:15 UTC 2006
Modified Files:
src/sys/dev/ic: rtl8169.c
Log Message:
Remove mii_mediachg() call from re_init().
It causes a few second TRX stalls on each ioctls
(on ifconfig(8) or tcpdump(8) etc.) and PHY seems
initialized properly without it at least on RTL8169S
with internal rgephy(4) PHY. Closes PR kern/34517.
XXX: maybe we should also test this on the original RTL8169
with external makphy(4).
To generate a diff of this commit:
cvs rdiff -r1.71 -r1.72 src/sys/dev/ic/rtl8169.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.