From: Eric Leblond Date: Thu, 4 Dec 2014 16:49:31 +0000 (+0100) Subject: util-ioctl: Add function to get number of RSS queues on iface X-Git-Tag: suricata-2.1beta3~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4bb6e67ba10a432c84f2e81fcbbebc911999110;p=thirdparty%2Fsuricata.git util-ioctl: Add function to get number of RSS queues on iface The number of RSS queues can be fetched via a standard ioctl which is independant of hardware. --- diff --git a/src/util-ioctl.c b/src/util-ioctl.c index f46004213e..b3a0f22478 100644 --- a/src/util-ioctl.c +++ b/src/util-ioctl.c @@ -210,3 +210,36 @@ int GetIfaceOffloading(char *pcap_dev) #endif } +int GetIfaceRSSQueuesNum(const char *pcap_dev) +{ +#ifdef HAVE_LINUX_ETHTOOL_H + struct ifreq ifr; + struct ethtool_rxnfc nfccmd; + int fd; + + (void)strlcpy(ifr.ifr_name, pcap_dev, sizeof(ifr.ifr_name)); + fd = socket(AF_INET, SOCK_DGRAM, 0); + if (fd == -1) { + return -1; + } + + nfccmd.cmd = ETHTOOL_GRXRINGS; + ifr.ifr_data = (void*) &nfccmd; + + if (ioctl(fd, SIOCETHTOOL, (char *)&ifr) < 0) { + if (errno != ENOTSUP) { + SCLogWarning(SC_ERR_SYSCALL, + "Failure when trying to get number of RSS queue ioctl: %d", + errno); + } + close(fd); + return 0; + } + close(fd); + SCLogInfo("Found %d RX RSS queues for '%s'", (int)nfccmd.data, + pcap_dev); + return (int)nfccmd.data; +#else + return 0; +#endif +} diff --git a/src/util-ioctl.h b/src/util-ioctl.h index 7bc5055710..d293a4d047 100644 --- a/src/util-ioctl.h +++ b/src/util-ioctl.h @@ -24,3 +24,4 @@ int GetIfaceMTU(char *pcap_dev); int GetIfaceMaxPacketSize(char *pcap_dev); int GetIfaceOffloading(char *pcap_dev); +int GetIfaceRSSQueuesNum(const char *pcap_dev);