From: Matt Mackall <mpm@selenic.com>
To: linux-kernel <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@osdl.org>
Subject: [PATCH 1/5] netpoll: fix unaligned accesses
Date: Thu, 26 Aug 2004 14:58:31 -0500 [thread overview]
Message-ID: <20040826195831.GY31237@waste.org> (raw)
Avoid some alignment traps.
Signed-off-by: Matt Mackall <mpm@selenic.com>
Index: linux/net/core/netpoll.c
===================================================================
--- linux.orig/net/core/netpoll.c 2004-08-24 21:36:22.000000000 -0500
+++ linux/net/core/netpoll.c 2004-08-26 10:47:48.693423643 -0500
@@ -20,6 +20,7 @@
#include <linux/sched.h>
#include <net/tcp.h>
#include <net/udp.h>
+#include <asm/unaligned.h>
/*
* We maintain a small pool of fully-sized skbs, to make sure the
@@ -206,17 +207,17 @@
iph = (struct iphdr *)skb_push(skb, sizeof(*iph));
- iph->version = 4;
- iph->ihl = 5;
+ /* iph->version = 4; iph->ihl = 5; */
+ put_unaligned(0x54, (unsigned char *)iph);
iph->tos = 0;
- iph->tot_len = htons(ip_len);
+ put_unaligned(htonl(ip_len), &(iph->tot_len));
iph->id = 0;
iph->frag_off = 0;
iph->ttl = 64;
iph->protocol = IPPROTO_UDP;
iph->check = 0;
- iph->saddr = htonl(np->local_ip);
- iph->daddr = htonl(np->remote_ip);
+ put_unaligned(htonl(np->local_ip), &(iph->saddr));
+ put_unaligned(htonl(np->remote_ip), &(iph->daddr));
iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
--
Mathematics is the supreme nostalgia of our time.
reply other threads:[~2004-08-26 20:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20040826195831.GY31237@waste.org \
--to=mpm@selenic.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®