NetBSD Problem Report #13385
Received: (qmail 19542 invoked from network); 5 Jul 2001 15:13:37 -0000
Message-Id: <20010705151607.25E8A18B49@dr-evil.shagadelic.org>
Date: Thu, 5 Jul 2001 08:16:07 -0700 (PDT)
From: thorpej@zembu.com
Reply-To: thorpej@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Subject: Network stack assumes aligned payload from devices
X-Send-Pr-Version: 3.95
>Number: 13385
>Category: kern
>Synopsis: Network stack assumes aligned payload from devices
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jul 05 15:14:00 +0000 2001
>Closed-Date:
>Last-Modified: Tue Sep 04 19:43:44 +0000 2001
>Originator: Jason R. Thorpe
>Release: All versions of NetBSD
>Organization:
Zembu Labs, Inc.
>Environment:
System: NetBSD dr-evil 1.5W NetBSD 1.5W (DR-EVIL) #200: Fri Jun 15 15:05:53 PDT 2001 thorpej@dr-evil:/u1/netbsd/src/sys/arch/i386/compile/DR-EVIL i386
Architecture: i386
Machine: i386
>Description:
The network stack assumes that the packets provided by
network device drivers are suitably aligned, or that the
CPU being used can perform unaligned access efficiently.
In the case of Ethernet, the header is 14 bytes. If a
device can only DMA to a 32-bit boundary (and I know of
devices which are even more strict, requiring *cacheline*
boundaries for DMA), this means that the payload after
the Ethernet header is misaligned.
On systems that cannot perform unaligned access, such as
the MIPS, Alpha, and SPARC, a fault occurs. On other systems,
such as the ARM, `incorrect' data will result from the
unaligned access. On systems such as the x86, the unaligned
access is *very* slow.
To avoid this, device drivers with their own DMA alignment
constraints generally must copy the packet into a new buffer,
who's offset is adjusted to compensate for the payload
alignment requirements.
Unfortunately, this leads to high CPU usage even at 100Mb/s,
and at 1000Mb/s, it basically destroys performance.
>How-To-Repeat:
Code inspection.
>Fix:
The correct fix would be to implement a sort of "extractor"
macro that would allow packet payload data to be accessed
in-place if the data is properly aligned, or copied to a
stack area if not aligned, and a way to copyback, if necessary.
The fix is not included here. This problem report is meant
mostly to formally document the problem.
>Release-Note:
>Audit-Trail:
From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
To: thorpej@zembu.com
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/13385: Network stack assumes aligned payload from devices
Date: Fri, 06 Jul 2001 08:30:53 +0900
>>Synopsis: Network stack assumes aligned payload from devices
for IPv6 portion, we can add some alignment check to IP6_EXTHDR_GET()
and m_pulldown(), and force alignment fixes to the mbuf chain.
for IPv4, we need to add random checks to places we call m_pullup().
anyway, i'll try to look into it.
itojun
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.