Skip to content

Commit cbe89e9

Browse files
committed
*: Convert interface_down to interface down callback
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
1 parent 6d37708 commit cbe89e9

28 files changed

Lines changed: 106 additions & 290 deletions

babeld/babel_interface.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,10 @@ babel_interface_up (ZAPI_CALLBACK_ARGS)
8686
}
8787

8888
int
89-
babel_interface_down (ZAPI_CALLBACK_ARGS)
89+
babel_ifp_down(struct interface *ifp)
9090
{
91-
struct stream *s = NULL;
92-
struct interface *ifp = NULL;
93-
9491
debugf(BABEL_DEBUG_IF, "receive a 'interface down'");
9592

96-
s = zclient->ibuf;
97-
ifp = zebra_interface_state_read(s, vrf_id); /* it updates iflist */
98-
9993
if (ifp == NULL) {
10094
return 0;
10195
}
@@ -1256,11 +1250,6 @@ int babel_ifp_up(struct interface *ifp)
12561250
return 0;
12571251
}
12581252

1259-
int babel_ifp_down(struct interface *ifp)
1260-
{
1261-
return 0;
1262-
}
1263-
12641253
int babel_ifp_destroy(struct interface *ifp)
12651254
{
12661255
return 0;

babeld/babel_zebra.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ void babelz_zebra_init(void)
241241

242242
zclient->zebra_connected = babel_zebra_connected;
243243
zclient->interface_delete = babel_interface_delete;
244-
zclient->interface_down = babel_interface_down;
245244
zclient->interface_address_add = babel_interface_address_add;
246245
zclient->interface_address_delete = babel_interface_address_delete;
247246
zclient->redistribute_route_add = babel_zebra_read_route;

bgpd/bgp_zebra.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -253,27 +253,20 @@ static int bgp_ifp_up(struct interface *ifp)
253253
return 0;
254254
}
255255

256-
static int bgp_interface_down(ZAPI_CALLBACK_ARGS)
256+
static int bgp_ifp_down(struct interface *ifp)
257257
{
258-
struct stream *s;
259-
struct interface *ifp;
260258
struct connected *c;
261259
struct nbr_connected *nc;
262260
struct listnode *node, *nnode;
263261
struct bgp *bgp;
264262
struct peer *peer;
265263

266-
bgp = bgp_lookup_by_vrf_id(vrf_id);
267-
268-
s = zclient->ibuf;
269-
ifp = zebra_interface_state_read(s, vrf_id);
270-
if (!ifp)
271-
return 0;
264+
bgp = bgp_lookup_by_vrf_id(ifp->vrf_id);
272265

273266
bgp_mac_del_mac_entry(ifp);
274267

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

278271
if (!bgp)
279272
return 0;
@@ -2707,11 +2700,6 @@ static int bgp_ifp_create(struct interface *ifp)
27072700
return 0;
27082701
}
27092702

