[PKTGEN]: Fix random packet sizes causing panic

Signed-off-by: Robert Olsson <robert.olsson@its.uu.se>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Robert Olsson and committed by David S. Miller 64053bee 60fe7403

+13 -16
+13 -16
net/core/pktgen.c
··· 151 151 #include <asm/timex.h> 152 152 153 153 154 - #define VERSION "pktgen v2.61: Packet Generator for packet performance testing.\n" 154 + #define VERSION "pktgen v2.62: Packet Generator for packet performance testing.\n" 155 155 156 156 /* #define PG_DEBUG(a) a */ 157 157 #define PG_DEBUG(a) ··· 1921 1921 struct iphdr *iph; 1922 1922 struct pktgen_hdr *pgh = NULL; 1923 1923 1924 + /* Update any of the values, used when we're incrementing various 1925 + * fields. 1926 + */ 1927 + mod_cur_headers(pkt_dev); 1928 + 1924 1929 skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + 16, GFP_ATOMIC); 1925 1930 if (!skb) { 1926 1931 sprintf(pkt_dev->result, "No memory"); ··· 1938 1933 eth = (__u8 *) skb_push(skb, 14); 1939 1934 iph = (struct iphdr *)skb_put(skb, sizeof(struct iphdr)); 1940 1935 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr)); 1941 - 1942 - /* Update any of the values, used when we're incrementing various 1943 - * fields. 1944 - */ 1945 - mod_cur_headers(pkt_dev); 1946 1936 1947 1937 memcpy(eth, pkt_dev->hh, 12); 1948 1938 *(u16*)&eth[12] = __constant_htons(ETH_P_IP); ··· 2192 2192 int datalen; 2193 2193 struct ipv6hdr *iph; 2194 2194 struct pktgen_hdr *pgh = NULL; 2195 - 2195 + 2196 + /* Update any of the values, used when we're incrementing various 2197 + * fields. 2198 + */ 2199 + mod_cur_headers(pkt_dev); 2200 + 2196 2201 skb = alloc_skb(pkt_dev->cur_pkt_size + 64 + 16, GFP_ATOMIC); 2197 2202 if (!skb) { 2198 2203 sprintf(pkt_dev->result, "No memory"); ··· 2211 2206 iph = (struct ipv6hdr *)skb_put(skb, sizeof(struct ipv6hdr)); 2212 2207 udph = (struct udphdr *)skb_put(skb, sizeof(struct udphdr)); 2213 2208 2214 - 2215 - /* Update any of the values, used when we're incrementing various 2216 - * fields. 2217 - */ 2218 - mod_cur_headers(pkt_dev); 2219 - 2220 - 2221 2209 memcpy(eth, pkt_dev->hh, 12); 2222 2210 *(u16*)&eth[12] = __constant_htons(ETH_P_IPV6); 2223 - 2224 - 2211 + 2225 2212 datalen = pkt_dev->cur_pkt_size-14- 2226 2213 sizeof(struct ipv6hdr)-sizeof(struct udphdr); /* Eth + IPh + UDPh */ 2227 2214