summaryrefslogtreecommitdiff
path: root/lib/if.c
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2020-05-19 12:57:08 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2020-05-19 16:02:12 +0200
commit1f7a68a2ff0ba1424131f30112e0cc1572f0bee3 (patch)
tree206d974454a96d215213a62a41f4589b1f603d42 /lib/if.c
parentb575f58bb0ffae3ad67a8f1b6bd09760c310c1cc (diff)
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 <philippe.guibert@6wind.com>
Diffstat (limited to 'lib/if.c')
-rw-r--r--lib/if.c13
1 files changed, 8 insertions, 5 deletions
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;