iwpriv配置失败的问题追踪[ioctl调用过程解析]

2019-07-12 22:31发布

现象:执行 iwpriv  athXXX  XXXX ,  ioctl报错

bugfix:
             【  app  】 [ iwpriv.c]  print_priv_info   --->   [iwlib.c] iw_get_priv_info  --->   iw_get_ext(skfd, ifname, SIOCGIWPRIV, &wrq)   --->   ioctl(skfd, request, pwrq)   
             【kernel】上述ioctl实际上通过系统调用进入kernel space,          
                fs/Ioctl.c
SYSCALL_DEFINE3(ioctl, unsigned int, fd,unsigned int, cmd, unsigned long, arg) { ……………………………………………………………………..          error= do_vfs_ioctl(filp, fd, cmd, arg);//调用虚拟文件系统的ioctl …………………………………………………………….. }                 do_vfs_ioctl   --->   vfs_ioctl(filp, cmd, arg)   --->   filp->f_op->unlocked_ioctl(filp, cmd, arg)                net/socket.c static const struct file_operations socket_file_ops = {
    .owner =    THIS_MODULE,
    .llseek =    no_llseek,
    .aio_read =    sock_aio_read,
    .aio_write =    sock_aio_write,
    .poll =        sock_poll,
    .unlocked_ioctl = sock_ioctl,
#ifdef CONFIG_COMPAT
    .compat_ioctl = compat_sock_ioctl,
#endif
    .mmap =        sock_mmap,
    .open =        sock_no_open,    /* special open code to disallow open via /proc */
    .release =    sock_close,
    .fasync =    sock_fasync,
    .sendpage =    sock_sendpage,
    .splice_write = generic_splice_sendpage,
    .splice_read =    sock_splice_read,
};
              static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)               ..............              #ifdef CONFIG_WEXT_CORE
                  if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST) {
                     err = dev_ioctl(net, cmd, argp);
                  } else
             #endif             net/core/dev.c
            dev_ioctl   --->   [net/wireless/wext-core.c] wext_handle_ioctl   --->   wext_ioctl_dispatch   --->   [net/wireless/wext-priv.c] iw_handler_get_private
             if (wrqu->data.length < dev->wireless_handlers->num_private_args)              ..........              追踪发现这里判断失败导致问题,向上追其根源:app中 iw_get_ext(skfd, ifname, SIOCGIWPRIV, &wrq)  分配的空间不足导致的问题