From tony@eric.net.au  Wed Dec 15 06:03:54 1999
Return-Path: <tony@eric.net.au>
Received: from gecko.eric.net.au (gecko.eric.net.au [203.36.118.3])
	by hub.freebsd.org (Postfix) with ESMTP id B7E891502D
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 15 Dec 1999 06:03:52 -0800 (PST)
	(envelope-from tony@eric.net.au)
Received: from random.n2-au (ppp162.eric.net.au [203.36.118.162])
	by gecko.eric.net.au (8.9.3/8.8.7) with ESMTP id AAA25566
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 16 Dec 1999 00:58:02 +1100
Received: from ivanova.n2-au (ivanova.n2-au [192.168.1.1])
	by random.n2-au (8.9.3/8.9.3/tf2) with ESMTP id BAA87637
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 16 Dec 1999 01:06:20 +1100 (EST)
	(envelope-from tony@random.n2-au)
Received: (from tony@localhost)
	by ivanova.n2-au (8.8.8/8.8.8/tf1) id AAA02445;
	Thu, 16 Dec 1999 00:55:15 +1100 (EST)
	(envelope-from tony@mail.n2-au)
Message-Id: <199912151355.AAA02445@ivanova.n2-au>
Date: Thu, 16 Dec 1999 00:55:15 +1100 (EST)
From: Tony Frank <tony@eric.net.au>
Reply-To: tfrank@eric.net.au
To: FreeBSD-gnats-submit@freebsd.org
Subject: Patch to enable bridging support for if_cs<Synopsis of the problem (one line)>
X-Send-Pr-Version: 3.2

>Number:         15493
>Category:       kern
>Synopsis:       Patch to enable bridging support for if_cs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Dec 15 06:10:02 PST 1999
>Closed-Date:    Sun Jul 22 08:21:12 PDT 2001
>Last-Modified:  Sun Jul 22 08:21:26 PDT 2001
>Originator:     Tony Frank
>Release:        FreeBSD 2.2.8-STABLE i386
>Organization:
>Environment:
dmesg.boot:

Copyright (c) 1992-1998 FreeBSD Inc.
Copyright (c) 1982, 1986, 1989, 1991, 1993
	The Regents of the University of California.  All rights reserved.

FreeBSD 2.2.8-STABLE #5: Mon Dec 13 00:30:17 EST 1999
    tony@ivanova.n2-au:/usr/src/sys/compile/IVANOVA
CPU: i486 DX2 (486-class CPU)
  Origin = "GenuineIntel"  Id = 0x435  Stepping=5
  Features=0x3<FPU,VME>
real memory  = 16777216 (16384K bytes)
avail memory = 14819328 (14472K bytes)
Probing for devices on the ISA bus:
sc0 at 0x60-0x6f irq 1 on motherboard
sc0: VGA color <8 virtual consoles, flags=0x0>
ed0 at 0x360-0x37f irq 12 on isa
ed0: address 00:00:01:12:38:47, type NE2000 (16 bit) 
sio0 at 0x3f8-0x3ff irq 5 on isa
sio0: type 16550A
sio1 at 0x2f8-0x2ff irq 9 on isa
sio1: type 16550A
lpt0 at 0x278-0x27f irq 7 on isa
lpt0: Interrupt-driven port
lp0: TCP/IP capable interface
fdc0 at 0x3f0-0x3f7 irq 6 drq 2 on isa
sea0 at 0x0 irq 11 maddr 0xc8000 msize 16384 on isa

sea0: type Future Domain TMC-885/TMC-950
sea0 waiting for scsi devices to settle
(sea0:0:0): "IBM XP31070W      !x 81K1" type 0 fixed SCSI 2
sd0(sea0:0:0): Direct-Access 1074MB (2199878 512 byte sectors)
sd0(sea0:0:0): with 3907 cyls, 5 heads, and an average 112 sectors/track
cs0 at 0x320-0x33f irq 10 on isa
cs0: ethernet address 00:20:35:e4:50:88
npx0 flags 0x1 on motherboard
npx0: INT 16 interface
BRIDGE TF9912, have 6 interfaces
-- index 1 ed0 type 6 phy 0 addrl 6 addr 00.00.01.12.38.47
-- index 3 cs0 type 6 phy 0 addrl 6 addr 00.20.35.e4.50.88
IP packet filtering initialized, divert disabled, logging limited to 100 packets/entry
DUMMYNET initialized (990504)

Kernel config file:

#
# IVANOVA - Custom config for IVANOVA, based on GENERIC
#

