mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 12:41:21 +00:00
babeld: fix interface bug, simplify code.
Perhaps could it be able to free already free memory (so free(NULL)), in function interface_reset(). On other hand, it initiated untracked interfaces, raising (at least) inappropriate messages. Finally, I remove the BABEL_IF_IS_ENABLE flag, witch was not really usefull. Note the test if_up isn't weaker, because (...IS_UP => ...IS_ENABLE).
This commit is contained in:
parent
6939454359
commit
8c4e57a575
@ -57,6 +57,8 @@ THE SOFTWARE.
|
|||||||
#include "xroute.h"
|
#include "xroute.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define IS_ENABLE(ifp) (babel_enable_if_lookup(ifp->name) >= 0)
|
||||||
|
|
||||||
static int babel_enable_if_lookup (const char *ifname);
|
static int babel_enable_if_lookup (const char *ifname);
|
||||||
static int babel_enable_if_add (const char *ifname);
|
static int babel_enable_if_add (const char *ifname);
|
||||||
static int babel_enable_if_delete (const char *ifname);
|
static int babel_enable_if_delete (const char *ifname);
|
||||||
@ -87,7 +89,7 @@ babel_interface_up (int cmd, struct zclient *client, zebra_size_t length)
|
|||||||
debugf(BABEL_DEBUG_IF, "receive a 'interface up'");
|
debugf(BABEL_DEBUG_IF, "receive a 'interface up'");
|
||||||
|
|
||||||
s = zclient->ibuf;
|
s = zclient->ibuf;
|
||||||
ifp = zebra_interface_state_read(s);
|
ifp = zebra_interface_state_read(s); /* it updates iflist */
|
||||||
|
|
||||||
if (ifp == NULL) {
|
if (ifp == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -106,7 +108,7 @@ babel_interface_down (int cmd, struct zclient *client, zebra_size_t length)
|
|||||||
debugf(BABEL_DEBUG_IF, "receive a 'interface down'");
|
debugf(BABEL_DEBUG_IF, "receive a 'interface down'");
|
||||||
|
|
||||||
s = zclient->ibuf;
|
s = zclient->ibuf;
|
||||||
ifp = zebra_interface_state_read(s);
|
ifp = zebra_interface_state_read(s); /* it updates iflist */
|
||||||
|
|
||||||
if (ifp == NULL) {
|
if (ifp == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -131,14 +133,30 @@ babel_interface_add (int cmd, struct zclient *client, zebra_size_t length)
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface_recalculate(ifp);
|
interface_recalculate(ifp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
babel_interface_delete (int cmd, struct zclient *client, zebra_size_t length)
|
babel_interface_delete (int cmd, struct zclient *client, zebra_size_t length)
|
||||||
{
|
{
|
||||||
|
struct interface *ifp;
|
||||||
|
struct stream *s;
|
||||||
|
|
||||||
debugf(BABEL_DEBUG_IF, "receive a 'interface delete'");
|
debugf(BABEL_DEBUG_IF, "receive a 'interface delete'");
|
||||||
|
|
||||||
|
s = zclient->ibuf;
|
||||||
|
ifp = zebra_interface_state_read(s); /* it updates iflist */
|
||||||
|
|
||||||
|
if (ifp == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (IS_ENABLE(ifp))
|
||||||
|
interface_reset(ifp);
|
||||||
|
|
||||||
|
/* To support pseudo interface do not free interface structure. */
|
||||||
|
/* if_delete(ifp); */
|
||||||
|
ifp->ifindex = IFINDEX_INTERNAL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +260,7 @@ babel_enable_if_add (const char *ifname)
|
|||||||
|
|
||||||
ifp = if_lookup_by_name(ifname);
|
ifp = if_lookup_by_name(ifname);
|
||||||
if (ifp != NULL)
|
if (ifp != NULL)
|
||||||
babel_get_if_nfo(ifp)->flags |= BABEL_IF_IS_ENABLE;
|
interface_recalculate(ifp);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -265,7 +283,7 @@ babel_enable_if_delete (const char *ifname)
|
|||||||
|
|
||||||
ifp = if_lookup_by_name(ifname);
|
ifp = if_lookup_by_name(ifname);
|
||||||
if (ifp != NULL)
|
if (ifp != NULL)
|
||||||
babel_get_if_nfo(ifp)->flags &= ~BABEL_IF_IS_ENABLE;
|
interface_reset(ifp);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -514,6 +532,9 @@ interface_recalculate(struct interface *ifp)
|
|||||||
int mtu, rc;
|
int mtu, rc;
|
||||||
struct ipv6_mreq mreq;
|
struct ipv6_mreq mreq;
|
||||||
|
|
||||||
|
if (!IS_ENABLE(ifp))
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (!if_is_operative(ifp) || !CHECK_FLAG(ifp->flags, IFF_RUNNING)) {
|
if (!if_is_operative(ifp) || !CHECK_FLAG(ifp->flags, IFF_RUNNING)) {
|
||||||
interface_reset(ifp);
|
interface_reset(ifp);
|
||||||
return -1;
|
return -1;
|
||||||
@ -594,13 +615,6 @@ interface_recalculate(struct interface *ifp)
|
|||||||
if(rc > 0)
|
if(rc > 0)
|
||||||
send_update(ifp, 0, NULL, 0);
|
send_update(ifp, 0, NULL, 0);
|
||||||
|
|
||||||
/* Check and set if interface is enable. */
|
|
||||||
if (babel_enable_if_lookup(ifp->name) >= 0) {
|
|
||||||
babel_ifp->flags |= BABEL_IF_IS_ENABLE;
|
|
||||||
} else {
|
|
||||||
babel_ifp->flags &= ~BABEL_IF_IS_ENABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,6 +627,9 @@ interface_reset(struct interface *ifp)
|
|||||||
struct ipv6_mreq mreq;
|
struct ipv6_mreq mreq;
|
||||||
babel_interface_nfo *babel_ifp = babel_get_if_nfo(ifp);
|
babel_interface_nfo *babel_ifp = babel_get_if_nfo(ifp);
|
||||||
|
|
||||||
|
if (!(babel_ifp->flags & BABEL_IF_IS_UP))
|
||||||
|
return 0;
|
||||||
|
|
||||||
debugf(BABEL_DEBUG_IF, "interface reset: %s", ifp->name);
|
debugf(BABEL_DEBUG_IF, "interface reset: %s", ifp->name);
|
||||||
babel_ifp->flags &= ~BABEL_IF_IS_UP;
|
babel_ifp->flags &= ~BABEL_IF_IS_UP;
|
||||||
|
|
||||||
|
@ -99,7 +99,6 @@ static inline babel_interface_nfo* babel_get_if_nfo(struct interface *ifp)
|
|||||||
#define BABEL_IF_SPLIT_HORIZON (1 << 2)
|
#define BABEL_IF_SPLIT_HORIZON (1 << 2)
|
||||||
#define BABEL_IF_LQ (1 << 3)
|
#define BABEL_IF_LQ (1 << 3)
|
||||||
#define BABEL_IF_FARAWAY (1 << 4)
|
#define BABEL_IF_FARAWAY (1 << 4)
|
||||||
#define BABEL_IF_IS_ENABLE (1 << 7)
|
|
||||||
|
|
||||||
/* Only INTERFERING can appear on the wire. */
|
/* Only INTERFERING can appear on the wire. */
|
||||||
#define BABEL_IF_CHANNEL_UNKNOWN 0
|
#define BABEL_IF_CHANNEL_UNKNOWN 0
|
||||||
@ -111,9 +110,7 @@ if_up(struct interface *ifp)
|
|||||||
{
|
{
|
||||||
return (if_is_operative(ifp) &&
|
return (if_is_operative(ifp) &&
|
||||||
ifp->connected != NULL &&
|
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_UP) &&
|
|
||||||
(babel_get_if_nfo(ifp)->flags & BABEL_IF_IS_ENABLE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* types:
|
/* types:
|
||||||
|
Loading…
Reference in New Issue
Block a user