Skip to content

Commit

Permalink
*: Convert interface_down to interface down callback
Browse files Browse the repository at this point in the history
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
  • Loading branch information
donaldsharp committed Sep 19, 2019
1 parent 6d37708 commit cbe89e9
Show file tree
Hide file tree
Showing 28 changed files with 106 additions and 290 deletions.
13 changes: 1 addition & 12 deletions babeld/babel_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,10 @@ babel_interface_up (ZAPI_CALLBACK_ARGS)
}

int
babel_interface_down (ZAPI_CALLBACK_ARGS)
babel_ifp_down(struct interface *ifp)
{
struct stream *s = NULL;
struct interface *ifp = NULL;

debugf(BABEL_DEBUG_IF, "receive a 'interface down'");

s = zclient->ibuf;
ifp = zebra_interface_state_read(s, vrf_id); /* it updates iflist */

if (ifp == NULL) {
return 0;
}
Expand Down Expand Up @@ -1256,11 +1250,6 @@ int babel_ifp_up(struct interface *ifp)
return 0;
}

int babel_ifp_down(struct interface *ifp)
{
return 0;
}

int babel_ifp_destroy(struct interface *ifp)
{
return 0;
Expand Down
1 change: 0 additions & 1 deletion babeld/babel_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ void babelz_zebra_init(void)

zclient->zebra_connected = babel_zebra_connected;
zclient->interface_delete = babel_interface_delete;
zclient->interface_down = babel_interface_down;
zclient->interface_address_add = babel_interface_address_add;
zclient->interface_address_delete = babel_interface_address_delete;
zclient->redistribute_route_add = babel_zebra_read_route;
Expand Down
19 changes: 3 additions & 16 deletions bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,27 +253,20 @@ static int bgp_ifp_up(struct interface *ifp)
return 0;
}

static int bgp_interface_down(ZAPI_CALLBACK_ARGS)
static int bgp_ifp_down(struct interface *ifp)
{
struct stream *s;
struct interface *ifp;
struct connected *c;
struct nbr_connected *nc;
struct listnode *node, *nnode;
struct bgp *bgp;
struct peer *peer;

bgp = bgp_lookup_by_vrf_id(vrf_id);

s = zclient->ibuf;
ifp = zebra_interface_state_read(s, vrf_id);
if (!ifp)
return 0;
bgp = bgp_lookup_by_vrf_id(ifp->vrf_id);

bgp_mac_del_mac_entry(ifp);

if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("Rx Intf down VRF %u IF %s", vrf_id, ifp->name);
zlog_debug("Rx Intf down VRF %u IF %s", ifp->vrf_id, ifp->name);

if (!bgp)
return 0;
Expand Down Expand Up @@ -2707,11 +2700,6 @@ static int bgp_ifp_create(struct interface *ifp)
return 0;
}

static int bgp_ifp_down(struct interface *ifp)
{
return 0;
}

