Subject: Re: kern/32644: gsip(4) sends byte-swapped vlan tags
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Christos Zoulas <christos@zoulas.com>
List: netbsd-bugs
Date: 01/30/2006 15:35:02
The following reply was made to PR kern/32644; it has been noted by GNATS.

From: christos@zoulas.com (Christos Zoulas)
To: Pavel Cahyna <pavel.cahyna@st.mff.cuni.cz>, gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org,
	netbsd-bugs@netbsd.org
Subject: Re: kern/32644: gsip(4) sends byte-swapped vlan tags
Date: Mon, 30 Jan 2006 10:32:47 -0500

 On Jan 30,  4:15pm, pcah8322@artax.karlin.mff.cuni.cz (Pavel Cahyna) wrote:
 -- Subject: Re: kern/32644: gsip(4) sends byte-swapped vlan tags
 
 | >  This does not seem right because in the first part of the patch you do:
 | >  
 | >  +			    htole32(EXTSTS_VPKT | 
 | >  +					(bswap16(VLAN_TAG_VALUE(mtag)) &
 | >  +					 EXTSTS_VTCI));
 | >  
 | >  and in the second:
 | >  
 | >  | +			VLAN_INPUT_TAG(ifp, m, bswap16(extsts & EXTSTS_VTCI),
 | >  
 | >  because in the first patch you are not bswapping16 EXTSTS_VTCI and in the
 | >  second you do?
 | 
 | I think it can be justified algebraically:
 | 
 | The firts patched part does:
 | 
 | mtag(host byte order) -> bswap16 -> &= EXTSTS_VTCI -> |= EXTSTS_VPKT ->
 | -> htole32 -> tx descriptor
 | 
 | while the second does:
 | 
 | rx descriptor -> le32toh -> &= EXTSTS_VTCI -> bswap16 -> mtag(host byte
 | order)
 | 
 | So, the second sequence is inverse to the first.
 
 Thanks, I see it now.
 
 christos