diff options
author | glebius <glebius@FreeBSD.org> | 2005-02-22 14:21:59 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2005-02-22 14:21:59 +0000 |
commit | 53f0cb84a4dbad4e888de3e76e61d475fd5a4ce9 (patch) | |
tree | 6fbcb8fdbd8b9cc40b53d1853f2dcf32f3303cae | |
parent | d552b6fe480d4086e05aa88c4bcf23baf0c470a3 (diff) | |
download | FreeBSD-src-53f0cb84a4dbad4e888de3e76e61d475fd5a4ce9.zip FreeBSD-src-53f0cb84a4dbad4e888de3e76e61d475fd5a4ce9.tar.gz |
- In if_link_state_change() extract function body from if-block, to improve
readability.
- Call carp_carpdev_state() from if_link_state_change() if interface has
associated CARP interface.
Sponsored by: Rambler
-rw-r--r-- | sys/net/if.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 3c25986..675bb2b 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -985,27 +985,33 @@ if_link_state_change(struct ifnet *ifp, int link_state) { int link; - /* Notify that the link state has changed. */ - if (ifp->if_link_state != link_state) { - ifp->if_link_state = link_state; - rt_ifmsg(ifp); - if (link_state == LINK_STATE_UP) - link = NOTE_LINKUP; - else if (link_state == LINK_STATE_DOWN) - link = NOTE_LINKDOWN; - else - link = NOTE_LINKINV; - KNOTE_UNLOCKED(&ifp->if_klist, link); - if (ifp->if_nvlans != 0) - (*vlan_link_state_p)(ifp, link); + /* Return if state hasn't changed. */ + if (ifp->if_link_state == link_state) + return; - if ((ifp->if_type == IFT_ETHER || ifp->if_type == IFT_L2VLAN) && - IFP2AC(ifp)->ac_netgraph != NULL) - (*ng_ether_link_state_p)(ifp, link_state); + ifp->if_link_state = link_state; - log(LOG_NOTICE, "%s: link state changed to %s\n", ifp->if_xname, - (link_state == LINK_STATE_UP) ? "UP" : "DOWN" ); - } + /* Notify that the link state has changed. */ + rt_ifmsg(ifp); + if (link_state == LINK_STATE_UP) + link = NOTE_LINKUP; + else if (link_state == LINK_STATE_DOWN) + link = NOTE_LINKDOWN; + else + link = NOTE_LINKINV; + KNOTE_UNLOCKED(&ifp->if_klist, link); + if (ifp->if_nvlans != 0) + (*vlan_link_state_p)(ifp, link); + + if ((ifp->if_type == IFT_ETHER || ifp->if_type == IFT_L2VLAN) && + IFP2AC(ifp)->ac_netgraph != NULL) + (*ng_ether_link_state_p)(ifp, link_state); +#ifdef DEV_CARP + if (ifp->if_carp) + carp_carpdev_state(ifp->if_carp); +#endif + log(LOG_NOTICE, "%s: link state changed to %s\n", ifp->if_xname, + (link_state == LINK_STATE_UP) ? "UP" : "DOWN" ); } /* |