summaryrefslogtreecommitdiffstats
path: root/pbrd
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2019-09-30 13:46:19 +0200
committerGitHub <noreply@github.com>2019-09-30 13:46:19 +0200
commit9898a2fb3441e7382dba4190233f466b8271deae (patch)
tree9629a5ce665db95addf0d0bc0f46864ef71b5a49 /pbrd
parentMerge pull request #5066 from ak503/libfrr_crash (diff)
parentlib: delete interface if you can in upper level protocol (diff)
downloadfrr-9898a2fb3441e7382dba4190233f466b8271deae.tar.xz
frr-9898a2fb3441e7382dba4190233f466b8271deae.zip
Merge pull request #5009 from donaldsharp/interface_deletion
lib, zebra: Allow for interface deletion when kernel event happens
Diffstat (limited to 'pbrd')
-rw-r--r--pbrd/pbr_main.c2
-rw-r--r--pbrd/pbr_zebra.c40
-rw-r--r--pbrd/pbr_zebra.h6
3 files changed, 12 insertions, 36 deletions
diff --git a/pbrd/pbr_main.c b/pbrd/pbr_main.c
index 246d836ac..bb92703ae 100644
--- a/pbrd/pbr_main.c
+++ b/pbrd/pbr_main.c
@@ -166,6 +166,8 @@ int main(int argc, char **argv, char **envp)
access_list_init();
pbr_nht_init();
pbr_map_init();
+ if_zapi_callbacks(pbr_ifp_create, pbr_ifp_up,
+ pbr_ifp_down, pbr_ifp_destroy);
pbr_zebra_init();
pbr_vty_init();
diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c
index d74d0fcd2..2bba83738 100644
--- a/pbrd/pbr_zebra.c
+++ b/pbrd/pbr_zebra.c
@@ -59,15 +59,8 @@ struct pbr_interface *pbr_if_new(struct interface *ifp)
}
/* Inteface addition message from zebra. */
-static int interface_add(ZAPI_CALLBACK_ARGS)
+int pbr_ifp_create(struct interface *ifp)
{
- struct interface *ifp;
-
- ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
-
- if (!ifp)
- return 0;
-
DEBUGD(&pbr_dbg_zebra,
"%s: %s", __PRETTY_FUNCTION__, ifp->name);
@@ -79,24 +72,11 @@ static int interface_add(ZAPI_CALLBACK_ARGS)
return 0;
}
-static int interface_delete(ZAPI_CALLBACK_ARGS)
+int pbr_ifp_destroy(struct interface *ifp)
{
- struct interface *ifp;
- struct stream *s;
-
- s = zclient->ibuf;
- /* zebra_interface_state_read () updates interface structure in iflist
- */
- ifp = zebra_interface_state_read(s, vrf_id);
-
- if (ifp == NULL)
- return 0;
-
DEBUGD(&pbr_dbg_zebra,
"%s: %s", __PRETTY_FUNCTION__, ifp->name);
- if_set_index(ifp, IFINDEX_INTERNAL);
-
return 0;
}
@@ -133,12 +113,8 @@ static int interface_address_delete(ZAPI_CALLBACK_ARGS)
return 0;
}
-static int interface_state_up(ZAPI_CALLBACK_ARGS)
+int pbr_ifp_up(struct interface *ifp)
{
- struct interface *ifp;
-
- ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
-
DEBUGD(&pbr_dbg_zebra,
"%s: %s is up", __PRETTY_FUNCTION__, ifp->name);
@@ -147,12 +123,8 @@ static int interface_state_up(ZAPI_CALLBACK_ARGS)
return 0;
}
-static int interface_state_down(ZAPI_CALLBACK_ARGS)
+int pbr_ifp_down(struct interface *ifp)
{
- struct interface *ifp;
-
- ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
-
DEBUGD(&pbr_dbg_zebra,
"%s: %s is down", __PRETTY_FUNCTION__, ifp->name);
@@ -447,10 +419,6 @@ void pbr_zebra_init(void)
zclient_init(zclient, ZEBRA_ROUTE_PBR, 0, &pbr_privs);
zclient->zebra_connected = zebra_connected;
- zclient->interface_add = interface_add;
- zclient->interface_delete = interface_delete;
- zclient->interface_up = interface_state_up;
- zclient->interface_down = interface_state_down;
zclient->interface_address_add = interface_address_add;
zclient->interface_address_delete = interface_address_delete;
zclient->route_notify_owner = route_notify_owner;
diff --git a/pbrd/pbr_zebra.h b/pbrd/pbr_zebra.h
index 4cbefe263..d5d938021 100644
--- a/pbrd/pbr_zebra.h
+++ b/pbrd/pbr_zebra.h
@@ -39,4 +39,10 @@ extern void pbr_send_pbr_map(struct pbr_map_sequence *pbrms,
struct pbr_map_interface *pmi, bool install);
extern struct pbr_interface *pbr_if_new(struct interface *ifp);
+
+extern int pbr_ifp_create(struct interface *ifp);
+extern int pbr_ifp_up(struct interface *ifp);
+extern int pbr_ifp_down(struct interface *ifp);
+extern int pbr_ifp_destroy(struct interface *ifp);
+
#endif