machine		"i386"
cpu		"I486_CPU"
ident		IVANOVA
maxusers	32
options 	"MSGBUF_SIZE=40960"
options		INET			#InterNETworking
options		FFS			#Berkeley Fast Filesystem
options 	NFS
options		"COMPAT_43"		#Compatible with BSD 4.3 [KEEP THIS!]
options		SCSI_DELAY=6		#Be pessimistic about Joe SCSI device
options		BOUNCE_BUFFERS		#include support for DMA bounce buffers
options		UCONSOLE		#Allow users to grab the console
options		FAILSAFE		#Be conservative
options		USERCONFIG		#boot -c editor
options 	MAXCONS=8
config		kernel	root on sd0
controller	isa0
options 	"AUTO_EOI_1"
options 	"AUTO_EOI_2" 		# may not work, might need to disable
controller	fdc0	at isa? port "IO_FD1" bio irq 6 drq 2 vector fdintr
disk		fd0	at fdc0 drive 0
controller	sea0	at isa? bio irq 11 iomem 0xc8000 iosiz 0x2000 vector seaintr
controller	scbus0
device		sd0
options 	SCSI_REPORT_GEOMETRY
device		sc0	at isa? port "IO_KBD" tty irq 1 vector scintr
options 	SC_HISTORY_SIZE=200
device		npx0	at isa? port "IO_NPX" flags 0x1 irq 13 vector npxintr
device		sio0	at isa? port "IO_COM1" tty irq 5 vector siointr
device		sio1	at isa? port "IO_COM2" tty irq 9 vector siointr
device		lpt0	at isa? port "IO_LPT2" tty irq 7 vector lptintr
device ed0 at isa? port 0x360 net irq 12 vector edintr  
device cs0 at isa? port 0x320 net irq ? vector csintr
pseudo-device	loop
pseudo-device	ether
pseudo-device   tun     2
pseudo-device   bpfilter 2
pseudo-device	log
pseudo-device	vn	1
pseudo-device	pty	16
pseudo-device	gzip		# Exec gzipped a.out's
options 	INCLUDE_CONFIG_FILE
options BRIDGE
options DUMMYNET
options 	IPFIREWALL
options 	IPFIREWALL_VERBOSE

>Description:
2 ethernet, cs0 and ed0.  I wanted to use bridging support to bridge the two
LAN segments.  if_cs does not presently support bridging, so I patched it.

>How-To-Repeat:

Configure a kernel with the cs ethernet card, and bridging support.  
It wont work without patches.

	

>Fix:
diff is for 2.2.8-STABLE version of if_cs.c in /usr/src/sys/i386/isa

it should map through to 4.0-CURRENT etc ok, as there doesn't appear to be
any major changes to the if_cs driver, at least not where bridging support
is concerned.

Please note, this is also my first attempt at patching anything.  It appears 
to work ok on my system here at home with no obvious side effects.  

Output of netstat -I ed0 and netstat -I cs0 after about a day of operation:

Name  Mtu   Network       Address            Ipkts Ierrs    Opkts Oerrs  Coll
ed0   1500  <Link>      00.00.01.12.38.47    93944     0    68357     0    25
Name  Mtu   Network       Address            Ipkts Ierrs    Opkts Oerrs  Coll
cs0   1500  <Link>      00.20.35.e4.50.88    68909   519    91346    91     0
cs0   1500  home.ethernet ivanova            68909   519    91346    91     0

output of netstat -m:

18 mbufs in use:
	1 mbufs allocated to data
	2 mbufs allocated to packet headers
	12 mbufs allocated to protocol control blocks
	3 mbufs allocated to socket names and addresses
0/12 mbuf clusters in use
26 Kbytes allocated to network (8% in use)
0 requests for memory denied
0 requests for memory delayed
0 calls to protocol drain routines

Anyway, here is the diff:

if_cs.c diff:

79a80,83
> #ifdef BRIDGE
> #include <net/bridge.h>
> #endif
> 
811a815,852
> #ifdef BRIDGE
>         if (do_bridge) {
>             struct ifnet *ifp_bdg ;
>             ifp_bdg = bridge_in(m);
>             if (ifp_bdg == BDG_DROP) {
>                 m_freem(m);
>                 return 0;
> 	    }
> 	    else {
>                 if (ifp_bdg != BDG_LOCAL )
>                     bdg_forward(&m, ifp_bdg); /* not local, need forwarding */
> 
>                 if (ifp_bdg == BDG_LOCAL || ifp_bdg == BDG_BCAST || 
> 			ifp_bdg == BDG_MCAST) {
> 
> 			m->m_pkthdr.len -= sizeof *eh;
> 			m->m_len -= sizeof *eh;
> 			m->m_data += sizeof *eh;
> 
> 			/* Feed the packet to the upper layer */
> 			ether_input(ifp, eh, m);
> 
> 			ifp->if_ipackets++;
> 
> 			if (length==ETHER_MAX_LEN-ETHER_CRC_LEN)
>                		         DELAY( cs_recv_delay );
> 
>                		return 0;
> 
> 		}
>                 else if (m) {
>                     m_freem(m);
> 		    return 0;
> 		}
>             
>             }
>         } else
> #endif
825a867
> 		if (m)
	
	


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: gnats-admin->freebsd-bugs 
Responsible-Changed-By: steve 
Responsible-Changed-When: Fri Dec 17 12:52:02 PST 1999 
Responsible-Changed-Why:  
Misfiled PR. 
State-Changed-From-To: open->closed 
State-Changed-By: dd 
State-Changed-When: Sun Jul 22 08:21:12 PDT 2001 
State-Changed-Why:  
overtaken by events; bridge support has been reworked, as has if_cs 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=15493 
>Unformatted:
