diff options
-rw-r--r-- | net/core/pktgen.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 54c634fab6c3..6e79e96cb4f2 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -427,7 +427,7 @@ static const char version[] = | |||
427 | static int pktgen_remove_device(struct pktgen_thread *t, struct pktgen_dev *i); | 427 | static int pktgen_remove_device(struct pktgen_thread *t, struct pktgen_dev *i); |
428 | static int pktgen_add_device(struct pktgen_thread *t, const char *ifname); | 428 | static int pktgen_add_device(struct pktgen_thread *t, const char *ifname); |
429 | static struct pktgen_dev *pktgen_find_dev(struct pktgen_thread *t, | 429 | static struct pktgen_dev *pktgen_find_dev(struct pktgen_thread *t, |
430 | const char *ifname); | 430 | const char *ifname, bool exact); |
431 | static int pktgen_device_event(struct notifier_block *, unsigned long, void *); | 431 | static int pktgen_device_event(struct notifier_block *, unsigned long, void *); |
432 | static void pktgen_run_all_threads(void); | 432 | static void pktgen_run_all_threads(void); |
433 | static void pktgen_reset_all_threads(void); | 433 | static void pktgen_reset_all_threads(void); |
@@ -1818,9 +1818,10 @@ static struct pktgen_dev *__pktgen_NN_threads(const char *ifname, int remove) | |||
1818 | { | 1818 | { |
1819 | struct pktgen_thread *t; | 1819 | struct pktgen_thread *t; |
1820 | struct pktgen_dev *pkt_dev = NULL; | 1820 | struct pktgen_dev *pkt_dev = NULL; |
1821 | bool exact = (remove == FIND); | ||
1821 | 1822 | ||
1822 | list_for_each_entry(t, &pktgen_threads, th_list) { | 1823 | list_for_each_entry(t, &pktgen_threads, th_list) { |
1823 | pkt_dev = pktgen_find_dev(t, ifname); | 1824 | pkt_dev = pktgen_find_dev(t, ifname, exact); |
1824 | if (pkt_dev) { | 1825 | if (pkt_dev) { |
1825 | if (remove) { | 1826 | if (remove) { |
1826 | if_lock(t); | 1827 | if_lock(t); |
@@ -3567,13 +3568,18 @@ static int pktgen_thread_worker(void *arg) | |||
3567 | } | 3568 | } |
3568 | 3569 | ||
3569 | static struct pktgen_dev *pktgen_find_dev(struct pktgen_thread *t, | 3570 | static struct pktgen_dev *pktgen_find_dev(struct pktgen_thread *t, |
3570 | const char *ifname) | 3571 | const char *ifname, bool exact) |
3571 | { | 3572 | { |
3572 | struct pktgen_dev *p, *pkt_dev = NULL; | 3573 | struct pktgen_dev *p, *pkt_dev = NULL; |
3573 | if_lock(t); | 3574 | size_t len = strlen(ifname); |
3574 | 3575 | ||
3576 | if_lock(t); | ||
3575 | list_for_each_entry(p, &t->if_list, list) | 3577 | list_for_each_entry(p, &t->if_list, list) |
3576 | if (strncmp(p->odevname, ifname, IFNAMSIZ) == 0) { | 3578 | if (strncmp(p->odevname, ifname, len) == 0) { |
3579 | if (p->odevname[len]) { | ||
3580 | if (exact || p->odevname[len] != '@') | ||
3581 | continue; | ||
3582 | } | ||
3577 | pkt_dev = p; | 3583 | pkt_dev = p; |
3578 | break; | 3584 | break; |
3579 | } | 3585 | } |