pktgen: fix packet generation
authorAlexei Starovoitov <ast@plumgrid.com>
Mon, 11 May 2015 22:19:48 +0000 (15:19 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 13 May 2015 03:09:52 +0000 (23:09 -0400)
pkt_gen->last_ok was not set properly, so after the first burst
pktgen instead of allocating new packet, will reuse old one, advance
eth_type_trans further, which would mean the stack will be seeing very
short bogus packets.

Fixes: 62f64aed622b ("pktgen: introduce xmit_mode '<start_xmit|netif_receive>'")
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/pktgen.c

index 8f2687da058ebe9036014ed2e0a31b7ee2540966..62f979984a23236db1109bb109f46a932840633f 100644 (file)
@@ -1189,6 +1189,16 @@ static ssize_t pktgen_if_write(struct file *file,
                                return -ENOTSUPP;
 
                        pkt_dev->xmit_mode = M_NETIF_RECEIVE;
+
+                       /* make sure new packet is allocated every time
+                        * pktgen_xmit() is called
+                        */
+                       pkt_dev->last_ok = 1;
+
+                       /* override clone_skb if user passed default value
+                        * at module loading time
+                        */
+                       pkt_dev->clone_skb = 0;
                } else {
                        sprintf(pg_result,
                                "xmit_mode -:%s:- unknown\nAvailable modes: %s",
@@ -3415,7 +3425,6 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
                                /* get out of the loop and wait
                                 * until skb is consumed
                                 */
-                               pkt_dev->last_ok = 1;
                                break;
                        }
                        /* skb was 'freed' by stack, so clean few