diff options
author | Andrew J. Schorr <ajschorr@alumni.princeton.edu> | 2008-01-10 16:24:32 +0100 |
---|---|---|
committer | Andrew J. Schorr <ajschorr@alumni.princeton.edu> | 2008-01-10 16:24:32 +0100 |
commit | c543a1737173fb438f1d8c06f650b2d0d479f45c (patch) | |
tree | ba940242e22f7e6798e6fd24b19864b5702474db /zebra/kernel_socket.c | |
parent | [link-detect] Static interface routes should behave properly with link-detect. (diff) | |
download | frr-c543a1737173fb438f1d8c06f650b2d0d479f45c.tar.xz frr-c543a1737173fb438f1d8c06f650b2d0d479f45c.zip |
[link-detect] Try to get BSD link-detect to work properly.
2008-01-10 Ingo Flaschberger <if@xip.at>
* configure.ac: Define HAVE_BSD_LINK_DETECT if <net/if_media.h> is
present.
* lib/zebra.h: If HAVE_BSD_LINK_DETECT is defined,
include <net/if_media.h>.
* zebra/ioctl.c: (if_get_flags) If HAVE_BSD_LINK_DETECT, use the
SIOCGIFMEDIA ioctl to ascertain link state.
* zebra/kernel_socket.c: (bsd_linkdetect_translate) New function to
map the ifm_data.ifi_link_state value into the IFF_RUNNING flag.
(ifm_read) Call bsd_linkdetect_translate to fix the IFF_RUNNING
flag before calling if_flags_update.
Diffstat (limited to 'zebra/kernel_socket.c')
-rw-r--r-- | zebra/kernel_socket.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index a91d76f59..cd30631b3 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -295,6 +295,18 @@ ifan_read (struct if_announcemsghdr *ifan) } #endif /* RTM_IFANNOUNCE */ +#ifdef HAVE_BSD_LINK_DETECT +/* BSD link detect translation */ +static void +bsd_linkdetect_translate (struct if_msghdr *ifm) +{ + if (ifm->ifm_data.ifi_link_state >= LINK_STATE_UP) + SET_FLAG(ifm->ifm_flags, IFF_RUNNING); + else + UNSET_FLAG(ifm->ifm_flags, IFF_RUNNING); +} +#endif /* HAVE_BSD_LINK_DETECT */ + /* * Handle struct if_msghdr obtained from reading routing socket or * sysctl (from interface_list). There may or may not be sockaddrs @@ -426,6 +438,11 @@ ifm_read (struct if_msghdr *ifm) * structure with ifindex IFINDEX_INTERNAL. */ ifp->ifindex = ifm->ifm_index; + +#ifdef HAVE_BSD_LINK_DETECT /* translate BSD kernel msg for link-state */ + bsd_linkdetect_translate(ifm); +#endif /* HAVE_BSD_LINK_DETECT */ + if_flags_update (ifp, ifm->ifm_flags); #if defined(__bsdi__) if_kvm_get_mtu (ifp); @@ -453,6 +470,10 @@ ifm_read (struct if_msghdr *ifm) return -1; } +#ifdef HAVE_BSD_LINK_DETECT /* translate BSD kernel msg for link-state */ + bsd_linkdetect_translate(ifm); +#endif /* HAVE_BSD_LINK_DETECT */ + /* update flags and handle operative->inoperative transition, if any */ if_flags_update (ifp, ifm->ifm_flags); |