summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/lib/bpf/xsk.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
index 5007b5d4fd2c..e02025bbe36d 100644
--- a/tools/lib/bpf/xsk.c
+++ b/tools/lib/bpf/xsk.c
@@ -317,15 +317,14 @@ static int xsk_load_xdp_prog(struct xsk_socket *xsk)
317 317
318static int xsk_get_max_queues(struct xsk_socket *xsk) 318static int xsk_get_max_queues(struct xsk_socket *xsk)
319{ 319{
320 struct ethtool_channels channels; 320 struct ethtool_channels channels = { .cmd = ETHTOOL_GCHANNELS };
321 struct ifreq ifr; 321 struct ifreq ifr = {};
322 int fd, err, ret; 322 int fd, err, ret;
323 323
324 fd = socket(AF_INET, SOCK_DGRAM, 0); 324 fd = socket(AF_INET, SOCK_DGRAM, 0);
325 if (fd < 0) 325 if (fd < 0)
326 return -errno; 326 return -errno;
327 327
328 channels.cmd = ETHTOOL_GCHANNELS;
329 ifr.ifr_data = (void *)&channels; 328 ifr.ifr_data = (void *)&channels;
330 strncpy(ifr.ifr_name, xsk->ifname, IFNAMSIZ - 1); 329 strncpy(ifr.ifr_name, xsk->ifname, IFNAMSIZ - 1);
331 ifr.ifr_name[IFNAMSIZ - 1] = '\0'; 330 ifr.ifr_name[IFNAMSIZ - 1] = '\0';
@@ -335,7 +334,7 @@ static int xsk_get_max_queues(struct xsk_socket *xsk)
335 goto out; 334 goto out;
336 } 335 }
337 336
338 if (channels.max_combined == 0 || errno == EOPNOTSUPP) 337 if (err || channels.max_combined == 0)
339 /* If the device says it has no channels, then all traffic 338 /* If the device says it has no channels, then all traffic
340 * is sent to a single stream, so max queues = 1. 339 * is sent to a single stream, so max queues = 1.
341 */ 340 */