Set the address flags when creating/updating an address with
rtnl_addr_add/rtnl_addr_build_add_request. Before, the flags
were not passed on.
As of now, the flags except IFA_F_NODAD|IFA_F_HOMEADDRESS are ignored by
the kernel. Still pass them on without filtering.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Add flags set/get methods aim to change bridge flags :
o hairpin_mode
o bpdu_guard
o root_block
o fast_leave
Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Lookup on IFLA_INFO_KIND information to setup the right link->l_af_ops callbacks
For example, if you setup a bridge this is avoid to trig IS_BRIDGE_LINK_ASSERT() on rtnl_link_bridge_get_flags() call.
line=<optimized out>, function=<optimized out>) at assert.c:94
0x7ffff5dc39a0 "rtnl_link_bridge_get_flags") at assert.c:103
Signed-off-by: Nicolas PLANEL <nicolas.planel@enovance.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
The application could use the same handler for multiple
nl_cb_type events. This patch stores the nl_cb_type in
the nl_cb struct during the callback. This allows the
application to obtain that information using the new
nl_cb_active_type() function. This way the callback
signature remains as is so existing applications are
not affected.
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Newer kernels support conntrack zones, which help to partition the
conntrack table into virtual conntrack tables.
This patch is for adding support for the optional attribute, adds
setters and getters, and adds support for the zone ID in the conntrack
dumper.
An example entry in NL_DUMP_LINE format looks like:
tcp SYN_SENT 10.128.128.99:43354 <-> 10.128.129.20:22 zone 1
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Recent kernels support conntrack time stamping, which is a helpful
feature to determine the duration of a flow without building a flow
cache in your user space application, just to keep the 'start' time of
your flow.
Timestamps are recorded with nanosecond resolution once this feature
is enabled.
This patch adds optional support for the CTA_TIMESTAMP, then
modifies the dump routine to write that info in a format similar
to /proc/net/nf_conntrack. This is an example output when using
NL_DUMP_LINE:
udp 10.128.128.28:56836 <-> 10.128.129.255:8612 delta-time 30
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Introduced by commit 8026fe2e3a ("link:
Free and realloc af specific data upon rtnl_link_set_family()")
link->l_af_data[link->l_af_ops->ao_family] is freed here but not set to
zero. That leads to double free made by link_free_data->do_foreach_af.
Fix this by setting link->l_af_data[link->l_af_ops->ao_family] to zero
rigth after free.
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
- 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.
If a hdrlen was provided that was greather than the actual
message length, a negative attributes length would result.
This was typically happening for RTM_GETLINK requests where
we can get a away with a 4 bytes header on the request side
but the response would use a 16 bytes header.
This resulted in strange -8 bytes leftover debug messages.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
The batched verdict implicitely ACKs all queue packet IDs up to the
one send back, which reduces the number of verdict messages send
to the kernel.
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Since commit "nl: Return -NLE_AGAIN if non-blocking socket would block",
nl_cache_mngr_data_ready returns -NLE_AGAIN to callers on non-blocking sockets.
Change it to consider -NLE_AGAIN as a non-error case as it is expected behavior
with the nl_recv changes.
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>
Assuming that the kernel does not send more than a page is no longer valid,
and enabling MSG_PEEK'ing by default to figure out the exact message buffer
requirements can have a negative influence on the performance of existing
applications. Bumping the default receive buffer space to 4 pages seems
a sane default.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
rtnl_link_af_unregister() attempts to write-lock info_lock twice
instead of releasing it before returning. It also will return with
info_lock write-locked if passed a NULL ops.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
There seams to be an error in the calculation of needed space for the message in nla_reserve. The current size of the message is counted twice: Once in NLMSG_ALIGN, once in the condition below.
This causes nla_put_* calls to be rejected if the allocation size of the message has been strictly calculated by the caller.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
- each *_get() should have corresponding *_put(). That rule was broken in nl_socket_alloc()
- Also, check if cb is NULL in nl_socket_set_cb (calls BUG())
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>
Previously 0 was returned which gave the caller no chance of detecting
when a non-blocking socket would block. If a caller intends to never
see an error message it should utilize poll()/select() to only read
when the socket has pending data or information.
Reported-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Add ICMPv6 type, code and ID (if set) by using the already available
conntrack atttributes.
Currently the ICMPv6 conntrack objects in libnl are without type, code
and ID. This e. g. is the output of nl_object_dump() without the patch:
ipv6-icmp ::1 <-> ::1
id 0xdd0871f0 family inet6 timeout 30s <NOREPLY,SNAT_INIT,DNAT_INIT>
The attached patch tries to solve that. It then looks like
ipv6-icmp ::1 <-> ::1 icmp type 128 code 0 id 28253
id 0xdf3a11f0 family inet6 timeout 30s <SNAT_INIT,DNAT_INIT>
It is the 'small' approach, because it reuses the existing ICMP
attributes of the conntrack object (currently only used for IPv4).
This way I can avoid to add new _icmp6_get_, _icmp6_set_ and
_icmp6_test_ functions.
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
Signed-off-by: Thomas Graf <tgraf@suug.ch>
The cache layer uses the message type array stored in the cache
ops to lookup which cache a message belongs to. Update to the
the message array with the resolved generic netlink id to make
it compatible with the caching API.
Allows to use nl_cache_refill() and others for generic netlink
based caches with dynamic generic netlink ids.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Previously if using rtnl_addr_set_prefixlen() the new prefix length
was not forwarded to the corresponding 'struct nl_addr' objects
associated with address already and thus the comparison function
would fail.
This patch also clears the internal ADDR_ATTR_PREFIXLEN flag if
the prefix length has been reset.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
memset() the binary address before overwriting it with new data
to avoid leaving around old portions of the address.
Signed-off-by: Thomas Graf <tgraf@suug.ch>