2710-
static int bgp_ifp_down(struct interface *ifp)
2711-
{
2712-
return 0;
2713-
}
2714-
27152703
static int bgp_ifp_destroy(struct interface *ifp)
27162704
{
27172705
return 0;
@@ -2738,7 +2726,6 @@ void bgp_zebra_init(struct thread_master *master, unsigned short instance)
27382726
zclient->interface_vrf_update = bgp_interface_vrf_update;
27392727
zclient->redistribute_route_add = zebra_read_route;
27402728
zclient->redistribute_route_del = zebra_read_route;
2741-
zclient->interface_down = bgp_interface_down;
27422729
zclient->nexthop_update = bgp_read_nexthop_update;
27432730
zclient->import_check_update = bgp_read_import_check_update;
27442731
zclient->fec_update = bgp_read_fec_update;

eigrpd/eigrp_interface.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ static int eigrp_ifp_up(struct interface *ifp)
181181

182182
static int eigrp_ifp_down(struct interface *ifp)
183183
{
184+
if (IS_DEBUG_EIGRP(zebra, ZEBRA_INTERFACE))
185+
zlog_debug("Zebra: Interface[%s] state change to down.",
186+
ifp->name);
187+
188+
if (ifp->info)
189+
eigrp_if_down(ifp->info);
190+
184191
return 0;
185192
}
186193

eigrpd/eigrp_zebra.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
static int eigrp_interface_delete(ZAPI_CALLBACK_ARGS);
5757
static int eigrp_interface_address_add(ZAPI_CALLBACK_ARGS);
5858
static int eigrp_interface_address_delete(ZAPI_CALLBACK_ARGS);
59-
static int eigrp_interface_state_down(ZAPI_CALLBACK_ARGS);
6059

6160
static int eigrp_zebra_read_route(ZAPI_CALLBACK_ARGS);
6261

@@ -111,7 +110,6 @@ void eigrp_zebra_init(void)
111110
zclient->zebra_connected = eigrp_zebra_connected;
112111
zclient->router_id_update = eigrp_router_id_update_zebra;
113112
zclient->interface_delete = eigrp_interface_delete;
114-
zclient->interface_down = eigrp_interface_state_down;
115113
zclient->interface_address_add = eigrp_interface_address_add;
116114
zclient->interface_address_delete = eigrp_interface_address_delete;
117115
zclient->redistribute_route_add = eigrp_zebra_read_route;
@@ -228,25 +226,6 @@ static int eigrp_interface_address_delete(ZAPI_CALLBACK_ARGS)
228226
return 0;
229227
}
230228

231-
static int eigrp_interface_state_down(ZAPI_CALLBACK_ARGS)
232-
{
233-
struct interface *ifp;
234-
235-
ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
236-
237-
if (ifp == NULL)
238-
return 0;
239-
240-
if (IS_DEBUG_EIGRP(zebra, ZEBRA_INTERFACE))
241-
zlog_debug("Zebra: Interface[%s] state change to down.",
242-
ifp->name);
243-
244-
if (ifp->info)
245-
eigrp_if_down(ifp->info);
246-
247-
return 0;
248-
}
249-
250229
void eigrp_zebra_route_add(struct eigrp *eigrp, struct prefix *p,
251230
struct list *successors, uint32_t distance)
252231
{

isisd/isis_circuit.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,13 @@ static int isis_ifp_up(struct interface *ifp)
14111411

14121412
static int isis_ifp_down(struct interface *ifp)
14131413
{
1414+
struct isis_circuit *circuit;
1415+
1416+
circuit = isis_csm_state_change(IF_DOWN_FROM_Z,
1417+
circuit_scan_by_ifp(ifp), ifp);
1418+
if (circuit)
1419+
SET_FLAG(circuit->flags, ISIS_CIRCUIT_FLAPPED_AFTER_SPF);
1420+
14141421
return 0;
14151422
}
14161423

isisd/isis_zebra.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,6 @@ static int isis_zebra_if_del(ZAPI_CALLBACK_ARGS)
9898
return 0;
9999
}
100100

