Bug 31954

Summary: rwhod does not see itself via xl0
Product: Base System Reporter: marcolz <marcolz>
Component: kernAssignee: Bill Fenner <fenner>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.4-STABLE   
Hardware: Any   
OS: Any   

Description marcolz 2001-11-13 17:30:01 UTC
	On systems with a 3com using the current stable-sourcetree,
	rwhod does not receive it's own broadcast packets, while on
	systems with a Intel Etherexpress pro 100, it works ok.
	Just replacing the 3com does the trick...

How-To-Repeat: 	Just start rwhod.
Comment 1 Bill Fenner 2001-11-14 08:53:21 UTC
What if you turn off hardware checksums?

  Bill
Comment 2 marcolz 2001-11-16 01:30:30 UTC
> 
> What if you turn off hardware checksums?

How ?

I did try setting net.inet.udp.checksum to 0, but that did not have any
effect.

Marc
Comment 3 Bill Fenner 2001-12-04 03:23:25 UTC
It turns out that when a broadcast packet is looped back, the checksums
are checked on the way in even if they were not calculated on the
way out.  This patch works for me; would you mind trying it?

Thanks,
  Bill

cvs diff: Diffing .
Index: if_ethersubr.c
===================================================================
RCS file: /home/ncvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.70.2.19
diff -u -r1.70.2.19 if_ethersubr.c
--- if_ethersubr.c	2001/11/04 22:32:16	1.70.2.19
+++ if_ethersubr.c	2001/12/04 03:15:34
@@ -331,12 +331,25 @@
 	 * reasons and compatibility with the original behavior.
 	 */
 	if ((ifp->if_flags & IFF_SIMPLEX) && (loop_copy != -1)) {
+		int csum_flags = 0;
+
+		if (m->m_pkthdr.csum_flags & CSUM_IP)
+			csum_flags |= (CSUM_IP_CHECKED|CSUM_IP_VALID);
+		if (m->m_pkthdr.csum_flags & CSUM_DELAY_DATA)
+			csum_flags |= (CSUM_DATA_VALID|CSUM_PSEUDO_HDR);
 		if ((m->m_flags & M_BCAST) || (loop_copy > 0)) {
 			struct mbuf *n = m_copy(m, 0, (int)M_COPYALL);
 
+			n->m_pkthdr.csum_flags |= csum_flags;
+			if (csum_flags & CSUM_DATA_VALID)
+				n->m_pkthdr.csum_data = 0xffff;
+
 			(void) if_simloop(ifp, n, dst->sa_family, hlen);
 		} else if (bcmp(eh->ether_dhost,
 		    eh->ether_shost, ETHER_ADDR_LEN) == 0) {
+			m->m_pkthdr.csum_flags |= csum_flags;
+			if (csum_flags & CSUM_DATA_VALID)
+				m->m_pkthdr.csum_data = 0xffff;
 			(void) if_simloop(ifp, m, dst->sa_family, hlen);
 			return (0);	/* XXX */
 		}
Comment 4 glennpj 2001-12-11 05:28:42 UTC
I tested the patch and it works fine.
Comment 5 glennpj 2001-12-11 05:32:42 UTC
I tested the patch and it works fine.
Comment 6 ru freebsd_committer freebsd_triage 2001-12-19 09:11:38 UTC
Responsible Changed
From-To: freebsd-bugs->fenner

Bill asked for a feedback, and originator says patch worked OK.
Comment 7 Jesper Skriver freebsd_committer freebsd_triage 2002-01-11 16:05:01 UTC
State Changed
From-To: open->closed

Patch committed to -current, will MFC before 4.5 if re@ approves