From 1f7a68a2ff0ba1424131f30112e0cc1572f0bee3 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Tue, 19 May 2020 12:57:08 +0100 Subject: lib, zebra: update interface name at netlink creation the interface name was not present in the hook in charge of updating the interface context to the registered hook service. For that, update the name before informing it. Signed-off-by: Philippe Guibert --- lib/if.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/if.c') diff --git a/lib/if.c b/lib/if.c index 5c0f5e61aa..be6fd1dfeb 100644 --- a/lib/if.c +++ b/lib/if.c @@ -217,14 +217,16 @@ struct interface *if_create_name(const char *name, vrf_id_t vrf_id) return ifp; } -struct interface *if_create_ifindex(ifindex_t ifindex, vrf_id_t vrf_id) +struct interface *if_create_ifindex(ifindex_t ifindex, vrf_id_t vrf_id, + char *optional_name) { struct interface *ifp; ifp = if_new(vrf_id); if_set_index(ifp, ifindex); - + if (optional_name) + if_set_name(ifp, optional_name); hook_call(if_add, ifp); return ifp; } @@ -554,7 +556,8 @@ struct interface *if_get_by_name(const char *name, vrf_id_t vrf_id) return NULL; } -struct interface *if_get_by_ifindex(ifindex_t ifindex, vrf_id_t vrf_id) +struct interface *if_get_by_ifindex(ifindex_t ifindex, vrf_id_t vrf_id, + char *optional_name) { struct interface *ifp; @@ -564,7 +567,7 @@ struct interface *if_get_by_ifindex(ifindex_t ifindex, vrf_id_t vrf_id) ifp = if_lookup_by_ifindex(ifindex, vrf_id); if (ifp) return ifp; - return if_create_ifindex(ifindex, vrf_id); + return if_create_ifindex(ifindex, vrf_id, optional_name); case VRF_BACKEND_VRF_LITE: ifp = if_lookup_by_index_all_vrf(ifindex); if (ifp) { @@ -576,7 +579,7 @@ struct interface *if_get_by_ifindex(ifindex_t ifindex, vrf_id_t vrf_id) if_update_to_new_vrf(ifp, vrf_id); return ifp; } - return if_create_ifindex(ifindex, vrf_id); + return if_create_ifindex(ifindex, vrf_id, optional_name); } return NULL; -- cgit v1.2.3