* Perform ifreq ioctl() on associated Ethernet device. * * @param[in] priv * Pointer to private structure. * @param req * Request number to pass to ioctl(). * @param[out] ifr * Interface request structure output buffer. * * @return * 0 on success, negative errno value otherwise and rte_errno is set. */
| 145 | * 0 on success, negative errno value otherwise and rte_errno is set. |
| 146 | */ |
| 147 | static int |
| 148 | mlx4_ifreq(const struct mlx4_priv *priv, int req, struct ifreq *ifr) |
| 149 | { |
| 150 | int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); |
| 151 | int ret; |
| 152 | |
| 153 | if (sock == -1) { |
| 154 | rte_errno = errno; |
| 155 | return -rte_errno; |
| 156 | } |
| 157 | ret = mlx4_get_ifname(priv, &ifr->ifr_name); |
| 158 | if (!ret && ioctl(sock, req, ifr) == -1) { |
| 159 | rte_errno = errno; |
| 160 | ret = -rte_errno; |
| 161 | } |
| 162 | close(sock); |
| 163 | return ret; |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * Get MAC address by querying netdevice. |
no test coverage detected