]> granicus.if.org Git - libnl/log
libnl
4 years agolibnl-3.5.0 release master libnl3_5_0
Thomas Haller [Sun, 1 Sep 2019 14:19:02 +0000 (16:19 +0200)]
libnl-3.5.0 release

4 years agoroute/qdisc: merge branch 'd0u9/htb_64'
Thomas Haller [Sun, 1 Sep 2019 13:57:12 +0000 (15:57 +0200)]
route/qdisc: merge branch 'd0u9/htb_64'

https://github.com/thom311/libnl/pull/205

4 years agoroute/qdisc: adjust API for 64 bit rate/ceil support for htb class
Thomas Haller [Sun, 1 Sep 2019 12:56:19 +0000 (14:56 +0200)]
route/qdisc: adjust API for 64 bit rate/ceil support for htb class

- existing API/ABI must stay unchanged. We cannot change parameter
  types. Ad most we can add new variants that support 64 bit integers.

- rtnl_tc_calc_txtime64() and rtnl_tc_calc_bufsize64() are trivial.
  We should not blow up the public API of libnl for such a thing.
  If the users needs it, they can just reimplement it.

- getters should return an error code. Especially if the return type
  does not support encoding an error there.

- don't add separate rs_rate64/rs_ceil64 field. Instead, extend the
  "rs_rate" field of "struct rtnl_ratespec" to 64 bits. It's internal
  API.

4 years agoAdd 64bit rate/ceil support for htb class
d0u9 [Wed, 31 Oct 2018 05:13:13 +0000 (13:13 +0800)]
Add 64bit rate/ceil support for htb class

Htb class has already supported 64bit rate and ceil settings for times.
Now, in this patch, we grant this ability to libnl library.

4 years agoroute/xfrmi: merge branch 'ebirger/add-xfrmi-support'
Thomas Haller [Sun, 1 Sep 2019 12:39:55 +0000 (14:39 +0200)]
route/xfrmi: merge branch 'ebirger/add-xfrmi-support'

Rebased original pull request #214 on master. One commit ("xfrmi: add
IFLA_XFRM_* definitions to if_link.h") was thereby dropped as it
is no longer necessary. Otherwise, the two remaining patches applied
cleanly. Then, add two more patches to the branch before merging.

https://github.com/thom311/libnl/pull/214

4 years agoroute/trivial: sort entries in "libnl-route-3.sym" asciibetically
Thomas Haller [Sun, 1 Sep 2019 12:29:49 +0000 (14:29 +0200)]
route/trivial: sort entries in "libnl-route-3.sym" asciibetically

4 years agoxfrmi: return error code from getters for XFRM links
Thomas Haller [Sun, 1 Sep 2019 12:38:22 +0000 (14:38 +0200)]
xfrmi: return error code from getters for XFRM links

Returning the value directly as uint32_t does not leave room for an error
code. E.g. we want to indicate to the caller whether the attribute is present
or not (-NLE_NOATTR). Currenlty, the code is quite unforgiving and will just
crash/assert against invalid arguments. In theory, we could also be more forgiving
and return a error code if the link argument is invalid.

4 years agoxfrmi: introduce XFRM interfaces support
Eyal Birger [Sun, 7 Apr 2019 14:09:34 +0000 (17:09 +0300)]
xfrmi: introduce XFRM interfaces support

XFRM interfaces were introduced in kernel 4.19.
This commit adds link support for these interfaces.

Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
4 years agodoc/route: fix example code comments
Eyal Birger [Sun, 7 Apr 2019 14:04:06 +0000 (17:04 +0300)]
doc/route: fix example code comments

Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
4 years agolib: fix error code from nfnl_exp_build_message()
Thomas Haller [Tue, 27 Aug 2019 12:58:35 +0000 (14:58 +0200)]
lib: fix error code from nfnl_exp_build_message()

Otherwise we return success but don't actually set the output
result. This can lead to a crash, in case of out-of-memory.

Found by Coverity.

https://bugzilla.redhat.com/show_bug.cgi?id=1606988

4 years agolib: accept %NULL arguments for nl_addr_cmp()
Thomas Haller [Tue, 27 Aug 2019 12:43:54 +0000 (14:43 +0200)]
lib: accept %NULL arguments for nl_addr_cmp()