101-
static int isis_zebra_if_state_down(ZAPI_CALLBACK_ARGS)
102-
{
103-
struct interface *ifp;
104-
struct isis_circuit *circuit;
105-
106-
ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
107-
108-
if (ifp == NULL)
109-
return 0;
110-
111-
circuit = isis_csm_state_change(IF_DOWN_FROM_Z,
112-
circuit_scan_by_ifp(ifp), ifp);
113-
if (circuit)
114-
SET_FLAG(circuit->flags, ISIS_CIRCUIT_FLAPPED_AFTER_SPF);
115-
116-
return 0;
117-
}
118-
119101
static int isis_zebra_if_address_add(ZAPI_CALLBACK_ARGS)
120102
{
121103
struct connected *c;
@@ -358,7 +340,6 @@ void isis_zebra_init(struct thread_master *master)
358340
zclient->zebra_connected = isis_zebra_connected;
359341
zclient->router_id_update = isis_router_id_update_zebra;
360342
zclient->interface_delete = isis_zebra_if_del;
361-
zclient->interface_down = isis_zebra_if_state_down;
362343
zclient->interface_address_add = isis_zebra_if_address_add;
363344
zclient->interface_address_delete = isis_zebra_if_address_del;
364345
zclient->interface_link_params = isis_zebra_link_params;

ldpd/ldp_zebra.c

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ static void ifc2kaddr(struct interface *, struct connected *,
4040
static int ldp_zebra_send_mpls_labels(int, struct kroute *);
4141
static int ldp_router_id_update(ZAPI_CALLBACK_ARGS);
4242
static int ldp_interface_delete(ZAPI_CALLBACK_ARGS);
43-
static int ldp_interface_status_change(ZAPI_CALLBACK_ARGS);
4443
static int ldp_interface_address_add(ZAPI_CALLBACK_ARGS);
4544
static int ldp_interface_address_delete(ZAPI_CALLBACK_ARGS);
4645
static int ldp_zebra_read_route(ZAPI_CALLBACK_ARGS);
@@ -329,19 +328,14 @@ ldp_interface_status_change_helper(struct interface *ifp)
329328

330329
return (0);
331330
}
332-
static int
333-
ldp_interface_status_change(ZAPI_CALLBACK_ARGS)
334-
{
335-
struct interface *ifp;
336331

337-
/*
338-
* zebra_interface_state_read() updates interface structure in
339-
* iflist.
340-
*/
341-
ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
342-
if (ifp == NULL)
343-
return (0);
332+
static int ldp_ifp_up(struct interface *ifp)
333+
{
334+
return ldp_interface_status_change_helper(ifp);
335+
}
344336

337+
static int ldp_ifp_down(struct interface *ifp)
338+
{
345339
return ldp_interface_status_change_helper(ifp);
346340
}
347341

@@ -535,16 +529,6 @@ ldp_zebra_connected(struct zclient *zclient)
535529

536530
extern struct zebra_privs_t ldpd_privs;
537531

538-
static int ldp_ifp_up(struct interface *ifp)
539-
{
540-
return ldp_interface_status_change_helper(ifp);
541-
}
542-
543-
static int ldp_ifp_down(struct interface *ifp)
544-
{
545-
return 0;
546-
}
547-
548532
static int ldp_ifp_destroy(struct interface *ifp)
549533
{
550534
return 0;
@@ -564,7 +548,6 @@ ldp_zebra_init(struct thread_master *master)
564548
zclient->zebra_connected = ldp_zebra_connected;
565549
zclient->router_id_update = ldp_router_id_update;
566550
zclient->interface_delete = ldp_interface_delete;
567-
zclient->interface_down = ldp_interface_status_change;
568551
zclient->interface_address_add = ldp_interface_address_add;
569552
zclient->interface_address_delete = ldp_interface_address_delete;
570553
zclient->redistribute_route_add = ldp_zebra_read_route;

lib/if.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ void if_up_via_zapi(struct interface *ifp)
187187
(*ifp_master.up_hook)(ifp);
188188
}
189189

190+
void if_down_via_zapi(struct interface *ifp)
191+
{
192+
if (ifp_master.down_hook)
193+
(*ifp_master.down_hook)(ifp);
194+
}
195+
190196
struct interface *if_create(const char *name, vrf_id_t vrf_id)
191197
{
192198
return if_create_backend(name, IFINDEX_INTERNAL, vrf_id);

lib/if.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ extern void if_zapi_callbacks(int (*create)(struct interface *ifp),
565565

566566
extern void if_new_via_zapi(struct interface *ifp);
567567
extern void if_up_via_zapi(struct interface *ifp);
568+
extern void if_down_via_zapi(struct interface *ifp);
568569

569570
extern const struct frr_yang_module_info frr_interface_info;
570571

0 commit comments

Comments
 (0)