902-unaligned_access_hacks.patch 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  1. --- a/arch/mips/include/asm/checksum.h
  2. +++ b/arch/mips/include/asm/checksum.h
  3. @@ -104,26 +104,30 @@ static inline __sum16 ip_fast_csum(const
  4. const unsigned int *stop = word + ihl;
  5. unsigned int csum;
  6. int carry;
  7. + unsigned int w;
  8. - csum = word[0];
  9. - csum += word[1];
  10. - carry = (csum < word[1]);
  11. + csum = net_hdr_word(word++);
  12. +
  13. + w = net_hdr_word(word++);
  14. + csum += w;
  15. + carry = (csum < w);
  16. csum += carry;
  17. - csum += word[2];
  18. - carry = (csum < word[2]);
  19. + w = net_hdr_word(word++);
  20. + csum += w;
  21. + carry = (csum < w);
  22. csum += carry;
  23. - csum += word[3];
  24. - carry = (csum < word[3]);
  25. + w = net_hdr_word(word++);
  26. + csum += w;
  27. + carry = (csum < w);
  28. csum += carry;
  29. - word += 4;
  30. do {
  31. - csum += *word;
  32. - carry = (csum < *word);
  33. + w = net_hdr_word(word++);
  34. + csum += w;
  35. + carry = (csum < w);
  36. csum += carry;
  37. - word++;
  38. } while (word != stop);
  39. return csum_fold(csum);
  40. @@ -192,69 +196,4 @@ static inline __sum16 ip_compute_csum(co
  41. return csum_fold(csum_partial(buff, len, 0));
  42. }
  43. -#define _HAVE_ARCH_IPV6_CSUM
  44. -static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
  45. - const struct in6_addr *daddr,
  46. - __u32 len, unsigned short proto,
  47. - __wsum sum)
  48. -{
  49. - __asm__(
  50. - " .set push # csum_ipv6_magic\n"
  51. - " .set noreorder \n"
  52. - " .set noat \n"
  53. - " addu %0, %5 # proto (long in network byte order)\n"
  54. - " sltu $1, %0, %5 \n"
  55. - " addu %0, $1 \n"
  56. -
  57. - " addu %0, %6 # csum\n"
  58. - " sltu $1, %0, %6 \n"
  59. - " lw %1, 0(%2) # four words source address\n"
  60. - " addu %0, $1 \n"
  61. - " addu %0, %1 \n"
  62. - " sltu $1, %0, %1 \n"
  63. -
  64. - " lw %1, 4(%2) \n"
  65. - " addu %0, $1 \n"
  66. - " addu %0, %1 \n"
  67. - " sltu $1, %0, %1 \n"
  68. -
  69. - " lw %1, 8(%2) \n"
  70. - " addu %0, $1 \n"
  71. - " addu %0, %1 \n"
  72. - " sltu $1, %0, %1 \n"
  73. -
  74. - " lw %1, 12(%2) \n"
  75. - " addu %0, $1 \n"
  76. - " addu %0, %1 \n"
  77. - " sltu $1, %0, %1 \n"
  78. -
  79. - " lw %1, 0(%3) \n"
  80. - " addu %0, $1 \n"
  81. - " addu %0, %1 \n"
  82. - " sltu $1, %0, %1 \n"
  83. -
  84. - " lw %1, 4(%3) \n"
  85. - " addu %0, $1 \n"
  86. - " addu %0, %1 \n"
  87. - " sltu $1, %0, %1 \n"
  88. -
  89. - " lw %1, 8(%3) \n"
  90. - " addu %0, $1 \n"
  91. - " addu %0, %1 \n"
  92. - " sltu $1, %0, %1 \n"
  93. -
  94. - " lw %1, 12(%3) \n"
  95. - " addu %0, $1 \n"
  96. - " addu %0, %1 \n"
  97. - " sltu $1, %0, %1 \n"
  98. -
  99. - " addu %0, $1 # Add final carry\n"
  100. - " .set pop"
  101. - : "=r" (sum), "=r" (proto)
  102. - : "r" (saddr), "r" (daddr),
  103. - "0" (htonl(len)), "1" (htonl(proto)), "r" (sum));
  104. -
  105. - return csum_fold(sum);
  106. -}
  107. -
  108. #endif /* _ASM_CHECKSUM_H */
  109. --- a/include/uapi/linux/ip.h
  110. +++ b/include/uapi/linux/ip.h
  111. @@ -102,7 +102,7 @@ struct iphdr {
  112. __be32 saddr;
  113. __be32 daddr;
  114. /*The options start here. */
  115. -};
  116. +} __attribute__((packed, aligned(2)));
  117. struct ip_auth_hdr {
  118. --- a/include/uapi/linux/ipv6.h
  119. +++ b/include/uapi/linux/ipv6.h
  120. @@ -123,7 +123,7 @@ struct ipv6hdr {
  121. struct in6_addr saddr;
  122. struct in6_addr daddr;
  123. -};
  124. +} __attribute__((packed, aligned(2)));
  125. /* index values for the variables in ipv6_devconf */
  126. --- a/include/uapi/linux/tcp.h
  127. +++ b/include/uapi/linux/tcp.h
  128. @@ -54,7 +54,7 @@ struct tcphdr {
  129. __be16 window;
  130. __sum16 check;
  131. __be16 urg_ptr;
  132. -};
  133. +} __attribute__((packed, aligned(2)));
  134. /*
  135. * The union cast uses a gcc extension to avoid aliasing problems
  136. @@ -64,7 +64,7 @@ struct tcphdr {
  137. union tcp_word_hdr {
  138. struct tcphdr hdr;
  139. __be32 words[5];
  140. -};
  141. +} __attribute__((packed, aligned(2)));
  142. #define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3])
  143. --- a/include/uapi/linux/udp.h
  144. +++ b/include/uapi/linux/udp.h
  145. @@ -24,7 +24,7 @@ struct udphdr {
  146. __be16 dest;
  147. __be16 len;
  148. __sum16 check;
  149. -};
  150. +} __attribute__((packed, aligned(2)));
  151. /* UDP socket options */
  152. #define UDP_CORK 1 /* Never send partially complete segments */
  153. --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
  154. +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
  155. @@ -39,8 +39,8 @@ static bool ipv4_pkt_to_tuple(const stru
  156. if (ap == NULL)
  157. return false;
  158. - tuple->src.u3.ip = ap[0];
  159. - tuple->dst.u3.ip = ap[1];
  160. + tuple->src.u3.ip = net_hdr_word(ap++);
  161. + tuple->dst.u3.ip = net_hdr_word(ap);
  162. return true;
  163. }
  164. --- a/include/uapi/linux/icmp.h
  165. +++ b/include/uapi/linux/icmp.h
  166. @@ -80,7 +80,7 @@ struct icmphdr {
  167. __be16 mtu;
  168. } frag;
  169. } un;
  170. -};
  171. +} __attribute__((packed, aligned(2)));
  172. /*
  173. --- a/net/ipv4/tcp_input.c
  174. +++ b/net/ipv4/tcp_input.c
  175. @@ -3896,13 +3896,14 @@ static bool tcp_parse_aligned_timestamp(
  176. {
  177. const __be32 *ptr = (const __be32 *)(th + 1);
  178. - if (*ptr == htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16)
  179. - | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) {
  180. + if (net_hdr_word(ptr) ==
  181. + htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
  182. + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) {
  183. tp->rx_opt.saw_tstamp = 1;
  184. ++ptr;
  185. - tp->rx_opt.rcv_tsval = ntohl(*ptr);
  186. + tp->rx_opt.rcv_tsval = get_unaligned_be32(ptr);
  187. ++ptr;
  188. - tp->rx_opt.rcv_tsecr = ntohl(*ptr);
  189. + tp->rx_opt.rcv_tsecr = get_unaligned_be32(ptr);
  190. return true;
  191. }
  192. return false;
  193. --- a/include/uapi/linux/in6.h
  194. +++ b/include/uapi/linux/in6.h
  195. @@ -36,7 +36,7 @@ struct in6_addr {
  196. #define s6_addr in6_u.u6_addr8
  197. #define s6_addr16 in6_u.u6_addr16
  198. #define s6_addr32 in6_u.u6_addr32
  199. -};
  200. +} __attribute__((packed, aligned(2)));
  201. /* IPv6 Wildcard Address (::) and Loopback Address (::1) defined in RFC2553
  202. * NOTE: Be aware the IN6ADDR_* constants and in6addr_* externals are defined
  203. --- a/net/ipv6/af_inet6.c
  204. +++ b/net/ipv6/af_inet6.c
  205. @@ -61,6 +61,7 @@
  206. #endif
  207. #include <asm/uaccess.h>
  208. +#include <asm/unaligned.h>
  209. #include <linux/mroute6.h>
  210. MODULE_AUTHOR("Cast of dozens");
  211. @@ -688,7 +689,7 @@ bool ipv6_opt_accepted(const struct sock
  212. if ((opt->hop && (np->rxopt.bits.hopopts ||
  213. np->rxopt.bits.ohopopts)) ||
  214. ((IPV6_FLOWINFO_MASK &
  215. - *(__be32 *)skb_network_header(skb)) &&
  216. + net_hdr_word(skb_network_header(skb))) &&
  217. np->rxopt.bits.rxflow) ||
  218. (opt->srcrt && (np->rxopt.bits.srcrt ||
  219. np->rxopt.bits.osrcrt)) ||
  220. --- a/net/ipv6/route.c
  221. +++ b/net/ipv6/route.c
  222. @@ -1013,7 +1013,7 @@ void ip6_route_input(struct sk_buff *skb
  223. .flowi6_iif = skb->dev->ifindex,
  224. .daddr = iph->daddr,
  225. .saddr = iph->saddr,
  226. - .flowlabel = (* (__be32 *) iph) & IPV6_FLOWINFO_MASK,
  227. + .flowlabel = net_hdr_word(iph) & IPV6_FLOWINFO_MASK,
  228. .flowi6_mark = skb->mark,
  229. .flowi6_proto = iph->nexthdr,
  230. };
  231. @@ -1177,7 +1177,7 @@ void ip6_update_pmtu(struct sk_buff *skb
  232. fl6.flowi6_flags = 0;
  233. fl6.daddr = iph->daddr;
  234. fl6.saddr = iph->saddr;
  235. - fl6.flowlabel = (*(__be32 *) iph) & IPV6_FLOWINFO_MASK;
  236. + fl6.flowlabel = net_hdr_word(iph) & IPV6_FLOWINFO_MASK,
  237. dst = ip6_route_output(net, NULL, &fl6);
  238. if (!dst->error)
  239. @@ -1205,7 +1205,7 @@ void ip6_redirect(struct sk_buff *skb, s
  240. fl6.flowi6_flags = 0;
  241. fl6.daddr = iph->daddr;
  242. fl6.saddr = iph->saddr;
  243. - fl6.flowlabel = (*(__be32 *) iph) & IPV6_FLOWINFO_MASK;
  244. + fl6.flowlabel = net_hdr_word(iph) & IPV6_FLOWINFO_MASK,
  245. dst = ip6_route_output(net, NULL, &fl6);
  246. if (!dst->error)
  247. --- a/net/ipv6/tcp_ipv6.c
  248. +++ b/net/ipv6/tcp_ipv6.c
  249. @@ -64,6 +64,7 @@
  250. #include <net/secure_seq.h>
  251. #include <net/tcp_memcontrol.h>
  252. +#include <asm/unaligned.h>
  253. #include <asm/uaccess.h>
  254. #include <linux/proc_fs.h>
  255. @@ -764,10 +765,10 @@ static void tcp_v6_send_response(struct
  256. topt = (__be32 *)(t1 + 1);
  257. if (ts) {
  258. - *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
  259. - (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP);
  260. - *topt++ = htonl(tcp_time_stamp);
  261. - *topt++ = htonl(ts);
  262. + put_unaligned_be32((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
  263. + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP, topt++);
  264. + put_unaligned_be32(tcp_time_stamp, topt++);
  265. + put_unaligned_be32(ts, topt++);
  266. }
  267. #ifdef CONFIG_TCP_MD5SIG
  268. --- a/include/linux/ipv6.h
  269. +++ b/include/linux/ipv6.h
  270. @@ -4,6 +4,7 @@
  271. #include <uapi/linux/ipv6.h>
  272. #define ipv6_optlen(p) (((p)->hdrlen+1) << 3)
  273. +
  274. /*
  275. * This structure contains configuration options per IPv6 link.
  276. */
  277. @@ -79,7 +80,7 @@ static inline struct ipv6hdr *ipipv6_hdr
  278. static inline __u8 ipv6_tclass(const struct ipv6hdr *iph)
  279. {
  280. - return (ntohl(*(__be32 *)iph) >> 20) & 0xff;
  281. + return (ntohl(net_hdr_word(iph)) >> 20) & 0xff;
  282. }
  283. /*
  284. --- a/net/ipv6/datagram.c
  285. +++ b/net/ipv6/datagram.c
  286. @@ -360,12 +360,12 @@ int ipv6_recv_error(struct sock *sk, str
  287. *(struct in6_addr *)(nh + serr->addr_offset);
  288. if (np->sndflow)
  289. sin->sin6_flowinfo =
  290. - (*(__be32 *)(nh + serr->addr_offset - 24) &
  291. - IPV6_FLOWINFO_MASK);
  292. + net_hdr_word(nh + serr->addr_offset - 24) &
  293. + IPV6_FLOWINFO_MASK;
  294. if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
  295. sin->sin6_scope_id = IP6CB(skb)->iif;
  296. } else {
  297. - ipv6_addr_set_v4mapped(*(__be32 *)(nh + serr->addr_offset),
  298. + ipv6_addr_set_v4mapped(net_hdr_word(nh + serr->addr_offset),
  299. &sin->sin6_addr);
  300. }
  301. }
  302. @@ -493,9 +493,10 @@ int ip6_datagram_recv_ctl(struct sock *s
  303. put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass);
  304. }
  305. - if (np->rxopt.bits.rxflow && (*(__be32 *)nh & IPV6_FLOWINFO_MASK)) {
  306. - __be32 flowinfo = *(__be32 *)nh & IPV6_FLOWINFO_MASK;
  307. - put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo);
  308. + if (np->rxopt.bits.rxflow) {
  309. + __be32 flowinfo = net_hdr_word(nh) & IPV6_FLOWINFO_MASK;
  310. + if (flowinfo)
  311. + put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo);
  312. }
  313. /* HbH is allowed only once */
  314. @@ -682,12 +683,12 @@ int ip6_datagram_send_ctl(struct net *ne
  315. }
  316. if (fl6->flowlabel&IPV6_FLOWINFO_MASK) {
  317. - if ((fl6->flowlabel^*(__be32 *)CMSG_DATA(cmsg))&~IPV6_FLOWINFO_MASK) {
  318. + if ((fl6->flowlabel^net_hdr_word(CMSG_DATA(cmsg)))&~IPV6_FLOWINFO_MASK) {
  319. err = -EINVAL;
  320. goto exit_f;
  321. }
  322. }
  323. - fl6->flowlabel = IPV6_FLOWINFO_MASK & *(__be32 *)CMSG_DATA(cmsg);
  324. + fl6->flowlabel = IPV6_FLOWINFO_MASK & net_hdr_word(CMSG_DATA(cmsg));
  325. break;
  326. case IPV6_2292HOPOPTS:
  327. --- a/net/ipv6/ip6_gre.c
  328. +++ b/net/ipv6/ip6_gre.c
  329. @@ -430,7 +430,7 @@ static void ip6gre_err(struct sk_buff *s
  330. t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr,
  331. flags & GRE_KEY ?
  332. - *(((__be32 *)p) + (grehlen / 4) - 1) : 0,
  333. + net_hdr_word(((__be32 *)p) + (grehlen / 4) - 1) : 0,
  334. p[1]);
  335. if (t == NULL)
  336. return;
  337. @@ -522,11 +522,11 @@ static int ip6gre_rcv(struct sk_buff *sk
  338. offset += 4;
  339. }
  340. if (flags&GRE_KEY) {
  341. - key = *(__be32 *)(h + offset);
  342. + key = net_hdr_word(h + offset);
  343. offset += 4;
  344. }
  345. if (flags&GRE_SEQ) {
  346. - seqno = ntohl(*(__be32 *)(h + offset));
  347. + seqno = ntohl(net_hdr_word(h + offset));
  348. offset += 4;
  349. }
  350. }
  351. @@ -772,7 +772,7 @@ static netdev_tx_t ip6gre_xmit2(struct s
  352. * Push down and install the IP header.
  353. */
  354. ipv6h = ipv6_hdr(skb);
  355. - *(__be32 *)ipv6h = fl6->flowlabel | htonl(0x60000000);
  356. + net_hdr_word(ipv6h) = fl6->flowlabel | htonl(0x60000000);
  357. dsfield = INET_ECN_encapsulate(0, dsfield);
  358. ipv6_change_dsfield(ipv6h, ~INET_ECN_MASK, dsfield);
  359. ipv6h->hop_limit = tunnel->parms.hop_limit;
  360. @@ -789,7 +789,7 @@ static netdev_tx_t ip6gre_xmit2(struct s
  361. if (tunnel->parms.o_flags&GRE_SEQ) {
  362. ++tunnel->o_seqno;
  363. - *ptr = htonl(tunnel->o_seqno);
  364. + net_hdr_word(ptr) = htonl(tunnel->o_seqno);
  365. ptr--;
  366. }
  367. if (tunnel->parms.o_flags&GRE_KEY) {
  368. @@ -897,9 +897,9 @@ static inline int ip6gre_xmit_ipv6(struc
  369. dsfield = ipv6_get_dsfield(ipv6h);
  370. if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
  371. - fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
  372. + fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_TCLASS_MASK;
  373. if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
  374. - fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_FLOWLABEL_MASK);
  375. + fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_FLOWLABEL_MASK;
  376. if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
  377. fl6.flowi6_mark = skb->mark;
  378. @@ -1240,7 +1240,7 @@ static int ip6gre_header(struct sk_buff
  379. struct ipv6hdr *ipv6h = (struct ipv6hdr *)skb_push(skb, t->hlen);
  380. __be16 *p = (__be16 *)(ipv6h+1);
  381. - *(__be32 *)ipv6h = t->fl.u.ip6.flowlabel | htonl(0x60000000);
  382. + net_hdr_word(ipv6h) = t->fl.u.ip6.flowlabel | htonl(0x60000000);
  383. ipv6h->hop_limit = t->parms.hop_limit;
  384. ipv6h->nexthdr = NEXTHDR_GRE;
  385. ipv6h->saddr = t->parms.laddr;
  386. --- a/net/ipv6/ip6_output.c
  387. +++ b/net/ipv6/ip6_output.c
  388. @@ -216,7 +216,7 @@ int ip6_xmit(struct sock *sk, struct sk_
  389. if (hlimit < 0)
  390. hlimit = ip6_dst_hoplimit(dst);
  391. - *(__be32 *)hdr = htonl(0x60000000 | (tclass << 20)) | fl6->flowlabel;
  392. + net_hdr_word(hdr) = htonl(0x60000000 | (tclass << 20)) | fl6->flowlabel;
  393. hdr->payload_len = htons(seg_len);
  394. hdr->nexthdr = proto;
  395. --- a/net/ipv6/ip6_tunnel.c
  396. +++ b/net/ipv6/ip6_tunnel.c
  397. @@ -1136,9 +1136,9 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, str
  398. dsfield = ipv6_get_dsfield(ipv6h);
  399. if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)
  400. - fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK);
  401. + fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_TCLASS_MASK;
  402. if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL)
  403. - fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_FLOWLABEL_MASK);
  404. + fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_FLOWLABEL_MASK;
  405. if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK)
  406. fl6.flowi6_mark = skb->mark;
  407. --- a/net/ipv6/exthdrs.c
  408. +++ b/net/ipv6/exthdrs.c
  409. @@ -578,7 +578,7 @@ static bool ipv6_hop_jumbo(struct sk_buf
  410. goto drop;
  411. }
  412. - pkt_len = ntohl(*(__be32 *)(nh + optoff + 2));
  413. + pkt_len = ntohl(net_hdr_word(nh + optoff + 2));
  414. if (pkt_len <= IPV6_MAXPLEN) {
  415. IP6_INC_STATS_BH(net, ipv6_skb_idev(skb),
  416. IPSTATS_MIB_INHDRERRORS);
  417. --- a/include/linux/types.h
  418. +++ b/include/linux/types.h
  419. @@ -212,5 +212,11 @@ struct callback_head {
  420. };
  421. #define rcu_head callback_head
  422. +struct net_hdr_word {
  423. + u32 words[1];
  424. +} __attribute__((packed, aligned(2)));
  425. +
  426. +#define net_hdr_word(_p) (((struct net_hdr_word *) (_p))->words[0])
  427. +
  428. #endif /* __ASSEMBLY__ */
  429. #endif /* _LINUX_TYPES_H */
  430. --- a/net/ipv4/af_inet.c
  431. +++ b/net/ipv4/af_inet.c
  432. @@ -1396,8 +1396,8 @@ static struct sk_buff **inet_gro_receive
  433. if (unlikely(ip_fast_csum((u8 *)iph, 5)))
  434. goto out_unlock;
  435. - id = ntohl(*(__be32 *)&iph->id);
  436. - flush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (id ^ IP_DF));
  437. + id = ntohl(net_hdr_word(&iph->id));
  438. + flush = (u16)((ntohl(net_hdr_word(iph)) ^ skb_gro_len(skb)) | (id ^ IP_DF));
  439. id >>= 16;
  440. for (p = *head; p; p = p->next) {
  441. --- a/net/ipv4/route.c
  442. +++ b/net/ipv4/route.c
  443. @@ -465,7 +465,7 @@ static struct neighbour *ipv4_neigh_look
  444. else if (skb)
  445. pkey = &ip_hdr(skb)->daddr;
  446. - n = __ipv4_neigh_lookup(dev, *(__force u32 *)pkey);
  447. + n = __ipv4_neigh_lookup(dev, net_hdr_word(pkey));
  448. if (n)
  449. return n;
  450. return neigh_create(&arp_tbl, pkey, dev);
  451. --- a/net/ipv4/tcp_output.c
  452. +++ b/net/ipv4/tcp_output.c
  453. @@ -456,15 +456,17 @@ static void tcp_options_write(__be32 *pt
  454. */
  455. if (unlikely(OPTION_MD5 & options)) {
  456. if (unlikely(OPTION_COOKIE_EXTENSION & options)) {
  457. - *ptr++ = htonl((TCPOPT_COOKIE << 24) |
  458. - (TCPOLEN_COOKIE_BASE << 16) |
  459. - (TCPOPT_MD5SIG << 8) |
  460. - TCPOLEN_MD5SIG);
  461. + net_hdr_word(ptr++) =
  462. + htonl((TCPOPT_COOKIE << 24) |
  463. + (TCPOLEN_COOKIE_BASE << 16) |
  464. + (TCPOPT_MD5SIG << 8) |
  465. + TCPOLEN_MD5SIG);
  466. } else {
  467. - *ptr++ = htonl((TCPOPT_NOP << 24) |
  468. - (TCPOPT_NOP << 16) |
  469. - (TCPOPT_MD5SIG << 8) |
  470. - TCPOLEN_MD5SIG);
  471. + net_hdr_word(ptr++) =
  472. + htonl((TCPOPT_NOP << 24) |
  473. + (TCPOPT_NOP << 16) |
  474. + (TCPOPT_MD5SIG << 8) |
  475. + TCPOLEN_MD5SIG);
  476. }
  477. options &= ~OPTION_COOKIE_EXTENSION;
  478. /* overload cookie hash location */
  479. @@ -473,26 +475,28 @@ static void tcp_options_write(__be32 *pt
  480. }
  481. if (unlikely(opts->mss)) {
  482. - *ptr++ = htonl((TCPOPT_MSS << 24) |
  483. - (TCPOLEN_MSS << 16) |
  484. - opts->mss);
  485. + net_hdr_word(ptr++) =
  486. + htonl((TCPOPT_MSS << 24) | (TCPOLEN_MSS << 16) |
  487. + opts->mss);
  488. }
  489. if (likely(OPTION_TS & options)) {
  490. if (unlikely(OPTION_SACK_ADVERTISE & options)) {
  491. - *ptr++ = htonl((TCPOPT_SACK_PERM << 24) |
  492. - (TCPOLEN_SACK_PERM << 16) |
  493. - (TCPOPT_TIMESTAMP << 8) |
  494. - TCPOLEN_TIMESTAMP);
  495. + net_hdr_word(ptr++) =
  496. + htonl((TCPOPT_SACK_PERM << 24) |
  497. + (TCPOLEN_SACK_PERM << 16) |
  498. + (TCPOPT_TIMESTAMP << 8) |
  499. + TCPOLEN_TIMESTAMP);
  500. options &= ~OPTION_SACK_ADVERTISE;
  501. } else {
  502. - *ptr++ = htonl((TCPOPT_NOP << 24) |
  503. - (TCPOPT_NOP << 16) |
  504. - (TCPOPT_TIMESTAMP << 8) |
  505. - TCPOLEN_TIMESTAMP);
  506. + net_hdr_word(ptr++) =
  507. + htonl((TCPOPT_NOP << 24) |
  508. + (TCPOPT_NOP << 16) |
  509. + (TCPOPT_TIMESTAMP << 8) |
  510. + TCPOLEN_TIMESTAMP);
  511. }
  512. - *ptr++ = htonl(opts->tsval);
  513. - *ptr++ = htonl(opts->tsecr);
  514. + net_hdr_word(ptr++) = htonl(opts->tsval);
  515. + net_hdr_word(ptr++) = htonl(opts->tsecr);
  516. }
  517. /* Specification requires after timestamp, so do it now.
  518. @@ -512,19 +516,20 @@ static void tcp_options_write(__be32 *pt
  519. __u8 *p = (__u8 *)ptr;
  520. /* 16-bit multiple */
  521. - *p++ = TCPOPT_COOKIE;
  522. - *p++ = TCPOLEN_COOKIE_BASE + cookie_size;
  523. - *p++ = *cookie_copy++;
  524. - *p++ = *cookie_copy++;
  525. + net_hdr_word(p++) = TCPOPT_COOKIE;
  526. + net_hdr_word(p++) = TCPOLEN_COOKIE_BASE + cookie_size;
  527. + net_hdr_word(p++) = *cookie_copy++;
  528. + net_hdr_word(p++) = *cookie_copy++;
  529. ptr++;
  530. cookie_size -= 2;
  531. } else {
  532. /* 32-bit multiple */
  533. - *ptr++ = htonl(((TCPOPT_NOP << 24) |
  534. - (TCPOPT_NOP << 16) |
  535. - (TCPOPT_COOKIE << 8) |
  536. - TCPOLEN_COOKIE_BASE) +
  537. - cookie_size);
  538. + net_hdr_word(ptr++) =
  539. + htonl(((TCPOPT_NOP << 24) |
  540. + (TCPOPT_NOP << 16) |
  541. + (TCPOPT_COOKIE << 8) |
  542. + TCPOLEN_COOKIE_BASE) +
  543. + cookie_size);
  544. }
  545. if (cookie_size > 0) {
  546. @@ -534,17 +539,19 @@ static void tcp_options_write(__be32 *pt
  547. }
  548. if (unlikely(OPTION_SACK_ADVERTISE & options)) {
  549. - *ptr++ = htonl((TCPOPT_NOP << 24) |
  550. - (TCPOPT_NOP << 16) |
  551. - (TCPOPT_SACK_PERM << 8) |
  552. - TCPOLEN_SACK_PERM);
  553. + net_hdr_word(ptr++) =
  554. + htonl((TCPOPT_NOP << 24) |
  555. + (TCPOPT_NOP << 16) |
  556. + (TCPOPT_SACK_PERM << 8) |
  557. + TCPOLEN_SACK_PERM);
  558. }
  559. if (unlikely(OPTION_WSCALE & options)) {
  560. - *ptr++ = htonl((TCPOPT_NOP << 24) |
  561. - (TCPOPT_WINDOW << 16) |
  562. - (TCPOLEN_WINDOW << 8) |
  563. - opts->ws);
  564. + net_hdr_word(ptr++) =
  565. + htonl((TCPOPT_NOP << 24) |
  566. + (TCPOPT_WINDOW << 16) |
  567. + (TCPOLEN_WINDOW << 8) |
  568. + opts->ws);
  569. }
  570. if (unlikely(opts->num_sack_blocks)) {
  571. @@ -552,16 +559,17 @@ static void tcp_options_write(__be32 *pt
  572. tp->duplicate_sack : tp->selective_acks;
  573. int this_sack;
  574. - *ptr++ = htonl((TCPOPT_NOP << 24) |
  575. - (TCPOPT_NOP << 16) |
  576. - (TCPOPT_SACK << 8) |
  577. - (TCPOLEN_SACK_BASE + (opts->num_sack_blocks *
  578. + net_hdr_word(ptr++) =
  579. + htonl((TCPOPT_NOP << 24) |
  580. + (TCPOPT_NOP << 16) |
  581. + (TCPOPT_SACK << 8) |
  582. + (TCPOLEN_SACK_BASE + (opts->num_sack_blocks *
  583. TCPOLEN_SACK_PERBLOCK)));
  584. for (this_sack = 0; this_sack < opts->num_sack_blocks;
  585. ++this_sack) {
  586. - *ptr++ = htonl(sp[this_sack].start_seq);
  587. - *ptr++ = htonl(sp[this_sack].end_seq);
  588. + net_hdr_word(ptr++) = htonl(sp[this_sack].start_seq);
  589. + net_hdr_word(ptr++) = htonl(sp[this_sack].end_seq);
  590. }
  591. tp->rx_opt.dsack = 0;
  592. @@ -570,9 +578,10 @@ static void tcp_options_write(__be32 *pt
  593. if (unlikely(OPTION_FAST_OPEN_COOKIE & options)) {
  594. struct tcp_fastopen_cookie *foc = opts->fastopen_cookie;
  595. - *ptr++ = htonl((TCPOPT_EXP << 24) |
  596. - ((TCPOLEN_EXP_FASTOPEN_BASE + foc->len) << 16) |
  597. - TCPOPT_FASTOPEN_MAGIC);
  598. + net_hdr_word(ptr++) =
  599. + htonl((TCPOPT_EXP << 24) |
  600. + ((TCPOLEN_EXP_FASTOPEN_BASE + foc->len) << 16) |
  601. + TCPOPT_FASTOPEN_MAGIC);
  602. memcpy(ptr, foc->val, foc->len);
  603. if ((foc->len & 3) == 2) {
  604. --- a/net/ipv4/igmp.c
  605. +++ b/net/ipv4/igmp.c
  606. @@ -470,7 +470,7 @@ static struct sk_buff *add_grec(struct s
  607. if (!skb)
  608. return NULL;
  609. psrc = (__be32 *)skb_put(skb, sizeof(__be32));
  610. - *psrc = psf->sf_inaddr;
  611. + net_hdr_word(psrc) = psf->sf_inaddr;
  612. scount++; stotal++;
  613. if ((type == IGMPV3_ALLOW_NEW_SOURCES ||
  614. type == IGMPV3_BLOCK_OLD_SOURCES) && psf->sf_crcount) {
  615. --- a/net/ipv4/ip_gre.c
  616. +++ b/net/ipv4/ip_gre.c
  617. @@ -518,7 +518,7 @@ static void ipgre_err(struct sk_buff *sk
  618. return;
  619. if (flags & GRE_KEY)
  620. - key = *(((__be32 *)p) + (grehlen / 4) - 1);
  621. + key = net_hdr_word(((__be32 *)p) + (grehlen / 4) - 1);
  622. switch (type) {
  623. default:
  624. --- a/include/uapi/linux/igmp.h
  625. +++ b/include/uapi/linux/igmp.h
  626. @@ -32,7 +32,7 @@ struct igmphdr {
  627. __u8 code; /* For newer IGMP */
  628. __sum16 csum;
  629. __be32 group;
  630. -};
  631. +} __attribute__((packed, aligned(2)));
  632. /* V3 group record types [grec_type] */
  633. #define IGMPV3_MODE_IS_INCLUDE 1
  634. @@ -48,7 +48,7 @@ struct igmpv3_grec {
  635. __be16 grec_nsrcs;
  636. __be32 grec_mca;
  637. __be32 grec_src[0];
  638. -};
  639. +} __attribute__((packed, aligned(2)));
  640. struct igmpv3_report {
  641. __u8 type;
  642. @@ -57,7 +57,7 @@ struct igmpv3_report {
  643. __be16 resv2;
  644. __be16 ngrec;
  645. struct igmpv3_grec grec[0];
  646. -};
  647. +} __attribute__((packed, aligned(2)));
  648. struct igmpv3_query {
  649. __u8 type;
  650. @@ -78,7 +78,7 @@ struct igmpv3_query {
  651. __u8 qqic;
  652. __be16 nsrcs;
  653. __be32 srcs[0];
  654. -};
  655. +} __attribute__((packed, aligned(2)));
  656. #define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* From RFC1112 */
  657. #define IGMP_HOST_MEMBERSHIP_REPORT 0x12 /* Ditto */
  658. --- a/net/core/flow_dissector.c
  659. +++ b/net/core/flow_dissector.c
  660. @@ -137,7 +137,7 @@ ipv6:
  661. nhoff += poff;
  662. ports = skb_header_pointer(skb, nhoff, sizeof(_ports), &_ports);
  663. if (ports)
  664. - flow->ports = *ports;
  665. + flow->ports = net_hdr_word(ports);
  666. }
  667. return true;
  668. --- a/include/uapi/linux/icmpv6.h
  669. +++ b/include/uapi/linux/icmpv6.h
  670. @@ -76,7 +76,7 @@ struct icmp6hdr {
  671. #define icmp6_addrconf_other icmp6_dataun.u_nd_ra.other
  672. #define icmp6_rt_lifetime icmp6_dataun.u_nd_ra.rt_lifetime
  673. #define icmp6_router_pref icmp6_dataun.u_nd_ra.router_pref
  674. -};
  675. +} __attribute__((packed, aligned(2)));
  676. #define ICMPV6_ROUTER_PREF_LOW 0x3
  677. --- a/include/net/ndisc.h
  678. +++ b/include/net/ndisc.h
  679. @@ -76,7 +76,7 @@ struct ra_msg {
  680. struct icmp6hdr icmph;
  681. __be32 reachable_time;
  682. __be32 retrans_timer;
  683. -};
  684. +} __attribute__((packed, aligned(2)));
  685. struct rd_msg {
  686. struct icmp6hdr icmph;
  687. @@ -142,10 +142,10 @@ static inline u32 ndisc_hashfn(const voi
  688. {
  689. const u32 *p32 = pkey;
  690. - return (((p32[0] ^ hash32_ptr(dev)) * hash_rnd[0]) +
  691. - (p32[1] * hash_rnd[1]) +
  692. - (p32[2] * hash_rnd[2]) +
  693. - (p32[3] * hash_rnd[3]));
  694. + return (((net_hdr_word(&p32[0]) ^ hash32_ptr(dev)) * hash_rnd[0]) +
  695. + (net_hdr_word(&p32[1]) * hash_rnd[1]) +
  696. + (net_hdr_word(&p32[2]) * hash_rnd[2]) +
  697. + (net_hdr_word(&p32[3]) * hash_rnd[3]));
  698. }
  699. static inline struct neighbour *__ipv6_neigh_lookup(struct neigh_table *tbl, struct net_device *dev, const void *pkey)
  700. @@ -163,8 +163,10 @@ static inline struct neighbour *__ipv6_n
  701. n = rcu_dereference_bh(n->next)) {
  702. u32 *n32 = (u32 *) n->primary_key;
  703. if (n->dev == dev &&
  704. - ((n32[0] ^ p32[0]) | (n32[1] ^ p32[1]) |
  705. - (n32[2] ^ p32[2]) | (n32[3] ^ p32[3])) == 0) {
  706. + ((n32[0] ^ net_hdr_word(&p32[0])) |
  707. + (n32[1] ^ net_hdr_word(&p32[1])) |
  708. + (n32[2] ^ net_hdr_word(&p32[2])) |
  709. + (n32[3] ^ net_hdr_word(&p32[3]))) == 0) {
  710. if (!atomic_inc_not_zero(&n->refcnt))
  711. n = NULL;
  712. break;
  713. --- a/net/sched/cls_u32.c
  714. +++ b/net/sched/cls_u32.c
  715. @@ -142,7 +142,7 @@ next_knode:
  716. data = skb_header_pointer(skb, toff, 4, &hdata);
  717. if (!data)
  718. goto out;
  719. - if ((*data ^ key->val) & key->mask) {
  720. + if ((net_hdr_word(data) ^ key->val) & key->mask) {
  721. n = n->next;
  722. goto next_knode;
  723. }
  724. @@ -193,8 +193,8 @@ check_terminal:
  725. &hdata);
  726. if (!data)
  727. goto out;
  728. - sel = ht->divisor & u32_hash_fold(*data, &n->sel,
  729. - n->fshift);
  730. + sel = ht->divisor & u32_hash_fold(net_hdr_word(data),
  731. + &n->sel, n->fshift);
  732. }
  733. if (!(n->sel.flags & (TC_U32_VAROFFSET | TC_U32_OFFSET | TC_U32_EAT)))
  734. goto next_ht;
  735. --- a/net/ipv6/ip6_offload.c
  736. +++ b/net/ipv6/ip6_offload.c
  737. @@ -200,7 +200,7 @@ static struct sk_buff **ipv6_gro_receive
  738. continue;
  739. iph2 = ipv6_hdr(p);
  740. - first_word = *(__be32 *)iph ^ *(__be32 *)iph2 ;
  741. + first_word = net_hdr_word(iph) ^ net_hdr_word(iph2);
  742. /* All fields must match except length and Traffic Class. */
  743. if (nlen != skb_network_header_len(p) ||
  744. --- a/include/net/addrconf.h
  745. +++ b/include/net/addrconf.h
  746. @@ -39,7 +39,7 @@ struct prefix_info {
  747. __be32 reserved2;
  748. struct in6_addr prefix;
  749. -};
  750. +} __attribute__((packed, aligned(2)));
  751. #include <linux/netdevice.h>
  752. --- a/include/net/inet_ecn.h
  753. +++ b/include/net/inet_ecn.h
  754. @@ -115,13 +115,13 @@ static inline int IP6_ECN_set_ce(struct
  755. {
  756. if (INET_ECN_is_not_ect(ipv6_get_dsfield(iph)))
  757. return 0;
  758. - *(__be32*)iph |= htonl(INET_ECN_CE << 20);
  759. + net_hdr_word(iph) |= htonl(INET_ECN_CE << 20);
  760. return 1;
  761. }
  762. static inline void IP6_ECN_clear(struct ipv6hdr *iph)
  763. {
  764. - *(__be32*)iph &= ~htonl(INET_ECN_MASK << 20);
  765. + net_hdr_word(iph) &= ~htonl(INET_ECN_MASK << 20);
  766. }
  767. static inline void ipv6_copy_dscp(unsigned int dscp, struct ipv6hdr *inner)
  768. --- a/include/net/ipv6.h
  769. +++ b/include/net/ipv6.h
  770. @@ -107,7 +107,7 @@ struct frag_hdr {
  771. __u8 reserved;
  772. __be16 frag_off;
  773. __be32 identification;
  774. -};
  775. +} __attribute__((packed, aligned(2)));
  776. #define IP6_MF 0x0001
  777. @@ -386,6 +386,8 @@ static inline bool __ipv6_prefix_equal(c
  778. unsigned int prefixlen)
  779. {
  780. unsigned int pdw, pbi;
  781. + /* Used for last <32-bit fraction of prefix */
  782. + u32 pbia1, pbia2;
  783. /* check complete u32 in prefix */
  784. pdw = prefixlen >> 5;
  785. @@ -394,7 +396,9 @@ static inline bool __ipv6_prefix_equal(c
  786. /* check incomplete u32 in prefix */
  787. pbi = prefixlen & 0x1f;
  788. - if (pbi && ((a1[pdw] ^ a2[pdw]) & htonl((0xffffffff) << (32 - pbi))))
  789. + pbia1 = net_hdr_word(&a1[pdw]);
  790. + pbia2 = net_hdr_word(&a2[pdw]);
  791. + if (pbi && ((pbia1 ^ pbia2) & htonl((0xffffffff) << (32 - pbi))))
  792. return false;
  793. return true;
  794. @@ -521,13 +525,13 @@ static inline void ipv6_addr_set_v4mappe
  795. */
  796. static inline int __ipv6_addr_diff(const void *token1, const void *token2, int addrlen)
  797. {
  798. - const __be32 *a1 = token1, *a2 = token2;
  799. + const struct in6_addr *a1 = token1, *a2 = token2;
  800. int i;
  801. addrlen >>= 2;
  802. for (i = 0; i < addrlen; i++) {
  803. - __be32 xb = a1[i] ^ a2[i];
  804. + __be32 xb = a1->s6_addr32[i] ^ a2->s6_addr32[i];
  805. if (xb)
  806. return i * 32 + 31 - __fls(ntohl(xb));
  807. }
  808. --- a/include/net/secure_seq.h
  809. +++ b/include/net/secure_seq.h
  810. @@ -2,6 +2,7 @@
  811. #define _NET_SECURE_SEQ
  812. #include <linux/types.h>
  813. +#include <linux/in6.h>
  814. extern __u32 secure_ip_id(__be32 daddr);
  815. extern __u32 secure_ipv6_id(const __be32 daddr[4]);
  816. --- a/include/uapi/linux/in.h
  817. +++ b/include/uapi/linux/in.h
  818. @@ -55,7 +55,7 @@ enum {
  819. /* Internet address. */
  820. struct in_addr {
  821. __be32 s_addr;
  822. -};
  823. +} __attribute__((packed, aligned(2)));
  824. #define IP_TOS 1
  825. #define IP_TTL 2
  826. --- a/net/core/secure_seq.c
  827. +++ b/net/core/secure_seq.c
  828. @@ -43,10 +43,11 @@ __u32 secure_tcpv6_sequence_number(const
  829. u32 secret[MD5_MESSAGE_BYTES / 4];
  830. u32 hash[MD5_DIGEST_WORDS];
  831. u32 i;
  832. + const struct in6_addr *daddr6 = (struct in6_addr *) daddr;
  833. memcpy(hash, saddr, 16);
  834. for (i = 0; i < 4; i++)
  835. - secret[i] = net_secret[i] + (__force u32)daddr[i];
  836. + secret[i] = net_secret[i] + (__force u32)daddr6->s6_addr32[i];
  837. secret[4] = net_secret[4] +
  838. (((__force u16)sport << 16) + (__force u16)dport);
  839. for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
  840. @@ -64,10 +65,11 @@ u32 secure_ipv6_port_ephemeral(const __b
  841. u32 secret[MD5_MESSAGE_BYTES / 4];
  842. u32 hash[MD5_DIGEST_WORDS];
  843. u32 i;
  844. + const struct in6_addr *daddr6 = (struct in6_addr *) daddr;
  845. memcpy(hash, saddr, 16);
  846. for (i = 0; i < 4; i++)
  847. - secret[i] = net_secret[i] + (__force u32) daddr[i];
  848. + secret[i] = net_secret[i] + (__force u32) daddr6->s6_addr32[i];
  849. secret[4] = net_secret[4] + (__force u32)dport;
  850. for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
  851. secret[i] = net_secret[i];
  852. @@ -165,10 +167,11 @@ u64 secure_dccpv6_sequence_number(__be32
  853. u32 hash[MD5_DIGEST_WORDS];
  854. u64 seq;
  855. u32 i;
  856. + const struct in6_addr *daddr6 = (struct in6_addr *) daddr;
  857. memcpy(hash, saddr, 16);
  858. for (i = 0; i < 4; i++)
  859. - secret[i] = net_secret[i] + daddr[i];
  860. + secret[i] = net_secret[i] + daddr6->s6_addr32[i];
  861. secret[4] = net_secret[4] +
  862. (((__force u16)sport << 16) + (__force u16)dport);
  863. for (i = 5; i < MD5_MESSAGE_BYTES / 4; i++)
  864. --- a/net/ipv6/ip6_fib.c
  865. +++ b/net/ipv6/ip6_fib.c
  866. @@ -144,7 +144,7 @@ static __inline__ __be32 addr_bit_set(co
  867. * See include/asm-generic/bitops/le.h.
  868. */
  869. return (__force __be32)(1 << ((~fn_bit ^ BITOP_BE32_SWIZZLE) & 0x1f)) &
  870. - addr[fn_bit >> 5];
  871. + net_hdr_word(&addr[fn_bit >> 5]);
  872. }
  873. static __inline__ struct fib6_node * node_alloc(void)
  874. --- a/net/netfilter/nf_conntrack_proto_tcp.c
  875. +++ b/net/netfilter/nf_conntrack_proto_tcp.c
  876. @@ -452,7 +452,7 @@ static void tcp_sack(const struct sk_buf
  877. /* Fast path for timestamp-only option */
  878. if (length == TCPOLEN_TSTAMP_ALIGNED
  879. - && *(__be32 *)ptr == htonl((TCPOPT_NOP << 24)
  880. + && net_hdr_word(ptr) == htonl((TCPOPT_NOP << 24)
  881. | (TCPOPT_NOP << 16)
  882. | (TCPOPT_TIMESTAMP << 8)
  883. | TCPOLEN_TIMESTAMP))
  884. --- a/net/netfilter/xt_LOG.c
  885. +++ b/net/netfilter/xt_LOG.c
  886. @@ -521,9 +521,9 @@ static void dump_ipv6_packet(struct sbuf
  887. /* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */
  888. sb_add(m, "LEN=%Zu TC=%u HOPLIMIT=%u FLOWLBL=%u ",
  889. ntohs(ih->payload_len) + sizeof(struct ipv6hdr),
  890. - (ntohl(*(__be32 *)ih) & 0x0ff00000) >> 20,
  891. + (ntohl(net_hdr_word(ih)) & 0x0ff00000) >> 20,
  892. ih->hop_limit,
  893. - (ntohl(*(__be32 *)ih) & 0x000fffff));
  894. + (ntohl(net_hdr_word(ih)) & 0x000fffff));
  895. fragment = 0;
  896. ptr = ip6hoff + sizeof(struct ipv6hdr);
  897. --- a/net/xfrm/xfrm_input.c
  898. +++ b/net/xfrm/xfrm_input.c
  899. @@ -77,8 +77,8 @@ int xfrm_parse_spi(struct sk_buff *skb,
  900. if (!pskb_may_pull(skb, hlen))
  901. return -EINVAL;
  902. - *spi = *(__be32*)(skb_transport_header(skb) + offset);
  903. - *seq = *(__be32*)(skb_transport_header(skb) + offset_seq);
  904. + *spi = net_hdr_word(skb_transport_header(skb) + offset);
  905. + *seq = net_hdr_word(skb_transport_header(skb) + offset_seq);
  906. return 0;
  907. }