Just be more forgiving. Also, this avoids a coverity warning:

    Error: FORWARD_NULL (CWE-476): [#def1]
    libnl-3.4.0/lib/route/addr.c:502: var_compare_op: Comparing "a->a_peer" to null implies that "a->a_peer" might be null.
    libnl-3.4.0/lib/route/addr.c:513: var_deref_model: Passing null pointer "a->a_peer" to "nl_addr_cmp", which dereferences it.
    libnl-3.4.0/lib/addr.c:587:8: deref_parm: Directly dereferencing parameter "a".
    #  585|   int nl_addr_cmp(const struct nl_addr *a, const struct nl_addr *b)
    #  586|   {
    #  587|->  int d = a->a_family - b->a_family;
    #  588|
    #  589|    if (d == 0) {

https://bugzilla.redhat.com/show_bug.cgi?id=1606988

4 years agoidiag: workaround and add comment about idiagnl_send_simple() only handling 8 bit...
Thomas Haller [Mon, 26 Aug 2019 13:49:17 +0000 (15:49 +0200)]
idiag: workaround and add comment about idiagnl_send_simple() only handling 8 bit flags

Related: https://github.com/thom311/libnl/pull/222#issuecomment-521956236

4 years agoSync linux headers to 4.19.66
Michael Forney [Fri, 16 Aug 2019 08:38:22 +0000 (01:38 -0700)]
Sync linux headers to 4.19.66

This fixes the build with musl libc.

Additionally, several changes were made to account for changes to the
headers:

- ip_mp_alg.h was removed, since it was removed in linux commit e06e7c61
  (v2.6.23), and the last use of those constants was removed in libnl
  commit 535e8316.
- Uses of TCF_META_ID_SK_ROUTE_CAPS were updated to
  __TCF_META_ID_SK_ROUTE_CAPS, since it was renamed in linux commit
  e20e6940 (v3.1).
- Uses of IF_CARRIER_DOWN and IF_CARRIER_UP were replaced with their
  values, 0 and 1, since they are not in linux/if.h (they appear to be
  libnl-specific, added in libnl commit 3540e44b).

https://github.com/thom311/libnl/pull/222

4 years agoall: merge branch 'michaelforney/portability'
Thomas Haller [Fri, 16 Aug 2019 05:43:11 +0000 (07:43 +0200)]
all: merge branch 'michaelforney/portability'

https://github.com/thom311/libnl/pull/221

4 years agoroute: Remove stray `;` at top-level
Michael Forney [Thu, 15 Aug 2019 21:30:52 +0000 (14:30 -0700)]
route: Remove stray `;` at top-level

4 years agoall: Use __typeof__ instead of typeof
Michael Forney [Sun, 11 Aug 2019 05:15:37 +0000 (05:15 +0000)]
all: Use __typeof__ instead of typeof

This allows libnl to be built with -std=c99, which prevents the compiler
from using non-reserved identifiers for extensions.

4 years agolib: Don't omit second operand to `?` operator
Michael Forney [Sun, 11 Aug 2019 04:57:33 +0000 (04:57 +0000)]
lib: Don't omit second operand to `?` operator

4 years agolib: Don't return expression in function returning void
Michael Forney [Sun, 11 Aug 2019 04:50:32 +0000 (04:50 +0000)]
lib: Don't return expression in function returning void

4 years agoall: Avoid pointer arithmetic on `void *`
Michael Forney [Sun, 11 Aug 2019 04:49:07 +0000 (04:49 +0000)]
all: Avoid pointer arithmetic on `void *`

ISO C requires that the pointer operand to the binary + operator be to
a complete object type[0].

[0] http://port70.net/~nsz/c/c11/n1570.html#6.5.6p2

4 years agodbg: Use __func__ instead of __PRETTY_FUNCTION__
Michael Forney [Thu, 15 Aug 2019 18:49:51 +0000 (11:49 -0700)]
dbg: Use __func__ instead of __PRETTY_FUNCTION__

These behave the same, except when used at top-level. This can't happen
since the macro body is a statement.

__func__ is standardized since C99, while __PRETTY_FUNCTION__ is a
GNU extension.

4 years agolib/genl: fix allocating buffer of too small size in cmd_msg_parser()
Thomas Haller [Thu, 15 Aug 2019 19:38:57 +0000 (21:38 +0200)]
lib/genl: fix allocating buffer of too small size in cmd_msg_parser()

Fixes: 7d3991b87b59b538cb98a7b11646760f23a7c19b
4 years agoAdd SPDX identifiers
Yegor Yefremov [Thu, 20 Jun 2019 14:33:19 +0000 (16:33 +0200)]
Add SPDX identifiers

Software Package Data Exchange identifiers help to detect source file
licenses and hence simplify the FOSS compliance process.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
https://github.com/thom311/libnl/pull/219

---

FILES=(
  lib/addr.c
  lib/attr.c
  lib/cache.c
  lib/cache_mngr.c
  lib/cache_mngt.c
  lib/data.c
  lib/error.c
  lib/fib_lookup/lookup.c
  lib/fib_lookup/request.c
  lib/genl/ctrl.c
  lib/genl/family.c
  lib/genl/genl.c
  lib/genl/mngt.c
  lib/handlers.c
  lib/hash.c
  lib/hashtable.c
  lib/idiag/idiag.c
  lib/idiag/idiag_meminfo_obj.c
  lib/idiag/idiag_msg_obj.c
  lib/idiag/idiag_req_obj.c
  lib/idiag/idiag_vegasinfo_obj.c
  lib/mpls.c
  lib/msg.c
  lib/netfilter/ct.c
  lib/netfilter/ct_obj.c
  lib/netfilter/exp.c
  lib/netfilter/exp_obj.c
  lib/netfilter/log.c
  lib/netfilter/log_msg.c
  lib/netfilter/log_msg_obj.c
  lib/netfilter/log_obj.c
  lib/netfilter/netfilter.c
  lib/netfilter/nfnl.c
  lib/netfilter/queue.c
  lib/netfilter/queue_msg.c
  lib/netfilter/queue_msg_obj.c
  lib/netfilter/queue_obj.c
  lib/nl.c
  lib/object.c
  lib/route/act.c
  lib/route/addr.c
  lib/route/class.c
  lib/route/classid.c
  lib/route/cls.c
  lib/route/link.c
  lib/route/neigh.c
  lib/route/neightbl.c
  lib/route/netconf.c
  lib/route/nexthop.c
  lib/route/nexthop_encap.c
  lib/route/nh_encap_mpls.c
  lib/route/pktloc.c
  lib/route/qdisc.c
  lib/route/route.c
  lib/route/route_obj.c
  lib/route/route_utils.c
  lib/route/rtnl.c
  lib/route/rule.c
  lib/route/tc.c
  lib/socket.c
  lib/utils.c
  lib/version.c
  lib/xfrm/ae.c
  lib/xfrm/lifetime.c
  lib/xfrm/sa.c
  lib/xfrm/selector.c
  lib/xfrm/sp.c
  lib/xfrm/template.c
  src/genl-ctrl-list.c
  src/idiag-socket-details.c
  src/lib/addr.c
  src/lib/class.c
  src/lib/cls.c
  src/lib/ct.c
  src/lib/exp.c
  src/lib/link.c
  src/lib/neigh.c
  src/lib/qdisc.c
  src/lib/route.c
  src/lib/rule.c
  src/lib/tc.c
  src/lib/utils.c
  src/nf-ct-add.c
  src/nf-ct-events.c
  src/nf-ct-list.c
  src/nf-exp-add.c
  src/nf-exp-delete.c
  src/nf-exp-list.c
  src/nf-log.c
  src/nf-monitor.c
  src/nf-queue.c
  src/nl-addr-add.c
  src/nl-addr-delete.c
  src/nl-addr-list.c
  src/nl-class-add.c
  src/nl-class-delete.c
  src/nl-class-list.c
  src/nl-classid-lookup.c
  src/nl-cls-add.c
  src/nl-cls-delete.c
  src/nl-cls-list.c
  src/nl-fib-lookup.c
  src/nl-link-enslave.c
  src/nl-link-ifindex2name.c
  src/nl-link-list.c
  src/nl-link-name2ifindex.c
  src/nl-link-release.c
  src/nl-link-set.c
  src/nl-link-stats.c
  src/nl-list-caches.c
  src/nl-list-sockets.c
  src/nl-monitor.c
  src/nl-neigh-add.c
  src/nl-neigh-delete.c
  src/nl-neigh-list.c
  src/nl-neightbl-list.c
  src/nl-pktloc-lookup.c
  src/nl-qdisc-add.c
  src/nl-qdisc-delete.c
  src/nl-qdisc-list.c
  src/nl-route-add.c
  src/nl-route-delete.c
  src/nl-route-get.c
  src/nl-route-list.c
  src/nl-rule-list.c
  src/nl-tctree-list.c
  src/nl-util-addr.c
)

sed '1s#^#/* SPDX-License-Identifier: LGPL-2.1-only */\n#' "${FILES[@]}" -i

4 years agoall: merge branch 'th/add-utils-and-various-cleanup'
Thomas Haller [Fri, 9 Aug 2019 14:53:45 +0000 (16:53 +0200)]
all: merge branch 'th/add-utils-and-various-cleanup'

https://github.com/thom311/libnl/pull/220

4 years agogenl: reject invalid group names in genl_family_add_grp()
Thomas Haller [Fri, 9 Aug 2019 12:50:32 +0000 (14:50 +0200)]
genl: reject invalid group names in genl_family_add_grp()

The compiler warns about string truncation:

  In function ‘genl_family_add_grp’,
      inlined from ‘family_clone’ at lib/genl/family.c:81:9,
      inlined from ‘family_clone’ at lib/genl/family.c:66:12:
  lib/genl/family.c:376:2: error: ‘strncpy’ output may be truncated copying 15 bytes from a string of length 15 [-Werror=stringop-truncation]
    376 |  strncpy(grp->name, name, GENL_NAMSIZ - 1);
        |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Obvioulsy, it's a bug to use an invalid group name. But better
handle it by checking for a suitable string length.

Also use _nl_strncpy() which asserts that no truncation occurs.

4 years agoroute/tc: ensure not string truncation in rtnl_tc_set_kind()
Thomas Haller [Fri, 9 Aug 2019 14:33:57 +0000 (16:33 +0200)]
route/tc: ensure not string truncation in rtnl_tc_set_kind()

The compiler warns:

  In function ‘rtnl_tc_set_kind’,
      inlined from ‘rtnl_tc_msg_parse’ at lib/route/tc.c:81:2:
  lib/route/tc.c:532:2: error: ‘strncpy’ output may be truncated copying 31 bytes from a string of length 31 [-Werror=stringop-truncation]
    532 |  strncpy(tc->tc_kind, kind, sizeof(tc->tc_kind) - 1);
        |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Now, there are two choices: either accept the truncation
or rejecting it.

While rejecting it is a change in behavior and API, I don't think that
any caller actually relied on that. That is because such "kind" name would
be invalid anyway (and rejected from kernel too).

So, tighten up the API and check for a suitable string length.

Also, use _nl_strncpy() instead of strncpy(). Note that that doesn't suppress
the warning, it merely (also) adds an _nl_assert() for something that already
shouldn't happen.

4 years agoroute/inet6: fix strncpy() in inet6_dump_details()
Thomas Haller [Fri, 9 Aug 2019 14:18:08 +0000 (16:18 +0200)]
route/inet6: fix strncpy() in inet6_dump_details()

Compiler warnings:

  lib/route/link/inet6.c: In function ‘inet6_dump_details’:
  lib/route/link/inet6.c:383:3: error: ‘strncpy’ output may be truncated copying between 0 and 63 bytes from a string of length 63 [-Werror=stringop-truncation]
    383 |   strncpy(&buf[offset], buf2, strlen(buf2));
        |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Also, passing "strlen(buf2)" as length argument to strncpy() is
certainly wrong.

4 years agoxfrm: fix memory corruption (dangling pointer) when when setting xfrmnl_sa
Thomas Haller [Fri, 9 Aug 2019 11:07:00 +0000 (13:07 +0200)]
xfrm: fix memory corruption (dangling pointer) when when setting xfrmnl_sa

The follow leaves a dangling pointer when the name argument is too long:

xfrmnl_sa_set_aead_params:

    if (sa->aead)
        free (sa->aead);
    if (   strlen (alg_name) >= sizeof (sa->aead->alg_name)
        || (sa->aead = calloc (1, newlen)) == NULL)
        return -1;

Fix that, but do more:

- ensure that we don't modify the object when the setter is going to
  fail. That means, first check whether we can succeed with all the
  steps that are requested, and (in case we cannot) fail without
  modifing the target object.

- bonus points for making the setter self-assignment safe by reordering
  the setting and freeing of the memory.

4 years agotravis: build tests with NL_MORE_ASSERTS enabled
Thomas Haller [Fri, 9 Aug 2019 12:56:03 +0000 (14:56 +0200)]
travis: build tests with NL_MORE_ASSERTS enabled

4 years agotravis: enable -Wvla compiler warning in tests
Thomas Haller [Fri, 9 Aug 2019 11:44:13 +0000 (13:44 +0200)]
travis: enable -Wvla compiler warning in tests

4 years agolib/genl: avoid VLA in cmd_msg_parser()
Thomas Haller [Fri, 9 Aug 2019 11:12:30 +0000 (13:12 +0200)]
lib/genl: avoid VLA in cmd_msg_parser()

We want to build with -Wvla, because VLAs interfere with static asserts
(if the condition of a static assert is not actually static, then VLAs
make it silently pass).

Also, VLAs should be avoided because we want to be in contol how much
we allocate on the stack.

4 years agoutils: add internal helper macros for cleanup
Thomas Haller [Thu, 8 Aug 2019 16:26:23 +0000 (18:26 +0200)]
utils: add internal helper macros for cleanup

Yes, these use gcc-isms like typeof(), __attribute__((__unused__)),
__attribute__((__cleanup__(fcn))) and expression statements.

First of all, this is now only required when building libnl3 itself.
The public headers still should to be conservative and only use C89
features.

Also, clang supports these too, so you can at least build libnl3 with
gcc and clang. Since libnl3 uses internally linux headers, and the linux
kernel also can only be compiled with gcc (and maybe clang), it seems
clear that on the target platform a suitable compiler is available.

If there is a reasonable request of a real-world compiler that is not
able to compile this, we can revisit some choices. But not having
__attribute__((__cleanup__(fcn))) is like programming C from a decade
ago. Especially during parsing (which libnl3 does obviously a lot), this
allows to return-early while cleanup up memory. While this sounds simple
to get right manually, in practice the resulting code is either
unnecessary complex or simply buggy.

To make implementing libnl3 more convenient, these helpers are
introduced.

4 years agoall: merge branch 'coverity-fixes'
Thomas Haller [Thu, 8 Aug 2019 15:45:00 +0000 (17:45 +0200)]
all: merge branch 'coverity-fixes'

https://bugzilla.redhat.com/show_bug.cgi?id=1606988

4 years agolink/sriov: fix memleak in rtnl_link_sriov_clone()
Thomas Haller [Thu, 8 Aug 2019 08:38:12 +0000 (10:38 +0200)]
link/sriov: fix memleak in rtnl_link_sriov_clone()

Found by Coverity.

4 years agoroute: fix strncpy() warning from coverity about unterminated string
Thomas Haller [Thu, 8 Aug 2019 08:16:54 +0000 (10:16 +0200)]
route: fix strncpy() warning from coverity about unterminated string

Coverity says:

  Error: BUFFER_SIZE_WARNING (CWE-120): [#def1]
  libnl-3.4.0/lib/route/cls/ematch/text.c:94: buffer_size_warning: Calling strncpy with a maximum size argument of 16 bytes on destination array "t->cfg.algo" of size 16 bytes might leave the destination string unterminated.
  #   92|    struct text_data *t = rtnl_ematch_data(e);
  #   93|
  #   94|->  strncpy(t->cfg.algo, algo, sizeof(t->cfg.algo));
  #   95|   }
  #   96|

  Error: BUFFER_SIZE_WARNING (CWE-120): [#def11]
  libnl-3.4.0/lib/xfrm/sa.c:1192: buffer_size_warning: Calling strncpy with a maximum size argument of 64 bytes on destination array "auth->alg_name" of size 64 bytes might leave the destination string unterminated.
  # 1190|    }
  # 1191|
  # 1192|->  strncpy(auth->alg_name, tmpl->auth->alg_name, sizeof(auth->alg_name));
  # 1193|    auth->alg_key_len = tmpl->auth->alg_key_len;
  # 1194|    memcpy(auth->alg_key, tmpl->auth->alg_key, (tmpl->auth->alg_key_len + 7) / 8);

4 years agoAdd CTA_LABELS and CTA_LABELS_MASK to ctattr_type according to the new kernel
xinbao [Fri, 14 Jun 2019 16:34:27 +0000 (09:34 -0700)]
Add CTA_LABELS and CTA_LABELS_MASK to ctattr_type according to the new kernel

https://github.com/thom311/libnl/pull/218

4 years agoattr: mark nested attributes as NLA_F_NESTED
Thomas Haller [Wed, 7 Aug 2019 12:53:26 +0000 (14:53 +0200)]
attr: mark nested attributes as NLA_F_NESTED

Kernel 5.2 is adding stricter checking for netlink messages.
In particular, for certain API it checks now that NLA_F_NESTED flag is
set for nested attributes ([1]).

Do like libmnl, which always adds this flag ([2]). So we should do
that as well.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b424e432e770d6dd572765459d5b6a96a19c5286
[2] https://git.netfilter.org/libmnl/tree/src/attr.c?id=5937dfcb0185f5cb9cf275992ea701ec4e619d9c#n535

4 years agodoc: fix typos in example in documentation
Thomas Haller [Wed, 7 Aug 2019 12:50:56 +0000 (14:50 +0200)]
doc: fix typos in example in documentation

https://github.com/thom311/libnl/issues/210

4 years agotests: use nl_send_auto() instead of deprecated nl_send_auto_complete() in test-genl.c
Byeonggon Lee [Wed, 27 Mar 2019 02:41:18 +0000 (11:41 +0900)]
tests: use nl_send_auto() instead of deprecated nl_send_auto_complete() in test-genl.c

https://github.com/thom311/libnl/pull/213

5 years agoroute/link: merge branch 'toanju/link-slave-kind'
Thomas Haller [Thu, 7 Mar 2019 10:54:16 +0000 (11:54 +0100)]
route/link: merge branch 'toanju/link-slave-kind'

https://github.com/thom311/libnl/pull/202

5 years agoroute/link: avoid dangling pointer in rtnl_link_set_slave_type()
Thomas Haller [Thu, 7 Mar 2019 10:28:14 +0000 (11:28 +0100)]
route/link: avoid dangling pointer in rtnl_link_set_slave_type()

- don't leave a dangling pointer, in case we unset the
  kind.

- try first to clone the string. If that fails, return early
  without modifying the link. Only start modifying the link,
  after we know it's going to succeed.

5 years agoroute/link: expose IFLA_INFO_SLAVE_KIND
Tobias Jungel [Mon, 22 Oct 2018 13:20:00 +0000 (15:20 +0200)]
route/link: expose IFLA_INFO_SLAVE_KIND

add rtnl_link_{get,set}_slave_type functions to expose the
IFLA_INFO_SLAVE_KIND attribute.

5 years agoroute/macvlan: style fixes in "lib/route/link/macvlan.c"
Thomas Haller [Mon, 8 Oct 2018 11:46:19 +0000 (13:46 +0200)]
route/macvlan: style fixes in "lib/route/link/macvlan.c"

5 years agolink: macvlan fixes
Wang Jian [Sat, 29 Sep 2018 11:09:17 +0000 (11:09 +0000)]
link: macvlan fixes

1. While parsing flags, it overrides mode.
2. Before, dump-line and dump-details are same leading that macvlan info will be shown twice while dumpping details.
   So make dump-line show nothing.
3. Add some spaces to show dump-details more prettier.

Signed-off-by: Wang Jian <jianjian.wang1@gmail.com>
Fixes: c76393e2037d78eb60c32f95b26f5b1e5b9422a6
http://lists.infradead.org/pipermail/libnl/2018-August/002405.html
http://lists.infradead.org/pipermail/libnl/2018-September/002406.html
http://lists.infradead.org/pipermail/libnl/2018-September/002411.html

5 years agonla_ok: fix overrun in attribute iteration.
Patrick Havelange [Fri, 27 Jul 2018 12:39:35 +0000 (14:39 +0200)]
nla_ok: fix overrun in attribute iteration.

A detailed explanation is provided in the original Linux kernel commit that
fixes the bug: 1045b03e07d85f3545118510a587035536030c1c

Valgrind spotted the issue when the remaining was negative.
This bug was triggering application crashes.

Signed-off-by: Patrick Havelange <patrick.havelange@tessares.net>
https://github.com/thom311/libnl/pull/199

5 years agoroute/cls: fix potential memory leak
Ilya Pronin [Thu, 23 Aug 2018 23:12:25 +0000 (16:12 -0700)]
route/cls: fix potential memory leak

rtnl_act_append() cannot add more than TCA_ACT_MAX_PRIO actions to the
same list. Because of that rtnl_basic_add_action() and
rtnl_u32_add_action() should not increment the reference counter of the
given action until it is successfully added to the filter's list.

Signed-off-by: Ilya Pronin <ipronin@twitter.com>
Fixes: e5d9b828f6ec64fd77854578fbf1c33f214f3ac4
https://github.com/thom311/libnl/pull/201

5 years agoroute/act: merge branch 'westermo/act-vlan'
Thomas Haller [Wed, 10 Oct 2018 09:40:42 +0000 (11:40 +0200)]
route/act: merge branch 'westermo/act-vlan'

https://github.com/thom311/libnl/pull/198

5 years agoroute/act: return error code from act-vlan getters
Thomas Haller [Wed, 10 Oct 2018 09:33:16 +0000 (11:33 +0200)]
route/act: return error code from act-vlan getters

Our API is unfortunately not consistent about this.
However, in general, getters should aim to return an
error code whether the attribute could be retrieved.

5 years agoroute/act: style fixes in "lib/route/act/vlan.c"
Thomas Haller [Mon, 8 Oct 2018 11:46:19 +0000 (13:46 +0200)]
route/act: style fixes in "lib/route/act/vlan.c"

5 years agoroute:act: add vlan action
Volodymyr Bendiuga [Fri, 4 May 2018 09:13:10 +0000 (11:13 +0200)]
route:act: add vlan action

For more information please see:
http://man7.org/linux/man-pages/man8/tc-vlan.8.html

Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
5 years agoinclude: import tc_vlan.h
Volodymyr Bendiuga [Fri, 4 May 2018 09:12:16 +0000 (11:12 +0200)]
include: import tc_vlan.h

Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
5 years agoroute/tc: merge branch ' westermo/tc-chain'
Thomas Haller [Wed, 10 Oct 2018 09:04:28 +0000 (11:04 +0200)]
route/tc: merge branch ' westermo/tc-chain'

https://github.com/thom311/libnl/pull/197

5 years agoroute/tc: return error code from rtnl_tc_get_chain()
Thomas Haller [Wed, 10 Oct 2018 09:02:36 +0000 (11:02 +0200)]
route/tc: return error code from rtnl_tc_get_chain()

Our API is unfortunately not consistent about this.
However, in general, getters should aim to return an
error code whether the attribute could be retrieved.

5 years agoroute:tc: allow to set chain index for tc objects
Volodymyr Bendiuga [Thu, 3 May 2018 06:51:35 +0000 (08:51 +0200)]
route:tc: allow to set chain index for tc objects

This is useful when one wants to chain filters.

Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
5 years agolib/tc: fix uninitalized err variable in rtnl_tc_msg_build()
Thomas Haller [Wed, 10 Oct 2018 08:59:27 +0000 (10:59 +0200)]
lib/tc: fix uninitalized err variable in rtnl_tc_msg_build()

Fixes: 52cd3c14ce42db53637f8f5dafaf0d5c24d724db
5 years agobuild: sort entries in libnl-route-3.sym
Thomas Haller [Wed, 10 Oct 2018 08:54:31 +0000 (10:54 +0200)]
build: sort entries in libnl-route-3.sym

5 years agolib/qdisc: merge branch 'westermo/qdisc-mqprio'
Thomas Haller [Wed, 10 Oct 2018 08:50:41 +0000 (10:50 +0200)]
lib/qdisc: merge branch 'westermo/qdisc-mqprio'

https://github.com/thom311/libnl/pull/196

5 years agolib/qdisc: avoid BUG() in "lib/route/qdisc/mqprio.c"
Thomas Haller [Tue, 9 Oct 2018 13:27:01 +0000 (15:27 +0200)]
lib/qdisc: avoid BUG() in "lib/route/qdisc/mqprio.c"

BUG() raises an assertion. It seems overly harsh.

For example, rtnl_tc_data() can fail if we fail to allocate
memory. Asserting against that, makes libnl3 not out-of-memory
safe.

Just return a regular error.

5 years agolib/qdisc: style fixes in "lib/route/qdisc/mqprio.c"
Thomas Haller [Mon, 8 Oct 2018 11:46:19 +0000 (13:46 +0200)]
lib/qdisc: style fixes in "lib/route/qdisc/mqprio.c"

5 years agolib/tc: ensure correct error code in rtnl_tc_msg_build()
Thomas Haller [Mon, 8 Oct 2018 11:41:25 +0000 (13:41 +0200)]
lib/tc: ensure correct error code in rtnl_tc_msg_build()

5 years agobuild: cleanup Makefile.am
Thomas Haller [Mon, 8 Oct 2018 11:11:14 +0000 (13:11 +0200)]
build: cleanup Makefile.am

Sort files asciibetically and add $(NULL) sentinel to
Makefile lines.

5 years agoroute:qdisc: add MQPRIO Qdisc
Volodymyr Bendiuga [Fri, 23 Feb 2018 14:37:07 +0000 (15:37 +0100)]
route:qdisc: add MQPRIO Qdisc

More about Qdisc mqprio can be found at:
http://man7.org/linux/man-pages/man8/tc-mqprio.8.html

Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
5 years agoinclude: import linux header pkt_sched.h
Volodymyr Bendiuga [Wed, 28 Mar 2018 06:48:30 +0000 (08:48 +0200)]
include: import linux header pkt_sched.h

Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
5 years agoroute/ip-tunnels: merge branch 'TummyFish/pr/194' (partial)
Thomas Haller [Mon, 25 Jun 2018 13:17:46 +0000 (15:17 +0200)]
route/ip-tunnels: merge branch 'TummyFish/pr/194' (partial)

Cherry-pick parts of the commits from pr#194.

https://github.com/thom311/libnl/pull/194

5 years agoinclude/linux: update copy of kernel headers
Thomas Haller [Mon, 25 Jun 2018 13:13:14 +0000 (15:13 +0200)]
include/linux: update copy of kernel headers

Taken from upstream kernel commit 29dcea88779c856c7dc92040a0c01233263101d4
(v4.17).

5 years agoif_tunnel: Update IFLA defines up to FWMARK
Thomas Winter [Fri, 8 Jun 2018 04:17:50 +0000 (16:17 +1200)]
if_tunnel: Update IFLA defines up to FWMARK

This is a new option that was added in Linux v4.12.

Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz>
5 years agoipvti: Fix wrong array size initialization
Thomas Winter [Fri, 8 Jun 2018 03:45:42 +0000 (15:45 +1200)]
ipvti: Fix wrong array size initialization

IPv4 VTI tunnels use the VTI defines.

Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz>
Fixes: 8f6301426a00d992d00238c7ddd666e96aa63e28
5 years agoipgre: Fix wrong array size initialization
Thomas Winter [Fri, 8 Jun 2018 03:43:53 +0000 (15:43 +1200)]
ipgre: Fix wrong array size initialization

IPv4 GRE tunnels use the GRE defines.

Signed-off-by: Thomas Winter <Thomas.Winter@alliedtelesis.co.nz>
Fixes: 57bdc4ff4895dd91cc723d22eecadcf48945e87c
5 years agoneigh: update neighbour.h and add missing flags
Tobias Jungel [Fri, 13 Apr 2018 09:10:43 +0000 (11:10 +0200)]
neigh: update neighbour.h and add missing flags

NTF_EXT_LEARNED, NTF_OFFLOADED and NTF_MASTER are added to neigh_flags.

https://github.com/thom311/libnl/pull/186

5 years agoroute/link/vxlan: Fix IPv4 set_local resetting ce_mask
Tuetuopay [Tue, 15 May 2018 12:11:20 +0000 (14:11 +0200)]
route/link/vxlan: Fix IPv4 set_local resetting ce_mask

rtnl_link_vxlan_set_local() removes the bit for the other IP version in
ce_mask. A missing flag inversion in the v4 part made this removal
reset all bits to 0 except the v6 one, screwing all link configuration.

Fixes: 2e68fb5b02304fa6a3e6429c4fdabb084e61b501
https://github.com/thom311/libnl/pull/192

5 years agoAdd support for cloning cgroup filter object.
d0u9 [Fri, 23 Mar 2018 13:21:11 +0000 (21:21 +0800)]
Add support for cloning cgroup filter object.

In this commit, we implement ematch_tree_clone(), which is basis of
cgroup_clone() interface. The whole ematch tree is deep-copied except
the e_ops filed.

Also, a new unit test is added for testing the interface, which named as
check-ematch-tree-clone.c located in tests directory.

https://github.com/thom311/libnl/pull/176

5 years agoneigh_dump_line: dump master as well
Tobias Jungel [Fri, 20 Apr 2018 13:11:46 +0000 (15:11 +0200)]
neigh_dump_line: dump master as well

In case NEIGH_ATTR_MASTER is set this dumps as well the master
interface.

https://github.com/thom311/libnl/pull/190

5 years agoneigh: add get/set functions for NEIGH_ATTR_MASTER
Tobias Jungel [Tue, 17 Apr 2018 10:54:14 +0000 (12:54 +0200)]
neigh: add get/set functions for NEIGH_ATTR_MASTER

Beeing able to set NEIGH_ATTR_MASTER hash based lookups are possible for
AF_BRIDGE neighbours.

https://github.com/thom311/libnl/pull/189

5 years agoneigh: merge branch 'toanju/bridge-neigh'
Thomas Haller [Mon, 25 Jun 2018 12:24:52 +0000 (14:24 +0200)]
neigh: merge branch 'toanju/bridge-neigh'

https://github.com/thom311/libnl/pull/188

5 years agonl-neigh-list: free allocated items
Tobias Jungel [Tue, 17 Apr 2018 11:49:23 +0000 (13:49 +0200)]
nl-neigh-list: free allocated items

5 years agowhitespace cleanup
Tobias Jungel [Tue, 17 Apr 2018 11:48:30 +0000 (13:48 +0200)]
whitespace cleanup

5 years agoneigh: cache updates as well query AF_BRIDGE neigh
Tobias Jungel [Tue, 17 Apr 2018 11:40:53 +0000 (13:40 +0200)]
neigh: cache updates as well query AF_BRIDGE neigh

This commit adds the query for AF_BRIDGE neighbours. A cache refresh now
includes these objects as well. The result of `./src/nl-neigh-list
--family=bridge` includes now as well the same entries you would
retrieve from the kernel by calling `bridge fdb show`.

5 years agonl: fix function name in debug msg
Matthieu Baerts [Tue, 8 May 2018 12:32:46 +0000 (14:32 +0200)]
nl: fix function name in debug msg

Just a typo.

Fixes: f545295 (lib: log errors from platform)
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
https://github.com/thom311/libnl/pull/191

5 years agoneigh: correct symbol exposed
Tobias Jungel [Tue, 17 Apr 2018 09:43:57 +0000 (11:43 +0200)]
neigh: correct symbol exposed

instead of exposing rtnl_neigh_ll_get the function
rtnl_neigh_get_by_vlan has to be exposed

Fixes: 3bf503d30c271822158414f63eed620afc9b10cd
https://github.com/thom311/libnl/pull/187

6 years agoroute/class: add new api rtnl_class_get_by_parent()
d0u9 [Sun, 1 Apr 2018 08:48:11 +0000 (16:48 +0800)]
route/class: add new api rtnl_class_get_by_parent()

This function searches a class cache previously allocated with
rtnl_class_alloc_cache() and searches for a class matching the interface
index and parent qdisc.

https://github.com/thom311/libnl/pull/185

6 years agolib/route: merge branch 'pr/184'
Thomas Haller [Wed, 11 Apr 2018 10:49:59 +0000 (12:49 +0200)]
lib/route: merge branch 'pr/184'

6 years agonl-msg: explicitly initialize nlmsg_seq and nlmsg_pid field in nlmsg_alloc_simple()
Thomas Haller [Wed, 11 Apr 2018 10:48:16 +0000 (12:48 +0200)]
nl-msg: explicitly initialize nlmsg_seq and nlmsg_pid field in nlmsg_alloc_simple()

This is no change in behavior, because the NL_AUTO_* macros are both
zero.

6 years agoroute/link: assert in rtnl_link_change() that the sequence number is set as expected
Thomas Haller [Wed, 11 Apr 2018 10:40:39 +0000 (12:40 +0200)]
route/link: assert in rtnl_link_change() that the sequence number is set as expected

6 years agoroute/link: fix sequence number handling in rtnl_link_change()
Tuetuopay [Mon, 9 Apr 2018 14:21:41 +0000 (16:21 +0200)]
route/link: fix sequence number handling in rtnl_link_change()

When rtnl_link_change() fails with -NLE_OPNOTSUPP, it retries
with RTM_SETLINK operation. However, it also needs to re-adjust
the sequence number. Otherwise, the second request might fail
with NLE_SEQ_MISMATCH, although it actually succeeded.

[thaller@redhat.com: changed commit message]

https://github.com/thom311/libnl/issues/179
https://github.com/thom311/libnl/pull/184

6 years agoroute/mall: merge branch 'pr/170'
Thomas Haller [Wed, 11 Apr 2018 10:23:39 +0000 (12:23 +0200)]
route/mall: merge branch 'pr/170'

https://github.com/thom311/libnl/pull/170

6 years agoroute/mall: fix deep cloning mall
Thomas Haller [Fri, 6 Apr 2018 14:42:55 +0000 (16:42 +0200)]
route/mall: fix deep cloning mall

rtnl_act_append() does not clone the object, it takes it over
and thus the source object is destroyed.

6 years agoroute:cls: add matchall classifier
Volodymyr Bendiuga [Tue, 24 Oct 2017 14:40:00 +0000 (16:40 +0200)]
route:cls: add matchall classifier

This simple classifier allows any traffic pass through.
Useful as an example for port mirroring.

Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
6 years agoinclude: copy entire pkt_cls.h from linux
Volodymyr Bendiuga [Fri, 23 Mar 2018 10:00:40 +0000 (11:00 +0100)]
include: copy entire pkt_cls.h from linux

Signed-off-by: Volodymyr Bendiuga <volodymyr.bendiuga@westermo.se>
6 years agocache: make "result" output argument for nl_cache_mngr_add() optional
Tuetuopay [Mon, 9 Apr 2018 08:34:31 +0000 (10:34 +0200)]
cache: make "result" output argument for nl_cache_mngr_add() optional

[thaller@redhat.com: rewritten commit message]

https://github.com/thom311/libnl/issues/178
https://github.com/thom311/libnl/pull/183

6 years agoneigh: support bridge entries for vxlan interfaces
Tobias Jungel [Fri, 6 Apr 2018 07:40:27 +0000 (09:40 +0200)]
neigh: support bridge entries for vxlan interfaces

bridge entries used for switching into vxlan interfaces do not include a
vlan. A comparison of such entires currently always fails which leads
to an invalid cache. This patch selectively adds the NEIGH_ATTR_VLAN
flag based on the passed entry.

https://github.com/thom311/libnl/pull/182

6 years agoneigh: set correct AF for NDA_DST
Tobias Jungel [Thu, 5 Apr 2018 11:24:59 +0000 (13:24 +0200)]
neigh: set correct AF for NDA_DST

In case using a VXLAN interface at a bridge you will set L2 bridging
entries using a IP destination to tunnel the according L2 traffic. The
current behavior for the dst entries for a neighbor is to use the AF of
the neighbor itself thus in this case AF_BRIDGE is set. This is changed
in the PR to update the family of the dst using nl_addr_guess_family.

https://github.com/thom311/libnl/pull/180

6 years agobuild: indent libnl-route-3.sym with tabs
Thomas Haller [Fri, 6 Apr 2018 17:35:36 +0000 (19:35 +0200)]
build: indent libnl-route-3.sym with tabs

6 years agobuild: sort entries in Makefile.am and .gitignore by name
Thomas Haller [Fri, 6 Apr 2018 17:34:33 +0000 (19:34 +0200)]
build: sort entries in Makefile.am and .gitignore by name

6 years agotests: merge branch 'pr/172'
Thomas Haller [Fri, 6 Apr 2018 17:42:16 +0000 (19:42 +0200)]
tests: merge branch 'pr/172'

https://github.com/thom311/libnl/pull/172

6 years agonf-ct-add typo
Lukáš Karas [Fri, 23 Feb 2018 18:20:38 +0000 (19:20 +0100)]
nf-ct-add typo

6 years agoadd demo program for listen conntrack events
Lukáš Karas [Fri, 23 Feb 2018 18:20:08 +0000 (19:20 +0100)]
add demo program for listen conntrack events

6 years agoroute/rule: merge branch 'rule-proto-and-port-range'
Thomas Haller [Fri, 6 Apr 2018 14:02:09 +0000 (16:02 +0200)]
route/rule: merge branch 'rule-proto-and-port-range'

http://lists.infradead.org/pipermail/libnl/2018-March/002398.html

6 years agorule: Add support for protocol and port ranges
David Ahern [Wed, 14 Mar 2018 00:17:25 +0000 (17:17 -0700)]
rule: Add support for protocol and port ranges

Add support for recent fib rule features - specifying a protocol
that installed a rule and an IP protocol plus port range for rules.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
6 years agoUpdate fib_rules.h to latest kernel
David Ahern [Wed, 14 Mar 2018 00:17:24 +0000 (17:17 -0700)]
Update fib_rules.h to latest kernel

Update fib_rules.h to kernel as of bfff4862653b
("net: fib_rules: support for match on ip_proto, sport and dport")

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
6 years agoroute/vrf: initalize clone destination with NULL in vrf_clone()
Jonas Johansson [Mon, 12 Mar 2018 12:51:36 +0000 (13:51 +0100)]
route/vrf: initalize clone destination with NULL in vrf_clone()

Signed-off-by: Jonas Johansson <jonasj76@gmail.com>
6 years agolib: route: rule: add rule_groups to cache ops
Roopa Prabhu [Wed, 14 Feb 2018 22:29:09 +0000 (14:29 -0800)]
lib: route: rule: add rule_groups to cache ops

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Acked-by: David Ahern <dsa@cumulusnetworks.com>