static int bgp_ifp_destroy(struct interface *ifp)
{
return 0;
Expand All @@ -2738,7 +2726,6 @@ void bgp_zebra_init(struct thread_master *master, unsigned short instance)
zclient->interface_vrf_update = bgp_interface_vrf_update;
zclient->redistribute_route_add = zebra_read_route;
zclient->redistribute_route_del = zebra_read_route;
zclient->interface_down = bgp_interface_down;
zclient->nexthop_update = bgp_read_nexthop_update;
zclient->import_check_update = bgp_read_import_check_update;
zclient->fec_update = bgp_read_fec_update;
Expand Down
7 changes: 7 additions & 0 deletions eigrpd/eigrp_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ static int eigrp_ifp_up(struct interface *ifp)

static int eigrp_ifp_down(struct interface *ifp)
{
if (IS_DEBUG_EIGRP(zebra, ZEBRA_INTERFACE))
zlog_debug("Zebra: Interface[%s] state change to down.",
ifp->name);

if (ifp->info)
eigrp_if_down(ifp->info);

return 0;
}

Expand Down
21 changes: 0 additions & 21 deletions eigrpd/eigrp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
static int eigrp_interface_delete(ZAPI_CALLBACK_ARGS);
static int eigrp_interface_address_add(ZAPI_CALLBACK_ARGS);
static int eigrp_interface_address_delete(ZAPI_CALLBACK_ARGS);
static int eigrp_interface_state_down(ZAPI_CALLBACK_ARGS);

static int eigrp_zebra_read_route(ZAPI_CALLBACK_ARGS);

Expand Down Expand Up @@ -111,7 +110,6 @@ void eigrp_zebra_init(void)
zclient->zebra_connected = eigrp_zebra_connected;
zclient->router_id_update = eigrp_router_id_update_zebra;
zclient->interface_delete = eigrp_interface_delete;
zclient->interface_down = eigrp_interface_state_down;
zclient->interface_address_add = eigrp_interface_address_add;
zclient->interface_address_delete = eigrp_interface_address_delete;
zclient->redistribute_route_add = eigrp_zebra_read_route;
Expand Down Expand Up @@ -228,25 +226,6 @@ static int eigrp_interface_address_delete(ZAPI_CALLBACK_ARGS)
return 0;
}

static int eigrp_interface_state_down(ZAPI_CALLBACK_ARGS)
{
struct interface *ifp;

ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);

if (ifp == NULL)
return 0;

if (IS_DEBUG_EIGRP(zebra, ZEBRA_INTERFACE))
zlog_debug("Zebra: Interface[%s] state change to down.",
ifp->name);

if (ifp->info)
eigrp_if_down(ifp->info);

return 0;
}

void eigrp_zebra_route_add(struct eigrp *eigrp, struct prefix *p,
struct list *successors, uint32_t distance)
{
Expand Down
7 changes: 7 additions & 0 deletions isisd/isis_circuit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,13 @@ static int isis_ifp_up(struct interface *ifp)

static int isis_ifp_down(struct interface *ifp)
{
struct isis_circuit *circuit;

circuit = isis_csm_state_change(IF_DOWN_FROM_Z,
circuit_scan_by_ifp(ifp), ifp);
if (circuit)
SET_FLAG(circuit->flags, ISIS_CIRCUIT_FLAPPED_AFTER_SPF);

return 0;
}

Expand Down
19 changes: 0 additions & 19 deletions isisd/isis_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,6 @@ static int isis_zebra_if_del(ZAPI_CALLBACK_ARGS)
return 0;
}

static int isis_zebra_if_state_down(ZAPI_CALLBACK_ARGS)
{
struct interface *ifp;
struct isis_circuit *circuit;

ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);

if (ifp == NULL)
return 0;

circuit = isis_csm_state_change(IF_DOWN_FROM_Z,
circuit_scan_by_ifp(ifp), ifp);
if (circuit)
SET_FLAG(circuit->flags, ISIS_CIRCUIT_FLAPPED_AFTER_SPF);

return 0;
}

