Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCTP]: Eliminate some pointer attributions to the skb layer headers

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Arnaldo Carvalho de Melo and committed by
David S. Miller
a27ef749 bd82393c

+6 -7
+4 -4
net/sctp/input.c
··· 506 506 void sctp_v4_err(struct sk_buff *skb, __u32 info) 507 507 { 508 508 struct iphdr *iph = (struct iphdr *)skb->data; 509 - struct sctphdr *sh = (struct sctphdr *)(skb->data + (iph->ihl <<2)); 509 + const int ihlen = iph->ihl * 4; 510 510 const int type = icmp_hdr(skb)->type; 511 511 const int code = icmp_hdr(skb)->code; 512 512 struct sock *sk; ··· 516 516 char *saveip, *savesctp; 517 517 int err; 518 518 519 - if (skb->len < ((iph->ihl << 2) + 8)) { 519 + if (skb->len < ihlen + 8) { 520 520 ICMP_INC_STATS_BH(ICMP_MIB_INERRORS); 521 521 return; 522 522 } ··· 525 525 saveip = skb->nh.raw; 526 526 savesctp = skb->h.raw; 527 527 skb_reset_network_header(skb); 528 - skb->h.raw = (char *)sh; 529 - sk = sctp_err_lookup(AF_INET, skb, sh, &asoc, &transport); 528 + skb_set_transport_header(skb, ihlen); 529 + sk = sctp_err_lookup(AF_INET, skb, sctp_hdr(skb), &asoc, &transport); 530 530 /* Put back, the original pointers. */ 531 531 skb->nh.raw = saveip; 532 532 skb->h.raw = savesctp;
+2 -3
net/sctp/ipv6.c
··· 122 122 int type, int code, int offset, __be32 info) 123 123 { 124 124 struct inet6_dev *idev; 125 - struct sctphdr *sh = (struct sctphdr *)(skb->data + offset); 126 125 struct sock *sk; 127 126 struct sctp_association *asoc; 128 127 struct sctp_transport *transport; ··· 135 136 saveip = skb->nh.raw; 136 137 savesctp = skb->h.raw; 137 138 skb_reset_network_header(skb); 138 - skb->h.raw = (char *)sh; 139 - sk = sctp_err_lookup(AF_INET6, skb, sh, &asoc, &transport); 139 + skb_set_transport_header(skb, offset); 140 + sk = sctp_err_lookup(AF_INET6, skb, sctp_hdr(skb), &asoc, &transport); 140 141 /* Put back, the original pointers. */ 141 142 skb->nh.raw = saveip; 142 143 skb->h.raw = savesctp;