cvs commit: src/sys/dev/bge if_bge.c

Oleg Bulyzhin oleg at FreeBSD.org
Mon Feb 6 14:36:00 PST 2006


On Mon, Feb 06, 2006 at 02:21:09PM -0800, Nate Lawson wrote:
> Oleg Bulyzhin wrote:
> >On Sun, Feb 05, 2006 at 05:58:17PM -0600, Alan Cox wrote:
> >>Unfortunately, it also breaks NFS over UDP.  Let me know if you need
> >>details.
> >>
> >>Alan
> >
> >
> >Fix attached. It's not bge problem it's five years old bug in ip_reass().
> >
> >Index: ip_input.c
> >===================================================================
> >RCS file: /home/ncvs/src/sys/netinet/ip_input.c,v
> >retrieving revision 1.314
> >diff -u -r1.314 ip_input.c
> >--- ip_input.c	2 Feb 2006 03:13:15 -0000	1.314
> >+++ ip_input.c	6 Feb 2006 21:44:45 -0000
> >@@ -982,10 +982,12 @@
> > 	nq = q->m_nextpkt;
> > 	q->m_nextpkt = NULL;
> > 	for (q = nq; q != NULL; q = nq) {
> >+		int sum;
> 
> It's not good to declare local variables in the for() context.  It's a 
> style(9) bug and also costs an extra instruction or two (to decrement 
> the stack pointer twice).

You are right, but i was not going to commit this as is. It's just 'proof of
concept' fix.

> 
> > 		nq = q->m_nextpkt;
> > 		q->m_nextpkt = NULL;
> > 		m->m_pkthdr.csum_flags &= q->m_pkthdr.csum_flags;
> >-		m->m_pkthdr.csum_data += q->m_pkthdr.csum_data;
> >+		sum = m->m_pkthdr.csum_data + q->m_pkthdr.csum_data;
> >+		m->m_pkthdr.csum_data = (sum & 0xffff) + (sum >> 16);
> > 		m_cat(m, q);
> > 	}
> > #ifdef MAC
> 
> I'm not familiar with this code.  So m->m_pkthdr.csum_data is 32 bits? 
> Couldn't the same thing be achieved with making it 16 bits since the add 
> will wrap normally?

It will not work cause it's not just a trivial sum it's so called
"1's complement sum" (refer rfc1071 for details).

> 
> -- 
> Nate

-- 
Oleg.



More information about the cvs-src mailing list