From andykras at hotmail.com Fri Aug 1 09:26:17 2014 From: andykras at hotmail.com (Andrew) Date: Fri, 1 Aug 2014 09:26:17 -0700 Subject: nl_connect EADDRINUSE error after child is forked In-Reply-To: <1406853500.4210.4.camel@hal> References: , <1406853500.4210.4.camel@hal> Message-ID: Thomas, Thanks! That definitely looks like it will take care of the problem I am seeing. I will give it a try and let you know the results. - Andrew ---------------------------------------- > Subject: Re: nl_connect EADDRINUSE error after child is forked > From: thaller at redhat.com > To: andykras at hotmail.com > CC: libnl at lists.infradead.org > Date: Fri, 1 Aug 2014 02:38:20 +0200 > > On Thu, 2014-07-31 at 16:32 -0700, Andrew wrote: >> [Re-send, hopefully with legible formatting] > > it's slightly better ;-) > > > > > >> 2) Implement a "best effort" auto-bind in libnl. > >> Basically, instead of giving up when socket() returns EADDRINUSE on the first available > >> port, try each port marked in the pool as available until the socket() call succeeds or > >> an error other than EADDRINUSE is returned. > > > Yes, this was done upstream, see > https://github.com/thom311/libnl/commit/4dd5fdd0af2c0b7ffe1dbc49313f263dbb2e906f . > > > Try to upgrade to version 3.2.25, or backport this commit. > > Possibly you want to backport all 4 commits that were merged with > https://github.com/thom311/libnl/commit/e21099908f6e22d869b2b8eeb1ffbcc2eff209e4 . > > > > Does that solve your issue? > Thomas > > From andykras at hotmail.com Fri Aug 1 10:23:31 2014 From: andykras at hotmail.com (Andrew) Date: Fri, 1 Aug 2014 10:23:31 -0700 Subject: nl_connect EADDRINUSE error after child is forked In-Reply-To: References: , <1406853500.4210.4.camel@hal>, Message-ID: Thomas, I confirmed that version 3.2.25 of libnl does address this issue. Thanks again, - Andrew ---------------------------------------- > From: andykras at hotmail.com > To: thaller at redhat.com > CC: libnl at lists.infradead.org > Subject: RE: nl_connect EADDRINUSE error after child is forked > Date: Fri, 1 Aug 2014 09:26:17 -0700 > > Thomas, > Thanks! That definitely looks like it will take care of the problem I am seeing. > I will give it a try and let you know the results. > - Andrew > > ---------------------------------------- >> Subject: Re: nl_connect EADDRINUSE error after child is forked >> From: thaller at redhat.com >> To: andykras at hotmail.com >> CC: libnl at lists.infradead.org >> Date: Fri, 1 Aug 2014 02:38:20 +0200 >> >> On Thu, 2014-07-31 at 16:32 -0700, Andrew wrote: >>> [Re-send, hopefully with legible formatting] >> >> it's slightly better ;-) >> >> >> >> >> >>> 2) Implement a "best effort" auto-bind in libnl. >> >>> Basically, instead of giving up when socket() returns EADDRINUSE on the first available >> >>> port, try each port marked in the pool as available until the socket() call succeeds or >> >>> an error other than EADDRINUSE is returned. >> >> >> Yes, this was done upstream, see >> https://github.com/thom311/libnl/commit/4dd5fdd0af2c0b7ffe1dbc49313f263dbb2e906f . >> >> >> Try to upgrade to version 3.2.25, or backport this commit. >> >> Possibly you want to backport all 4 commits that were merged with >> https://github.com/thom311/libnl/commit/e21099908f6e22d869b2b8eeb1ffbcc2eff209e4 . >> >> >> >> Does that solve your issue? >> Thomas >> >> > From thaller at redhat.com Fri Aug 1 10:37:24 2014 From: thaller at redhat.com (Thomas Haller) Date: Fri, 01 Aug 2014 19:37:24 +0200 Subject: nl_connect EADDRINUSE error after child is forked In-Reply-To: References: , <1406853500.4210.4.camel@hal> , Message-ID: <1406914644.4462.0.camel@hal> On Fri, 2014-08-01 at 10:23 -0700, Andrew wrote: > Thomas, > I confirmed that version 3.2.25 of libnl does address this issue. > Thanks again, > - Andrew hi Andrew, Good to know. Thanks for checking. Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: This is a digitally signed message part URL: From cbosdonnat at suse.com Fri Aug 8 08:19:32 2014 From: cbosdonnat at suse.com (Cedric Bosdonnat) Date: Fri, 08 Aug 2014 17:19:32 +0200 Subject: Problem adding a new route Message-ID: <1407511172.2107.5.camel@laptop.localnet> Hi all, I'm trying to netlinkify libvirt a bit more... and I'm having a problem with the route adding function. The code is here: https://github.com/cbosdo/libvirt/commit/b661e278c3dbbff84c9424b4ce56976153c18297 Starting a container with a gateway seems to add it as I can see it in /proc/net/route and with the route tool. However the route doesn't work and 'ip route' doesn't list it. Is there anything obvious I have forgotten? I'm not using the libnl-route, only libnl since I guess we'll have platforms with old versions of libnl. Thanks for the help, -- Cedric From wkevils at gmail.com Thu Aug 14 22:50:14 2014 From: wkevils at gmail.com (Kevin Wilson) Date: Fri, 15 Aug 2014 08:50:14 +0300 Subject: Netlink sockets (SOCK_DGRAM) over a network Message-ID: Hi, According to the manpage (7) of netlink, it is possible to open a netlink socket of type SOCK_DGRAM. My question is: is it possible to have a netlink connection over a LAN, when one side is on machine A and one side is on machine B with SOCK_DGRAM netlink sockets? Regards, Rami From thaller at redhat.com Mon Aug 18 06:24:30 2014 From: thaller at redhat.com (Thomas Haller) Date: Mon, 18 Aug 2014 15:24:30 +0200 Subject: [PATCH 1/1] link: fix memory leaks due to repeated calls to .io_alloc() Message-ID: <1408368270-28313-1-git-send-email-thaller@redhat.com> All the io_alloc() implementation unconditionally allocated new memory, thus leaking memory if called more then once. Fix io_alloc() implementations not to allocate new memory if not needed. This happens for example in link_msg_parser() which first calls rtnl_link_set_type(): #0 macvlan_alloc (link=0x609d50) at route/link/macvlan.c:56 #1 0x00007ffff7b99a78 in rtnl_link_set_type (link=link at entry=0x609d50, type=type at entry=0x609a94 "macvlan") at route/link.c:2233 #2 0x00007ffff7b99c28 in link_msg_parser (ops=, who=, n=, pp=0x7fffffffd870) at route/link.c:547 #3 0x00007ffff7dea109 in nl_cache_parse (ops=0x7ffff7dd8600 , who=0x603338, nlh=0x6098a0, params=0x7fffffffd870) at cache.c:914 #4 0x00007ffff7dea15b in update_msg_parser (msg=, arg=) at cache.c:668 #5 0x00007ffff7def7bf in nl_cb_call (msg=, type=, cb=) at ../include/netlink-private/netlink.h:142 #6 recvmsgs (cb=0x6057a0, sk=0x6034c0) at nl.c:952 #7 nl_recvmsgs_report (sk=sk at entry=0x6034c0, cb=cb at entry=0x6057a0) at nl.c:1003 #8 0x00007ffff7defb79 in nl_recvmsgs (sk=sk at entry=0x6034c0, cb=cb at entry=0x6057a0) at nl.c:1027 #9 0x00007ffff7de9668 in __cache_pickup (sk=0x6034c0, cache=0x603510, param=param at entry=0x7fffffffd870) at cache.c:701 #10 0x00007ffff7dea08d in nl_cache_pickup (sk=, cache=) at cache.c:753 #11 0x0000000000400d56 in main () and later ops->io_parse(): #0 macvlan_alloc (link=0x609d50) at route/link/macvlan.c:56 #1 0x00007ffff7baae9d in macvlan_parse (link=0x609d50, data=, xstats=) at route/link/macvlan.c:79 #2 0x00007ffff7b99c80 in link_msg_parser (ops=, who=, n=, pp=0x7fffffffd870) at route/link.c:567 #3 0x00007ffff7dea109 in nl_cache_parse (ops=0x7ffff7dd8600 , who=0x603338, nlh=0x6098a0, params=0x7fffffffd870) at cache.c:914 #4 0x00007ffff7dea15b in update_msg_parser (msg=, arg=) at cache.c:668 #5 0x00007ffff7def7bf in nl_cb_call (msg=, type=, cb=) at ../include/netlink-private/netlink.h:142 #6 recvmsgs (cb=0x6057a0, sk=0x6034c0) at nl.c:952 #7 nl_recvmsgs_report (sk=sk at entry=0x6034c0, cb=cb at entry=0x6057a0) at nl.c:1003 #8 0x00007ffff7defb79 in nl_recvmsgs (sk=sk at entry=0x6034c0, cb=cb at entry=0x6057a0) at nl.c:1027 #9 0x00007ffff7de9668 in __cache_pickup (sk=0x6034c0, cache=0x603510, param=param at entry=0x7fffffffd870) at cache.c:701 #10 0x00007ffff7dea08d in nl_cache_pickup (sk=, cache=) at cache.c:753 #11 0x0000000000400d56 in main () https://github.com/thom311/libnl/issues/59 Signed-off-by: Thomas Haller --- lib/route/link/can.c | 14 +++++++++----- lib/route/link/ip6tnl.c | 14 +++++++++----- lib/route/link/ipgre.c | 14 +++++++++----- lib/route/link/ipip.c | 14 +++++++++----- lib/route/link/ipvti.c | 14 +++++++++----- lib/route/link/macvlan.c | 10 +++++++--- lib/route/link/sit.c | 14 +++++++++----- lib/route/link/vlan.c | 12 +++++++++--- lib/route/link/vxlan.c | 10 +++++++--- 9 files changed, 77 insertions(+), 39 deletions(-) diff --git a/lib/route/link/can.c b/lib/route/link/can.c index 489119d..4ce554b 100644 --- a/lib/route/link/can.c +++ b/lib/route/link/can.c @@ -73,11 +73,15 @@ static int can_alloc(struct rtnl_link *link) { struct can_info *ci; - ci = calloc(1, sizeof(*ci)); - if (!ci) - return -NLE_NOMEM; - - link->l_info = ci; + if (link->l_info) + memset(link->l_info, 0, sizeof(*ci)); + else { + ci = calloc(1, sizeof(*ci)); + if (!ci) + return -NLE_NOMEM; + + link->l_info = ci; + } return 0; } diff --git a/lib/route/link/ip6tnl.c b/lib/route/link/ip6tnl.c index 26f3507..378b8a3 100644 --- a/lib/route/link/ip6tnl.c +++ b/lib/route/link/ip6tnl.c @@ -73,11 +73,15 @@ static int ip6_tnl_alloc(struct rtnl_link *link) { struct ip6_tnl_info *ip6_tnl; - ip6_tnl = calloc(1, sizeof(*ip6_tnl)); - if (!ip6_tnl) - return -NLE_NOMEM; - - link->l_info = ip6_tnl; + if (link->l_info) + memset(link->l_info, 0, sizeof(*ip6_tnl)); + else { + ip6_tnl = calloc(1, sizeof(*ip6_tnl)); + if (!ip6_tnl) + return -NLE_NOMEM; + + link->l_info = ip6_tnl; + } return 0; } diff --git a/lib/route/link/ipgre.c b/lib/route/link/ipgre.c index 3927ab4..2ff03fc 100644 --- a/lib/route/link/ipgre.c +++ b/lib/route/link/ipgre.c @@ -75,11 +75,15 @@ static int ipgre_alloc(struct rtnl_link *link) { struct ipgre_info *ipgre; - ipgre = calloc(1, sizeof(*ipgre)); - if (!ipgre) - return -NLE_NOMEM; - - link->l_info = ipgre; + if (link->l_info) + memset(link->l_info, 0, sizeof(*ipgre)); + else { + ipgre = calloc(1, sizeof(*ipgre)); + if (!ipgre) + return -NLE_NOMEM; + + link->l_info = ipgre; + } return 0; } diff --git a/lib/route/link/ipip.c b/lib/route/link/ipip.c index ecf86ad..38f8fef 100644 --- a/lib/route/link/ipip.c +++ b/lib/route/link/ipip.c @@ -62,11 +62,15 @@ static int ipip_alloc(struct rtnl_link *link) { struct ipip_info *ipip; - ipip = calloc(1, sizeof(*ipip)); - if (!ipip) - return -NLE_NOMEM; - - link->l_info = ipip; + if (link->l_info) + memset(link->l_info, 0, sizeof(*ipip)); + else { + ipip = calloc(1, sizeof(*ipip)); + if (!ipip) + return -NLE_NOMEM; + + link->l_info = ipip; + } return 0; } diff --git a/lib/route/link/ipvti.c b/lib/route/link/ipvti.c index 71f61c3..b94c573 100644 --- a/lib/route/link/ipvti.c +++ b/lib/route/link/ipvti.c @@ -59,11 +59,15 @@ static int ipvti_alloc(struct rtnl_link *link) { struct ipvti_info *ipvti; - ipvti = calloc(1, sizeof(*ipvti)); - if (!ipvti) - return -NLE_NOMEM; - - link->l_info = ipvti; + if (link->l_info) + memset(link->l_info, 0, sizeof(*ipvti)); + else { + ipvti = calloc(1, sizeof(*ipvti)); + if (!ipvti) + return -NLE_NOMEM; + + link->l_info = ipvti; + } return 0; } diff --git a/lib/route/link/macvlan.c b/lib/route/link/macvlan.c index c3eeb3f..b8380aa 100644 --- a/lib/route/link/macvlan.c +++ b/lib/route/link/macvlan.c @@ -55,10 +55,14 @@ static int macvlan_alloc(struct rtnl_link *link) { struct macvlan_info *mvi; - if ((mvi = calloc(1, sizeof(*mvi))) == NULL) - return -NLE_NOMEM; + if (link->l_info) + memset(link->l_info, 0, sizeof(*mvi)); + else { + if ((mvi = calloc(1, sizeof(*mvi))) == NULL) + return -NLE_NOMEM; - link->l_info = mvi; + link->l_info = mvi; + } return 0; } diff --git a/lib/route/link/sit.c b/lib/route/link/sit.c index 0fc1ecd..788bbb8 100644 --- a/lib/route/link/sit.c +++ b/lib/route/link/sit.c @@ -69,11 +69,15 @@ static int sit_alloc(struct rtnl_link *link) { struct sit_info *sit; - sit = calloc(1, sizeof(*sit)); - if (!sit) - return -NLE_NOMEM; - - link->l_info = sit; + if (link->l_info) + memset(link->l_info, 0, sizeof(*sit)); + else { + sit = calloc(1, sizeof(*sit)); + if (!sit) + return -NLE_NOMEM; + + link->l_info = sit; + } return 0; } diff --git a/lib/route/link/vlan.c b/lib/route/link/vlan.c index f977bc4..9dc0d42 100644 --- a/lib/route/link/vlan.c +++ b/lib/route/link/vlan.c @@ -67,10 +67,16 @@ static int vlan_alloc(struct rtnl_link *link) { struct vlan_info *vi; - if ((vi = calloc(1, sizeof(*vi))) == NULL) - return -NLE_NOMEM; + if (link->l_info) { + vi = link->l_info; + free(vi->vi_egress_qos); + memset(link->l_info, 0, sizeof(*vi)); + } else { + if ((vi = calloc(1, sizeof(*vi))) == NULL) + return -NLE_NOMEM; - link->l_info = vi; + link->l_info = vi; + } return 0; } diff --git a/lib/route/link/vxlan.c b/lib/route/link/vxlan.c index f3e3538..8a9c6e0 100644 --- a/lib/route/link/vxlan.c +++ b/lib/route/link/vxlan.c @@ -91,10 +91,14 @@ static int vxlan_alloc(struct rtnl_link *link) { struct vxlan_info *vxi; - if ((vxi = calloc(1, sizeof(*vxi))) == NULL) - return -NLE_NOMEM; + if (link->l_info) + memset(link->l_info, 0, sizeof(*vxi)); + else { + if ((vxi = calloc(1, sizeof(*vxi))) == NULL) + return -NLE_NOMEM; - link->l_info = vxi; + link->l_info = vxi; + } return 0; } -- 1.9.3 From dcbw at redhat.com Mon Aug 18 08:05:36 2014 From: dcbw at redhat.com (Dan Williams) Date: Mon, 18 Aug 2014 10:05:36 -0500 Subject: Problem adding a new route In-Reply-To: <1407511172.2107.5.camel@laptop.localnet> References: <1407511172.2107.5.camel@laptop.localnet> Message-ID: <1408374336.9920.5.camel@dcbw.local> On Fri, 2014-08-08 at 17:19 +0200, Cedric Bosdonnat wrote: > Hi all, > > I'm trying to netlinkify libvirt a bit more... and I'm having a problem > with the route adding function. > > The code is here: > https://github.com/cbosdo/libvirt/commit/b661e278c3dbbff84c9424b4ce56976153c18297 > > Starting a container with a gateway seems to add it as I can see it > in /proc/net/route and with the route tool. However the route doesn't > work and 'ip route' doesn't list it. > > Is there anything obvious I have forgotten? I'm not using the > libnl-route, only libnl since I guess we'll have platforms with old > versions of libnl. > > Thanks for the help, I can't see anything immediately wrong, about all I can suggest is to dump the message you're creating with libnl and see what it looks like, then modify /sbin/ip to dump it's messages and run the command with it, and compare the two. What I've found is that the kernel often wants a very specific message, and if you don't build that up correctly it'll either reject it or do the wrong thing. Dan From thaller at redhat.com Mon Aug 18 14:25:49 2014 From: thaller at redhat.com (Thomas Haller) Date: Mon, 18 Aug 2014 23:25:49 +0200 Subject: [PATCH 1/1] link: fix memory leaks due to repeated calls to .io_alloc() In-Reply-To: <1408368270-28313-1-git-send-email-thaller@redhat.com> References: <1408368270-28313-1-git-send-email-thaller@redhat.com> Message-ID: <1408397149.3709.9.camel@hal> On Mon, 2014-08-18 at 15:24 +0200, Thomas Haller wrote: > All the io_alloc() implementation unconditionally allocated > new memory, thus leaking memory if called more then once. > Fix io_alloc() implementations not to allocate new memory > if not needed. > > This happens for example in link_msg_parser() which first > calls rtnl_link_set_type(): Note that pull request https://github.com/thom311/libnl/pull/60 proposes a different fix. We could use both approaches. Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: This is a digitally signed message part URL: From cbosdonnat at suse.com Mon Aug 25 08:48:01 2014 From: cbosdonnat at suse.com (Cedric Bosdonnat) Date: Mon, 25 Aug 2014 17:48:01 +0200 Subject: Problem adding a new route In-Reply-To: <1408374336.9920.5.camel@dcbw.local> References: <1407511172.2107.5.camel@laptop.localnet> <1408374336.9920.5.camel@dcbw.local> Message-ID: <1408981681.2115.15.camel@laptop.localnet> Hi Dan, On Mon, 2014-08-18 at 10:05 -0500, Dan Williams wrote: > On Fri, 2014-08-08 at 17:19 +0200, Cedric Bosdonnat wrote: > > Hi all, > > > > I'm trying to netlinkify libvirt a bit more... and I'm having a problem > > with the route adding function. > > > > The code is here: > > https://github.com/cbosdo/libvirt/commit/b661e278c3dbbff84c9424b4ce56976153c18297 > > > > Starting a container with a gateway seems to add it as I can see it > > in /proc/net/route and with the route tool. However the route doesn't > > work and 'ip route' doesn't list it. > > > > Is there anything obvious I have forgotten? I'm not using the > > libnl-route, only libnl since I guess we'll have platforms with old > > versions of libnl. > > > > Thanks for the help, > > I can't see anything immediately wrong, about all I can suggest is to > dump the message you're creating with libnl and see what it looks like, > then modify /sbin/ip to dump it's messages and run the command with it, > and compare the two. What I've found is that the kernel often wants a > very specific message, and if you don't build that up correctly it'll > either reject it or do the wrong thing. Thanks for your idea. Instead of modifying /sbin/ip, I just debugged it: it's pretty convenient to see the actual message before it is sent. This way I found I had some uninitialized values, thus not set to 0 thought they should. Now it works :) -- Cedric From tgraf at suug.ch Mon Aug 25 16:09:06 2014 From: tgraf at suug.ch (Thomas Graf) Date: Tue, 26 Aug 2014 01:09:06 +0200 Subject: [PATCH 0/6] Trivial fixes Message-ID: Thomas Graf (6): Remove pointless N < 0 checks nf: nfnl_*_str2copy_mode() should return int xfrm: Remove unused function __assign_addr() nf: Remove unused function htonll() xfrm: Remove unused variable sp_id and sa_id src: Silence all warnings include/netlink/netfilter/log.h | 2 +- include/netlink/netfilter/queue.h | 2 +- lib/handlers.c | 8 ++++---- lib/netfilter/ct.c | 8 -------- lib/netfilter/log_obj.c | 2 +- lib/netfilter/queue_obj.c | 2 +- lib/route/tc.c | 2 +- lib/xfrm/sa.c | 2 -- lib/xfrm/sp.c | 17 ----------------- src/nf-log.c | 5 ++--- src/nf-queue.c | 5 ++--- src/nl-monitor.c | 3 +-- src/nl-neightbl-list.c | 4 ++-- src/nl-route-get.c | 7 ++----- src/nl-rule-list.c | 4 ++-- 15 files changed, 20 insertions(+), 53 deletions(-) -- 1.9.3 From tgraf at suug.ch Mon Aug 25 16:09:07 2014 From: tgraf at suug.ch (Thomas Graf) Date: Tue, 26 Aug 2014 01:09:07 +0200 Subject: [PATCH 1/6] Remove pointless N < 0 checks In-Reply-To: References: Message-ID: <1608b933cf48a8ad4ae7957ea6d9d80587417ff4.1409008101.git.tgraf@suug.ch> route/tc.c:553:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare] if (id < 0 || id > RTNL_TC_STATS_MAX) Signed-off-by: Thomas Graf --- lib/handlers.c | 8 ++++---- lib/route/tc.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/handlers.c b/lib/handlers.c index a6a97bb..9cf5a96 100644 --- a/lib/handlers.c +++ b/lib/handlers.c @@ -203,7 +203,7 @@ struct nl_cb *nl_cb_alloc(enum nl_cb_kind kind) int i; struct nl_cb *cb; - if (kind < 0 || kind > NL_CB_KIND_MAX) + if (kind > NL_CB_KIND_MAX) return NULL; cb = calloc(1, sizeof(*cb)); @@ -293,10 +293,10 @@ enum nl_cb_type nl_cb_active_type(struct nl_cb *cb) int nl_cb_set(struct nl_cb *cb, enum nl_cb_type type, enum nl_cb_kind kind, nl_recvmsg_msg_cb_t func, void *arg) { - if (type < 0 || type > NL_CB_TYPE_MAX) + if (type > NL_CB_TYPE_MAX) return -NLE_RANGE; - if (kind < 0 || kind > NL_CB_KIND_MAX) + if (kind > NL_CB_KIND_MAX) return -NLE_RANGE; if (kind == NL_CB_CUSTOM) { @@ -343,7 +343,7 @@ int nl_cb_set_all(struct nl_cb *cb, enum nl_cb_kind kind, int nl_cb_err(struct nl_cb *cb, enum nl_cb_kind kind, nl_recvmsg_err_cb_t func, void *arg) { - if (kind < 0 || kind > NL_CB_KIND_MAX) + if (kind > NL_CB_KIND_MAX) return -NLE_RANGE; if (kind == NL_CB_CUSTOM) { diff --git a/lib/route/tc.c b/lib/route/tc.c index 34c3b57..d98991d 100644 --- a/lib/route/tc.c +++ b/lib/route/tc.c @@ -550,7 +550,7 @@ char *rtnl_tc_get_kind(struct rtnl_tc *tc) */ uint64_t rtnl_tc_get_stat(struct rtnl_tc *tc, enum rtnl_tc_stat id) { - if (id < 0 || id > RTNL_TC_STATS_MAX) + if (id > RTNL_TC_STATS_MAX) return 0; return tc->tc_stats[id]; -- 1.9.3 From tgraf at suug.ch Mon Aug 25 16:09:08 2014 From: tgraf at suug.ch (Thomas Graf) Date: Tue, 26 Aug 2014 01:09:08 +0200 Subject: [PATCH 2/6] nf: nfnl_*_str2copy_mode() should return int In-Reply-To: References: Message-ID: ... to be able to return a negative error code for unknown modes. Signed-off-by: Thomas Graf --- include/netlink/netfilter/log.h | 2 +- include/netlink/netfilter/queue.h | 2 +- lib/netfilter/log_obj.c | 2 +- lib/netfilter/queue_obj.c | 2 +- src/nf-log.c | 2 +- src/nf-queue.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/netlink/netfilter/log.h b/include/netlink/netfilter/log.h index 2002fa8..e48eddf 100644 --- a/include/netlink/netfilter/log.h +++ b/include/netlink/netfilter/log.h @@ -58,7 +58,7 @@ extern enum nfnl_log_copy_mode nfnl_log_get_copy_mode(const struct nfnl_log *); extern char * nfnl_log_copy_mode2str(enum nfnl_log_copy_mode, char *, size_t); -extern enum nfnl_log_copy_mode nfnl_log_str2copy_mode(const char *); +extern int nfnl_log_str2copy_mode(const char *); extern void nfnl_log_set_copy_range(struct nfnl_log *, uint32_t); extern int nfnl_log_test_copy_range(const struct nfnl_log *); diff --git a/include/netlink/netfilter/queue.h b/include/netlink/netfilter/queue.h index 664610d..224d469 100644 --- a/include/netlink/netfilter/queue.h +++ b/include/netlink/netfilter/queue.h @@ -54,7 +54,7 @@ extern enum nfnl_queue_copy_mode nfnl_queue_get_copy_mode(const struct nfnl_queu extern char * nfnl_queue_copy_mode2str(enum nfnl_queue_copy_mode, char *, size_t); -extern enum nfnl_queue_copy_mode nfnl_queue_str2copy_mode(const char *); +extern int nfnl_queue_str2copy_mode(const char *); extern void nfnl_queue_set_copy_range(struct nfnl_queue *, uint32_t); diff --git a/lib/netfilter/log_obj.c b/lib/netfilter/log_obj.c index 5e1bf9e..3fdb347 100644 --- a/lib/netfilter/log_obj.c +++ b/lib/netfilter/log_obj.c @@ -69,7 +69,7 @@ char *nfnl_log_copy_mode2str(enum nfnl_log_copy_mode copy_mode, char *buf, ARRAY_SIZE(copy_modes)); } -enum nfnl_log_copy_mode nfnl_log_str2copy_mode(const char *name) +int nfnl_log_str2copy_mode(const char *name) { return __str2type(name, copy_modes, ARRAY_SIZE(copy_modes)); } diff --git a/lib/netfilter/queue_obj.c b/lib/netfilter/queue_obj.c index b51f5ec..36ed3c5 100644 --- a/lib/netfilter/queue_obj.c +++ b/lib/netfilter/queue_obj.c @@ -65,7 +65,7 @@ char *nfnl_queue_copy_mode2str(enum nfnl_queue_copy_mode copy_mode, char *buf, ARRAY_SIZE(copy_modes)); } -enum nfnl_queue_copy_mode nfnl_queue_str2copy_mode(const char *name) +int nfnl_queue_str2copy_mode(const char *name) { return __str2type(name, copy_modes, ARRAY_SIZE(copy_modes)); } diff --git a/src/nf-log.c b/src/nf-log.c index 913ba16..c0cffe0 100644 --- a/src/nf-log.c +++ b/src/nf-log.c @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) struct nl_sock *rt_sock; struct nl_cache *link_cache; struct nfnl_log *log; - enum nfnl_log_copy_mode copy_mode; + int copy_mode; uint32_t copy_range; int err; int family; diff --git a/src/nf-queue.c b/src/nf-queue.c index 922d9c8..7151381 100644 --- a/src/nf-queue.c +++ b/src/nf-queue.c @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) struct nl_sock *rt_sock; struct nl_cache *link_cache; struct nfnl_queue *queue; - enum nfnl_queue_copy_mode copy_mode; + int copy_mode; uint32_t copy_range; int err = 1; int family; -- 1.9.3 From tgraf at suug.ch Mon Aug 25 16:09:09 2014 From: tgraf at suug.ch (Thomas Graf) Date: Tue, 26 Aug 2014 01:09:09 +0200 Subject: [PATCH 3/6] xfrm: Remove unused function __assign_addr() In-Reply-To: References: Message-ID: Signed-off-by: Thomas Graf --- lib/xfrm/sp.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/lib/xfrm/sp.c b/lib/xfrm/sp.c index cf16297..e6ab195 100644 --- a/lib/xfrm/sp.c +++ b/lib/xfrm/sp.c @@ -1296,21 +1296,6 @@ int xfrmnl_sp_set_mark (struct xfrmnl_sp* sp, unsigned int value, unsigned int m return 0; } -static inline int __assign_addr(struct xfrmnl_sp* sp, struct nl_addr **pos, - struct nl_addr *new, int flag) -{ - if (*pos) - nl_addr_put(*pos); - - nl_addr_get(new); - *pos = new; - - sp->ce_mask |= flag; - - return 0; -} - - /** @} */ static struct nl_object_ops xfrm_sp_obj_ops = { -- 1.9.3 From tgraf at suug.ch Mon Aug 25 16:09:10 2014 From: tgraf at suug.ch (Thomas Graf) Date: Tue, 26 Aug 2014 01:09:10 +0200 Subject: [PATCH 4/6] nf: Remove unused function htonll() In-Reply-To: References: Message-ID: <5c53b198dc4f365c682ce4181066c195ead98038.1409008101.git.tgraf@suug.ch> Signed-off-by: Thomas Graf --- lib/netfilter/ct.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/netfilter/ct.c b/lib/netfilter/ct.c index 36a83db..903c584 100644 --- a/lib/netfilter/ct.c +++ b/lib/netfilter/ct.c @@ -35,19 +35,11 @@ static uint64_t ntohll(uint64_t x) { return x; } -static uint64_t htonll(uint64_t x) -{ - return x; -} #elif __BYTE_ORDER == __LITTLE_ENDIAN static uint64_t ntohll(uint64_t x) { return bswap_64(x); } -static uint64_t htonll(uint64_t x) -{ - return bswap_64(x); -} #endif static struct nla_policy ct_policy[CTA_MAX+1] = { -- 1.9.3 From tgraf at suug.ch Mon Aug 25 16:09:11 2014 From: tgraf at suug.ch (Thomas Graf) Date: Tue, 26 Aug 2014 01:09:11 +0200 Subject: [PATCH 5/6] xfrm: Remove unused variable sp_id and sa_id In-Reply-To: References: Message-ID: <78d7c4aed9d7c39d237edf6cbaef35ee38ed5115.1409008101.git.tgraf@suug.ch> Cc: Sruthi Yellamraju Signed-off-by: Thomas Graf --- lib/xfrm/sa.c | 2 -- lib/xfrm/sp.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/lib/xfrm/sa.c b/lib/xfrm/sa.c index 07633e5..9b5ea9d 100644 --- a/lib/xfrm/sa.c +++ b/lib/xfrm/sa.c @@ -655,7 +655,6 @@ int xfrmnl_sa_parse(struct nlmsghdr *n, struct xfrmnl_sa **result) struct nlattr *tb[XFRMA_MAX + 1]; struct xfrm_usersa_info* sa_info; struct xfrm_user_expire* ue; - struct xfrm_usersa_id* sa_id; int len, err; struct nl_addr* addr; @@ -675,7 +674,6 @@ int xfrmnl_sa_parse(struct nlmsghdr *n, struct xfrmnl_sa **result) } else if (n->nlmsg_type == XFRM_MSG_DELSA) { - sa_id = nlmsg_data(n); sa_info = (struct xfrm_usersa_info*)(nlmsg_data(n) + sizeof (struct xfrm_usersa_id) + NLA_HDRLEN); } else diff --git a/lib/xfrm/sp.c b/lib/xfrm/sp.c index e6ab195..76cdc61 100644 --- a/lib/xfrm/sp.c +++ b/lib/xfrm/sp.c @@ -518,7 +518,6 @@ int xfrmnl_sp_parse(struct nlmsghdr *n, struct xfrmnl_sp **result) struct xfrmnl_sp *sp; struct nlattr *tb[XFRMA_MAX + 1]; struct xfrm_userpolicy_info *sp_info; - struct xfrm_userpolicy_id *sp_id; int len, err; struct nl_addr* addr; @@ -531,7 +530,6 @@ int xfrmnl_sp_parse(struct nlmsghdr *n, struct xfrmnl_sp **result) sp->ce_msgtype = n->nlmsg_type; if (n->nlmsg_type == XFRM_MSG_DELPOLICY) { - sp_id = nlmsg_data(n); sp_info = (struct xfrm_userpolicy_info*)(nlmsg_data(n) + sizeof (struct xfrm_userpolicy_id) + NLA_HDRLEN); } else -- 1.9.3 From tgraf at suug.ch Mon Aug 25 16:09:12 2014 From: tgraf at suug.ch (Thomas Graf) Date: Tue, 26 Aug 2014 01:09:12 +0200 Subject: [PATCH 6/6] src: Silence all warnings In-Reply-To: References: Message-ID: <7d09ff2792117717e31fcb636bc3328ef45f7196.1409008101.git.tgraf@suug.ch> Signed-off-by: Thomas Graf --- src/nf-log.c | 3 +-- src/nf-queue.c | 3 +-- src/nl-monitor.c | 3 +-- src/nl-neightbl-list.c | 4 ++-- src/nl-route-get.c | 7 ++----- src/nl-rule-list.c | 4 ++-- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/nf-log.c b/src/nf-log.c index c0cffe0..1e2c1e4 100644 --- a/src/nf-log.c +++ b/src/nf-log.c @@ -52,7 +52,6 @@ int main(int argc, char *argv[]) { struct nl_sock *nf_sock; struct nl_sock *rt_sock; - struct nl_cache *link_cache; struct nfnl_log *log; int copy_mode; uint32_t copy_range; @@ -116,7 +115,7 @@ int main(int argc, char *argv[]) rt_sock = nl_cli_alloc_socket(); nl_cli_connect(rt_sock, NETLINK_ROUTE); - link_cache = nl_cli_link_alloc_cache(rt_sock); + nl_cli_link_alloc_cache(rt_sock); while (1) { fd_set rfds; diff --git a/src/nf-queue.c b/src/nf-queue.c index 7151381..b043c80 100644 --- a/src/nf-queue.c +++ b/src/nf-queue.c @@ -60,7 +60,6 @@ static int event_input(struct nl_msg *msg, void *arg) int main(int argc, char *argv[]) { struct nl_sock *rt_sock; - struct nl_cache *link_cache; struct nfnl_queue *queue; int copy_mode; uint32_t copy_range; @@ -116,7 +115,7 @@ int main(int argc, char *argv[]) rt_sock = nl_cli_alloc_socket(); nl_cli_connect(rt_sock, NETLINK_ROUTE); - link_cache = nl_cli_link_alloc_cache(rt_sock); + nl_cli_link_alloc_cache(rt_sock); nl_socket_set_buffer_size(nf_sock, 1024*127, 1024*127); diff --git a/src/nl-monitor.c b/src/nl-monitor.c index fdf6497..16ecac0 100644 --- a/src/nl-monitor.c +++ b/src/nl-monitor.c @@ -35,7 +35,6 @@ static int event_input(struct nl_msg *msg, void *arg) int main(int argc, char *argv[]) { struct nl_sock *sock; - struct nl_cache *link_cache; int err = 1; int i, idx; @@ -92,7 +91,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Warning: Unknown group: %s\n", argv[idx]); } - link_cache = nl_cli_link_alloc_cache(sock); + nl_cli_link_alloc_cache(sock); while (1) { fd_set rfds; diff --git a/src/nl-neightbl-list.c b/src/nl-neightbl-list.c index 5010b92..4c4230f 100644 --- a/src/nl-neightbl-list.c +++ b/src/nl-neightbl-list.c @@ -28,7 +28,7 @@ static void print_usage(void) int main(int argc, char *argv[]) { struct nl_sock *sock; - struct nl_cache *link_cache, *neightbl_cache; + struct nl_cache *neightbl_cache; struct nl_dump_params params = { .dp_type = NL_DUMP_LINE, .dp_fd = stdout, @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) sock = nl_cli_alloc_socket(); nl_cli_connect(sock, NETLINK_ROUTE); - link_cache = nl_cli_link_alloc_cache(sock); + nl_cli_link_alloc_cache(sock); neightbl_cache = nl_cli_alloc_cache(sock, "neighbour table", rtnl_neightbl_alloc_cache); diff --git a/src/nl-route-get.c b/src/nl-route-get.c index 9d9a448..1ee47e4 100644 --- a/src/nl-route-get.c +++ b/src/nl-route-get.c @@ -43,7 +43,6 @@ static int cb(struct nl_msg *msg, void *arg) int main(int argc, char *argv[]) { struct nl_sock *sock; - struct nl_cache *link_cache, *route_cache; struct nl_addr *dst; int err = 1; @@ -52,8 +51,8 @@ int main(int argc, char *argv[]) sock = nl_cli_alloc_socket(); nl_cli_connect(sock, NETLINK_ROUTE); - link_cache = nl_cli_link_alloc_cache(sock); - route_cache = nl_cli_route_alloc_cache(sock, 0); + nl_cli_link_alloc_cache(sock); + nl_cli_route_alloc_cache(sock, 0); dst = nl_cli_addr_parse(argv[1], AF_INET); @@ -83,7 +82,5 @@ int main(int argc, char *argv[]) nl_cli_fatal(err, "%s", nl_geterror(err)); } - //nl_cache_dump(route_cache, ¶ms); - return 0; } diff --git a/src/nl-rule-list.c b/src/nl-rule-list.c index 8b474fa..7c450e2 100644 --- a/src/nl-rule-list.c +++ b/src/nl-rule-list.c @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) { struct nl_sock *sock; struct rtnl_rule *rule; - struct nl_cache *link_cache, *rule_cache; + struct nl_cache *rule_cache; struct nl_dump_params params = { .dp_fd = stdout, .dp_type = NL_DUMP_LINE, @@ -42,7 +42,7 @@ int main(int argc, char *argv[]) sock = nl_cli_alloc_socket(); nl_cli_connect(sock, NETLINK_ROUTE); - link_cache = nl_cli_link_alloc_cache(sock); + nl_cli_link_alloc_cache(sock); rule_cache = nl_cli_rule_alloc_cache(sock); rule = nl_cli_rule_alloc(); -- 1.9.3 From tgraf at suug.ch Mon Aug 25 17:08:21 2014 From: tgraf at suug.ch (Thomas Graf) Date: Tue, 26 Aug 2014 02:08:21 +0200 Subject: [PATCH] build: Add continuous integration support via travis-ci Message-ID: This allows any libnl github repo to link to travis-ci which will result in new commits and pull requests to be automatically built with both gcc and clang. Any build failures including the addition of warnings are reported to the author and committer. Signed-off-by: Thomas Graf --- .travis.yml | 8 ++++++++ .travis/run.sh | 9 +++++++++ 2 files changed, 17 insertions(+) create mode 100644 .travis.yml create mode 100755 .travis/run.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..efc8ae5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: c +compiler: + - gcc + - clang + +before_install: + +script: ./.travis/run.sh diff --git a/.travis/run.sh b/.travis/run.sh new file mode 100755 index 0000000..c204cb8 --- /dev/null +++ b/.travis/run.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +CFLAGS="-Werror" + +if [ $CC = "clang" ]; then + CFLAGS="$CFLAGS -Wno-error=unused-command-line-argument" +fi + +./autogen.sh && ./configure && make CFLAGS="$FLAGS" -- 1.9.3 From tgraf at suug.ch Mon Aug 25 17:11:30 2014 From: tgraf at suug.ch (Thomas Graf) Date: Tue, 26 Aug 2014 01:11:30 +0100 Subject: [PATCH] build: Add continuous integration support via travis-ci In-Reply-To: References: Message-ID: <20140826001130.GB9152@casper.infradead.org> On 08/26/14 at 02:08am, Thomas Graf wrote: > This allows any libnl github repo to link to travis-ci which > will result in new commits and pull requests to be automatically > built with both gcc and clang. Any build failures including the > addition of warnings are reported to the author and committer. > > Signed-off-by: Thomas Graf An example build report can be found here [0] [0] https://travis-ci.org/tgraf/libnl/builds/33543411 @Thomas: Adding the libnl main repo to travis-ci is as easy as signing into travis-ci.org with your github id, adding the libnl repo and enabling CI builds in the presence of a yml file. From thaller at redhat.com Tue Aug 26 03:00:23 2014 From: thaller at redhat.com (Thomas Haller) Date: Tue, 26 Aug 2014 12:00:23 +0200 Subject: [PATCH 1/6] Remove pointless N < 0 checks In-Reply-To: <1608b933cf48a8ad4ae7957ea6d9d80587417ff4.1409008101.git.tgraf@suug.ch> References: <1608b933cf48a8ad4ae7957ea6d9d80587417ff4.1409008101.git.tgraf@suug.ch> Message-ID: <1409047223.2466.10.camel@hal> On Tue, 2014-08-26 at 01:09 +0200, Thomas Graf wrote: > route/tc.c:553:9: warning: comparison of unsigned enum expression < 0 is > always false [-Wtautological-compare] > if (id < 0 || id > RTNL_TC_STATS_MAX) > > Signed-off-by: Thomas Graf > --- > lib/handlers.c | 8 ++++---- > lib/route/tc.c | 2 +- > 2 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/lib/handlers.c b/lib/handlers.c > index a6a97bb..9cf5a96 100644 > --- a/lib/handlers.c > +++ b/lib/handlers.c > @@ -203,7 +203,7 @@ struct nl_cb *nl_cb_alloc(enum nl_cb_kind kind) > int i; > struct nl_cb *cb; > > - if (kind < 0 || kind > NL_CB_KIND_MAX) > + if (kind > NL_CB_KIND_MAX) > return NULL; Isn't the signedness of enums implementation defined? For NetworkManager we did instead: http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=a2a36d845066a5e3ad1b6d2953993a1a433340ff Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: This is a digitally signed message part URL: From thaller at redhat.com Tue Aug 26 03:03:52 2014 From: thaller at redhat.com (Thomas Haller) Date: Tue, 26 Aug 2014 12:03:52 +0200 Subject: [PATCH 2/6] nf: nfnl_*_str2copy_mode() should return int In-Reply-To: References: Message-ID: <1409047432.2466.12.camel@hal> On Tue, 2014-08-26 at 01:09 +0200, Thomas Graf wrote: > ... to be able to return a negative error code for unknown modes. > > Signed-off-by: Thomas Graf > --- > include/netlink/netfilter/log.h | 2 +- > include/netlink/netfilter/queue.h | 2 +- > lib/netfilter/log_obj.c | 2 +- > lib/netfilter/queue_obj.c | 2 +- > src/nf-log.c | 2 +- > src/nf-queue.c | 2 +- > 6 files changed, 6 insertions(+), 6 deletions(-) isn't this an ABI break? -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: This is a digitally signed message part URL: From tgraf at suug.ch Tue Aug 26 03:06:52 2014 From: tgraf at suug.ch (Thomas Graf) Date: Tue, 26 Aug 2014 11:06:52 +0100 Subject: [PATCH 1/6] Remove pointless N < 0 checks In-Reply-To: <1409047223.2466.10.camel@hal> References: <1608b933cf48a8ad4ae7957ea6d9d80587417ff4.1409008101.git.tgraf@suug.ch> <1409047223.2466.10.camel@hal> Message-ID: <20140826100652.GE9152@casper.infradead.org> On 08/26/14 at 12:00pm, Thomas Haller wrote: > On Tue, 2014-08-26 at 01:09 +0200, Thomas Graf wrote: > > route/tc.c:553:9: warning: comparison of unsigned enum expression < 0 is > > always false [-Wtautological-compare] > > if (id < 0 || id > RTNL_TC_STATS_MAX) > > > > Signed-off-by: Thomas Graf > > --- > > lib/handlers.c | 8 ++++---- > > lib/route/tc.c | 2 +- > > 2 files changed, 5 insertions(+), 5 deletions(-) > > > > diff --git a/lib/handlers.c b/lib/handlers.c > > index a6a97bb..9cf5a96 100644 > > --- a/lib/handlers.c > > +++ b/lib/handlers.c > > @@ -203,7 +203,7 @@ struct nl_cb *nl_cb_alloc(enum nl_cb_kind kind) > > int i; > > struct nl_cb *cb; > > > > - if (kind < 0 || kind > NL_CB_KIND_MAX) > > + if (kind > NL_CB_KIND_MAX) > > return NULL; > > > Isn't the signedness of enums implementation defined? > > For NetworkManager we did instead: > http://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=a2a36d845066a5e3ad1b6d2953993a1a433340ff Casting would be even better. I agree. Feel free to drop this patch of the series and I will resend with casting in place. From tgraf at suug.ch Tue Aug 26 03:21:37 2014 From: tgraf at suug.ch (Thomas Graf) Date: Tue, 26 Aug 2014 11:21:37 +0100 Subject: [PATCH 2/6] nf: nfnl_*_str2copy_mode() should return int In-Reply-To: <1409047432.2466.12.camel@hal> References: <1409047432.2466.12.camel@hal> Message-ID: <20140826102137.GF9152@casper.infradead.org> On 08/26/14 at 12:03pm, Thomas Haller wrote: > On Tue, 2014-08-26 at 01:09 +0200, Thomas Graf wrote: > > ... to be able to return a negative error code for unknown modes. > > > > Signed-off-by: Thomas Graf > > --- > > include/netlink/netfilter/log.h | 2 +- > > include/netlink/netfilter/queue.h | 2 +- > > lib/netfilter/log_obj.c | 2 +- > > lib/netfilter/queue_obj.c | 2 +- > > src/nf-log.c | 2 +- > > src/nf-queue.c | 2 +- > > 6 files changed, 6 insertions(+), 6 deletions(-) > > > isn't this an ABI break? Strictly speaking it is. We should be fine unless we compile with -fshort-enums though. I should have mentioned this in the commit message actually: assuming that enum can translate to anything, I can't see how a caller could correctly check for the -1 error condition. Even if we require the caller to cast, what do we have him cast it to? So either way, we are breaking the ABI in a minor way. Thoughts? From thaller at redhat.com Tue Aug 26 03:40:58 2014 From: thaller at redhat.com (Thomas Haller) Date: Tue, 26 Aug 2014 12:40:58 +0200 Subject: [PATCH 2/6] nf: nfnl_*_str2copy_mode() should return int In-Reply-To: <20140826102137.GF9152@casper.infradead.org> References: <1409047432.2466.12.camel@hal> <20140826102137.GF9152@casper.infradead.org> Message-ID: <1409049658.2466.18.camel@hal> On Tue, 2014-08-26 at 11:21 +0100, Thomas Graf wrote: > On 08/26/14 at 12:03pm, Thomas Haller wrote: > > On Tue, 2014-08-26 at 01:09 +0200, Thomas Graf wrote: > > > ... to be able to return a negative error code for unknown modes. > > > > > > Signed-off-by: Thomas Graf > > > --- > > > include/netlink/netfilter/log.h | 2 +- > > > include/netlink/netfilter/queue.h | 2 +- > > > lib/netfilter/log_obj.c | 2 +- > > > lib/netfilter/queue_obj.c | 2 +- > > > src/nf-log.c | 2 +- > > > src/nf-queue.c | 2 +- > > > 6 files changed, 6 insertions(+), 6 deletions(-) > > > > > > isn't this an ABI break? > > Strictly speaking it is. We should be fine unless we compile > with -fshort-enums though. > > I should have mentioned this in the commit message actually: > assuming that enum can translate to anything, I can't see how > a caller could correctly check for the -1 error condition. > Even if we require the caller to cast, what do we have him cast > it to? shouldn't the correct way be: if (value == (enum nfnl_queue_copy_mode) -1) ... > So either way, we are breaking the ABI in a minor way. > > Thoughts? given that the enum size depends on compiler/compiler options (-fshort-enums), it seems wrong to have them as function arguments/return values in first place. for that reason, we should get rid of enums for that purpose. Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: This is a digitally signed message part URL: From tgraf at suug.ch Tue Aug 26 03:45:35 2014 From: tgraf at suug.ch (Thomas Graf) Date: Tue, 26 Aug 2014 11:45:35 +0100 Subject: [PATCH 2/6] nf: nfnl_*_str2copy_mode() should return int In-Reply-To: <1409049658.2466.18.camel@hal> References: <1409047432.2466.12.camel@hal> <20140826102137.GF9152@casper.infradead.org> <1409049658.2466.18.camel@hal> Message-ID: <20140826104535.GG9152@casper.infradead.org> On 08/26/14 at 12:40pm, Thomas Haller wrote: > On Tue, 2014-08-26 at 11:21 +0100, Thomas Graf wrote: > > On 08/26/14 at 12:03pm, Thomas Haller wrote: > > > On Tue, 2014-08-26 at 01:09 +0200, Thomas Graf wrote: > > > > ... to be able to return a negative error code for unknown modes. > > > > > > > > Signed-off-by: Thomas Graf > > > > --- > > > > include/netlink/netfilter/log.h | 2 +- > > > > include/netlink/netfilter/queue.h | 2 +- > > > > lib/netfilter/log_obj.c | 2 +- > > > > lib/netfilter/queue_obj.c | 2 +- > > > > src/nf-log.c | 2 +- > > > > src/nf-queue.c | 2 +- > > > > 6 files changed, 6 insertions(+), 6 deletions(-) > > > > > > > > > isn't this an ABI break? > > > > Strictly speaking it is. We should be fine unless we compile > > with -fshort-enums though. > > > > I should have mentioned this in the commit message actually: > > assuming that enum can translate to anything, I can't see how > > a caller could correctly check for the -1 error condition. > > Even if we require the caller to cast, what do we have him cast > > it to? > > shouldn't the correct way be: > > if (value == (enum nfnl_queue_copy_mode) -1) I can see that work if the same or a compatible compiler is used for both libnl and the application. I cannot see that work if the compiler of libnl and the compiler of the app choose a different enum size (which would be the ABI breakage reason in the first place). > > So either way, we are breaking the ABI in a minor way. > > > > Thoughts? > > given that the enum size depends on compiler/compiler options > (-fshort-enums), it seems wrong to have them as function > arguments/return values in first place. > > for that reason, we should get rid of enums for > that purpose. Agreed. From thaller at redhat.com Tue Aug 26 03:56:35 2014 From: thaller at redhat.com (Thomas Haller) Date: Tue, 26 Aug 2014 12:56:35 +0200 Subject: [PATCH] build: Add continuous integration support via travis-ci In-Reply-To: <20140826001130.GB9152@casper.infradead.org> References: <20140826001130.GB9152@casper.infradead.org> Message-ID: <1409050595.2466.19.camel@hal> On Tue, 2014-08-26 at 01:11 +0100, Thomas Graf wrote: > On 08/26/14 at 02:08am, Thomas Graf wrote: > > This allows any libnl github repo to link to travis-ci which > > will result in new commits and pull requests to be automatically > > built with both gcc and clang. Any build failures including the > > addition of warnings are reported to the author and committer. > > > > Signed-off-by: Thomas Graf > > An example build report can be found here [0] > > [0] https://travis-ci.org/tgraf/libnl/builds/33543411 > > @Thomas: Adding the libnl main repo to travis-ci is as easy as > signing into travis-ci.org with your github id, adding the libnl > repo and enabling CI builds in the presence of a yml file. merged to master: https://github.com/thom311/libnl/commit/03f3f3c4c0f0a6136a3c30a1e554a53c0a6f3a06 I am trying out travis-ci.org... Nice indeed :) Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: This is a digitally signed message part URL: From thaller at redhat.com Tue Aug 26 04:16:00 2014 From: thaller at redhat.com (Thomas Haller) Date: Tue, 26 Aug 2014 13:16:00 +0200 Subject: [PATCH 0/6] Trivial fixes In-Reply-To: References: Message-ID: <1409051760.2466.20.camel@hal> On Tue, 2014-08-26 at 01:09 +0200, Thomas Graf wrote: > Thomas Graf (6): > Remove pointless N < 0 checks > nf: nfnl_*_str2copy_mode() should return int > xfrm: Remove unused function __assign_addr() > nf: Remove unused function htonll() > xfrm: Remove unused variable sp_id and sa_id > src: Silence all warnings merged all patches as: https://github.com/thom311/libnl/commit/54f6d7d1b376348a710c482e3f6852ffaa8675c3 except: "[PATCH 1/6] Remove pointless N < 0 checks" Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: This is a digitally signed message part URL: From thaller at redhat.com Tue Aug 26 04:48:17 2014 From: thaller at redhat.com (Thomas Haller) Date: Tue, 26 Aug 2014 13:48:17 +0200 Subject: [PATCH 1/1] travis: run `make check` in travis build Message-ID: <1409053697-22150-1-git-send-email-thaller@redhat.com> Test programs are only compiled when running `make check`. Also, fix passing $CFLAGS argument to make. Signed-off-by: Thomas Haller --- Note before we called `make CFLAGS="$FLAGS"`. That seems like a typo. .travis/run.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis/run.sh b/.travis/run.sh index c204cb8..941037a 100755 --- a/.travis/run.sh +++ b/.travis/run.sh @@ -1,9 +1,14 @@ #!/bin/bash +set -e + CFLAGS="-Werror" -if [ $CC = "clang" ]; then +if [ "$CC" = "clang" ]; then CFLAGS="$CFLAGS -Wno-error=unused-command-line-argument" fi -./autogen.sh && ./configure && make CFLAGS="$FLAGS" +./autogen.sh +./configure +make CFLAGS="$CFLAGS" +make CFLAGS="$CFLAGS" check -- 1.9.3 From tgraf at suug.ch Tue Aug 26 04:53:59 2014 From: tgraf at suug.ch (Thomas Graf) Date: Tue, 26 Aug 2014 12:53:59 +0100 Subject: [PATCH 1/1] travis: run `make check` in travis build In-Reply-To: <1409053697-22150-1-git-send-email-thaller@redhat.com> References: <1409053697-22150-1-git-send-email-thaller@redhat.com> Message-ID: <20140826115359.GA28327@casper.infradead.org> On 08/26/14 at 01:48pm, Thomas Haller wrote: > Test programs are only compiled when running `make check`. > Also, fix passing $CFLAGS argument to make. > > Signed-off-by: Thomas Haller Acked-by: Thomas Graf This will actually make the build fail for now as 1/6 was not merged and clang will complain about the < 0 enum checks. From tgraf at suug.ch Tue Aug 26 05:08:41 2014 From: tgraf at suug.ch (Thomas Graf) Date: Tue, 26 Aug 2014 14:08:41 +0200 Subject: [PATCH v2] Remove pointless N < 0 checks Message-ID: <6add8930d5d145e83eac7216d9973b7de92bd21e.1409054863.git.tgraf@suug.ch> route/tc.c:553:9: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare] if (id < 0 || id > RTNL_TC_STATS_MAX) Signed-off-by: Thomas Graf --- v2: Add cast to unsigned int as suggested by Thomas Haller lib/handlers.c | 8 ++++---- lib/route/tc.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/handlers.c b/lib/handlers.c index a6a97bb..97a0d9c 100644 --- a/lib/handlers.c +++ b/lib/handlers.c @@ -203,7 +203,7 @@ struct nl_cb *nl_cb_alloc(enum nl_cb_kind kind) int i; struct nl_cb *cb; - if (kind < 0 || kind > NL_CB_KIND_MAX) + if ((unsigned int) kind > NL_CB_KIND_MAX) return NULL; cb = calloc(1, sizeof(*cb)); @@ -293,10 +293,10 @@ enum nl_cb_type nl_cb_active_type(struct nl_cb *cb) int nl_cb_set(struct nl_cb *cb, enum nl_cb_type type, enum nl_cb_kind kind, nl_recvmsg_msg_cb_t func, void *arg) { - if (type < 0 || type > NL_CB_TYPE_MAX) + if ((unsigned int) type > NL_CB_TYPE_MAX) return -NLE_RANGE; - if (kind < 0 || kind > NL_CB_KIND_MAX) + if ((unsigned int) kind > NL_CB_KIND_MAX) return -NLE_RANGE; if (kind == NL_CB_CUSTOM) { @@ -343,7 +343,7 @@ int nl_cb_set_all(struct nl_cb *cb, enum nl_cb_kind kind, int nl_cb_err(struct nl_cb *cb, enum nl_cb_kind kind, nl_recvmsg_err_cb_t func, void *arg) { - if (kind < 0 || kind > NL_CB_KIND_MAX) + if ((unsigned int) kind > NL_CB_KIND_MAX) return -NLE_RANGE; if (kind == NL_CB_CUSTOM) { diff --git a/lib/route/tc.c b/lib/route/tc.c index 34c3b57..53b69d5 100644 --- a/lib/route/tc.c +++ b/lib/route/tc.c @@ -550,7 +550,7 @@ char *rtnl_tc_get_kind(struct rtnl_tc *tc) */ uint64_t rtnl_tc_get_stat(struct rtnl_tc *tc, enum rtnl_tc_stat id) { - if (id < 0 || id > RTNL_TC_STATS_MAX) + if ((unsigned int) id > RTNL_TC_STATS_MAX) return 0; return tc->tc_stats[id]; -- 1.9.3 From thaller at redhat.com Tue Aug 26 05:17:06 2014 From: thaller at redhat.com (Thomas Haller) Date: Tue, 26 Aug 2014 14:17:06 +0200 Subject: [PATCH v2] Remove pointless N < 0 checks In-Reply-To: <6add8930d5d145e83eac7216d9973b7de92bd21e.1409054863.git.tgraf@suug.ch> References: <6add8930d5d145e83eac7216d9973b7de92bd21e.1409054863.git.tgraf@suug.ch> Message-ID: <1409055426.22794.0.camel@hal> On Tue, 2014-08-26 at 14:08 +0200, Thomas Graf wrote: > route/tc.c:553:9: warning: comparison of unsigned enum expression < 0 is > always false [-Wtautological-compare] > if (id < 0 || id > RTNL_TC_STATS_MAX) > > Signed-off-by: Thomas Graf > --- > v2: Add cast to unsigned int as suggested by Thomas Haller merged to master: https://github.com/thom311/libnl/commit/7c775184c107b8abd1acd3122c357e0d020376df Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: This is a digitally signed message part URL: From thaller at redhat.com Tue Aug 26 05:17:39 2014 From: thaller at redhat.com (Thomas Haller) Date: Tue, 26 Aug 2014 14:17:39 +0200 Subject: [PATCH 1/1] travis: run `make check` in travis build In-Reply-To: <20140826115359.GA28327@casper.infradead.org> References: <1409053697-22150-1-git-send-email-thaller@redhat.com> <20140826115359.GA28327@casper.infradead.org> Message-ID: <1409055459.22794.1.camel@hal> On Tue, 2014-08-26 at 12:53 +0100, Thomas Graf wrote: > On 08/26/14 at 01:48pm, Thomas Haller wrote: > > Test programs are only compiled when running `make check`. > > Also, fix passing $CFLAGS argument to make. > > > > Signed-off-by: Thomas Haller > > Acked-by: Thomas Graf > > This will actually make the build fail for now as 1/6 was not merged > and clang will complain about the < 0 enum checks. merged to master: https://github.com/thom311/libnl/commit/8cd946a683b81460bbb5e3f62acd5a65225581d7 Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: This is a digitally signed message part URL: From tgraf at suug.ch Wed Aug 27 03:26:35 2014 From: tgraf at suug.ch (Thomas Graf) Date: Wed, 27 Aug 2014 12:26:35 +0200 Subject: [PATCH 0/2] nl-pktloc fixes Message-ID: Thomas Graf (2): utils: Define ARRAY_SIZE() if not yet defined nl-pkt-lookup: Be safe and use ARRAY_SIZE() and strncpy() include/netlink-private/netlink.h | 2 -- include/netlink/utils.h | 4 ++++ src/nl-pktloc-lookup.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) -- 1.9.3 From tgraf at suug.ch Wed Aug 27 03:26:36 2014 From: tgraf at suug.ch (Thomas Graf) Date: Wed, 27 Aug 2014 12:26:36 +0200 Subject: [PATCH 1/2] utils: Define ARRAY_SIZE() if not yet defined In-Reply-To: References: Message-ID: <1fffc5fd4dd16db39c0915e7ef3b91633d25eca2.1409135134.git.tgraf@suug.ch> Allows using ARRAY_SIZE() in src examples Signed-off-by: Thomas Graf --- include/netlink-private/netlink.h | 2 -- include/netlink/utils.h | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h index 39f4dff..dcc3ad2 100644 --- a/include/netlink-private/netlink.h +++ b/include/netlink-private/netlink.h @@ -144,8 +144,6 @@ static inline int nl_cb_call(struct nl_cb *cb, int type, struct nl_msg *msg) return ret; } -#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0])) - /* This is also defined in stddef.h */ #ifndef offsetof #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) diff --git a/include/netlink/utils.h b/include/netlink/utils.h index 6b4b787..9c64eba 100644 --- a/include/netlink/utils.h +++ b/include/netlink/utils.h @@ -118,6 +118,10 @@ enum { }; int nl_has_capability (int capability); +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0])) +#endif + #ifdef __cplusplus } #endif -- 1.9.3 From tgraf at suug.ch Wed Aug 27 03:26:37 2014 From: tgraf at suug.ch (Thomas Graf) Date: Wed, 27 Aug 2014 12:26:37 +0200 Subject: [PATCH 2/2] nl-pkt-lookup: Be safe and use ARRAY_SIZE() and strncpy() In-Reply-To: References: Message-ID: Signed-off-by: Thomas Graf --- src/nl-pktloc-lookup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nl-pktloc-lookup.c b/src/nl-pktloc-lookup.c index 17c867b..b4e8147 100644 --- a/src/nl-pktloc-lookup.c +++ b/src/nl-pktloc-lookup.c @@ -73,8 +73,8 @@ static char *get_align_txt(struct rtnl_pktloc *loc) { static char buf[16]; - if (loc->align <= 4) - strcpy(buf, align_txt[loc->align]); + if (loc->align < ARRAY_SIZE(align_txt)) + strncpy(buf, align_txt[loc->align], sizeof(buf) - 1); else snprintf(buf, sizeof(buf), "%u", loc->align); -- 1.9.3 From thaller at redhat.com Wed Aug 27 04:48:44 2014 From: thaller at redhat.com (Thomas Haller) Date: Wed, 27 Aug 2014 13:48:44 +0200 Subject: [PATCH 1/2] utils: Define ARRAY_SIZE() if not yet defined In-Reply-To: <1fffc5fd4dd16db39c0915e7ef3b91633d25eca2.1409135134.git.tgraf@suug.ch> References: <1fffc5fd4dd16db39c0915e7ef3b91633d25eca2.1409135134.git.tgraf@suug.ch> Message-ID: <1409140124.31739.25.camel@hal> On Wed, 2014-08-27 at 12:26 +0200, Thomas Graf wrote: > Allows using ARRAY_SIZE() in src examples > > Signed-off-by: Thomas Graf > --- > include/netlink-private/netlink.h | 2 -- > include/netlink/utils.h | 4 ++++ > 2 files changed, 4 insertions(+), 2 deletions(-) > > diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h > index 39f4dff..dcc3ad2 100644 > --- a/include/netlink-private/netlink.h > +++ b/include/netlink-private/netlink.h > @@ -144,8 +144,6 @@ static inline int nl_cb_call(struct nl_cb *cb, int type, struct nl_msg *msg) > return ret; > } > > -#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0])) > - > /* This is also defined in stddef.h */ > #ifndef offsetof > #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) > diff --git a/include/netlink/utils.h b/include/netlink/utils.h > index 6b4b787..9c64eba 100644 > --- a/include/netlink/utils.h > +++ b/include/netlink/utils.h > @@ -118,6 +118,10 @@ enum { > }; > int nl_has_capability (int capability); > > +#ifndef ARRAY_SIZE > +#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0])) > +#endif isn't it problematic to define ARRAY_SIZE in our public headers? I feel we should not define anything without our nl specific prefixes. maybe we can add another project-internal (private) header, that can be used by ./src/ too? Thomas -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: This is a digitally signed message part URL: From tgraf at suug.ch Wed Aug 27 04:59:04 2014 From: tgraf at suug.ch (Thomas Graf) Date: Wed, 27 Aug 2014 12:59:04 +0100 Subject: [PATCH 1/2] utils: Define ARRAY_SIZE() if not yet defined In-Reply-To: <1409140124.31739.25.camel@hal> References: <1fffc5fd4dd16db39c0915e7ef3b91633d25eca2.1409135134.git.tgraf@suug.ch> <1409140124.31739.25.camel@hal> Message-ID: <20140827115904.GE13116@casper.infradead.org> On 08/27/14 at 01:48pm, Thomas Haller wrote: > isn't it problematic to define ARRAY_SIZE in our public headers? > > I feel we should not define anything without our nl specific prefixes. > > > maybe we can add another project-internal (private) header, that can be > used by ./src/ too? The issue here is that this should really be part of libc. I thought about the the prefix and I'm fine with that. ARRAY_SIZE() seems pretty well defined which is why I've added the #ifndef. ARRAY_SIZE() was already part of the private header but src/ is supposed to be using the public headers. I would rather add it to pktloc itself than start using private headers widely in src/ From wkevils at gmail.com Sun Aug 31 08:04:53 2014 From: wkevils at gmail.com (Kevin Wilson) Date: Sun, 31 Aug 2014 18:04:53 +0300 Subject: building tests Message-ID: Hello, libnl list, How can I build the modules under the "tests" folder after cloning the latest libnl tree ? it seem that make does not build them. Regards, Kevin W.