summaryrefslogtreecommitdiffstats
path: root/lib/netfilter/nfnl.c
diff options
context:
space:
mode:
authorThomas Graf <tgr@lsx.localdomain>2008-05-14 17:49:44 +0200
committerThomas Graf <tgr@lsx.localdomain>2008-05-14 17:49:44 +0200
commit8a3efffa5b3fde252675239914118664d36a2c24 (patch)
treef8efc71b2bd4736f2a56084efea05d7ee191a422 /lib/netfilter/nfnl.c
parent85f932552e61c5997c1e83fe386098c94d93c273 (diff)
downloadandroid_external_libnl-8a3efffa5b3fde252675239914118664d36a2c24.tar.gz
android_external_libnl-8a3efffa5b3fde252675239914118664d36a2c24.tar.bz2
android_external_libnl-8a3efffa5b3fde252675239914118664d36a2c24.zip
Thread-safe error handling
In order for the interface to become more thread safe, the error handling was revised to no longer depend on a static errno and error string buffer. This patch converts all error paths to return a libnl specific error code which can be translated to a error message using nl_geterror(int error). The functions nl_error() and nl_get_errno() are therefore obsolete. This change required various sets of function prototypes to be changed in order to return an error code, the most prominent are: struct nl_cache *foo_alloc_cache(...); changed to: int foo_alloc_cache(..., struct nl_cache **); struct nl_msg *foo_build_request(...); changed to: int foo_build_request(..., struct nl_msg **); struct foo *foo_parse(...); changed to: int foo_parse(..., struct foo **); This pretty much only leaves trivial allocation functions to still return a pointer object which can still return NULL to signal out of memory. This change is a serious API and ABI breaker, sorry!
Diffstat (limited to 'lib/netfilter/nfnl.c')
-rw-r--r--lib/netfilter/nfnl.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/netfilter/nfnl.c b/lib/netfilter/nfnl.c
index 554e234..2441f69 100644
--- a/lib/netfilter/nfnl.c
+++ b/lib/netfilter/nfnl.c
@@ -6,7 +6,7 @@
* License as published by the Free Software Foundation version 2.1
* of the License.
*
- * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
+ * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
* Copyright (c) 2007 Philip Craig <philipc@snapgear.com>
* Copyright (c) 2007 Secure Computing Corporation
*/
@@ -178,7 +178,7 @@ static int nfnlmsg_append(struct nl_msg *msg, uint8_t family, uint16_t res_id)
nfg = nlmsg_reserve(msg, sizeof(*nfg), NLMSG_ALIGNTO);
if (nfg == NULL)
- return nl_errno(ENOMEM);
+ return -NLE_NOMEM;
nfg->nfgen_family = family;
nfg->version = NFNETLINK_V0;
@@ -236,7 +236,7 @@ int nfnlmsg_put(struct nl_msg *msg, uint32_t pid, uint32_t seq,
nlh = nlmsg_put(msg, pid, seq, NFNLMSG_TYPE(subsys_id, type), 0, flags);
if (nlh == NULL)
- return nl_get_errno();
+ return -NLE_MSGSIZE;
return nfnlmsg_append(msg, family, res_id);
}