ipv6_monster_patch.patch

Monster ipv6 patch replacing virtually every *(__be32 *) instance with __get_unaligned_cpu32() - Robert Bradley, 04/18/2012 06:05 am

Download (5.4 kB)

 
b/include/linux/icmpv6.h
76 76
#define icmp6_addrconf_other	icmp6_dataun.u_nd_ra.other
77 77
#define icmp6_rt_lifetime	icmp6_dataun.u_nd_ra.rt_lifetime
78 78
#define icmp6_router_pref	icmp6_dataun.u_nd_ra.router_pref
79
};
79
} __packed;
80 80

  
81 81
#ifdef __KERNEL__
82 82
#include <linux/skbuff.h>
b/include/linux/ipv6.h
49 49
	 *	type specific data
50 50
	 *	variable length field
51 51
	 */
52
};
52
} __packed;
53 53

  
54 54

  
55 55
struct ipv6_opt_hdr {
b/net/ipv6/af_inet6.c
695 695
		if ((opt->hop && (np->rxopt.bits.hopopts ||
696 696
				  np->rxopt.bits.ohopopts)) ||
697 697
		    ((IPV6_FLOWINFO_MASK &
698
		      *(__be32 *)skb_network_header(skb)) &&
698
		      __get_unaligned_cpu32((__be32 *)skb_network_header(skb))) &&
699 699
		     np->rxopt.bits.rxflow) ||
700 700
		    (opt->srcrt && (np->rxopt.bits.srcrt ||
701 701
		     np->rxopt.bits.osrcrt)) ||
b/net/ipv6/datagram.c
358 358
				*(struct in6_addr *)(nh + serr->addr_offset);
359 359
			if (np->sndflow)
360 360
				sin->sin6_flowinfo =
361
					(*(__be32 *)(nh + serr->addr_offset - 24) &
361
					(__get_unaligned_cpu32((__be32 *)(nh + serr->addr_offset - 24)) &
362 362
					 IPV6_FLOWINFO_MASK);
363 363
			if (ipv6_addr_type(&sin->sin6_addr) & IPV6_ADDR_LINKLOCAL)
364 364
				sin->sin6_scope_id = IP6CB(skb)->iif;
365 365
		} else {
366
			ipv6_addr_set_v4mapped(*(__be32 *)(nh + serr->addr_offset),
366
			ipv6_addr_set_v4mapped(__get_unaligned_cpu32((__be32 *)(nh + serr->addr_offset)),
367 367
					       &sin->sin6_addr);
368 368
		}
369 369
	}
......
485 485
	}
486 486

  
487 487
	if (np->rxopt.bits.rxtclass) {
488
		int tclass = (ntohl(*(__be32 *)ipv6_hdr(skb)) >> 20) & 0xff;
488
		int tclass = (ntohl(__get_unaligned_cpu32((__be32 *)ipv6_hdr(skb))) >> 20) & 0xff;
489 489
		put_cmsg(msg, SOL_IPV6, IPV6_TCLASS, sizeof(tclass), &tclass);
490 490
	}
491 491

  
492
	if (np->rxopt.bits.rxflow && (*(__be32 *)nh & IPV6_FLOWINFO_MASK)) {
493
		__be32 flowinfo = *(__be32 *)nh & IPV6_FLOWINFO_MASK;
492
	if (np->rxopt.bits.rxflow && (__get_unaligned_cpu32((__be32 *)nh) & IPV6_FLOWINFO_MASK)) {
493
		__be32 flowinfo = __get_unaligned_cpu32((__be32 *)nh) & IPV6_FLOWINFO_MASK;
494 494
		put_cmsg(msg, SOL_IPV6, IPV6_FLOWINFO, sizeof(flowinfo), &flowinfo);
495 495
	}
496 496

  
......
585 585

  
586 586
			sin6.sin6_family = AF_INET6;
587 587
			sin6.sin6_addr = ipv6_hdr(skb)->daddr;
588
			sin6.sin6_port = ports[1];
588
			sin6.sin6_port = __get_unaligned_cpu16(&(ports[1]));
589 589
			sin6.sin6_flowinfo = 0;
590 590
			sin6.sin6_scope_id = 0;
591 591

  
......
677 677
			}
678 678

  
679 679
			if (fl6->flowlabel&IPV6_FLOWINFO_MASK) {
680
				if ((fl6->flowlabel^*(__be32 *)CMSG_DATA(cmsg))&~IPV6_FLOWINFO_MASK) {
680
				if ((fl6->flowlabel^__get_unaligned_cpu32((__be32 *)CMSG_DATA(cmsg)))&~IPV6_FLOWINFO_MASK) {
681 681
					err = -EINVAL;
682 682
					goto exit_f;
683 683
				}
684 684
			}
685
			fl6->flowlabel = IPV6_FLOWINFO_MASK & *(__be32 *)CMSG_DATA(cmsg);
685
			fl6->flowlabel = IPV6_FLOWINFO_MASK & __get_unaligned_cpu32((__be32 *)CMSG_DATA(cmsg));
686 686
			break;
687 687

  
688 688
		case IPV6_2292HOPOPTS:
b/net/ipv6/exthdrs.c
593 593
		goto drop;
594 594
	}
595 595

  
596
	pkt_len = ntohl(*(__be32 *)(nh + optoff + 2));
596
	pkt_len = ntohl(__get_unaligned_cpu32((__be32 *)(nh + optoff + 2)));
597 597
	if (pkt_len <= IPV6_MAXPLEN) {
598 598
		IP6_INC_STATS_BH(net, ipv6_skb_idev(skb),
599 599
				 IPSTATS_MIB_INHDRERRORS);
b/net/ipv6/netfilter/ip6t_LOG.c
64 64
	/* Max length: 44 "LEN=65535 TC=255 HOPLIMIT=255 FLOWLBL=FFFFF " */
65 65
	sb_add(m, "LEN=%Zu TC=%u HOPLIMIT=%u FLOWLBL=%u ",
66 66
	       ntohs(ih->payload_len) + sizeof(struct ipv6hdr),
67
	       (ntohl(*(__be32 *)ih) & 0x0ff00000) >> 20,
67
	       (ntohl(__get_unaligned_cpu32((__be32 *)ih)) & 0x0ff00000) >> 20,
68 68
	       ih->hop_limit,
69
	       (ntohl(*(__be32 *)ih) & 0x000fffff));
69
	       (ntohl(__get_unaligned_cpu32((__be32 *)ih)) & 0x000fffff));
70 70

  
71 71
	fragment = 0;
72 72
	ptr = ip6hoff + sizeof(struct ipv6hdr);
b/net/ipv6/xfrm6_policy.c
160 160
			     pskb_may_pull(skb, nh + offset + 4 - skb->data))) {
161 161
				__be16 *ports = (__be16 *)exthdr;
162 162

  
163
				fl6->fl6_sport = ports[!!reverse];
164
				fl6->fl6_dport = ports[!reverse];
163
				fl6->fl6_sport = __get_unaligned_cpu16(ports[!!reverse]);
164
				fl6->fl6_dport = __get_unaligned_cpu16(ports[!reverse]);
165 165
			}
166 166
			fl6->flowi6_proto = nexthdr;
167 167
			return;