From 76bd9baa402501d23a2cbd6b5a8faea42cd01284 Mon Sep 17 00:00:00 2001 From: Matt Mackall Date: Mon, 30 Aug 2004 20:37:42 -0700 Subject: [PATCH] [PATCH] netpoll: fix unaligned accesses Avoid some alignment traps. Signed-off-by: Matt Mackall Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- net/core/netpoll.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 5276e4134f874..7af1205b74835 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -21,6 +21,7 @@ #include #include #include +#include /* * We maintain a small pool of fully-sized skbs, to make sure the @@ -207,17 +208,17 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len) 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); -- 2.53.0