Search code examples
ioctlcentos8

Inappropriate ioctl for device SIOCGIWRANGE with Atheros in CentOS8


I am trying to get the list of frequencies of a wireless extension using iwlib but the function iw_get_range_info returns -1:

if((m_skfd = iw_sockets_open()) < 0)
{
  printf("Error while opening socket.");
  return;
}
if(iw_get_range_info(m_skfd, m_ifname, &m_range) < 0)
{
  printf("No frequency information.");
  return;
}

in iwlib.c, I see that the function that is being called is iw_get_ext(skfd, ifname, SIOCGIWRANGE, &wrq) so I modified this function in iwlib.h to get error code:

static inline int
iw_get_ext(int          skfd,       /* Socket to the kernel */
       const char *     ifname,     /* Device name */
       int          request,    /* WE ID */
       struct iwreq *   pwrq)       /* Fixed part of the request */
{
  /* Set device name */
  strncpy(pwrq->ifr_name, ifname, IFNAMSIZ);
  /* Do the request */
  int result = ioctl(skfd, request, pwrq);
  if (result < 0)
  {
    printf("ioctl failed and returned errno %s \n",strerror(errno));
  }
  return(result);
}

The error that is returned is "Inappropriate ioctl for device" (error 0x19). So ioctl is failing.

The wireless extensions uses the chipset Qualcomm Atheros QCA9890. Driver version is 10.2.4.70.9-2 (but same issue with 10.2.4-1.0-00045).

Except for this, I am able to use the extension normally and to perform AP scans.

The important thing to note is that the same code with the same hardware is working fine with Ubuntu 16.04 (kernel 4.15.0-118-generic) but not CentOS 8 (kernel 4.18.0-193.19.1.el8_2.x86_64).

Also, the command dmesg | grep ath returns:

[    2.013673] systemd[1]: Started Hardware RNG Entropy Gatherer Daemon.
[   10.052991] ath10k_pci 0000:06:00.0: pci irq msi oper_irq_mode 2 irq_mode 0 reset_mode 0
[   10.231675] ath10k_pci 0000:06:00.0: qca988x hw2.0 target 0x4100016c chip_id 0x043202ff sub 0000:0000
[   10.233800] ath10k_pci 0000:06:00.0: kconfig debug 0 debugfs 1 tracing 0 dfs 0 testmode 0
[   10.236144] ath10k_pci 0000:06:00.0: firmware ver 10.2.4.70.9-2 api 5 features no-p2p,raw-mode crc32 b8d50af5
[   10.287676] ath10k_pci 0000:06:00.0: board_file api 1 bmi_id N/A crc32 bebc7c08
[   11.501908] ath10k_pci 0000:06:00.0: unsupported HTC service id: 1536
[   11.523523] ath10k_pci 0000:06:00.0: htt-ver 2.1 wmi-op 5 htt-op 2 cal otp max-sta 128 raw 0 hwcrypto 1
[   11.597526] ath: EEPROM regdomain: 0x0
[   11.597529] ath: EEPROM indicates default country code should be used
[   11.597530] ath: doing EEPROM country->regdmn map search
[   11.597532] ath: country maps to regdmn code: 0x3a
[   11.597533] ath: Country alpha2 being used: US
[   11.597534] ath: Regpair used: 0x3a
[   11.644556] ath10k_pci 0000:06:00.0 wlp6s0: renamed from wlan0

What could be causing this issue?


Solution

  • I think you're having this issue because you're using Wireless extension, which is the old way of communicating with a wireless device. See this answer for more details.