From: Felix Fietkau Date: Sun, 13 Jan 2013 14:54:39 +0000 (+0000) Subject: ar71xx: improve unaligned access patches, add a net_hdr_word() macro which assumes... X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=b5bcbdfbb50ce46bfc19a909cbd303e7ed21ee7d;p=openwrt%2Fstaging%2Fldir.git ar71xx: improve unaligned access patches, add a net_hdr_word() macro which assumes 2-byte aligned access and generates better code than {get,put}_unaligned_cpu32 SVN-Revision: 35129 --- diff --git a/target/linux/ar71xx/patches-3.7/902-unaligned_access_hacks.patch b/target/linux/ar71xx/patches-3.7/902-unaligned_access_hacks.patch index 9145919abe..4ce2d22eee 100644 --- a/target/linux/ar71xx/patches-3.7/902-unaligned_access_hacks.patch +++ b/target/linux/ar71xx/patches-3.7/902-unaligned_access_hacks.patch @@ -1,14 +1,6 @@ --- a/arch/mips/include/asm/checksum.h +++ b/arch/mips/include/asm/checksum.h -@@ -12,6 +12,7 @@ - #define _ASM_CHECKSUM_H - - #include -+#include - - #include - -@@ -104,26 +105,30 @@ static inline __sum16 ip_fast_csum(const +@@ -104,26 +104,30 @@ static inline __sum16 ip_fast_csum(const const unsigned int *stop = word + ihl; unsigned int csum; int carry; @@ -17,23 +9,23 @@ - csum = word[0]; - csum += word[1]; - carry = (csum < word[1]); -+ csum = __get_unaligned_cpu32(word++); ++ csum = net_hdr_word(word++); + -+ w = __get_unaligned_cpu32(word++); ++ w = net_hdr_word(word++); + csum += w; + carry = (csum < w); csum += carry; - csum += word[2]; - carry = (csum < word[2]); -+ w = __get_unaligned_cpu32(word++); ++ w = net_hdr_word(word++); + csum += w; + carry = (csum < w); csum += carry; - csum += word[3]; - carry = (csum < word[3]); -+ w = __get_unaligned_cpu32(word++); ++ w = net_hdr_word(word++); + csum += w; + carry = (csum < w); csum += carry; @@ -42,7 +34,7 @@ do { - csum += *word; - carry = (csum < *word); -+ w = __get_unaligned_cpu32(word++); ++ w = net_hdr_word(word++); + csum += w; + carry = (csum < w); csum += carry; @@ -119,8 +111,8 @@ - tuple->src.u3.ip = ap[0]; - tuple->dst.u3.ip = ap[1]; -+ tuple->src.u3.ip = __get_unaligned_cpu32(ap++); -+ tuple->dst.u3.ip = __get_unaligned_cpu32(ap); ++ tuple->src.u3.ip = net_hdr_word(ap++); ++ tuple->dst.u3.ip = net_hdr_word(ap); return true; } @@ -143,7 +135,7 @@ - if (*ptr == htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) - | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) { -+ if (__get_unaligned_cpu32(ptr) == ++ if (net_hdr_word(ptr) == + htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | + (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) { tp->rx_opt.saw_tstamp = 1; @@ -177,13 +169,466 @@ #include MODULE_AUTHOR("Cast of dozens"); -@@ -880,7 +881,8 @@ static struct sk_buff **ipv6_gro_receive +@@ -687,7 +688,7 @@ bool ipv6_opt_accepted(const struct sock + if ((opt->hop && (np->rxopt.bits.hopopts || + np->rxopt.bits.ohopopts)) || + ((IPV6_FLOWINFO_MASK & +- *(__be32 *)skb_network_header(skb)) && ++ net_hdr_word(skb_network_header(skb))) && + np->rxopt.bits.rxflow) || + (opt->srcrt && (np->rxopt.bits.srcrt || + np->rxopt.bits.osrcrt)) || +@@ -880,7 +881,7 @@ static struct sk_buff **ipv6_gro_receive continue; iph2 = ipv6_hdr(p); - first_word = *(__be32 *)iph ^ *(__be32 *)iph2 ; -+ first_word = __get_unaligned_cpu32((__u32 *) iph) ^ -+ __get_unaligned_cpu32((__u32 *) iph2); ++ first_word = net_hdr_word(iph) ^ net_hdr_word(iph2); /* All fields must match except length and Traffic Class. */ if (nlen != skb_network_header_len(p) || +--- a/net/ipv6/route.c ++++ b/net/ipv6/route.c +@@ -59,6 +59,7 @@ + #include + + #include ++#include + + #ifdef CONFIG_SYSCTL + #include +@@ -938,7 +939,7 @@ void ip6_route_input(struct sk_buff *skb + .flowi6_iif = skb->dev->ifindex, + .daddr = iph->daddr, + .saddr = iph->saddr, +- .flowlabel = (* (__be32 *) iph) & IPV6_FLOWINFO_MASK, ++ .flowlabel = net_hdr_word(iph) & IPV6_FLOWINFO_MASK, + .flowi6_mark = skb->mark, + .flowi6_proto = iph->nexthdr, + }; +@@ -1108,7 +1109,7 @@ void ip6_update_pmtu(struct sk_buff *skb + fl6.flowi6_flags = 0; + fl6.daddr = iph->daddr; + fl6.saddr = iph->saddr; +- fl6.flowlabel = (*(__be32 *) iph) & IPV6_FLOWINFO_MASK; ++ fl6.flowlabel = net_hdr_word(iph) & IPV6_FLOWINFO_MASK, + + dst = ip6_route_output(net, NULL, &fl6); + if (!dst->error) +@@ -1136,7 +1137,7 @@ void ip6_redirect(struct sk_buff *skb, s + fl6.flowi6_flags = 0; + fl6.daddr = iph->daddr; + fl6.saddr = iph->saddr; +- fl6.flowlabel = (*(__be32 *) iph) & IPV6_FLOWINFO_MASK; ++ fl6.flowlabel = net_hdr_word(iph) & IPV6_FLOWINFO_MASK, + + dst = ip6_route_output(net, NULL, &fl6); + if (!dst->error) +--- a/net/ipv6/tcp_ipv6.c ++++ b/net/ipv6/tcp_ipv6.c +@@ -64,6 +64,7 @@ + #include + #include + ++#include + #include + + #include +@@ -851,10 +852,10 @@ static void tcp_v6_send_response(struct + topt = (__be32 *)(t1 + 1); + + if (ts) { +- *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | +- (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP); +- *topt++ = htonl(tcp_time_stamp); +- *topt++ = htonl(ts); ++ put_unaligned_be32((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | ++ (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP, topt++); ++ put_unaligned_be32(tcp_time_stamp, topt++); ++ put_unaligned_be32(ts, topt++); + } + + #ifdef CONFIG_TCP_MD5SIG +--- a/include/linux/ipv6.h ++++ b/include/linux/ipv6.h +@@ -4,6 +4,7 @@ + #include + + #define ipv6_optlen(p) (((p)->hdrlen+1) << 3) ++ + /* + * This structure contains configuration options per IPv6 link. + */ +--- a/net/ipv6/datagram.c ++++ b/net/ipv6/datagram.c +@@ -360,12 +360,12 @@ int ipv6_recv_error(struct sock *sk, str + *(struct in6_addr *)(nh + serr->addr_offset); + if (np->sndflow) + sin->sin6_flowinfo = +- (*(__be32 *)(nh + serr->addr_offset - 24) & +- IPV6_FLOWINFO_MASK); ++ net_hdr_word(nh + serr->addr_offset - 24) & ++ IPV6_FLOWINFO_MASK; + if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL) + sin->sin6_scope_id = IP6CB(skb)->iif; + } else { +- ipv6_addr_set_v4mapped(*(__be32 *)(nh + serr->addr_offset), ++ ipv6_addr_set_v4mapped(net_hdr_word(nh + serr->addr_offset), + &sin->sin6_addr); + } + } +@@ -492,9 +492,10 @@ int datagram_recv_ctl(struct sock *sk, s + put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass); + } + +- if (np->rxopt.bits.rxflow && (*(__be32 *)nh & IPV6_FLOWINFO_MASK)) { +- __be32 flowinfo = *(__be32 *)nh & IPV6_FLOWINFO_MASK; +- put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo); ++ if (np->rxopt.bits.rxflow) { ++ __be32 flowinfo = net_hdr_word(nh) & IPV6_FLOWINFO_MASK; ++ if (flowinfo) ++ put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo); + } + + /* HbH is allowed only once */ +@@ -680,12 +681,12 @@ int datagram_send_ctl(struct net *net, s + } + + if (fl6->flowlabel&IPV6_FLOWINFO_MASK) { +- if ((fl6->flowlabel^*(__be32 *)CMSG_DATA(cmsg))&~IPV6_FLOWINFO_MASK) { ++ if ((fl6->flowlabel^net_hdr_word(CMSG_DATA(cmsg)))&~IPV6_FLOWINFO_MASK) { + err = -EINVAL; + goto exit_f; + } + } +- fl6->flowlabel = IPV6_FLOWINFO_MASK & *(__be32 *)CMSG_DATA(cmsg); ++ fl6->flowlabel = IPV6_FLOWINFO_MASK & net_hdr_word(CMSG_DATA(cmsg)); + break; + + case IPV6_2292HOPOPTS: +--- a/net/ipv6/ip6_gre.c ++++ b/net/ipv6/ip6_gre.c +@@ -445,7 +445,7 @@ static void ip6gre_err(struct sk_buff *s + + t = ip6gre_tunnel_lookup(skb->dev, &ipv6h->daddr, &ipv6h->saddr, + flags & GRE_KEY ? +- *(((__be32 *)p) + (grehlen / 4) - 1) : 0, ++ net_hdr_word(((__be32 *)p) + (grehlen / 4) - 1) : 0, + p[1]); + if (t == NULL) + return; +@@ -537,11 +537,11 @@ static int ip6gre_rcv(struct sk_buff *sk + offset += 4; + } + if (flags&GRE_KEY) { +- key = *(__be32 *)(h + offset); ++ key = net_hdr_word(h + offset); + offset += 4; + } + if (flags&GRE_SEQ) { +- seqno = ntohl(*(__be32 *)(h + offset)); ++ seqno = ntohl(net_hdr_word(h + offset)); + offset += 4; + } + } +@@ -788,7 +788,7 @@ static netdev_tx_t ip6gre_xmit2(struct s + * Push down and install the IP header. + */ + ipv6h = ipv6_hdr(skb); +- *(__be32 *)ipv6h = fl6->flowlabel | htonl(0x60000000); ++ net_hdr_word(ipv6h) = fl6->flowlabel | htonl(0x60000000); + dsfield = INET_ECN_encapsulate(0, dsfield); + ipv6_change_dsfield(ipv6h, ~INET_ECN_MASK, dsfield); + ipv6h->hop_limit = tunnel->parms.hop_limit; +@@ -805,7 +805,7 @@ static netdev_tx_t ip6gre_xmit2(struct s + + if (tunnel->parms.o_flags&GRE_SEQ) { + ++tunnel->o_seqno; +- *ptr = htonl(tunnel->o_seqno); ++ net_hdr_word(ptr) = htonl(tunnel->o_seqno); + ptr--; + } + if (tunnel->parms.o_flags&GRE_KEY) { +@@ -913,9 +913,9 @@ static inline int ip6gre_xmit_ipv6(struc + + dsfield = ipv6_get_dsfield(ipv6h); + if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS) +- fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK); ++ fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_TCLASS_MASK; + if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL) +- fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_FLOWLABEL_MASK); ++ fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_FLOWLABEL_MASK; + if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK) + fl6.flowi6_mark = skb->mark; + +@@ -1256,7 +1256,7 @@ static int ip6gre_header(struct sk_buff + struct ipv6hdr *ipv6h = (struct ipv6hdr *)skb_push(skb, t->hlen); + __be16 *p = (__be16 *)(ipv6h+1); + +- *(__be32 *)ipv6h = t->fl.u.ip6.flowlabel | htonl(0x60000000); ++ net_hdr_word(ipv6h) = t->fl.u.ip6.flowlabel | htonl(0x60000000); + ipv6h->hop_limit = t->parms.hop_limit; + ipv6h->nexthdr = NEXTHDR_GRE; + ipv6h->saddr = t->parms.laddr; +--- a/net/ipv6/ip6_output.c ++++ b/net/ipv6/ip6_output.c +@@ -216,7 +216,7 @@ int ip6_xmit(struct sock *sk, struct sk_ + if (hlimit < 0) + hlimit = ip6_dst_hoplimit(dst); + +- *(__be32 *)hdr = htonl(0x60000000 | (tclass << 20)) | fl6->flowlabel; ++ net_hdr_word(hdr) = htonl(0x60000000 | (tclass << 20)) | fl6->flowlabel; + + hdr->payload_len = htons(seg_len); + hdr->nexthdr = proto; +--- a/net/ipv6/ip6_tunnel.c ++++ b/net/ipv6/ip6_tunnel.c +@@ -1110,9 +1110,9 @@ ip6ip6_tnl_xmit(struct sk_buff *skb, str + + dsfield = ipv6_get_dsfield(ipv6h); + if (t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS) +- fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_TCLASS_MASK); ++ fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_TCLASS_MASK; + if (t->parms.flags & IP6_TNL_F_USE_ORIG_FLOWLABEL) +- fl6.flowlabel |= (*(__be32 *) ipv6h & IPV6_FLOWLABEL_MASK); ++ fl6.flowlabel |= net_hdr_word(ipv6h) & IPV6_FLOWLABEL_MASK; + if (t->parms.flags & IP6_TNL_F_USE_ORIG_FWMARK) + fl6.flowi6_mark = skb->mark; + +--- a/net/ipv6/exthdrs.c ++++ b/net/ipv6/exthdrs.c +@@ -622,7 +622,7 @@ static bool ipv6_hop_jumbo(struct sk_buf + goto drop; + } + +- pkt_len = ntohl(*(__be32 *)(nh + optoff + 2)); ++ pkt_len = ntohl(net_hdr_word(nh + optoff + 2)); + if (pkt_len <= IPV6_MAXPLEN) { + IP6_INC_STATS_BH(net, ipv6_skb_idev(skb), + IPSTATS_MIB_INHDRERRORS); +--- a/include/linux/types.h ++++ b/include/linux/types.h +@@ -211,5 +211,11 @@ struct callback_head { + }; + #define rcu_head callback_head + ++struct net_hdr_word { ++ u32 words[1]; ++} __attribute__((packed, aligned(2))); ++ ++#define net_hdr_word(_p) (((struct net_hdr_word *) (_p))->words[0]) ++ + #endif /* __ASSEMBLY__ */ + #endif /* _LINUX_TYPES_H */ +--- a/net/ipv4/af_inet.c ++++ b/net/ipv4/af_inet.c +@@ -1388,8 +1388,8 @@ static struct sk_buff **inet_gro_receive + if (unlikely(ip_fast_csum((u8 *)iph, 5))) + goto out_unlock; + +- id = ntohl(*(__be32 *)&iph->id); +- flush = (u16)((ntohl(*(__be32 *)iph) ^ skb_gro_len(skb)) | (id ^ IP_DF)); ++ id = ntohl(net_hdr_word(&iph->id)); ++ flush = (u16)((ntohl(net_hdr_word(iph)) ^ skb_gro_len(skb)) | (id ^ IP_DF)); + id >>= 16; + + for (p = *head; p; p = p->next) { +--- a/net/ipv4/route.c ++++ b/net/ipv4/route.c +@@ -465,7 +465,7 @@ static struct neighbour *ipv4_neigh_look + else if (skb) + pkey = &ip_hdr(skb)->daddr; + +- n = __ipv4_neigh_lookup(dev, *(__force u32 *)pkey); ++ n = __ipv4_neigh_lookup(dev, net_hdr_word(pkey)); + if (n) + return n; + return neigh_create(&arp_tbl, pkey, dev); +--- a/net/ipv4/tcp_output.c ++++ b/net/ipv4/tcp_output.c +@@ -456,15 +456,17 @@ static void tcp_options_write(__be32 *pt + */ + if (unlikely(OPTION_MD5 & options)) { + if (unlikely(OPTION_COOKIE_EXTENSION & options)) { +- *ptr++ = htonl((TCPOPT_COOKIE << 24) | +- (TCPOLEN_COOKIE_BASE << 16) | +- (TCPOPT_MD5SIG << 8) | +- TCPOLEN_MD5SIG); ++ net_hdr_word(ptr++) = ++ htonl((TCPOPT_COOKIE << 24) | ++ (TCPOLEN_COOKIE_BASE << 16) | ++ (TCPOPT_MD5SIG << 8) | ++ TCPOLEN_MD5SIG); + } else { +- *ptr++ = htonl((TCPOPT_NOP << 24) | +- (TCPOPT_NOP << 16) | +- (TCPOPT_MD5SIG << 8) | +- TCPOLEN_MD5SIG); ++ net_hdr_word(ptr++) = ++ htonl((TCPOPT_NOP << 24) | ++ (TCPOPT_NOP << 16) | ++ (TCPOPT_MD5SIG << 8) | ++ TCPOLEN_MD5SIG); + } + options &= ~OPTION_COOKIE_EXTENSION; + /* overload cookie hash location */ +@@ -473,26 +475,28 @@ static void tcp_options_write(__be32 *pt + } + + if (unlikely(opts->mss)) { +- *ptr++ = htonl((TCPOPT_MSS << 24) | +- (TCPOLEN_MSS << 16) | +- opts->mss); ++ net_hdr_word(ptr++) = ++ htonl((TCPOPT_MSS << 24) | (TCPOLEN_MSS << 16) | ++ opts->mss); + } + + if (likely(OPTION_TS & options)) { + if (unlikely(OPTION_SACK_ADVERTISE & options)) { +- *ptr++ = htonl((TCPOPT_SACK_PERM << 24) | +- (TCPOLEN_SACK_PERM << 16) | +- (TCPOPT_TIMESTAMP << 8) | +- TCPOLEN_TIMESTAMP); ++ net_hdr_word(ptr++) = ++ htonl((TCPOPT_SACK_PERM << 24) | ++ (TCPOLEN_SACK_PERM << 16) | ++ (TCPOPT_TIMESTAMP << 8) | ++ TCPOLEN_TIMESTAMP); + options &= ~OPTION_SACK_ADVERTISE; + } else { +- *ptr++ = htonl((TCPOPT_NOP << 24) | +- (TCPOPT_NOP << 16) | +- (TCPOPT_TIMESTAMP << 8) | +- TCPOLEN_TIMESTAMP); ++ net_hdr_word(ptr++) = ++ htonl((TCPOPT_NOP << 24) | ++ (TCPOPT_NOP << 16) | ++ (TCPOPT_TIMESTAMP << 8) | ++ TCPOLEN_TIMESTAMP); + } +- *ptr++ = htonl(opts->tsval); +- *ptr++ = htonl(opts->tsecr); ++ net_hdr_word(ptr++) = htonl(opts->tsval); ++ net_hdr_word(ptr++) = htonl(opts->tsecr); + } + + /* Specification requires after timestamp, so do it now. +@@ -512,19 +516,20 @@ static void tcp_options_write(__be32 *pt + __u8 *p = (__u8 *)ptr; + + /* 16-bit multiple */ +- *p++ = TCPOPT_COOKIE; +- *p++ = TCPOLEN_COOKIE_BASE + cookie_size; +- *p++ = *cookie_copy++; +- *p++ = *cookie_copy++; ++ net_hdr_word(p++) = TCPOPT_COOKIE; ++ net_hdr_word(p++) = TCPOLEN_COOKIE_BASE + cookie_size; ++ net_hdr_word(p++) = *cookie_copy++; ++ net_hdr_word(p++) = *cookie_copy++; + ptr++; + cookie_size -= 2; + } else { + /* 32-bit multiple */ +- *ptr++ = htonl(((TCPOPT_NOP << 24) | +- (TCPOPT_NOP << 16) | +- (TCPOPT_COOKIE << 8) | +- TCPOLEN_COOKIE_BASE) + +- cookie_size); ++ net_hdr_word(ptr++) = ++ htonl(((TCPOPT_NOP << 24) | ++ (TCPOPT_NOP << 16) | ++ (TCPOPT_COOKIE << 8) | ++ TCPOLEN_COOKIE_BASE) + ++ cookie_size); + } + + if (cookie_size > 0) { +@@ -534,17 +539,19 @@ static void tcp_options_write(__be32 *pt + } + + if (unlikely(OPTION_SACK_ADVERTISE & options)) { +- *ptr++ = htonl((TCPOPT_NOP << 24) | +- (TCPOPT_NOP << 16) | +- (TCPOPT_SACK_PERM << 8) | +- TCPOLEN_SACK_PERM); ++ net_hdr_word(ptr++) = ++ htonl((TCPOPT_NOP << 24) | ++ (TCPOPT_NOP << 16) | ++ (TCPOPT_SACK_PERM << 8) | ++ TCPOLEN_SACK_PERM); + } + + if (unlikely(OPTION_WSCALE & options)) { +- *ptr++ = htonl((TCPOPT_NOP << 24) | +- (TCPOPT_WINDOW << 16) | +- (TCPOLEN_WINDOW << 8) | +- opts->ws); ++ net_hdr_word(ptr++) = ++ htonl((TCPOPT_NOP << 24) | ++ (TCPOPT_WINDOW << 16) | ++ (TCPOLEN_WINDOW << 8) | ++ opts->ws); + } + + if (unlikely(opts->num_sack_blocks)) { +@@ -552,16 +559,17 @@ static void tcp_options_write(__be32 *pt + tp->duplicate_sack : tp->selective_acks; + int this_sack; + +- *ptr++ = htonl((TCPOPT_NOP << 24) | +- (TCPOPT_NOP << 16) | +- (TCPOPT_SACK << 8) | +- (TCPOLEN_SACK_BASE + (opts->num_sack_blocks * ++ net_hdr_word(ptr++) = ++ htonl((TCPOPT_NOP << 24) | ++ (TCPOPT_NOP << 16) | ++ (TCPOPT_SACK << 8) | ++ (TCPOLEN_SACK_BASE + (opts->num_sack_blocks * + TCPOLEN_SACK_PERBLOCK))); + + for (this_sack = 0; this_sack < opts->num_sack_blocks; + ++this_sack) { +- *ptr++ = htonl(sp[this_sack].start_seq); +- *ptr++ = htonl(sp[this_sack].end_seq); ++ net_hdr_word(ptr++) = htonl(sp[this_sack].start_seq); ++ net_hdr_word(ptr++) = htonl(sp[this_sack].end_seq); + } + + tp->rx_opt.dsack = 0; +@@ -570,9 +578,10 @@ static void tcp_options_write(__be32 *pt + if (unlikely(OPTION_FAST_OPEN_COOKIE & options)) { + struct tcp_fastopen_cookie *foc = opts->fastopen_cookie; + +- *ptr++ = htonl((TCPOPT_EXP << 24) | +- ((TCPOLEN_EXP_FASTOPEN_BASE + foc->len) << 16) | +- TCPOPT_FASTOPEN_MAGIC); ++ net_hdr_word(ptr++) = ++ htonl((TCPOPT_EXP << 24) | ++ ((TCPOLEN_EXP_FASTOPEN_BASE + foc->len) << 16) | ++ TCPOPT_FASTOPEN_MAGIC); + + memcpy(ptr, foc->val, foc->len); + if ((foc->len & 3) == 2) { +--- a/net/ipv4/igmp.c ++++ b/net/ipv4/igmp.c +@@ -470,7 +470,7 @@ static struct sk_buff *add_grec(struct s + if (!skb) + return NULL; + psrc = (__be32 *)skb_put(skb, sizeof(__be32)); +- *psrc = psf->sf_inaddr; ++ net_hdr_word(psrc) = psf->sf_inaddr; + scount++; stotal++; + if ((type == IGMPV3_ALLOW_NEW_SOURCES || + type == IGMPV3_BLOCK_OLD_SOURCES) && psf->sf_crcount) { +--- a/net/ipv4/ip_gre.c ++++ b/net/ipv4/ip_gre.c +@@ -533,7 +533,7 @@ static void ipgre_err(struct sk_buff *sk + return; + + if (flags & GRE_KEY) +- key = *(((__be32 *)p) + (grehlen / 4) - 1); ++ key = net_hdr_word(((__be32 *)p) + (grehlen / 4) - 1); + + switch (type) { + default: