| 775 | } |
| 776 | |
| 777 | static int |
| 778 | tap_ioctl(struct pmd_internals *pmd, unsigned long request, |
| 779 | struct ifreq *ifr, int set, enum ioctl_mode mode) |
| 780 | { |
| 781 | short req_flags = ifr->ifr_flags; |
| 782 | int remote = pmd->remote_if_index && |
| 783 | (mode == REMOTE_ONLY || mode == LOCAL_AND_REMOTE); |
| 784 | |
| 785 | if (!pmd->remote_if_index && mode == REMOTE_ONLY) |
| 786 | return 0; |
| 787 | /* |
| 788 | * If there is a remote netdevice, apply ioctl on it, then apply it on |
| 789 | * the tap netdevice. |
| 790 | */ |
| 791 | apply: |
| 792 | if (remote) |
| 793 | strlcpy(ifr->ifr_name, pmd->remote_iface, IFNAMSIZ); |
| 794 | else if (mode == LOCAL_ONLY || mode == LOCAL_AND_REMOTE) |
| 795 | strlcpy(ifr->ifr_name, pmd->name, IFNAMSIZ); |
| 796 | switch (request) { |
| 797 | case SIOCSIFFLAGS: |
| 798 | /* fetch current flags to leave other flags untouched */ |
| 799 | if (ioctl(pmd->ioctl_sock, SIOCGIFFLAGS, ifr) < 0) |
| 800 | goto error; |
| 801 | if (set) |
| 802 | ifr->ifr_flags |= req_flags; |
| 803 | else |
| 804 | ifr->ifr_flags &= ~req_flags; |
| 805 | break; |
| 806 | case SIOCGIFFLAGS: |
| 807 | case SIOCGIFHWADDR: |
| 808 | case SIOCSIFHWADDR: |
| 809 | case SIOCSIFMTU: |
| 810 | break; |
| 811 | default: |
| 812 | TAP_LOG(WARNING, "%s: ioctl() called with wrong arg", |
| 813 | pmd->name); |
| 814 | return -EINVAL; |
| 815 | } |
| 816 | if (ioctl(pmd->ioctl_sock, request, ifr) < 0) |
| 817 | goto error; |
| 818 | if (remote-- && mode == LOCAL_AND_REMOTE) |
| 819 | goto apply; |
| 820 | return 0; |
| 821 | |
| 822 | error: |
| 823 | TAP_LOG(DEBUG, "%s(%s) failed: %s(%d)", ifr->ifr_name, |
| 824 | tap_ioctl_req2str(request), strerror(errno), errno); |
| 825 | return -errno; |
| 826 | } |
| 827 | |
| 828 | static int |
| 829 | tap_link_set_down(struct rte_eth_dev *dev) |
no test coverage detected