Linux Wifi [DRAFT]
Created at 2017-05-12T15:55:04+09:00

Concepts

Subsystem

Driver

$ lsmod | grep iwl
iwlmvm                360448  0
mac80211              757760  1 iwlmvm
iwlwifi               229376  1 iwlmvm
cfg80211              581632  3 iwlmvm,iwlwifi,mac80211

$ journalctl -k | grep wlp3s0    # wl (wireless lan) + p (pci) + 3 (bus) + s + 0    (slot)
May 12 14:40:42 hiogawa-ubuntu-thinkpad13 kernel: iwlwifi 0000:03:00.0 wlp3s0: renamed from wlan0

$ journalctl -k | grep enp0s31f6 # en (ethernet)     + p (pci) + 0 (bus) + s + 31f6 (slot) ??
May 12 14:40:42 hiogawa-ubuntu-thinkpad13 kernel: e1000e 0000:00:1f.6 enp0s31f6: renamed from eth0
[ registration ]
(drivers/net/wireless/intel/iwlwifi/)
- module_init(iwl_drv_init) => iwl_pci_register_driver => pci_register_driver(&iwl_pci_driver)
- iwl_pci_probe =>
  - ??

[ from user space (netlink) ]
- dev_change_name =>
  - netdev_info(dev, "renamed from %s\n", oldname) (e.g. wlan0 to wlp3s0)


[ udev ]
[ udev - /lib/udev/rules.d/80-net-setup-link.rules ]
- IMPORT{builtin}="net_setup_link"

[ udev - systemd/src/udev/udev-builtin-net_setup_link.c ]
- builtin_net_setup_link =>
  - link_config_apply =>
    - should_rename
    - rtnl_set_link_properties

[ udev - /lib/udev/rules.d/80-ifupdown.rules ]
SUBSYSTEM=="net", ACTION=="add|remove", RUN+="ifupdown-hotplug"

[ udev - /lib/udev/ifupdown-hotplug (shell script) ]
- do_everything => (for add ACTION) net_ifup =>
  - ifquery
  - systemctl --no-block start $(systemd-escape --template ifup@.service $INTERFACE)

[ udev - ifup@.service ]      
- ifup --allow=hotplug =>
  - fork-exec to if-xxx.d shell scripts with environment variable

[ udev - /etc/network/{if-pre-up.d,if-up.d}/wpasupplicant ]
- ...

[ udev - /etc/network/if-pre-up.d/wireless-tools ]
- ...

TODO

  • kernel-userspace interaction
    • intel wireless driver
    • iw, wpa_supplicant, nmcli
  • detail status from cli iw dev wlp3s0 scan
  • then how about mobile wireless network (e.g. 4G) ?
    • spec, protocol, authentication ?

Reference