MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mlx5_ifreq_by_ifname

Function mlx5_ifreq_by_ifname

dpdk/drivers/net/mlx5/linux/mlx5_ethdev_os.c:198–219  ·  view source on GitHub ↗

* Perform ifreq ioctl() on associated netdev ifname. * * @param[in] ifname * Pointer to netdev name. * @param req * Request number to pass to ioctl(). * @param[out] ifr * Interface request structure output buffer. * * @return * 0 on success, a negative errno value otherwise and rte_errno is set. */

Source from the content-addressed store, hash-verified

196 * 0 on success, a negative errno value otherwise and rte_errno is set.
197 */
198static int
199mlx5_ifreq_by_ifname(const char *ifname, int req, struct ifreq *ifr)
200{
201 int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
202 int ret = 0;
203
204 if (sock == -1) {
205 rte_errno = errno;
206 return -rte_errno;
207 }
208 rte_strscpy(ifr->ifr_name, ifname, sizeof(ifr->ifr_name));
209 ret = ioctl(sock, req, ifr);
210 if (ret == -1) {
211 rte_errno = errno;
212 goto error;
213 }
214 close(sock);
215 return 0;
216error:
217 close(sock);
218 return -rte_errno;
219}
220
221/**
222 * Perform ifreq ioctl() on associated Ethernet device.

Callers 4

mlx5_ifreqFunction · 0.85
mlx5_os_get_stats_nFunction · 0.85

Calls 4

rte_strscpyFunction · 0.85
socketClass · 0.50
ioctlFunction · 0.50
closeFunction · 0.50

Tested by

no test coverage detected