| 791 | } |
| 792 | |
| 793 | static void enable_pdump(struct rte_ring *r, struct rte_mempool *mp) |
| 794 | { |
| 795 | struct interface *intf; |
| 796 | unsigned int count = 0; |
| 797 | uint32_t flags; |
| 798 | int ret; |
| 799 | |
| 800 | flags = RTE_PDUMP_FLAG_RXTX; |
| 801 | if (use_pcapng) |
| 802 | flags |= RTE_PDUMP_FLAG_PCAPNG; |
| 803 | |
| 804 | TAILQ_FOREACH(intf, &interfaces, next) { |
| 805 | ret = rte_pdump_enable_bpf(intf->port, RTE_PDUMP_ALL_QUEUES, |
| 806 | flags, intf->opts.snap_len, |
| 807 | r, mp, intf->bpf_prm); |
| 808 | if (ret < 0) { |
| 809 | const struct interface *intf2; |
| 810 | |
| 811 | /* unwind any previous enables */ |
| 812 | TAILQ_FOREACH(intf2, &interfaces, next) { |
| 813 | if (intf == intf2) |
| 814 | break; |
| 815 | rte_pdump_disable(intf2->port, |
| 816 | RTE_PDUMP_ALL_QUEUES, RTE_PDUMP_FLAG_RXTX); |
| 817 | if (intf2->opts.promisc_mode) |
| 818 | rte_eth_promiscuous_disable(intf2->port); |
| 819 | } |
| 820 | rte_exit(EXIT_FAILURE, |
| 821 | "Packet dump enable on %u:%s failed %s\n", |
| 822 | intf->port, intf->name, |
| 823 | rte_strerror(rte_errno)); |
| 824 | } |
| 825 | |
| 826 | if (intf->opts.promisc_mode) { |
| 827 | if (rte_eth_promiscuous_get(intf->port) == 1) { |
| 828 | /* promiscuous already enabled */ |
| 829 | intf->opts.promisc_mode = false; |
| 830 | } else { |
| 831 | ret = rte_eth_promiscuous_enable(intf->port); |
| 832 | if (ret != 0) |
| 833 | fprintf(stderr, |
| 834 | "port %u set promiscuous enable failed: %d\n", |
| 835 | intf->port, ret); |
| 836 | intf->opts.promisc_mode = false; |
| 837 | } |
| 838 | } |
| 839 | ++count; |
| 840 | } |
| 841 | |
| 842 | fputs("Capturing on ", stdout); |
| 843 | TAILQ_FOREACH(intf, &interfaces, next) { |
| 844 | if (intf != TAILQ_FIRST(&interfaces)) { |
| 845 | if (count > 2) |
| 846 | putchar(','); |
| 847 | putchar(' '); |
| 848 | if (TAILQ_NEXT(intf, next) == NULL) |
| 849 | fputs("and ", stdout); |
| 850 | } |
no test coverage detected