Commit 76bd9baa authored by Matt Mackall's avatar Matt Mackall Committed by Linus Torvalds

[PATCH] netpoll: fix unaligned accesses

Avoid some alignment traps.
Signed-off-by: default avatarMatt Mackall <mpm@selenic.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 4dca0193
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/rcupdate.h> #include <linux/rcupdate.h>
#include <net/tcp.h> #include <net/tcp.h>
#include <net/udp.h> #include <net/udp.h>
#include <asm/unaligned.h>
/* /*
* We maintain a small pool of fully-sized skbs, to make sure the * 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) ...@@ -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 = (struct iphdr *)skb_push(skb, sizeof(*iph));
iph->version = 4; /* iph->version = 4; iph->ihl = 5; */
iph->ihl = 5; put_unaligned(0x54, (unsigned char *)iph);
iph->tos = 0; iph->tos = 0;
iph->tot_len = htons(ip_len); put_unaligned(htonl(ip_len), &(iph->tot_len));
iph->id = 0; iph->id = 0;
iph->frag_off = 0; iph->frag_off = 0;
iph->ttl = 64; iph->ttl = 64;
iph->protocol = IPPROTO_UDP; iph->protocol = IPPROTO_UDP;
iph->check = 0; iph->check = 0;
iph->saddr = htonl(np->local_ip); put_unaligned(htonl(np->local_ip), &(iph->saddr));
iph->daddr = htonl(np->remote_ip); put_unaligned(htonl(np->remote_ip), &(iph->daddr));
iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
eth = (struct ethhdr *) skb_push(skb, ETH_HLEN); eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment