aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/pktgen.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/pktgen.c')
-rw-r--r--net/core/pktgen.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index fdac61cac1bd..d0dac57291af 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -476,23 +476,22 @@ static int pgctrl_show(struct seq_file *seq, void *v)
476static ssize_t pgctrl_write(struct file *file, const char __user *buf, 476static ssize_t pgctrl_write(struct file *file, const char __user *buf,
477 size_t count, loff_t *ppos) 477 size_t count, loff_t *ppos)
478{ 478{
479 int err = 0;
480 char data[128]; 479 char data[128];
481 struct pktgen_net *pn = net_generic(current->nsproxy->net_ns, pg_net_id); 480 struct pktgen_net *pn = net_generic(current->nsproxy->net_ns, pg_net_id);
482 481
483 if (!capable(CAP_NET_ADMIN)) { 482 if (!capable(CAP_NET_ADMIN))
484 err = -EPERM; 483 return -EPERM;
485 goto out; 484
486 } 485 if (count == 0)
486 return -EINVAL;
487 487
488 if (count > sizeof(data)) 488 if (count > sizeof(data))
489 count = sizeof(data); 489 count = sizeof(data);
490 490
491 if (copy_from_user(data, buf, count)) { 491 if (copy_from_user(data, buf, count))
492 err = -EFAULT; 492 return -EFAULT;
493 goto out; 493
494 } 494 data[count - 1] = 0; /* Strip trailing '\n' and terminate string */
495 data[count - 1] = 0; /* Make string */
496 495
497 if (!strcmp(data, "stop")) 496 if (!strcmp(data, "stop"))
498 pktgen_stop_all_threads_ifs(pn); 497 pktgen_stop_all_threads_ifs(pn);
@@ -506,10 +505,7 @@ static ssize_t pgctrl_write(struct file *file, const char __user *buf,
506 else 505 else
507 pr_warning("Unknown command: %s\n", data); 506 pr_warning("Unknown command: %s\n", data);
508 507
509 err = count; 508 return count;
510
511out:
512 return err;
513} 509}
514 510
515static int pgctrl_open(struct inode *inode, struct file *file) 511static int pgctrl_open(struct inode *inode, struct file *file)
@@ -1251,7 +1247,13 @@ static ssize_t pktgen_if_write(struct file *file,
1251 "Flag -:%s:- unknown\nAvailable flags, (prepend ! to un-set flag):\n%s", 1247 "Flag -:%s:- unknown\nAvailable flags, (prepend ! to un-set flag):\n%s",
1252 f, 1248 f,
1253 "IPSRC_RND, IPDST_RND, UDPSRC_RND, UDPDST_RND, " 1249 "IPSRC_RND, IPDST_RND, UDPSRC_RND, UDPDST_RND, "
1254 "MACSRC_RND, MACDST_RND, TXSIZE_RND, IPV6, MPLS_RND, VID_RND, SVID_RND, FLOW_SEQ, IPSEC, NODE_ALLOC\n"); 1250 "MACSRC_RND, MACDST_RND, TXSIZE_RND, IPV6, "
1251 "MPLS_RND, VID_RND, SVID_RND, FLOW_SEQ, "
1252 "QUEUE_MAP_RND, QUEUE_MAP_CPU, UDPCSUM, "
1253#ifdef CONFIG_XFRM
1254 "IPSEC, "
1255#endif
1256 "NODE_ALLOC\n");
1255 return count; 1257 return count;
1256 } 1258 }
1257 sprintf(pg_result, "OK: flags=0x%x", pkt_dev->flags); 1259 sprintf(pg_result, "OK: flags=0x%x", pkt_dev->flags);