diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-06-29 15:09:23 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-06-29 15:09:23 +0200 |
commit | 16895dbf7314117dc0f5c909de4764fca4a539d2 (patch) | |
tree | 02e9b5acac6f675add11f14b89d211bc7c98df48 /lib/if.c | |
parent | Merge pull request #764 from Jafaral/ospfintaddr (diff) | |
download | frr-16895dbf7314117dc0f5c909de4764fca4a539d2.tar.xz frr-16895dbf7314117dc0f5c909de4764fca4a539d2.zip |
bgpd, lib, zebra: Fix if_update function to represent what it does
The if_update function was taking the interface name as
input and reapplying it, using strncpy to reapply the name.
This has several issues. strncpy should not be used
to copy memory in place. The second issue is that
the interface name is not actually changing when we
update interface to be in the new vrf.
Since every usage of if_update was just reapplying the same
name the interface actually had, just remove that part of
the function and rename it to if_update_to_new_vrf
to represent what it is actually doing.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/if.c')
-rw-r--r-- | lib/if.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -158,7 +158,7 @@ if_create (const char *name, int namelen, vrf_id_t vrf_id) /* Create new interface structure. */ void -if_update (struct interface *ifp, const char *name, int namelen, vrf_id_t vrf_id) +if_update_to_new_vrf (struct interface *ifp, vrf_id_t vrf_id) { struct list *intf_list = vrf_iflist_get (vrf_id); @@ -166,10 +166,6 @@ if_update (struct interface *ifp, const char *name, int namelen, vrf_id_t vrf_id if (vrf_iflist (ifp->vrf_id)) listnode_delete (vrf_iflist (ifp->vrf_id), ifp); - assert (name); - assert (namelen <= INTERFACE_NAMSIZ); /* Need space for '\0' at end. */ - strncpy (ifp->name, name, namelen); - ifp->name[namelen] = '\0'; ifp->vrf_id = vrf_id; if (if_lookup_by_name (ifp->name, vrf_id) == NULL) listnode_add_sort (intf_list, ifp); @@ -453,7 +449,7 @@ if_get_by_name_len (const char *name, size_t namelen, vrf_id_t vrf_id, int vty) } else { - if_update (ifp, name, namelen, vrf_id); + if_update_to_new_vrf (ifp, vrf_id); return ifp; } } |