Re: [PATCH 2/2] libnl3: Fix ESRCH return types
- From: Dan Williams <dcbw redhat com>
- To: Alfredo Matos <alfredo matos caixamagica pt>
- Cc: networkmanager-list gnome org
- Subject: Re: [PATCH 2/2] libnl3: Fix ESRCH return types
- Date: Tue, 16 Aug 2011 17:00:45 -0500
On Thu, 2011-08-04 at 10:26 +0100, Alfredo Matos wrote:
> ESRCH becomes NLE_OBJ_NOTFOUND. Includes workaround for libnl
> aliased return value where ESRCH is being converted to a generic
> unspecified error by libnl [1].
Applied, thanks!
Dan
> [1] http://git.kernel.org/?p=libs/netlink/libnl.git;a=commit;h=7e9d5f
> ---
> src/nm-netlink-utils.c | 7 ++++++-
> src/nm-system.c | 10 +++++-----
> 2 files changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/src/nm-netlink-utils.c b/src/nm-netlink-utils.c
> index cbdbe6e..bbf6e4d 100644
> --- a/src/nm-netlink-utils.c
> +++ b/src/nm-netlink-utils.c
> @@ -181,7 +181,12 @@ nm_netlink_route_delete (struct rtnl_route *route)
> nlh = nm_netlink_get_default_handle ();
> err = rtnl_route_delete (nlh, route, 0);
> - return (err && (err != -NLE_RANGE)) ? FALSE : TRUE;
> + /* Workaround libnl BUG: ESRCH is aliased to generic NLE_FAILURE
> + * See: http://git.kernel.org/?p=libs/netlink/libnl.git;a=commit;h=7e9d5f */
> + if (err == -NLE_FAILURE)
> + err = -NLE_OBJ_NOTFOUND;
> +
> + return (err && (err != -NLE_OBJ_NOTFOUND)) ? FALSE : TRUE;
> }
> diff --git a/src/nm-system.c b/src/nm-system.c
> index 11e9ad0..d74e0c8 100644
> --- a/src/nm-system.c
> +++ b/src/nm-system.c
> @@ -136,7 +136,7 @@ nm_system_device_set_ip4_route (int ifindex,
> /* Add the route */
> err = rtnl_route_add (nlh, route, 0);
> - if (err == -ESRCH && ip4_gateway) {
> + if (((err == -NLE_OBJ_NOTFOUND) || (err == -NLE_FAILURE)) && ip4_gateway) {
> /* Gateway might be over a bridge; try adding a route to gateway first */
> struct rtnl_route *route2;
> @@ -524,7 +524,7 @@ nm_system_set_ip6_route (int ifindex,
> /* Add the route */
> err = rtnl_route_add (nlh, route, 0);
> - if (err == -ESRCH && ip6_gateway) {
> + if (((err == -NLE_OBJ_NOTFOUND) || (err == -NLE_FAILURE)) && ip6_gateway) {
> /* Gateway might be over a bridge; try adding a route to gateway first */
> struct rtnl_route *route2;
> @@ -953,7 +953,7 @@ nm_system_replace_default_ip4_route_vpn (int ifindex,
> err = replace_default_ip4_route (ifindex, int_gw, mss);
> if (err == 0) {
> return TRUE;
> - } else if (err != -ESRCH) {
> + } else if ((err != -NLE_OBJ_NOTFOUND) && (err != -NLE_FAILURE)) {
> nm_log_err (LOGD_DEVICE | LOGD_IP4,
> "(%s): failed to set IPv4 default route: %d",
> iface, err);
> @@ -999,7 +999,7 @@ nm_system_replace_default_ip4_route (int ifindex, guint32 gw, guint32 mss)
> err = replace_default_ip4_route (ifindex, gw, mss);
> if (err == 0) {
> return TRUE;
> - } else if (err != -ESRCH) {
> + } else if ((err != -NLE_OBJ_NOTFOUND) && (err != -NLE_FAILURE)) {
> nm_log_err (LOGD_DEVICE | LOGD_IP4,
> "(%s): failed to set IPv4 default route: %d",
> iface, err);
> @@ -1141,7 +1141,7 @@ nm_system_replace_default_ip6_route (int ifindex, const struct in6_addr *gw)
> err = replace_default_ip6_route (ifindex, gw);
> if (err == 0)
> return TRUE;
> - if (err != -ESRCH) {
> + if ((err != -NLE_OBJ_NOTFOUND) && (err != -NLE_FAILURE)) {
> nm_log_err (LOGD_DEVICE | LOGD_IP6,
> "(%s): failed to set IPv6 default route: %d",
> iface, err);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]