net: core: don't account for udp header size when computing seglen
[firefly-linux-kernel-4.4.55.git] / net / core / pktgen.c
index fdac61cac1bd11b15a69f78584029731e9310e4e..d068ec25db1ee42982ed4e6d934de612d9b09a26 100644 (file)
@@ -476,23 +476,22 @@ static int pgctrl_show(struct seq_file *seq, void *v)
 static ssize_t pgctrl_write(struct file *file, const char __user *buf,
                            size_t count, loff_t *ppos)
 {
-       int err = 0;
        char data[128];
        struct pktgen_net *pn = net_generic(current->nsproxy->net_ns, pg_net_id);
 
-       if (!capable(CAP_NET_ADMIN)) {
-               err = -EPERM;
-               goto out;
-       }
+       if (!capable(CAP_NET_ADMIN))
+               return -EPERM;
+
+       if (count == 0)
+               return -EINVAL;
 
        if (count > sizeof(data))
                count = sizeof(data);
 
-       if (copy_from_user(data, buf, count)) {
-               err = -EFAULT;
-               goto out;
-       }
-       data[count - 1] = 0;    /* Make string */
+       if (copy_from_user(data, buf, count))
+               return -EFAULT;
+
+       data[count - 1] = 0;    /* Strip trailing '\n' and terminate string */
 
        if (!strcmp(data, "stop"))
                pktgen_stop_all_threads_ifs(pn);
@@ -506,10 +505,7 @@ static ssize_t pgctrl_write(struct file *file, const char __user *buf,
        else
                pr_warning("Unknown command: %s\n", data);
 
-       err = count;
-
-out:
-       return err;
+       return count;
 }
 
 static int pgctrl_open(struct inode *inode, struct file *file)
@@ -1251,7 +1247,13 @@ static ssize_t pktgen_if_write(struct file *file,
                                "Flag -:%s:- unknown\nAvailable flags, (prepend ! to un-set flag):\n%s",
                                f,
                                "IPSRC_RND, IPDST_RND, UDPSRC_RND, UDPDST_RND, "
-                               "MACSRC_RND, MACDST_RND, TXSIZE_RND, IPV6, MPLS_RND, VID_RND, SVID_RND, FLOW_SEQ, IPSEC, NODE_ALLOC\n");
+                               "MACSRC_RND, MACDST_RND, TXSIZE_RND, IPV6, "
+                               "MPLS_RND, VID_RND, SVID_RND, FLOW_SEQ, "
+                               "QUEUE_MAP_RND, QUEUE_MAP_CPU, UDPCSUM, "
+#ifdef CONFIG_XFRM
+                               "IPSEC, "
+#endif
+                               "NODE_ALLOC\n");
                        return count;
                }
                sprintf(pg_result, "OK: flags=0x%x", pkt_dev->flags);
@@ -3338,7 +3340,7 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
 
        __netif_tx_lock_bh(txq);
 
-       if (unlikely(netif_xmit_frozen_or_stopped(txq))) {
+       if (unlikely(netif_xmit_frozen_or_drv_stopped(txq))) {
                ret = NETDEV_TX_BUSY;
                pkt_dev->last_ok = 0;
                goto unlock;