static int isis_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
{
struct connected *c;
Expand Down Expand Up @@ -358,7 +340,6 @@ void isis_zebra_init(struct thread_master *master)
zclient->zebra_connected = isis_zebra_connected;
zclient->router_id_update = isis_router_id_update_zebra;
zclient->interface_delete = isis_zebra_if_del;
zclient->interface_down = isis_zebra_if_state_down;
zclient->interface_address_add = isis_zebra_if_address_add;
zclient->interface_address_delete = isis_zebra_if_address_del;
zclient->interface_link_params = isis_zebra_link_params;
Expand Down
29 changes: 6 additions & 23 deletions ldpd/ldp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ static void ifc2kaddr(struct interface *, struct connected *,
static int ldp_zebra_send_mpls_labels(int, struct kroute *);
static int ldp_router_id_update(ZAPI_CALLBACK_ARGS);
static int ldp_interface_delete(ZAPI_CALLBACK_ARGS);
static int ldp_interface_status_change(ZAPI_CALLBACK_ARGS);
static int ldp_interface_address_add(ZAPI_CALLBACK_ARGS);
static int ldp_interface_address_delete(ZAPI_CALLBACK_ARGS);
static int ldp_zebra_read_route(ZAPI_CALLBACK_ARGS);
Expand Down Expand Up @@ -329,19 +328,14 @@ ldp_interface_status_change_helper(struct interface *ifp)

return (0);
}
static int
ldp_interface_status_change(ZAPI_CALLBACK_ARGS)
{
struct interface *ifp;

/*
* zebra_interface_state_read() updates interface structure in
* iflist.
*/
ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
if (ifp == NULL)
return (0);
static int ldp_ifp_up(struct interface *ifp)
{
return ldp_interface_status_change_helper(ifp);
}

static int ldp_ifp_down(struct interface *ifp)
{
return ldp_interface_status_change_helper(ifp);
}

Expand Down Expand Up @@ -535,16 +529,6 @@ ldp_zebra_connected(struct zclient *zclient)

extern struct zebra_privs_t ldpd_privs;

static int ldp_ifp_up(struct interface *ifp)
{
return ldp_interface_status_change_helper(ifp);
}

static int ldp_ifp_down(struct interface *ifp)
{
return 0;
}

static int ldp_ifp_destroy(struct interface *ifp)
{
return 0;
Expand All @@ -564,7 +548,6 @@ ldp_zebra_init(struct thread_master *master)
zclient->zebra_connected = ldp_zebra_connected;
zclient->router_id_update = ldp_router_id_update;
zclient->interface_delete = ldp_interface_delete;
zclient->interface_down = ldp_interface_status_change;
zclient->interface_address_add = ldp_interface_address_add;
zclient->interface_address_delete = ldp_interface_address_delete;
zclient->redistribute_route_add = ldp_zebra_read_route;
Expand Down
6 changes: 6 additions & 0 deletions lib/if.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ void if_up_via_zapi(struct interface *ifp)
(*ifp_master.up_hook)(ifp);
}

void if_down_via_zapi(struct interface *ifp)
{
if (ifp_master.down_hook)
(*ifp_master.down_hook)(ifp);
}

struct interface *if_create(const char *name, vrf_id_t vrf_id)
{
return if_create_backend(name, IFINDEX_INTERNAL, vrf_id);
Expand Down
1 change: 1 addition & 0 deletions lib/if.h
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ extern void if_zapi_callbacks(int (*create)(struct interface *ifp),

extern void if_new_via_zapi(struct interface *ifp);
extern void if_up_via_zapi(struct interface *ifp);
extern void if_down_via_zapi(struct interface *ifp);

extern const struct frr_yang_module_info frr_interface_info;

Expand Down
17 changes: 14 additions & 3 deletions lib/zclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,19 @@ static void zclient_interface_up(struct zclient *zclient, vrf_id_t vrf_id)
if_up_via_zapi(ifp);
}

static void zclient_interface_down(struct zclient *zclient, vrf_id_t vrf_id)
{
struct interface *ifp;
struct stream *s = zclient->ibuf;

ifp = zebra_interface_state_read(s, vrf_id);

if (!ifp)
return;

if_down_via_zapi(ifp);
}

static void link_params_set_value(struct stream *s, struct if_link_params *iflp)
{

Expand Down Expand Up @@ -2838,9 +2851,7 @@ static int zclient_read(struct thread *thread)
zclient_interface_up(zclient, vrf_id);
break;
case ZEBRA_INTERFACE_DOWN:
if (zclient->interface_down)
(*zclient->interface_down)(command, zclient, length,
vrf_id);
zclient_interface_down(zclient, vrf_id);
break;
case ZEBRA_INTERFACE_VRF_UPDATE:
if (zclient->interface_vrf_update)
Expand Down
1 change: 0 additions & 1 deletion lib/zclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ struct zclient {
void (*zebra_capabilities)(struct zclient_capabilities *cap);
int (*router_id_update)(ZAPI_CALLBACK_ARGS);
int (*interface_delete)(ZAPI_CALLBACK_ARGS);
int (*interface_down)(ZAPI_CALLBACK_ARGS);
int (*interface_address_add)(ZAPI_CALLBACK_ARGS);
int (*interface_address_delete)(ZAPI_CALLBACK_ARGS);
int (*interface_link_params)(ZAPI_CALLBACK_ARGS);
Expand Down
14 changes: 2 additions & 12 deletions nhrpd/nhrp_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,11 @@ int nhrp_ifp_up(struct interface *ifp)
return 0;
}

int nhrp_interface_down(ZAPI_CALLBACK_ARGS)
int nhrp_ifp_down(struct interface *ifp)
{
struct interface *ifp;

ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
if (ifp == NULL)
return 0;

debugf(NHRP_DEBUG_IF, "if-down: %s", ifp->name);
nhrp_interface_update(ifp);

return 0;
}

Expand Down Expand Up @@ -424,11 +419,6 @@ void nhrp_interface_set_source(struct interface *ifp, const char *ifname)
nhrp_interface_update_nbma(ifp);
}

int nhrp_ifp_down(struct interface *ifp)
{
return 0;
}

int nhrp_ifp_destroy(struct interface *ifp)
{
return 0;
Expand Down
1 change: 0 additions & 1 deletion nhrpd/nhrp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ void nhrp_zebra_init(void)
zclient = zclient_new(master, &zclient_options_default);
zclient->zebra_connected = nhrp_zebra_connected;
zclient->interface_delete = nhrp_interface_delete;
zclient->interface_down = nhrp_interface_down;
zclient->interface_address_add = nhrp_interface_address_add;
zclient->interface_address_delete = nhrp_interface_address_delete;
zclient->redistribute_route_add = nhrp_route_read;
Expand Down
9 changes: 9 additions & 0 deletions ospf6d/ospf6_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -1962,6 +1962,15 @@ static int ospf6_ifp_up(struct interface *ifp)

static int ospf6_ifp_down(struct interface *ifp)
{
if (IS_OSPF6_DEBUG_ZEBRA(RECV))
zlog_debug(
"Zebra Interface state change: "
"%s index %d flags %llx metric %d mtu %d bandwidth %d",
ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
ifp->metric, ifp->mtu6, ifp->bandwidth);

ospf6_interface_state_update(ifp);

return 0;
}

Expand Down
20 changes: 0 additions & 20 deletions ospf6d/ospf6_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,6 @@ static int ospf6_zebra_if_del(ZAPI_CALLBACK_ARGS)
return 0;
}

static int ospf6_zebra_if_state_update(ZAPI_CALLBACK_ARGS)
{
struct interface *ifp;

ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
if (ifp == NULL)
return 0;

if (IS_OSPF6_DEBUG_ZEBRA(RECV))
zlog_debug(
"Zebra Interface state change: "
"%s index %d flags %llx metric %d mtu %d bandwidth %d",
ifp->name, ifp->ifindex, (unsigned long long)ifp->flags,
ifp->metric, ifp->mtu6, ifp->bandwidth);

ospf6_interface_state_update(ifp);
return 0;
}

static int ospf6_zebra_if_address_update_add(ZAPI_CALLBACK_ARGS)
{
struct connected *c;
Expand Down Expand Up @@ -571,7 +552,6 @@ void ospf6_zebra_init(struct thread_master *master)
zclient->zebra_connected = ospf6_zebra_connected;
zclient->router_id_update = ospf6_router_id_update_zebra;
zclient->interface_delete = ospf6_zebra_if_del;
zclient->interface_down = ospf6_zebra_if_state_update;
zclient->interface_address_add = ospf6_zebra_if_address_update_add;
zclient->interface_address_delete =
ospf6_zebra_if_address_update_delete;
Expand Down
Loading

0 comments on commit cbe89e9

Please sign in to comment.