From b982d2da8f3511f0d21984d70aa18cc6c43338d2 Mon Sep 17 00:00:00 2001 From: Hiroaki KAWAI Date: Wed, 9 Apr 2014 10:09:16 +0900 Subject: [PATCH 1/3] python: fix wrongly passing argument to function in ObjIterator.next() self.__next__() bound method does not take an extra argument. https://github.com/thom311/libnl/pull/57 Signed-off-by: Hiroaki KAWAI Signed-off-by: Thomas Haller (cherry picked from commit cb319e22f5680b49fad62dc7f0eb35b7d737cb3b) --- python/netlink/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/netlink/core.py b/python/netlink/core.py index fbd1c9e..e5864cf 100644 --- a/python/netlink/core.py +++ b/python/netlink/core.py @@ -449,7 +449,7 @@ class ObjIterator(object): return capi.nl_cache_get_next(self._nl_object) def next(self): - return self.__next__(self) + return self.__next__() def __next__(self): if self._end: -- 1.9.0 From a6aab53a1ab360f50947db1b026286647ff94049 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 31 Jan 2014 14:15:13 +0100 Subject: [PATCH 2/3] route: fix return value of nl_rtgen_request() According to documentation, nl_rtgen_request() returns 0 on success, but before it returned the number of bytes sent. Signed-off-by: Thomas Haller (cherry picked from commit b70174668b9867de573cf51471bc98bfe7fd2bc3) --- lib/route/rtnl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/route/rtnl.c b/lib/route/rtnl.c index 82397e9..6a55ca1 100644 --- a/lib/route/rtnl.c +++ b/lib/route/rtnl.c @@ -34,15 +34,20 @@ * Fills out a routing netlink request message and sends it out * using nl_send_simple(). * - * @return 0 on success or a negative error code. + * @return 0 on success or a negative error code. Due to a bug in + * older versions, this returned the number of bytes sent. So for + * compatibility, treat positive return values as success too. */ int nl_rtgen_request(struct nl_sock *sk, int type, int family, int flags) { + int err; struct rtgenmsg gmsg = { .rtgen_family = family, }; - return nl_send_simple(sk, type, flags, &gmsg, sizeof(gmsg)); + err = nl_send_simple(sk, type, flags, &gmsg, sizeof(gmsg)); + + return err >= 0 ? 0 : err; } /** @} */ -- 1.9.0 From 0e0e12bfc306b7f4ca945af6c8c31f1dc5549191 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 19 Feb 2014 19:22:13 +0100 Subject: [PATCH 3/3] utils: fix nl_msec2str() which always returned '0msec' for whole second durations If the duration was without subsecond part, the function always returned '0msec', instead of giving the time in days, hours, minutes or seconds. Regression introduced by commit b3fb89f445108677d405c62865b25aeea209d10a. Signed-off-by: Thomas Haller Acked-by: Thomas Graf (cherry picked from commit 3fb0aae0bc37eafe868d28f0f12ee8803d7ad266) --- lib/utils.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/utils.c b/lib/utils.c index 275138d..267368e 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -551,6 +551,11 @@ char * nl_msec2str(uint64_t msec, char *buf, size_t len) static const char *units[5] = {"d", "h", "m", "s", "msec"}; char * const buf_orig = buf; + if (msec == 0) { + snprintf(buf, len, "0msec"); + return buf_orig; + } + #define _SPLIT(idx, unit) if ((split[idx] = msec / unit)) msec %= unit _SPLIT(0, 86400000); /* days */ _SPLIT(1, 3600000); /* hours */ @@ -559,11 +564,6 @@ char * nl_msec2str(uint64_t msec, char *buf, size_t len) #undef _SPLIT split[4] = msec; - if (msec == 0) { - snprintf(buf, len, "0msec"); - return buf_orig; - } - for (i = 0; i < ARRAY_SIZE(split) && len; i++) { int l; if (split[i] == 0) -- 1.9.0 From a0688f9a6ef3f37cb6908251826d352a8f50d8e5 Mon Sep 17 00:00:00 2001 From: Cong Wang Date: Sun, 23 Mar 2014 12:02:10 -0700 Subject: [PATCH 1/1] act: fix a pointer in rtnl_act_msg_parse() Signed-off-by: Cong Wang Acked-by: Thomas Graf Signed-off-by: Thomas Haller (cherry picked from commit b8d90d9bb19b5d9e4e5f71c4f6bb0eaadd78d7a0) --- lib/route/act.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/route/act.c b/lib/route/act.c index 2bb222b..d3391ec 100644 --- a/lib/route/act.c +++ b/lib/route/act.c @@ -452,7 +452,7 @@ err_free: static int rtnl_act_msg_parse(struct nlmsghdr *n, struct rtnl_act **act) { - struct rtnl_tc *tc = TC_CAST(act); + struct rtnl_tc *tc = TC_CAST(*act); struct nl_cache *link_cache; struct nlattr *tb[TCAA_MAX + 1]; struct tcamsg *tm; -- 1.9.0