Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 04 Apr 2002 17:10:10 -0500
From:      David Watson <dwatson@eecs.umich.edu>
To:        freebsd-net@freebsd.org
Subject:   Failure to set promiscuous correctly
Message-ID:  <200204042210.g34MAAR42207@skippy.eecs.umich.edu>

next in thread | raw e-mail | index | archive | help
I'm experience a really weird condition with the bridging code.
It looks like there is some race condition that causes an interface
to look like it's in promiscuous mode when it really isn't.

My setup has two Intel Gigabit cards with the Intel em driver.
(The gx driver causes auto-negotiation to fail with the switch
I'm using.)  I'm running 4.5-RELEASE, with some custom modifications
to the kernel.  I have been able to verify the condition with a
4.5 GENERIC kernel which uses the wx drivers.

Immediately after booting the first card (em0) is up and assigned
an ip address (10.5.5.2), the second card is unmodified (no ip address
assigned) and has the flags:
em1: flags=0xffff8802 <BROADCAST,SIMPLEX,MULTICAST>

I then issue the following commands (from a file):
sysctl -w net.link.ether.bridge=1
sysctl -w net.link.ether.bridge_ipfw=1
sysctl -w net.link.ether.bridge_cfg=em0:1,em1:1

and get the following output from my my instrumented ifpromisc():

em0: promiscuous mode enabled (dw)
em0: ioctl succeeded!
>> now em0 promisc ON if_flags 0xffff8943 bdg_flags 0x5
em1: promiscuous mode enabled (dw)
em1: ioctl succeeded!
em1: promiscuous counter = 2, promiscuous mode is already enabled
>> now em1 promisc ON if_flags 0xffff8943 bdg_flags 0x5
>> now em1 promisc ON if_flags 0xffff8943 bdg_flags 0x5
em0: promiscuous mode disabled
em0: ioctl succeeded!
em0: promiscuous mode enabled (dw)
em0: ioctl succeeded!
>> now em0 promisc ON if_flags 0xffff8943 bdg_flags 0x5
em1: promiscuous counter = 2, promiscuous mode is already enabled
>> now em1 promisc ON if_flags 0xffff8943 bdg_flags 0x5

em1 now has the flags:
em1: flags=0xffff8943 <UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST>

but is _not_ really in promisc mode (i.e. bridging doesn't work,
packets that I can verify are hitting the card never hit the
interface statistics...).  I can manually take the card out of
promisc and back in using ioctl and things work just fine.

It looks like one attempt to turn off promisc mode manages to turn
it off on the card, but not in the flags and the promisc counter.
Note that this doesn't always happen.  Sometimes the interface
truly ends up in promisc and bridging works just fine.  Enabling the
DEB macro in bridge.c seems to ensure that it works correctly.

I thought I would fix the problem while I had the code torn apart
but I can't think of the next place to look.  dmesg and my instrumentation
follows.

David Watson



dmesg:
Copyright (c) 1992-2002 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
	The Regents of the University of California. All rights reserved.
FreeBSD 4.5-RELEASE #26: Thu Apr  4 11:30:33 EST 2002
    dwatson@skippy.eecs.umich.edu:/usr/home/dwatson/work/scrubber/new_scrub/fbsd_4.5/sys/compile/SCRUB
Timecounter "i8254"  frequency 1193182 Hz
Timecounter "TSC"  frequency 731023035 Hz
CPU: Pentium III/Pentium III Xeon/Celeron (731.02-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x683  Stepping = 3
  Features=0x383fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE>
real memory  = 1744814080 (1703920K bytes)
Kernel map size: 2145390592, (2046 M)
sio0: gdb debugging port
avail memory = 382730240 (373760K bytes)
Preloaded elf kernel "kernel" at 0x802ff000.
Pentium Pro MTRR support enabled
md0: Malloc disk
npx0: <math processor> on motherboard
npx0: INT 16 interface
pcib0: <ServerWorks NB6635 3.0LE host to PCI bridge> on motherboard
pci0: <PCI bus> on pcib0
pci0: <S3 Savage 4 graphics accelerator> at 1.0
pci0: <unknown card> (vendor=0x1022, dev=0x2000) at 2.0 irq 11
pci0: <unknown card> (vendor=0x8086, dev=0x1229) at 9.0 irq 15
isab0: <ServerWorks IB6566 PCI to ISA bridge> at device 15.0 on pci0
isa0: <ISA bus> on isab0
atapci0: <ServerWorks ROSB4 ATA33 controller> port 0x840-0x84f at device 15.1 on pci0
ata0: at 0x1f0 irq 14 on atapci0
ata1: at 0x170 irq 15 on atapci0
pci0: <OHCI USB controller> at 15.2 irq 9
pcib1: <ServerWorks NB6635 3.0LE host to PCI bridge> on motherboard
pci1: <PCI bus> on pcib1
ahc0: <Adaptec aic7899 Ultra160 SCSI adapter> port 0x4b00-0x4bff mem 0xeffff000-0xefffffff irq 10 at device 3.0 on pci1
aic7899: Ultra160 Wide Channel A, SCSI Id=7, 32/255 SCBs
ahc1: <Adaptec aic7899 Ultra160 SCSI adapter> port 0x4c00-0x4cff mem 0xefffe000-0xefffefff irq 10 at device 3.1 on pci1
aic7899: Ultra160 Wide Channel B, SCSI Id=7, 32/255 SCBs
em0: <Intel(R) PRO/1000 Network Connection, Version - 1.0.9> mem 0xeffc0000-0xeffdffff irq 11 at device 5.0 on pci1
em0:  Speed:1000 Mbps  Duplex:Full
em1: <Intel(R) PRO/1000 Network Connection, Version - 1.0.9> mem 0xeffa0000-0xeffbffff irq 15 at device 6.0 on pci1
em1:  Speed:1000 Mbps  Duplex:Full
orm0: <Option ROM> at iomem 0xc0000-0xc9fff on isa0
fdc0: <NEC 72065B or clone> at port 0x3f0-0x3f5,0x3f7 irq 6 drq 2 on isa0
fdc0: FIFO enabled, 8 bytes threshold
fd0: <1440-KB 3.5" drive> on fdc0 drive 0
atkbdc0: <Keyboard controller (i8042)> at port 0x60,0x64 on isa0
atkbd0: <AT Keyboard> flags 0x1 irq 1 on atkbdc0
kbd0 at atkbd0
vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
sc0: <System console> at flags 0x100 on isa0
sc0: VGA <16 virtual consoles, flags=0x300>
sio0 at port 0x3f8-0x3ff irq 4 flags 0x80 on isa0
sio0: type 16550A
sio1 at port 0x2f8-0x2ff irq 3 on isa0
sio1: type 16550A
ppc0: <Parallel port> at port 0x378-0x37f irq 7 on isa0
ppc0: Generic chipset (NIBBLE-only) in COMPATIBLE mode
plip0: <PLIP network interface> on ppbus0
lpt0: <Printer> on ppbus0
lpt0: Interrupt-driven port
ppi0: <Parallel I/O> on ppbus0
IP packet filtering initialized, divert disabled, rule-based forwarding disabled, default to accept, logging disabled
BRIDGE 011031, have 5 interfaces
-- index 1  type 6 phy 0 addrl 6 addr 00.d0.b7.45.85.cf
-- index 2  type 6 phy 0 addrl 6 addr 00.d0.b7.45.85.2e
acd0: CDROM <CRN-8241B> at ata0-master using PIO4
Waiting 10 seconds for SCSI devices to settle
pass1 at ahc1 bus 0 target 8 lun 0
pass1: <IBM YGLv3 S2 0> Fixed Processor SCSI-2 device 
pass1: 3.300MB/s transfers
da0 at ahc1 bus 0 target 0 lun 0
da0: <IBM-PSG DDYS-T09170M  F S96E> Fixed Direct Access SCSI-3 device 
da0: 160.000MB/s transfers (80.000MHz, offset 63, 16bit), Tagged Queueing Enabled
da0: 8678MB (17774160 512 byte sectors: 255H 63S/T 1106C)
Mounting root from ufs:/dev/da0s1a

ifpromisc from if.c:

ifpromisc(ifp, pswitch)
	struct ifnet *ifp;
	int pswitch;
{
	struct ifreq ifr;
	int error;
	int oldflags;

	oldflags = ifp->if_flags;
	if (pswitch) {
		/*
		 * If the device is not configured up, we cannot put it in
		 * promiscuous mode.
		 */
		if ((ifp->if_flags & IFF_UP) == 0) {
			log(LOG_INFO,
			    "%s%d: not up, promiscuous mode NOT enabled\n",
			    ifp->if_name, ifp->if_unit);
			return (ENETDOWN);
		}
		if (ifp->if_pcount++ != 0) {
			log(LOG_INFO,
			    "%s%d: promiscuous counter = %d, promiscuous "
			    "mode is already enabled\n",
			    ifp->if_name, ifp->if_unit, ifp->if_pcount);
			return (0);
		}
		ifp->if_flags |= IFF_PROMISC;
		log(LOG_INFO, "%s%d: promiscuous mode enabled (dw)\n",
		    ifp->if_name, ifp->if_unit);
	} else {
		if (--ifp->if_pcount > 0)
			return (0);
		ifp->if_flags &= ~IFF_PROMISC;
		log(LOG_INFO, "%s%d: promiscuous mode disabled\n",
		    ifp->if_name, ifp->if_unit);
	}
	ifr.ifr_flags = ifp->if_flags;
	error = (*ifp->if_ioctl)(ifp, SIOCSIFFLAGS, (caddr_t)&ifr);
	if (error == 0) {
		log(LOG_INFO, "%s%d: ioctl succeeded!\n",
		    ifp->if_name, ifp->if_unit);
		rt_ifmsg(ifp);
	} else {
		log(LOG_INFO, "%s%d: ioctl failed (%d)!\n",
		    ifp->if_name, ifp->if_unit, error);
		ifp->if_flags = oldflags;
	}
	return error;
}



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?200204042210.g34MAAR42207>