| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Coverity warns "Signed integer overflow for expression '1<<31'".
|
| |
|
| |
|
|
|
|
|
| |
Move all the declarations from "netlink-private/types.h" to places
closer to where they are used.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
nl_object_identical() gets the ID attributes and then checks whether
these attributes are identical for both objects, by calling the compare
implementation.
If an object doesn't have all ID attributes set, previously there was no
way that this object would compare identical to anything.
That seems not right. For example, kernel has for many objects a rather
fuzzy understanding of what constitutes the ID attributes of an object.
For routes and routing rules for example, most attributes are part of
their ID, but also most of them are commonly missing and unset (note
that libnl3's understanding of about equality for routes is not correct
and does not correspond to kernels understanding. That is a known bug).
Anyway, such incomplete objects, if we have them at hand, we still shall
give them a chance to be evaluated as identical. Of course, and object
that has a certain ID attribute set must not compare identical to an
object that has the attribute missing. But if both objects miss the
attribute, they shall still be able to compare identical.
While at it, use uint64_t for the attribute mask. That corresponds to
the object's ce_mask and the API of oo_compare().
Note that if the object's ops would return id-attributes as 0xFFFFFFFF,
it previously would choose the intersection of the present attributes.
That is not correct either. If the ops don't specify any attributes,
then all present attributes shall be compared, not those that are
present in both.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
nl_object_identical() only considers two objects as identical, if all
their ID attributes are set. That means, two objects that are
incomplete (with unset ID attributes) never compare identical.
That cannot be right. At least not if both objects are the very same
pointer.
That is also important for nl_cache_clear() and nl_cache_remove(). An
object must be identical to itself, otherwise it cannot be removed from
the cache anymore.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
For AF_INET/IPv4 addresses, the ID equality comparison must include
the net-part of the peer address:
unshare -n
ip link add T type dummy
ip link set T up
ip addr add 192.168.5.10/24 dev T
ip addr add 192.168.5.10 peer 192.168.6.1/24 dev T
ip addr add 192.168.5.10 peer 192.168.7.1/24 dev T
ip addr add 192.168.5.10 peer 192.168.7.2/24 dev T
# RTNETLINK answers: File exists
ip addr change 192.168.5.10 peer 192.168.7.2/24 dev T
ip addr show | grep 192.168.7.
# inet 192.168.5.10 peer 192.168.7.1/24 scope global T
For AF_INET6/IPv6 addresses, the prefix length of the address
is not part of the ID:
unshare -n
ip link add T type dummy
ip link set T up
ip addr add 192.168.7.10/24 dev T
ip addr add 192.168.7.10/23 dev T
ip addr add 1:2:3:4:5::1/64 dev T
ip addr add 1:2:3:4:5::1/63 dev T
# RTNETLINK answers: File exists
ip addr change 1:2:3:4:5::1/63 dev T
ip addr show | grep 1:2:3:4:5::1
# inet6 1:2:3:4:5::1/64 scope global
*sigh*
http://lists.infradead.org/pipermail/libnl/2016-June/002158.html
Signed-off-by: Thomas Haller <thaller@redhat.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
| |
Signed-off-by: Thomas Haller <thaller@redhat.com>
|
|
|
|
|
|
|
|
|
|
| |
Previously coverity was complaining about a use-after-free.
This was not a real problem, because the printf statement
does not dereferenciate the pointer. Change it to avoid
the warning.
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
|
|
|
|
|
|
|
|
|
| |
The check for !obj indicates that obj might be NULL, thus move the call
to obj_ops(obj) - which dereferences obj - after the check.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
|
|
|
|
| |
Signed-off-by: Thomas Graf <tgraf@suug.ch>
|
|
|
|
|
|
|
|
|
|
|
|
| |
Since commit: "cache pickup: Avoid duplicates during cache pickup",
nfnl_ct_alloc_cache no longer properly fills the cache, as it doesn't
define oo_id_attrs so all items are considered duplicates.
Instead of adding a ~0 oo_id_attrs to ct_obj, this changes
nl_object_identical to default to comparing all attributes if
neither oo_id_attrs_get or oo_id_attrs are provided.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
|
|
|
|
|
|
|
|
|
| |
Passing a NULL pointer would cause a NULL pointer dereference within
nl_object_free().
Returning early on NULL pointer is the behavior free(3) and other
nl*_free() functions.
Signed-off-by: Emmanuel Roullit <emmanuel.roullit@gmail.com>
|
|
|
|
|
|
|
| |
This clarifies the seperation between public and private
header files.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch adds new cache find api
nl_cache_find api was suggested by Thomas.
Unlike nl_cache_search, this patch uses
nl_object_match_filter() to look for an
object match.
Am not sure this matches what was decided
on the list few weeks back. I will be happy
to make any changes.
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
|
|
|
|
| |
Signed-off-by: Thomas Graf <tgraf@suug.ch>
|
|
|
|
|
|
|
|
|
|
|
| |
This patch adds the required structures and access functions to create
and manage hashtables for netlink cache objects
Signed-off-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Signed-off-by: Nolan Leake <nolan@cumulusnetworks.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This patch adds support to update a cache object during cache_include instead
of the current approach of deleting the original object and adding a new one.
This operation is conditional on the object implementing the operation. If
the update is not successful, cache_include falls back to the existing cache
inclusion process of deleting and adding the object.
It adds a new object operation called oo_update. oo_update takes two objects
as arguments, first being the existing cache object that needs update, the
second argument being the new object. Currently it is left to the implementor
to use the msg type to decide wether to delete or add the new object attributes
to the old one. But the operation type or msg type can be easily made part of the
object arguments.
The motivation for this change is explained below in the context of including
support for AF_BRIDGE objects into the link cache.
libnl today deletes an object before it includes an identical object.
But for some objects like the AF_BRIDGE objects this does not work well.
link cache uses the ifindex as its key in object searches.
If link cache were to support AF_BRIDGE family objects, todays implementation,
- will replace the original link object with the bridge port link object
for add notifications
- And a bridge port delete notification from kernel would delete the
link object from the cache leaving the cache without the link object
until the kernel sends another notification for that link
The bridge port link notification contains some base link object attributes
plus bridge specific protocol info attributes. In such cases we think an
operation to update the existing object in place in cache might be useful.
This can be made to work for AF_INET6 link objects too.
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Nolan Leake <nolan@cumulusnetworks.com>
Reviewed-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The current oo_id_attrs nl_object op allows a fixed
id attribute list for an cache. But a cache with multiple families
may need to specify different id attributes for different families.
An example for this is the bridge fdb entries in the neigh cache:
neigh entries belonging to the AF_UNSPEC family use
(NEIGH_ATTR_IFINDEX | NEIGH_ATTR_DST | NEIGH_ATTR_FAMILY) as id attributes.
AF_BRIDGE fdb entries which also support the same msg type, will need to use
(NEIGH_ATTR_LLADDR | NEIGH_ATTR_FAMILY) as id attributes.
Today you cannot specify different set of attributes to two families belonging
to the same cache.
This patch adds a new object function oo_id_attrs_get to get the attributes.
An example implementation of oo_id_attrs_get for the neigh cache will
look like:
static uint32_t neigh_id_attrs_get(struct nl_object *obj)
{
struct rtnl_neigh *neigh = (struct rtnl_neigh *)obj;
if (neigh->n_family == AF_BRIDGE)
return (NEIGH_ATTR_LLADDR | NEIGH_ATTR_FAMILY);
else
return (NEIGH_ATTR_IFINDEX | NEIGH_ATTR_DST | NEIGH_ATTR_FAMILY);
}
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Reviewed-by: Nolan Leake <nolan@cumulusnetworks.com>
Reviewed-by: Shrijeet Mukherjee <shm@cumulusnetworks.com>
Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
1. Fix some places where unsigned value compared < 0
2. Fix obsolete %Z specifier to more portable %z
3. Some erroneous types substitution
4. nl_msec2str() - 64-bit msec is now properly used,
Only safe changes. I mean int <--> uint32_t and signed/unsigned fixes.
Some functinos require size_t argument instead of int, but changes of
signatures of that functions is terrible thing.
Also, I do not pretend for a full list of fixes.
Just to shut up clang -Wall -Wextra
One more thing. ifindex. I don't change that because changes will
be too big for simple fix.
|
|
|
|
|
|
|
|
| |
Attached is a patch to fix two problems with dumping objects to a buffer in=
stead of a file descriptor.
One was a problem in detecting the end of the buffer in the newline code.
The other was a problem with clearing the whole buffer before printing each=
object.
|
|
|
|
|
|
|
|
|
|
| |
- changes the modules hierarchy to better represent the set of libaries
- list the header file that needs to be included
- remove examples/doc from api ref that is included in the guide
- add references to the guide
- fix doxygen api linking for version 1.8.0
- readd doxygen mainpage to config file
- fix a couple of doxygen doc bugs
|
| |
|
| |
|
|
|
|
| |
Mostly killing doxygen warnings, some doc updates to caching
|
|
|
|
|
|
|
|
|
|
|
|
| |
Rules don't have unique identifiers, so all attributes are compared
by initializing the ID mask to ~0. This doesn't work however since
nl_object_identical verifies whether the ID attributes are actually
present before comparing the objects, which is never the case.
Work around by using the intersection of present attributes when
comparing two rule objects.
Signed-off-by: Patrick McHardy <kaber@trash.net>
|
|
|
|
|
| |
based on my finding, ce_mask needs to be identical on clones; otherwise
some functions (like "dump") will treat clones differently.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In order for the interface to become more thread safe, the error
handling was revised to no longer depend on a static errno and
error string buffer.
This patch converts all error paths to return a libnl specific
error code which can be translated to a error message using
nl_geterror(int error). The functions nl_error() and
nl_get_errno() are therefore obsolete.
This change required various sets of function prototypes to be
changed in order to return an error code, the most prominent
are:
struct nl_cache *foo_alloc_cache(...);
changed to:
int foo_alloc_cache(..., struct nl_cache **);
struct nl_msg *foo_build_request(...);
changed to:
int foo_build_request(..., struct nl_msg **);
struct foo *foo_parse(...);
changed to:
int foo_parse(..., struct foo **);
This pretty much only leaves trivial allocation functions to
still return a pointer object which can still return NULL to
signal out of memory.
This change is a serious API and ABI breaker, sorry!
|
|
|
|
|
|
|
|
|
|
| |
Adds all missing routing attributes and brings the routing
related code to a working state. In the process the API
was broken several times with the justification that nobody
is using this code yet.
The changes include new example code which is also a prototype
for how plain CLI tools could look like to control routes.
|
|
|