* Can we rely on ethernet header padding?
@ 2013-03-19 15:05 Michal Kubecek
2013-03-19 15:21 ` Eric Dumazet
0 siblings, 1 reply; 5+ messages in thread
From: Michal Kubecek @ 2013-03-19 15:05 UTC (permalink / raw)
To: netdev; +Cc: netfilter-devel
Hello,
a customer of ours ran into
http://bugzilla.netfilter.org/show_bug.cgi?id=765
They checked that commit a504b86e prevents the crash but I'm not sure it
is sufficient.
The crash happens when br_nf_pre_routing_finish_bridge() calls
neigh_hh_bridge() which copies not only destination MAC address but also
the padding with it. IIUC this is for performance reasons (so that
aligned 8 bytes are copied rather than 6).
But I wonder whether we can rely on the fact that every skb on an
ethernet-like device has ethernet header padded at least to the 16 bytes
expected by neigh_hh_bridge() and neigh_hh_output() or whether the
bridge code should make sure. I tried to look for such test but couldn't
find any, even if commit a504b86e description mentions reallocating the
skb rather than a crash.
Thanks in advance,
Michal Kubecek
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Can we rely on ethernet header padding?
2013-03-19 15:05 Can we rely on ethernet header padding? Michal Kubecek
@ 2013-03-19 15:21 ` Eric Dumazet
2013-03-19 15:48 ` Michal Kubecek
0 siblings, 1 reply; 5+ messages in thread
From: Eric Dumazet @ 2013-03-19 15:21 UTC (permalink / raw)
To: Michal Kubecek; +Cc: netdev, netfilter-devel
On Tue, 2013-03-19 at 16:05 +0100, Michal Kubecek wrote:
> Hello,
>
> a customer of ours ran into
>
> http://bugzilla.netfilter.org/show_bug.cgi?id=765
>
> They checked that commit a504b86e prevents the crash but I'm not sure it
> is sufficient.
>
> The crash happens when br_nf_pre_routing_finish_bridge() calls
> neigh_hh_bridge() which copies not only destination MAC address but also
> the padding with it. IIUC this is for performance reasons (so that
> aligned 8 bytes are copied rather than 6).
>
> But I wonder whether we can rely on the fact that every skb on an
> ethernet-like device has ethernet header padded at least to the 16 bytes
> expected by neigh_hh_bridge() and neigh_hh_output() or whether the
> bridge code should make sure. I tried to look for such test but couldn't
> find any, even if commit a504b86e description mentions reallocating the
> skb rather than a crash.
Thats a side effect.
Before calling netif_rx() the driver usually calls eth_type_trans()
to pull the ethernet header, so there is the room for 14 bytes.
Normally a driver has NET_SKB_PAD bytes of headroom before the ethernet
header, so the bridge code is safe only if all drivers use this
NET_SKB_PAD padding on receive side. And they really should for
performance reasons.
Better not touch bridge code to catch offending drivers
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Can we rely on ethernet header padding?
2013-03-19 15:21 ` Eric Dumazet
@ 2013-03-19 15:48 ` Michal Kubecek
2013-03-19 21:25 ` Stephen Hemminger
0 siblings, 1 reply; 5+ messages in thread
From: Michal Kubecek @ 2013-03-19 15:48 UTC (permalink / raw)
To: Eric Dumazet; +Cc: netdev, netfilter-devel
On Tue, Mar 19, 2013 at 08:21:35AM -0700, Eric Dumazet wrote:
>
> Normally a driver has NET_SKB_PAD bytes of headroom before the ethernet
> header, so the bridge code is safe only if all drivers use this
> NET_SKB_PAD padding on receive side. And they really should for
> performance reasons.
>
> Better not touch bridge code to catch offending drivers
That makes sense. Thank you for your reply.
Michal Kubecek
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Can we rely on ethernet header padding?
2013-03-19 15:48 ` Michal Kubecek
@ 2013-03-19 21:25 ` Stephen Hemminger
2013-03-20 9:54 ` Michal Kubecek
0 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2013-03-19 21:25 UTC (permalink / raw)
To: Michal Kubecek; +Cc: Eric Dumazet, netdev, netfilter-devel
On Tue, 19 Mar 2013 16:48:06 +0100
Michal Kubecek <mkubecek@suse.cz> wrote:
> On Tue, Mar 19, 2013 at 08:21:35AM -0700, Eric Dumazet wrote:
> >
> > Normally a driver has NET_SKB_PAD bytes of headroom before the ethernet
> > header, so the bridge code is safe only if all drivers use this
> > NET_SKB_PAD padding on receive side. And they really should for
> > performance reasons.
> >
> > Better not touch bridge code to catch offending drivers
>
> That makes sense. Thank you for your reply.
>
My view is that the bridge code must check before assuming headroom.
But because of that, it means a packet copy would be necessary for cases
where packets arrive without enough headroom.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Can we rely on ethernet header padding?
2013-03-19 21:25 ` Stephen Hemminger
@ 2013-03-20 9:54 ` Michal Kubecek
0 siblings, 0 replies; 5+ messages in thread
From: Michal Kubecek @ 2013-03-20 9:54 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Eric Dumazet, netdev, netfilter-devel
On Tue, Mar 19, 2013 at 02:25:53PM -0700, Stephen Hemminger wrote:
>
> My view is that the bridge code must check before assuming headroom.
> But because of that, it means a packet copy would be necessary for cases
> where packets arrive without enough headroom.
Yes, but for most users this is better than a crash. How about issuing a
WARN_ONCE() in such case so that we avoid writing out of the buffer but
still allow developers (and users who check logs) to catch the problem?
Michal Kubecek
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-03-20 9:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-19 15:05 Can we rely on ethernet header padding? Michal Kubecek
2013-03-19 15:21 ` Eric Dumazet
2013-03-19 15:48 ` Michal Kubecek
2013-03-19 21:25 ` Stephen Hemminger
2013-03-20 9:54 ` Michal Kubecek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).