diff options
author | Tom Grennan <tgrennan@vyatta.com> | 2008-04-10 21:56:49 +0000 |
---|---|---|
committer | Tom Grennan <tgrennan@vyatta.com> | 2008-04-10 21:56:49 +0000 |
commit | c1bdabf8dd2f22a33fdc35b70b93e871f179445d (patch) | |
tree | 570e66e842fc556fc643e97aa37e0183ded19f56 /zebra/ioctl.c | |
parent | db59fcc9e02b5755a92e4d2913420c1e09e05517 (diff) | |
parent | 9334b80b2c84f33d0d749b4a172f1d87a77a8544 (diff) | |
download | quagga-c1bdabf8dd2f22a33fdc35b70b93e871f179445d.tar.bz2 quagga-c1bdabf8dd2f22a33fdc35b70b93e871f179445d.tar.xz |
Merge branch 'upstream' into hollywood
Conflicts:
ChangeLog
zebra/zebra_rib.c
Diffstat (limited to 'zebra/ioctl.c')
-rw-r--r-- | zebra/ioctl.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/zebra/ioctl.c b/zebra/ioctl.c index c9ec8d57..d536771a 100644 --- a/zebra/ioctl.c +++ b/zebra/ioctl.c @@ -33,6 +33,10 @@ #include "zebra/rt.h" #include "zebra/interface.h" +#ifdef HAVE_BSD_LINK_DETECT +#include <net/if_media.h> +#endif /* HAVE_BSD_LINK_DETECT*/ + extern struct zebra_privs_t zserv_privs; /* clear and set interface name string */ @@ -192,6 +196,7 @@ if_set_prefix (struct interface *ifp, struct connected *ifc) struct prefix_ipv4 *p; p = (struct prefix_ipv4 *) ifc->address; + rib_lookup_and_pushup (p); memset (&addreq, 0, sizeof addreq); strncpy ((char *)&addreq.ifra_name, ifp->name, sizeof addreq.ifra_name); @@ -344,6 +349,9 @@ if_get_flags (struct interface *ifp) { int ret; struct ifreq ifreq; +#ifdef HAVE_BSD_LINK_DETECT + struct ifmediareq ifmr; +#endif /* HAVE_BSD_LINK_DETECT */ ifreq_set_name (&ifreq, ifp); @@ -353,6 +361,24 @@ if_get_flags (struct interface *ifp) zlog_err("if_ioctl(SIOCGIFFLAGS) failed: %s", safe_strerror(errno)); return; } +#ifdef HAVE_BSD_LINK_DETECT /* Detect BSD link-state at start-up */ + (void) memset(&ifmr, 0, sizeof(ifmr)); + strncpy (&ifmr.ifm_name, ifp->name, IFNAMSIZ); + if (if_ioctl(SIOCGIFMEDIA, (caddr_t) &ifmr) < 0) + { + zlog_err("if_ioctl(SIOCGIFMEDIA) failed: %s", safe_strerror(errno)); + return; + } + if (ifmr.ifm_status & IFM_AVALID) /* Link state is valid */ + { + if (ifmr.ifm_status & IFM_ACTIVE) + SET_FLAG(ifreq.ifr_flags, IFF_RUNNING); + else + UNSET_FLAG(ifreq.ifr_flags, IFF_RUNNING); + } + else /* Force always up */ + SET_FLAG(ifreq.ifr_flags, IFF_RUNNING); +#endif /* HAVE_BSD_LINK_DETECT */ if_flags_update (ifp, (ifreq.ifr_flags & 0x0000ffff)); } |