There are two ways to config more IP addr on a dev:
1. ip addr add
2. ifconfig ethn:m
I want to know the difference in source code layer. Following is what I found:
For 1,ip addr add, netlink is used for communication between user space and kernel space. The handler for this cmd is inet_rtm_newaddr(), then it will call __inet_insert_ifa() in which it will add a new in_ifaddr struct to net_device->(in_device *)ip_ptr-> (in_ifaddr *) ifa_list.
For 2,ifconifg ethn:m, ioctl is used. Call chain is: inet_ioctl->devinet_ioctl -> inet_set_ifa -> inet_insert_ifa -> __inet_insert_ifa.
It seems that there is no difference. But I have been told they are different.
Where is the difference?
Thanks in advantage.