Bug 15493

Summary: Patch to enable bridging support for if_cs
Product: Base System Reporter: Tony Frank <tony>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 2.2.8-STABLE   
Hardware: Any   
OS: Any   

Description Tony Frank 1999-12-15 14:10:02 UTC
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.

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)
How-To-Repeat: 
Configure a kernel with the cs ethernet card, and bridging support.  
It wont work without patches.
Comment 1 Steve Price freebsd_committer freebsd_triage 1999-12-17 20:52:02 UTC
Responsible Changed
From-To: gnats-admin->freebsd-bugs

Misfiled PR. 
Comment 2 dd freebsd_committer freebsd_triage 2001-07-22 16:21:12 UTC
State Changed
From-To: open->closed

overtaken by events; bridge support has been reworked, as has if_cs