Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 06 Feb 2006 15:06:10 -0800
From:      Nate Lawson <nate@root.org>
To:        Oleg Bulyzhin <oleg@FreeBSD.org>
Cc:        cvs-src@FreeBSD.org, src-committers@FreeBSD.org, Alan Cox <alc@cs.rice.edu>, cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/sys/dev/bge if_bge.c
Message-ID:  <43E7D662.6000608@root.org>
In-Reply-To: <20060206223436.GB57775@lath.rinet.ru>
References:  <200602020958.k129wWtc066930@repoman.freebsd.org> <20060202100637.GB24350@lath.rinet.ru> <20060205235817.GQ5499@cs.rice.edu> <20060206221141.GA57775@lath.rinet.ru> <43E7CBD5.5090203@root.org> <20060206223436.GB57775@lath.rinet.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
Oleg Bulyzhin wrote:
> On Mon, Feb 06, 2006 at 02:21:09PM -0800, Nate Lawson wrote:
>>Oleg Bulyzhin wrote:
>>>		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).

You're right, but aren't you missing the NOT step?
1. 2's complement sum
2. Add in carry
3. 1's complement of result (not)

-- 
Nate



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?43E7D662.6000608>