pktgen.c (20b0c718c3bb122107bebadbb8ecf4bab76fb392) pktgen.c (0945574750f3040a2309d960a569215598a64672)
1/*
2 * Authors:
3 * Copyright 2001, 2002 by Robert Olsson <robert.olsson@its.uu.se>
4 * Uppsala University and
5 * Swedish University of Agricultural Sciences
6 *
7 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
8 * Ben Greear <greearb@candelatech.com>

--- 462 unchanged lines hidden (view full) ---

471{
472 seq_puts(seq, version);
473 return 0;
474}
475
476static ssize_t pgctrl_write(struct file *file, const char __user *buf,
477 size_t count, loff_t *ppos)
478{
1/*
2 * Authors:
3 * Copyright 2001, 2002 by Robert Olsson <robert.olsson@its.uu.se>
4 * Uppsala University and
5 * Swedish University of Agricultural Sciences
6 *
7 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
8 * Ben Greear <greearb@candelatech.com>

--- 462 unchanged lines hidden (view full) ---

471{
472 seq_puts(seq, version);
473 return 0;
474}
475
476static ssize_t pgctrl_write(struct file *file, const char __user *buf,
477 size_t count, loff_t *ppos)
478{
479 int err = 0;
480 char data[128];
481 struct pktgen_net *pn = net_generic(current->nsproxy->net_ns, pg_net_id);
482
479 char data[128];
480 struct pktgen_net *pn = net_generic(current->nsproxy->net_ns, pg_net_id);
481
483 if (!capable(CAP_NET_ADMIN)) {
484 err = -EPERM;
485 goto out;
486 }
482 if (!capable(CAP_NET_ADMIN))
483 return -EPERM;
487
488 if (count == 0)
489 return -EINVAL;
490
491 if (count > sizeof(data))
492 count = sizeof(data);
493
484
485 if (count == 0)
486 return -EINVAL;
487
488 if (count > sizeof(data))
489 count = sizeof(data);
490
494 if (copy_from_user(data, buf, count)) {
495 err = -EFAULT;
496 goto out;
497 }
491 if (copy_from_user(data, buf, count))
492 return -EFAULT;
493
498 data[count - 1] = 0; /* Strip trailing '\n' and terminate string */
499
500 if (!strcmp(data, "stop"))
501 pktgen_stop_all_threads_ifs(pn);
502
503 else if (!strcmp(data, "start"))
504 pktgen_run_all_threads(pn);
505
506 else if (!strcmp(data, "reset"))
507 pktgen_reset_all_threads(pn);
508
509 else
510 pr_warning("Unknown command: %s\n", data);
511
494 data[count - 1] = 0; /* Strip trailing '\n' and terminate string */
495
496 if (!strcmp(data, "stop"))
497 pktgen_stop_all_threads_ifs(pn);
498
499 else if (!strcmp(data, "start"))
500 pktgen_run_all_threads(pn);
501
502 else if (!strcmp(data, "reset"))
503 pktgen_reset_all_threads(pn);
504
505 else
506 pr_warning("Unknown command: %s\n", data);
507
512 err = count;
513
514out:
515 return err;
508 return count;
516}
517
518static int pgctrl_open(struct inode *inode, struct file *file)
519{
520 return single_open(file, pgctrl_show, PDE_DATA(inode));
521}
522
523static const struct file_operations pktgen_fops = {

--- 3305 unchanged lines hidden ---
509}
510
511static int pgctrl_open(struct inode *inode, struct file *file)
512{
513 return single_open(file, pgctrl_show, PDE_DATA(inode));
514}
515
516static const struct file_operations pktgen_fops = {

--- 3305 unchanged lines hidden ---