Skip to content

Commit 37a5e36

Browse files
committed
error: revert mapping EHOSTUNREACH/ENETDOWN
Earlier commits - 45449e0 ('Add EHOSTUNREACH to nl_syserr2nlerr') - fe74608 ('Add ENETDOWN to nl_syserr2nlerr') introduced NLE_HOSTUNREACH and NLE_NETDOWN. So now failures with those error codes would no longer return NLE_FAILURE. This is a desirable change (in principle), but also an API break. As it causes problems ([1]), gut the change for now. We keep the error defines (and the assigned NLE error numbers), but we no longer map the errno.h codes, which in practice reverts those two changes. This is only an intermediate solution, to revert the break. We should bring this change back, but somehow "better". It's not clear how exactly we can improve the API without breaking it. For example, we could identify a few old functions which must stick to the old behavior, while new functions (or functions where nobody cares) get the new error codes. [1] #433 (comment)
1 parent 3e65a4f commit 37a5e36

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/error.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,21 @@ int nl_syserr2nlerr(int error)
106106
case EBUSY: return NLE_BUSY;
107107
case ERANGE: return NLE_RANGE;
108108
case ENODEV: return NLE_NODEV;
109-
case EHOSTUNREACH: return NLE_HOSTUNREACH;
110-
case ENETDOWN: return NLE_NETDOWN;
109+
110+
/* Historically, NLE_HOSTUNREACH and NLE_NETDOWN did not exit (it was
111+
* all NLE_FAILURE). Introducing a new error code later on was an API
112+
* change, which caused problems:
113+
*
114+
* https://github.com/thom311/libnl/pull/433#issuecomment-3625794675
115+
*
116+
* For now, this change is undone by still map EHOSTUNREACH/ENETDOWN
117+
* to NLE_FAILURE.
118+
*
119+
* We should bring the change back in the future, but do it somehow(?)
120+
* smart to not break existing users. */
121+
case EHOSTUNREACH: return NLE_FAILURE;
122+
case ENETDOWN: return NLE_FAILURE;
123+
111124
default: return NLE_FAILURE;
112125
}
113126
}

0 commit comments

Comments
 (0)