第三次执行inet_ioctl函数:
[ 27.297526] ================================> inet_ioctl SSSS
[ 27.303692] ====> ioctl_num = 3 cmd = 0x8914
[ 27.308188] ====> delay 5s.
[ 32.284443] ====> GIFADDR/SIFADDR ......
[ 32.288554] ====> devinet_ioctl SSSS
[ 32.292298] ====> ifr.ifr_name = lo
[ 32.295979] ====> switch (cmd) 1
[ 32.299369] ====> switch (cmd) 2
[ 32.302861] ====> dev_change_flags SSSS
[ 32.306915] ====> dev->flags = 0x8, flags = 0x49
[ 32.311751] ----> __dev_change_flags SSSS
[ 32.315976] ----> dev_flags = 0x8
[ 32.319447] ----> dev_flags = 0x8
[ 32.322915] ----> dev_set_rx_mode IIII
[ 32.327220] ====> __dev_set_rx_mode SSSS
[ 32.331339] ====> no IFF_UP
[ 32.334328] ----> IFF_UP = 0x1 old_flags = 0x8
[ 32.338983] 1111 __dev_open start
[ 32.342451] 1111 netif_device_present IIII
[ 32.346770] 1111 netpoll_poll_disable IIII
[ 32.351060] 1111 call_netdevice_notifiers IIII
[ 32.355747] 1111 notifier_to_errno IIII
[ 32.359763] 1111 set_bit __LINK_STATE_START
[ 32.364258] 1111 netpoll_poll_enable IIII
[ 32.368455] 2222 __dev_open middle
[ 32.372015] 2222 dev_set_rx_mode IIII
[ 32.375873] ====> __dev_set_rx_mode SSSS
[ 32.379980] ====> no IFF_UNICAST_FLT
[ 32.383774] 3333 __dev_open over
[ 32.387156] ----> __dev_change_flags EEEE
[ 32.391354] ----> __dev_notify_flags SSSS
[ 32.396088] ----> __dev_notify_flags EEEE
[ 32.400299] ====> changes = 0x1
[ 32.403645] ====> dev_change_flags EEEE
[ 32.407667] ====> devinet_ioctl EEEE ret = 0
[ 32.412137] =========================> inet_ioctl EEEEEEEEEEEEEE
0x8914被定义为宏SIOCSIFFLAGS,这个函数稍微复杂一些,因为devinet_ioctl函数会调用net/core/dev.c中的dev_change_flags函数。由于flags中关键的IFF_UP参数,使得由原来的0x08变成了0x09。
第四次执行inet_ioctl函数(同第二步):
[ 16.399259] ================================> inet_ioctl SSSS
[ 16.405364] ====> cmd = 0x8913
[ 16.408562] ====> NO VALID SIOC*
[ 16.411940] =========================> inet_ioctl EEEEEEEEEEEEEE
第五次执行inet_ioctl函数:
[ 37.417057] ================================> inet_ioctl SSSS
[ 37.423199] ====> ioctl_num = 5 cmd = 0x8914
[ 37.427671] ====> delay 5s.
[ 42.403872] ====> GIFADDR/SIFADDR ......
[ 42.407983] ====> devinet_ioctl SSSS
[ 42.411727] ====> ifr.ifr_name = lo
[ 42.415406] ====> switch (cmd) 1
[ 42.418794] ====> switch (cmd) 2
[ 42.422263] ====> dev_change_flags SSSS
[ 42.426305] ====> dev->flags = 0x9, flags = 0x49
[ 42.431138] ----> __dev_change_flags SSSS
[ 42.435358] ----> dev_flags = 0x9
[ 42.438827] ----> dev_flags = 0x9
[ 42.442296] ----> dev_set_rx_mode IIII
[ 42.446246] ====> __dev_set_rx_mode SSSS
[ 42.450351] ====> no IFF_UNICAST_FLT
[ 42.454119] ----> __dev_change_flags EEEE
[ 42.458317] ----> __dev_notify_flags SSSS
[ 42.462513] ----> __dev_notify_flags EEEE
[ 42.466731] ====> changes = 0x0
[ 42.470019] ====> dev_change_flags EEEE
[ 42.474061] ====> devinet_ioctl EEEE ret = 0
[ 42.478532] =========================> inet_ioctl EEEEEEEEEEEEEE
0x8914被定义为宏SIOCSIFFLAGS,这是第二次执行了,flags的值仍然为0x09;
Anyway,继续往下看~
第六次执行inet_ioctl函数(同第二步):
[ 16.589222] ================================> inet_ioctl SSSS
[ 16.595428] ====> cmd = 0x8913
[ 16.598629] ====> NO VALID SIOC*
[ 16.602006] =========================> inet_ioctl EEEEEEEEEEEEEE
第一次到第六次对ioctl的执行,都是对本地网卡的操作,也就是对127.0.0.1的操作。这也是为什么dev_set_rx_mode函数调用的ops->ndo_*函数们没有被赋值的原因,因为本地网卡哪里来的对cpsw外设和PHY寄存器的操作呢?它不过是个虚拟出来的网卡罢了。
ping本地网卡不会丢包,永远都是LOOPBACK,简直是网络调试利器~~~
下面是more and more的inet_ioctl函数分析,而且是对eth0的了;
很多是吧~很麻烦是吧~Well, life is not simple. 哇哈哈哈哈!
文章评论(0条评论)
登录后参与讨论