From: Arvid Brodin <arvid.brodin@enea.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: "David S. Miller" <davem@davemloft.net>, <netdev@vger.kernel.org>,
Bruno Ferreira <balferreira@googlemail.com>,
Arvid Brodin <arvid.brodin@xdin.com>
Subject: Re: [RFC] net/hsr: Add support for IEC 62439-3 High-availability Seamless Redundancy
Date: Thu, 5 Apr 2012 01:09:48 +0200 [thread overview]
Message-ID: <4F7CD4BC.4000006@enea.com> (raw)
In-Reply-To: <20120403113751.21fd0b17@s6510.linuxnetplumber.net>
Stephen Hemminger wrote:
> On Tue, 27 Mar 2012 15:20:45 +0200
> Arvid Brodin <arvid.brodin@enea.com> wrote:
>
>> +config NONSTANDARD_HSR
>> + bool "HSR: Use efficient tag (breaks HSR standard, read help!)"
>> + depends on HSR
>> + ---help---
>> + The HSR standard specifies a 6-byte HSR tag to be inserted into the
>> + transmitted network frames. This breaks the 32-bit alignment that the
>> + Linux network stack relies on, and would cause kernel panics on
>> + certain architectures. To avoid this, the whole frame payload is
>> + memmoved 2 bytes on reception on these architectures - which is very
>> + inefficient!
>
> This option won't fly. Don't do it.
> If you need to copy/realign packets on some architecture the stack
> should be changed to handle it.
Ok. The problems are in net/ipv4/icmp.c. The below patch seems to do
the trick for me - does it look OK (and if so, should I resend it as
a normal patch instead of a reply or is this enough)?
Note that I've only triggered this problem in icmp_echo(), but I
noticed that icmp_timestamp() does the same thing, so I made the change
there too.
[PATCH] net/ipv4/icmp: Fix kernel panic due to unaligned access with HSR on AVR32
icmp_echo() and icmp_timestamp() requires the icmphdr struct to be
32-bit aligned. This causes a kernel panic on AVR32 when HSR is used,
since the HSR protocol inserts a 6-byte "HSR tag" into Ethernet frame
headers, thus changing the alignment.
HSR = IEC 62439-3 High-availability Seamless Redundancy.
Signed-off-by: Arvid Brodin <arvid.brodin@xdin.com>
---
net/ipv4/icmp.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 2cb2bf8..fdd8097 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -818,7 +818,8 @@ static void icmp_echo(struct sk_buff *skb)
if (!net->ipv4.sysctl_icmp_echo_ignore_all) {
struct icmp_bxm icmp_param;
- icmp_param.data.icmph = *icmp_hdr(skb);
+ memcpy(&icmp_param.data.icmph, icmp_hdr(skb),
+ sizeof(icmp_param.data.icmph));
icmp_param.data.icmph.type = ICMP_ECHOREPLY;
icmp_param.skb = skb;
icmp_param.offset = 0;
@@ -854,7 +855,8 @@ static void icmp_timestamp(struct sk_buff *skb)
icmp_param.data.times[2] = icmp_param.data.times[1];
if (skb_copy_bits(skb, 0, &icmp_param.data.times[0], 4))
BUG();
- icmp_param.data.icmph = *icmp_hdr(skb);
+ memcpy(&icmp_param.data.icmph, icmp_hdr(skb),
+ sizeof(icmp_param.data.icmph));
icmp_param.data.icmph.type = ICMP_TIMESTAMPREPLY;
icmp_param.data.icmph.code = 0;
icmp_param.skb = skb;
--
1.6.3.3
--
Arvid Brodin
Enea Services Stockholm AB - since February 16 a part of Xdin in the Alten
Group. Soon we will be working under the common brand Xdin. Read more at
www.xdin.com.
next prev parent reply other threads:[~2012-04-04 23:09 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-27 13:20 [RFC] net/hsr: Add support for IEC 62439-3 High-availability Seamless Redundancy Arvid Brodin
2012-04-03 18:37 ` Stephen Hemminger
2012-04-04 23:09 ` Arvid Brodin [this message]
2012-04-04 23:55 ` Stephen Hemminger
2012-04-05 0:21 ` David Miller
2012-04-06 15:51 ` Arvid Brodin
2012-04-06 16:43 ` David Miller
2012-04-06 17:08 ` Arvid Brodin
2012-04-06 17:06 ` Ben Hutchings
2012-04-06 18:19 ` Stephen Hemminger
2012-04-11 0:00 ` Arvid Brodin
2012-04-11 1:28 ` Stephen Hemminger
2012-04-11 14:39 ` Arvid Brodin
2012-04-05 0:17 ` David Miller
2012-04-05 19:21 ` Ben Hutchings
2012-04-05 22:31 ` David Miller
2012-05-14 18:11 ` Arvid Brodin
2012-05-14 18:28 ` Stephen Hemminger
2012-05-24 17:09 ` Arvid Brodin
2012-05-24 17:16 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F7CD4BC.4000006@enea.com \
--to=arvid.brodin@enea.com \
--cc=arvid.brodin@xdin.com \
--cc=balferreira@googlemail.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.