diff options
author | Jordan Augé <jordan.auge+fdio@cisco.com> | 2019-11-27 00:52:50 +0100 |
---|---|---|
committer | Jordan Augé <jordan.auge+fdio@cisco.com> | 2019-11-27 15:20:55 +0100 |
commit | de378e3805f7be9e6185270f932e3e53beaf01c6 (patch) | |
tree | 7e93058143dcbc7ed5d14844192f0394dc7394af /ctrl/facemgr | |
parent | 9f68d804475a36965f641550b5a0134603776564 (diff) |
[HICN-416] Fix error handling in facemgr netlink interface
Change-Id: Ia04a2f01005ec28a92cc5065ee2f3bddad27f573
Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'ctrl/facemgr')
-rw-r--r-- | ctrl/facemgr/src/interfaces/netlink/netlink.c | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/ctrl/facemgr/src/interfaces/netlink/netlink.c b/ctrl/facemgr/src/interfaces/netlink/netlink.c index 653f49d26..62d4fdf90 100644 --- a/ctrl/facemgr/src/interfaces/netlink/netlink.c +++ b/ctrl/facemgr/src/interfaces/netlink/netlink.c @@ -212,13 +212,22 @@ int parse_link(struct nlmsghdr * h, facelet_t ** facelet, *running = ifi->ifi_flags & IFF_RUNNING; - *facelet = facelet_create(); netdevice_t * netdevice = netdevice_create_from_name(interface_name); - if (!netdevice) - goto ERROR_ND; - int rc = facelet_set_netdevice(*facelet, *netdevice); - if (rc < 0) - goto ERROR; + if (!netdevice) { + ERROR("[netlink.parse_link] error creating netdevice '%s'", interface_name); + goto ERR_ND; + } + + *facelet = facelet_create(); + if (!*facelet) { + ERROR("[netlink.parse_link] error creating facelet"); + goto ERR_FACELET; + } + + if (facelet_set_netdevice(*facelet, *netdevice) < 0) { + ERROR("[netlink.parse_link] error setting netdevice"); + goto ERR; + } // FIXME Tags #if 0 @@ -250,12 +259,12 @@ int parse_link(struct nlmsghdr * h, facelet_t ** facelet, netdevice_free(netdevice); return 0; -ERROR: - netdevice_free(netdevice); -ERROR_ND: +ERR: facelet_free(*facelet); *facelet = NULL; - +ERR_FACELET: + netdevice_free(netdevice); +ERR_ND: return -1; } @@ -316,7 +325,7 @@ int parse_addr(struct nlmsghdr * h, facelet_t ** facelet, netdevice_t * netdevice = netdevice_create_from_index(ifa->ifa_index); if (!netdevice) { ERROR("[netlink.parse_addr] error creating netdevice '%s'", interface_name); - goto ERROR_ND; + goto ERR_ND; } if (interface_name) { @@ -324,28 +333,32 @@ int parse_addr(struct nlmsghdr * h, facelet_t ** facelet, } *facelet = facelet_create(); + if (!*facelet) { + ERROR("[netlink.parse_addr] error creating facelet"); + goto ERR_FACELET; + } if (facelet_set_netdevice(*facelet, *netdevice) < 0) { ERROR("[netlink.parse_addr] error setting netdevice"); - goto ERROR; + goto ERR; } if (facelet_set_family(*facelet, ifa->ifa_family) < 0) { ERROR("[netlink.parse_addr] error setting family"); - goto ERROR; + goto ERR; } if (facelet_set_local_addr(*facelet, local_addr) < 0) { ERROR("[netlink.parse_addr] error setting local address"); - goto ERROR; + goto ERR; } netdevice_free(netdevice); return 0; -ERROR: - netdevice_free(netdevice); -ERROR_ND: +ERR: facelet_free(*facelet); *facelet = NULL; - +ERR_FACELET: + netdevice_free(netdevice); +ERR_ND: return -1; } |