##summary
When a ip addr is added, two unicat route entries are added to route table.
- a host route entry is added to local table.
The packet to local host will be routed by this route entry. The route still is valid, even the related interface is shut down. - a connected route is added to main table.
It is used to forward the packet to the hosts in the same sub network, it will disappear when interface down - two broad cast routes entry also added.
##broadcast route:
1 | ~ # dmesg -c |
###ip link set eth1 up
1 | ~ # ip link set dev eth1 up |
1 | ~ # ip route show table local |
###two broadcast routes are added.
1 | ~ # ip route list table local <=== two broadcast routes are added to local, a host route(ip_local_in) is added also. |
1 | ~ # ip route list table main <=== |
1 | ~ # ip link set dev eth1 down |
1 | ~ # ip link set dev lo up <== MUST confirm lo up. |
###related source:
in net/ipv4/devinet.c, register_inetaddr_notifier
1 | 178 static BLOCKING_NOTIFIER_HEAD(inetaddr_chain); |
1 | 1190 register_inetaddr_notifier(&fib_inetaddr_notifier); |
- add a hostroute
- add connect route
- add two broadcast for network_address.255|0
net/ipv4/fib_frontend.c
1 | 698 static void fib_magic(int cmd, int type, __be32 dst, int dst_len, struct in_ifaddr *ifa) |