Commit b9959c2e4460b1df1d113d829180398588bb04b4

Authored by Changli Gao
Committed by David S. Miller
1 parent aca071c1c1

net_sched: sch_sfq: use proto_ports_offset() to support AH message

Signed-off-by: Changli Gao <xiaosuo@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 16 additions and 17 deletions Side-by-side Diff

... ... @@ -123,40 +123,39 @@
123 123 case htons(ETH_P_IP):
124 124 {
125 125 const struct iphdr *iph;
  126 + int poff;
126 127  
127 128 if (!pskb_network_may_pull(skb, sizeof(*iph)))
128 129 goto err;
129 130 iph = ip_hdr(skb);
130 131 h = (__force u32)iph->daddr;
131 132 h2 = (__force u32)iph->saddr ^ iph->protocol;
132   - if (!(iph->frag_off&htons(IP_MF|IP_OFFSET)) &&
133   - (iph->protocol == IPPROTO_TCP ||
134   - iph->protocol == IPPROTO_UDP ||
135   - iph->protocol == IPPROTO_UDPLITE ||
136   - iph->protocol == IPPROTO_SCTP ||
137   - iph->protocol == IPPROTO_DCCP ||
138   - iph->protocol == IPPROTO_ESP) &&
139   - pskb_network_may_pull(skb, iph->ihl * 4 + 4))
140   - h2 ^= *(((u32*)iph) + iph->ihl);
  133 + if (iph->frag_off & htons(IP_MF|IP_OFFSET))
  134 + break;
  135 + poff = proto_ports_offset(iph->protocol);
  136 + if (poff >= 0 &&
  137 + pskb_network_may_pull(skb, iph->ihl * 4 + 4 + poff)) {
  138 + iph = ip_hdr(skb);
  139 + h2 ^= *(u32*)((void *)iph + iph->ihl * 4 + poff);
  140 + }
141 141 break;
142 142 }
143 143 case htons(ETH_P_IPV6):
144 144 {
145 145 struct ipv6hdr *iph;
  146 + int poff;
146 147  
147 148 if (!pskb_network_may_pull(skb, sizeof(*iph)))
148 149 goto err;
149 150 iph = ipv6_hdr(skb);
150 151 h = (__force u32)iph->daddr.s6_addr32[3];
151 152 h2 = (__force u32)iph->saddr.s6_addr32[3] ^ iph->nexthdr;
152   - if ((iph->nexthdr == IPPROTO_TCP ||
153   - iph->nexthdr == IPPROTO_UDP ||
154   - iph->nexthdr == IPPROTO_UDPLITE ||
155   - iph->nexthdr == IPPROTO_SCTP ||
156   - iph->nexthdr == IPPROTO_DCCP ||
157   - iph->nexthdr == IPPROTO_ESP) &&
158   - pskb_network_may_pull(skb, sizeof(*iph) + 4))
159   - h2 ^= *(u32*)&iph[1];
  153 + poff = proto_ports_offset(iph->nexthdr);
  154 + if (poff >= 0 &&
  155 + pskb_network_may_pull(skb, sizeof(*iph) + 4 + poff)) {
  156 + iph = ipv6_hdr(skb);
  157 + h2 ^= *(u32*)((void *)iph + sizeof(*iph) + poff);
  158 + }
160 159 break;
161 160 }
162 161 default: