summaryrefslogtreecommitdiffstats
path: root/lib/idiag
Commit message (Collapse)AuthorAgeFilesLines
* include: use <linux/$file> instead of <linux-private/linux/$file>Thomas Haller2023-08-083-3/+3
| | | | | | As we now copy all linux headers, and we have include/linux-private in our include search path, just include the linux headers as we commonly do.
* include: include private linux headers with explicit pathThomas Haller2023-08-033-3/+3
| | | | | | | We have copies of the linux headers in include/linux-private. For those files, include the copies explicitly. No practice there is no difference, since we build with :-Ilinux-private".
* include: drop "netlink-private/netlink.h" and move declarationsThomas Haller2023-08-025-9/+6
|
* all: cleanup includes and use "nm-default.h"Thomas Haller2023-08-025-5/+20
|
* include: split and drop "netlink-private/types.h"Thomas Haller2023-08-025-3/+86
| | | | | Move all the declarations from "netlink-private/types.h" to places closer to where they are used.
* lib: use _nl_{init,exit} instead of __{init,exit}Thomas Haller2023-07-281-2/+2
| | | | | We should have things with "nl" prefix in our headers. Also, netlink-private/netlink.h is not header-only, preferably header-only stuff is in netlink-private/utils.h
* all: use "_nl_packed" macro instead of "__attribute__((packed))"Thomas Haller2023-07-281-1/+1
|
* all: rework ATTR_DIFF() macros to not generate attribute namesThomas Haller2023-07-281-23/+38
| | | | | | | | | | I find macros that stitch together names like "FAMILY_ATTR_##ATTR" very confusing, because we no longer see where a certain name is used. It breaks grepping for symbols, and it breaks cscope. Yes, it's more verbose to not do that. If you really think that those names are too verbose, then maybe they should get a shorter name. And not use macros to make them palatable.
* lib: make nl_object_clone() out-of-memory safeThomas Haller2022-03-162-1/+4
| | | | | | | | | | | | | | | | | nl_object_clone() first does a shallow copy using memcpy(). That is useful, because it can correctly copy simple fields (like numbers). For pointer values, we need to implement oo_clone() to fixup the pointers and get the deep-copy correct. Now, oo_clone() must always follow through, to un-alias the copied pointer. In particular also in the error case. The oo_clone() implementations sometimes fail (with ENOMEM) and just return. In those cases, we must make sure that we don't leave the wrong pointers there. The pointers must be cleared first. Otherwise, any failure (which basically are ENOMEM) leave the object in an inconsistent state, and we double-free/use-after-free the pointers.
* license: fix and add SPDX license identifiers and drop license commentsThomas Haller2020-04-165-35/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This also fixes a few wrong SPDX license identifiers, where the original license comment indicates GPL-2.0-only. This is not done manually, but by running the following script: --- #!/bin/bash # Tool to drop license comments, adding SPDX license identifiers, while preserving # copyright comments. The point is not to manually do this task, but perform some # hacked up string replacement. _cp() { /bin/cp "$@" } _cat() { /bin/cat "$@" } in_file() { local T=$(mktemp) _cp -f "$1" "$T" _cat "$T" rm -f "$T" } out_file() { local T=$(mktemp) _cat - > "$T" _cp -f "$T" "$1" rm -f "$T" } join() { _cat "$@" | awk '{ printf("%s#x#", $0)}' } unjoin() { _cat - | sed 's/#x#/\n/g' } files_all() { git ls-files | grep -v '\.png$' | grep -v '^include/linux-private/' } adjust() { NEWLINES='\(#x#\)\+' COPYRIGHTS='\(\( \* Copyright (c) 20..\(-20..\|, 20..\)\? [^#]\+#x#\)\+\( \*#x# \* \(Stolen[^#]*\|Based on [^#]*\)#x#\)\?\)' _cat - | \ sed '1s%^\(/\* SPDX-License-Identifier: LGPL-2.1-only \*/\|\)#x#/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x#/*#x#\2 */#x##x#%' | \ sed '1s%^/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x##x#%' | \ sed '1s%^\(\)/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU Lesser General Public#x# \*[ ]\+License as published by the Free Software Foundation version 2.1#x# \*[ ]\+of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: LGPL-2.1-only \*/#x#/*#x#\2 */#x##x#%' | \ sed '1s%^\(/\* SPDX-License-Identifier: LGPL-2.1-only \*/\|\)#x#/\*#x# \* [^#]*#x# \*#x# \*[ ]\+This library is free software; you can redistribute it and/or#x# \*[ ]\+modify it under the terms of the GNU General Public License as#x# \*[ ]\+published by the Free Software Foundation version 2 of the License.#x# \*#x#'"$COPYRIGHTS"' \*/'"$NEWLINES"'%/\* SPDX-License-Identifier: GPL-2.0-only \*/#x#/*#x#\2 */#x##x#%' } FILES=( $(files_all) ) for f in "${FILES[@]}"; do echo "processing \"$f\"..." in_file "$f" | join | adjust | unjoin | out_file "$f" done
* idiag: workaround and add comment about idiagnl_send_simple() only handling ↵Thomas Haller2019-08-262-2/+13
| | | | | | 8 bit flags Related: https://github.com/thom311/libnl/pull/222#issuecomment-521956236
* lib: Don't omit second operand to `?` operatorMichael Forney2019-08-161-1/+1
|
* Add SPDX identifiersYegor Yefremov2019-08-125-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* trivial: whitespace-only fixes for src and libPeter Wu2016-08-121-11/+11
| | | | | | | | | | | Fixes alignment, lines with just whitespace and mixed tab/space indentation. Searched, reviewed and optionally fixed in vim using regex ^\t* [\t ]*\([^*us ]\|$\)\|\t\+$ http://lists.infradead.org/pipermail/libnl/2016-August/002183.html Signed-off-by: Peter Wu <peter@lekensteyn.nl> Signed-off-by: Thomas Haller <thaller@redhat.com>
* lib: update ce-mask to uint64_tDavid Ahern2016-02-123-7/+7
| | | | | | | | | | | | | | | | | | | | lib/route/link.c already defines 32 attributes which fills the current uint32_t used for ce_mask. To accommodate more attributes the mask needs to be expanded. This patch updates the definition to uint64_t. The nl_object_diff API is maintained for ABI with existing users. A new nl_object_diff64 API is added for the expanded attribute list. The MSB of the 32-bit API is used to indicate if higher order attributes had a mismatch. (Suggested by Thomas). Note that LINK_ATTR_LINK_NETNSID changes. But since the attribute flags are not public API it shouldn't be a problem. http://lists.infradead.org/pipermail/libnl/2015-December/002078.html http://lists.infradead.org/pipermail/libnl/2015-December/002083.html Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* lib/doc: clearify return value of send_simple() functionsThomas Haller2015-05-121-1/+2
| | | | | | | | | | | | | | | | | | The return value of the *nl_send_simple() functions is inconsistent and not according to the documentation. nl_send_simple() is document to return the number of bytes sent. Other *nl_send_simple() functions are documented to return 0 on success -- for the most part. See also commit b70174668b9867de573cf51471bc98bfe7fd2bc3 which changed behavior of nl_rtgen_request() to be according to documenation. Don't change behavior again, only adjust the documentation. http://lists.infradead.org/pipermail/libnl/2015-May/001872.html Reported-by: Xiao Jia <stfairy@gmail.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: fix set of identifying properties for idiag_msg_objThomas Haller2014-11-271-5/+17
| | | | | | | | | The key for a struct idiag_msg_obj should be 'family x src x dst x sport x dport'. http://lists.infradead.org/pipermail/libnl/2014-November/001768.html Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: fix idiagnl_compare() to compare all attributesThomas Haller2014-11-271-4/+22
| | | | | | | | | This is not important for nl_object_identical() which only considers the required attributes. But for using nl_object_diff() or nl_object_filter(), all attributes must be compared. Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: make objects 'idiag_vegasinfo' and 'idiag_meminfo' comparableThomas Haller2014-11-272-0/+30
| | | | | Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: don't dump unset properties of idiag_msgThomas Haller2014-11-271-22/+24
| | | | | Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: fix idiagnl_exts2str()Thomas Haller2014-11-251-9/+20
| | | | | | | | | | | | | | | | | | idiagnl_exts2str() is used to print req->idiag_ext, which is the extention types combined as flags, such as ( (1 << (INET_DIAG_TOS - 1)) | (1 << (INET_DIAG_MEMINFO - 1)) ). This function was wrong from the beginning because the string lookup array had indexes such as 'INET_DIAG_TOS', instead of '(1 << (INET_DIAG_TOS - 1)'. Fix also idiagnl_attrs2str() which now converts an extension type (e.g. INET_DIAG_TOS) to a string. Still this function is deprecated, as the function name is not clear and it is not used or very useful. Fixes: 22eb2569a595be98ae09fc4192860c1d2c3aa54c Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: add missing enum types for idiagnl_exts2str()Thomas Haller2014-11-251-0/+2
| | | | | Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: add a oo_compare() function for idiag_msg objectsThomas Haller2014-11-241-0/+17
| | | | | | | | | | Having a oo_keygen() function only makes sense together with a oo_compare() function because after hashing, you still have to compare the objects for equality (in case of hash collission). Fixes: 9c066b9271493ce3efff0b9d7b6e424990bba3f2 Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: add change attributes for idiag_msg_objThomas Haller2014-11-241-14/+127
| | | | | Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: remove clone functions from trivial structuresThomas Haller2014-11-242-23/+0
| | | | | | | | A oo_clone() function is only needed for complex sturctures to deep copy an object. Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: fix idiagnl_msg_clone()Thomas Haller2014-11-241-2/+25
| | | | | | | | | | | | | | For one, we did not clone all pointer values. Hence, every cloned object was very broken and resulted in dangling pointers and double free/unref. Apparently nobody was really using this function up to now. Also, fix the return cases for NLE_NOMEM, so that we did not assume ownership of pointers in 'src'. Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: fix memory leak in idiagnl_msg_set_cong()Thomas Haller2014-11-241-0/+1
| | | | | Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: deprecate IDIAG_TIMER_* value for IDIAGNL_TIMER_*Thomas Haller2014-11-241-7/+7
| | | | | Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: deprecate IDIAG_SS_* socket statesThomas Haller2014-11-241-15/+12
| | | | | | | | | | These values mirror TCP_* socket states from 'netinit/tcp.h'. There is no good reason to expose a copy of those values. User space should use the original values (if they care). The only value that is actually useful is IDIAGNL_SS_ALL. Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: deprecate netlink message type defines in idiagnl.hThomas Haller2014-11-241-2/+2
| | | | | Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: deprecate IDIAG_ATTR_* enumerationThomas Haller2014-11-242-62/+59
| | | | | | | | | | | | | | | | | | IDIAG_ATTR_* were a copy of the INET_DIAG_* extension kernel flags. Redefining them is wrong, user space should continue to use the values provided via the kernel headers. Also they were misused as change flags (ce_mask), which they are not. Deprecate the IDIAG_ATTR_* flags and redefine them to what the originally are: INET_DIAG_*. Also deprecated idiagnl_attrs2str() because there is already idiagnl_exts2str(). idiagnl_attrs2str() in the sense of libnl change flags (ce_mask) makes no sense. Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: fix out of bound error parsing idiag messagesThomas Haller2014-11-241-1/+1
| | | | | Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: add a copy of linux/sock_diag.hCong Wang2014-11-241-9/+10
| | | | | | | | | | | | | | | | | | | | When we test idiag on 3.4 kernel, we always get ERANGE. This is because libnl has its own copy for SK_MEMINFO_*, which is actually newer than 3.4, where SK_MEMINFO_VARS is larger than kernel's. We add a copy from latest kernel, so on older kernel libnl should still compile. Note, for kernel < 3.6 we don't have SK_MEMINFO_BACKLOG, we have to relax the minlen. 'sock_diag.h' comes from v3.17 kernel sources (bfe01a5ba2490f299e1d2d5508cbbbadd897bbe9), file 'include/uapi/linux/sock_diag.h'. Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: provide a hash function for idiag objectsCong Wang2014-11-241-0/+28
| | | | | | | | | | | | | | | Without ->oo_keygen, libnl will use linear search for cache objects. This is extremely slow for idiag when we have a lot of TCP connections. Provide a hash function for idiag so that libnl will be able to lookup a hashtable. http://lists.infradead.org/pipermail/libnl/2014-November/001715.html Cc: Thomas Graf <tgraf@suug.ch> Cc: Thomas Haller <thaller@redhat.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: fix a typo in idiagnl_req_set_ifindex()Cong Wang2014-09-241-1/+1
| | | | | Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* style: require comma after __ADD() macroThomas Haller2014-07-271-42/+42
| | | | | | | $ sed -i 's/^\([\t ]\+\<__ADD\> \?([^)]\+)\) *$/\1,/' `git grep -w -l __ADD` Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* More safely parse vegas info and mem info.Joe Damato2013-07-261-20/+26
|
* Add support for inet diag Netlink protocol.Joe Damato2013-07-195-0/+1456
- Inet diag allows users to gather low-level socket information. - This library provides a higher-level API for creating inetdiag requests (via idiagnl_connect and idiagnl_send_simple) and parsing the replies (via idiagnl_msg_parse). A cache is also provided (via idiagnl_msg_alloc_cache). - Request and message objects provide APIs for accessing and setting the various properties of each. - This library also allows the user to parse the inetdiag response attributes which contain information about traffic class, TOS, congestion, socket memory info, and more depending on the kernel version used. - Includes doxygen documentation.