diff options
author | Matthieu Boutier <boutier@pps.jussieu.fr> | 2012-01-18 00:52:06 +0100 |
---|---|---|
committer | Paul Jakma <paul@quagga.net> | 2012-03-25 17:06:52 +0100 |
commit | 0ee8a1f1d61ce55642d9164625ab36700fe2c3a9 (patch) | |
tree | 1bb2592f6386b38bb6254cd7d6267a2cde056275 | |
parent | 4eedea551290906fc76f3a0c908ae759e78bb68a (diff) |
babeld: avoid segfault (bug 706).
-rw-r--r-- | babeld/babel_interface.c | 10 | ||||
-rw-r--r-- | babeld/babel_interface.h | 5 |
2 files changed, 14 insertions, 1 deletions
diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index b80bf94e..edfa2b40 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -486,6 +486,13 @@ interface_recalculate(struct interface *ifp) int mtu, rc; struct ipv6_mreq mreq; + if (!if_is_operative(ifp) || !CHECK_FLAG(ifp->flags, IFF_RUNNING)) { + interface_reset(ifp); + return -1; + } + + babel_ifp->flags |= BABEL_IF_IS_UP; + mtu = MIN(ifp->mtu, ifp->mtu6); /* We need to be able to fit at least two messages into a packet, @@ -577,6 +584,9 @@ interface_reset(struct interface *ifp) struct ipv6_mreq mreq; babel_interface_nfo *babel_ifp = babel_get_if_nfo(ifp); + debugf(BABEL_DEBUG_IF, "interface reset: %s", ifp->name); + babel_ifp->flags &= ~BABEL_IF_IS_UP; + flush_interface_routes(ifp, 0); babel_ifp->buffered = 0; babel_ifp->bufsize = 0; diff --git a/babeld/babel_interface.h b/babeld/babel_interface.h index 7a6efb93..d9fb9a4a 100644 --- a/babeld/babel_interface.h +++ b/babeld/babel_interface.h @@ -90,12 +90,15 @@ static inline babel_interface_nfo* babel_get_if_nfo(struct interface *ifp) #define BABEL_IF_SPLIT_HORIZON (1 << 2) #define BABEL_IF_LQ (1 << 3) #define BABEL_IF_IS_ENABLE (1 << 4) +#define BABEL_IF_IS_UP (1 << 5) static inline int if_up(struct interface *ifp) { - return (if_is_up(ifp) && + return (if_is_operative(ifp) && ifp->connected != NULL && + babel_get_if_nfo(ifp) != NULL && + (babel_get_if_nfo(ifp)->flags & BABEL_IF_IS_UP) && (babel_get_if_nfo(ifp)->flags & BABEL_IF_IS_ENABLE)); } |