summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* Wrong calcultation in nla_reserveEmmanuel Thierry2013-04-281-1/+1
| | | | | | | 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>
* attr: Fix typo in nla_is_nested()Thomas Graf2013-04-281-1/+1
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Merge branch 'fixes' of https://github.com/socketpair/libnlThomas Graf2013-04-282-6/+15
|\
| * Fix leak of cb if nl_socket_alloc_cb() failed to allocate socketКоренберг Марк (дома)2013-04-271-4/+13
| | | | | | | | | | - 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())
| * dump_attrs: "NLA_F_NESTED" => nla_is_nested(nla)Коренберг Марк (дома)2013-04-261-2/+2
| |
* | attr: nla_is_nested() must access nla_type directlyThomas Graf2013-04-281-1/+1
|/ | | | | | Can't used nla_type() as it applies NLA_TYPE_MASK first Signed-off-by: Thomas Graf <tgraf@suug.ch>
* addr: only translate more recent address family names and ARP types if definedThomas Graf2013-04-052-0/+10
| | | | | | Helps making libnl compilable with older kernel headers Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Perform no operation on nl_object_free(NULL).Emmanuel Roullit2013-04-031-1/+6
| | | | | | | | | 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>
* msg: Pretty print generic netlink header in nl_msg_dump()Thomas Graf2013-04-021-41/+97
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* nl: Return -NLE_AGAIN if non-blocking socket would blockThomas Graf2013-04-021-5/+0
| | | | | | | | | | 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>
* genl: Fix cb reference leak in genl_ctrl_probe_by_name()Thomas Graf2013-04-021-2/+7
| | | | | | nl_socket_get_cb() bumps the cb reference counter Signed-off-by: Thomas Graf <tgraf@suug.ch>
* ct: add ICMPv6 type,code and IDHolger Eitzenberger2013-04-021-18/+45
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* nl: Print file:line:func in debugging messages and provide --disable-debug ↵Thomas Graf2013-04-023-1/+9
| | | | | | | | | to disable debugging Compiling libnl with --disable-debug will result in the ignorance of the 'NLDBG' environment variable. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: Improve debugging messages of cache operationsThomas Graf2013-04-011-24/+38
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* genl: Update mt_id of cache ops when resolving genl idThomas Graf2013-04-011-0/+4
| | | | | | | | | | | | 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>
* genl: Provide internal function to resolve name to idThomas Graf2013-04-011-0/+26
| | | | | | Like genl_ops_resolve() but uses its own socket. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* rtnl-addr: Fix invalid call to nl_addr_set_prefixlen() if neither local or ↵Thomas Graf2013-03-141-4/+7
| | | | | | peer address are present Signed-off-by: Thomas Graf <tgraf@suug.ch>
* rtnl-addr: Inherit prefix length to nl_addr objs in rtnl_addr_set_prefixlen()Thomas Graf2013-03-141-3/+32
| | | | | | | | | | | | 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>
* addr: Update to latest address familiy definition for translationThomas Graf2013-03-141-2/+11
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* addr: improve API reference documentation for nl_addr_*()Thomas Graf2013-03-141-40/+164
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* addr: Reset unused portion of binary address in nl_addr_set_binary_addr()Thomas Graf2013-03-141-1/+4
| | | | | | | 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>
* msg: Pretty print error message header even if incompleteThomas Graf2013-03-141-15/+24
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* msg: Pretty print padding attributes in nl_msg_dump()Thomas Graf2013-03-141-3/+7
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* attr: Warn application if nla_parse() observes same attribute multiple timesThomas Graf2013-03-141-8/+13
| | | | | | | | Use a debugging message to warn applications if an attribute is found multiple times in the same message. It is perfectly valid to rely on this behaviour but it is likely to indicate a bug. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* attr: No longer warn about attribute of type 0Thomas Graf2013-03-141-3/+2
| | | | | | The kernel will start using type 0 attributes for padding purposes. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* attr: Do not enforce maximum length for NLA_FLAG attributesThomas Graf2013-03-141-3/+1
| | | | | | | Although wasteful, NLA_FLAG with non zero payload cause no harm and should thus not be rejected. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* attr: Add nla_nest_cancel() to remove partially added nested attributesThomas Graf2013-03-141-2/+23
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Use thread-safe strerror_r() instead of strerror()Thomas Graf2013-02-284-6/+8
| | | | | | | We have only ever fed well known error codes into strerror() so it should never have been a problem though. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Fix rtnl_link_af_data_compare return valueroopa2013-02-241-7/+11
| | | | | | | | | | | | | | | | | | | | This patch fixes a bug where because of the af_ops check being first in the function, we were returning ~0 if af_ops was null even if both objects really did not have af_data and we should be returning 0. Its better to have the af_data present check before anything else. So, Rearranged some of the code in rtnl_link_af_data_compare. Changes include: - Do the attribute present check before anything else - If ao_compare op not present, return ~0 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> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: move af_data_compare to the endroopa2013-02-241-6/+6
| | | | | | | | | | | | | | In the current code if rtnl_link_af_data_compare returns value > 0 we mark PROTINFO attribute in the diff mask and return without comparing flags. This patch makes af_data to be the last thing we compare. 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> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* bond: Provide rtnl_link_bond_alloc()Thomas Graf2013-02-141-14/+27
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* vlan: Provide rtnl_link_vlan_alloc()Thomas Graf2013-02-141-1/+22
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* bridge: Provide rtnl_link_bridge_alloc()Thomas Graf2013-02-141-0/+21
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* bridge: Support the new bridging attributesThomas Graf2013-02-071-12/+362
| | | | | | | | | | | | | This provides support for the new bridging attributes provided in IFLA_PROTINFO while maintaining backwards compatibility with older kernels. A set of new API functions are exported to access the bridging information. rtnl_link_bridge_has_ext_info() can be used to check whether a bridge object has been constructed based on the newly available attributes or the old message format. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* attr: Provide nla_is_nested() functionThomas Graf2013-02-051-1/+12
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Free and realloc af specific data upon rtnl_link_set_family()Thomas Graf2013-02-051-0/+6
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Hold af_ops reference for each AF_SPEC block during lifetime of link ↵Thomas Graf2013-02-051-4/+6
| | | | | | object Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Modify link policy on the stackThomas Graf2013-02-051-2/+5
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Keep reference to af_ops during lifetime of link objectThomas Graf2013-02-051-0/+4
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Fix af_ops leak on ENOMEMThomas Graf2013-02-051-1/+3
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* can: Fix nested message creation in can_put_attrs()Holger Dengler2013-02-011-0/+2
| | | | | | Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de> Signed-off-by: Holger Dengler <dengler@linutronix.de> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* neigh: Remove check for AF_UNSPEC in rtnl_neigh_get()Thomas Graf2013-02-011-2/+2
| | | | | | | | | | | | | This check was introduces to not accidently return AF_BRIDGE objects to unaware API users as they do differ in structure. However, such objects are only available if explicitely requests using the NL_CACHE_AF_ITER flag or by using arg1 == AF_BRIDGE for the cache. Therefore remove this check and allow rtnl_neigh_get() to be used to fetch any neighbor object of a cache. Reported-by: Maxime Bizon <mbizon@freebox.fr> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Fix mask calculation in nl_addr_cmp_prefix()Thomas Graf2013-01-311-2/+2
| | | | | Signed-off-by: Malte Langermann <mlangermann@radiodata.biz> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Merge branch 'nattuple' of https://github.com/rmfought/libnlThomas Graf2013-01-311-2/+6
|\
| * netfilter: correct error in construction of NAT tupleRich Fought2013-01-291-2/+6
| |
* | link cache: remove AF_UNSPEC check in rtnl_get_link and rtnl_get_link_by_nameroopa2013-01-311-3/+2
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch reverts back the AF_UNSPEC check introduced by AF_BRIDGE changes at http://lists.infradead.org/pipermail/libnl/2012-November/000796.html After the addition of AF_BRIDGE support, link cache can now contain objects of type AF_BRIDGE. To make sure existing api's did not return AF_BRIDGE objects and surprise existing callers, I introduced the check for AF_UNSPEC. But from what Andy Wang reported, rtnl_link_get_by_name returns the first link object with matching ifindex and that could have not only been AF_UNSPEC but also of family AF_INET6. And his app always got an AF_INET6 object prior to the patch that introduced the AF_UNSPEC check. I could just add AF_INET6 family check along with AF_UNSPEC in the apis and that should work well. But thinking about it some more, removing the AF_UNSPEC change seems to be safer at this point. That way this api will retain its semantics and return the first object with matching ifindex. It could be of any supported family. The user will know if the cache contains bridge objects, because they are available only with the cache flag NL_CACHE_AF_ITER. Besides, if new users want to search for a specific object, nl_cache_find is a better option. Reported-by: Andy Wang <Andy.Wang@watchguard.com> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* can: add helper function to get CAN bus stateBenedikt Spranger2013-01-251-0/+19
| | | | | | Add a helper function to get the CAN bus state. Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de>
* Merge pull request #29 from rmfought/natdir32Thomas Graf2013-01-241-3/+3
|\ | | | | netfilter: expectation NAT direction is 32 bit attribute
| * netfilter: keep 8-bit API for 32-bit NAT dir attributeRich Fought2013-01-241-2/+2
| |
| * netfilter: expectation NAT direction is 32 bit attributeRich Fought2013-01-232-5/+5
| |