summaryrefslogtreecommitdiffstats
path: root/include
Commit message (Collapse)AuthorAgeFilesLines
* hashtable: let caller decide whether to append/prepend object to hashtableThomas Haller2016-07-081-0/+2
| | | | | | | | | | nl_hash_table_add() should not ask the object whether to append/prepend. Instead, the caller should decide on that. Add an internal function _nl_hash_table_add() which accepts an @append argument. Signed-off-by: Thomas Haller <thaller@redhat.com>
* hashtable: remove internal data structures from public APIThomas Haller2016-07-082-11/+14
| | | | | | | | | | | | | | Hide the internal data structures for hashtable from public header "hashtable.h". Note that we just recently broke ABI/API by modifying these structs. Maybe the entire hashtable API should be private. Anyway, that seems to late now. Fixes: c6f89ed02f04ac4984be34418774a7b06ff54f79 Signed-off-by: Thomas Haller <thaller@redhat.com>
* route: cache and object changes to support non-exclusive and append routesRoopa Prabhu2016-07-082-0/+9
| | | | | | | | | | | | | | | | | | | | | | | Problem (ipv4 only): Todays libnl route cache looks at prefix + tos + priority to lookup a route object. To support route append operation, where routes with same prefix + tos + priority but different nexthop information can co-exist, we need to also look at nexthop info. Else we will wrongly store only one route for all appended routes. This happens Because the libnl cache inclusion process looks up a route by prefix + tos + priority and replaces it with the new object with the same prefix + tos + priority. Only adding nexthop attribute during lookup does not solve the whole problem. Because NLM_F_REPLACE of objects needs special handling. This patch implements route cache callback .co_cache_search_attrs_get and route object callback .oo_hash_attrs_get to return appropriate attributes for searching route objects depending on type of route and the netlink message flags (NLM_F_APPEND or NLM_F_REPLACE). This is used during cache inclusion process. Also adds ROUTE_ATTR_MULTIPATH to the list of route attribute keys to search. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
* obj_ops: add new oo_hash_attrs_get to get hash key attributes of any objectRoopa Prabhu2016-07-081-0/+5
| | | | | | | | This callback supports querying of hash key attributes of an object. This will be used by caches (like the route cache) to decide on search attributes during cache inclusion depending on netlink message flags. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
* cache: modify nl_cache_search to look at cache provided attributes for searchRoopa Prabhu2016-07-084-0/+23
| | | | | | | | | | | | This patch adds a new cache operation co_cache_search_attrs_get to request for attributes to use in the search. This gives the cache an opportunity to use search attributes based on netlink message flags. This is mainly to give the route cache an ability to decide on the cache inclusion depending on the netlink header flags like NLM_F_APPEND and NLM_F_REPLACE. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
* hashtable: convert hashtable bucket list to a circular doubly linked listRoopa Prabhu2016-07-081-1/+1
| | | | | | | | | | This patch converts hashtable bucket list to a circular doubly linked list for O(1) enqueue/dequeue. This helps support: - a netlink object append that causes enqueue at tail and - support for non-exclusive (ie create only flag) netlink objects causes an enqueue at head Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
* cache: add new NL_OBJ_DUMP cache flag (ce_flags)Roopa Prabhu2016-07-081-0/+1
| | | | | | | | kernel does not include NLM_F_APPEND or NLM_F_REPLACE flags during dumps. This flag helps distinguish object cache inclusion due to netlink dumps from those resulting from netlink notifications. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
* nl_object: add new ce_msgflags field to nl_objectRoopa Prabhu2016-07-081-0/+1
| | | | | | | | | | | This patch adds a new flag ce_msgflags to nl_object and adds a first user of this flag, the route object. This enables the route cache to make proper cache inclusion decisions based on netlink msg flags like NLM_F_APPEND, NLM_F_REPLACE Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
* libnl-3.2.28 releaselibnl3_2_28Thomas Haller2016-07-081-0/+6
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* build: fix adding macsec files to include/Makefile.amThomas Haller2016-06-301-0/+2
| | | | Fixes: 885ff4ae1efce35f8db378b2533025c3c931823c
* route/addr: add capability NL_CAPABILITY_RTNL_ADDR_PEER_FIX to indicate ↵Thomas Haller2016-06-291-0/+7
| | | | | | address fixes Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/addr: fix ID comparison for AF_INET and AF_INET6 addressesThomas Haller2016-06-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* xfrm: allow avoiding buffer overflow for key in xfrmnl_sa_get_*_params()Thomas Haller2016-06-291-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous API of xfrmnl_sa_get_*_params() would always require a @key buffer, but it was not possible to avoid buffer overflow because the required size was unknown. That is not really fixable, because the old API is broken. Now, allow omitting the @key argument to only request the @key_size. That allows the caller to ask beforehand how large the @key buffer must be: ((@key_size + 7) / 8). Unfortunately, omitting the key against previous versions of libnl leads to a crash. And passing a key against older versions makes it impossible to avoid buffer-overflow. Another option would be to add functions like xfrmnl_sa_get_crypto_params_keylen() so the user can query the required buffer size by calling that instead of xfrmnl_sa_get_crypto_params(). However, then the user also requires a backport of the new API and this will not be possible against older libnl3 versions either. Thus, if the user already requires the fix, he can just as well require a backport of this patch and then safely call xfrmnl_sa_get_crypto_params() without @key argument. This way has the advantage/disadvantage, that it can detect the presence of the patch at runtime. The cumbersome way to get it right would be: unsiged key_len; char *key; int r; if (!nl_has_capability(17 /*NL_CAPABILITY_XFRM_SA_KEY_SIZE*/)) { /* no way to use this API safely. Abort. */ return -NLE_OPNOTSUPP; } r = xfrmnl_sa_get_crypto_params(sa, NULL, &key_len, NULL); if (r < 0) return r; key = malloc((key_len + 7) / 8); if (!key) return -NLE_NOMEM; r = xfrmnl_sa_get_crypto_params(sa, NULL, &key_len, &key); if (r < 0) { free(key); return r; } ... http://lists.infradead.org/pipermail/libnl/2016-June/002155.html Signed-off-by: Thomas Haller <thaller@redhat.com>
* lib/route: add macsec supportSabrina Dubroca2016-06-251-0/+73
| | | | Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
* import macsec uapi headersSabrina Dubroca2016-06-252-0/+199
| | | | Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
* pass flags through ->io_compare opSabrina Dubroca2016-06-251-2/+3
| | | | | | | | | | Currently rtnl_link_info_data_compare doesn't pass flags (LOOSE_COMPARISON) to the ->io_compare op, so we cannot do a match on only the attributes that are actually set in the filter object used in a cache lookup via nl_cache_find(). Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: Thomas Haller <thaller@redhat.com>
* xfrm: make character pointers in setters constThomas Egerer2016-06-251-7/+9
| | | | | | | | | | | | All of these pointers are either strcpy'd or memcpy'd and usually const in a calling application. Changing them to const in the header does not break the compatibility and allows for users with const pointers to use the library without compiler warnings. Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com> Signed-off-by: Thomas Haller <thaller@redhat.com> http://lists.infradead.org/pipermail/libnl/2016-June/002137.html
* lib: return error on Netlink attribute length overflowPrzemyslaw Szczerbik2016-06-241-1/+2
| | | | | | | | | | | | | | Netlink attribute length is defined as u16. It's possible to exceed nla_len when creating nested attributes. Storing incorrect length due to overflow will cause a reader to read only a part of nested attribute or skip it entirely. As a solution cancel the addition of a nested attribute when nla_len size is exceeded. Signed-off-by: Przemyslaw Szczerbik <przemek.szczerbik@gmail.com> Signed-off-by: Thomas Haller <thaller@redhat.com> http://lists.infradead.org/pipermail/libnl/2016-May/002131.html
* link: allow overwriting IFLA_EXT_MASK flag in ao_get_af() functionThomas Haller2016-06-241-1/+2
| | | | | | | Instead of setting it twice, once during link_request_update() and later in bridge_get_af(), pass ext_filter_mask to ao_get_af(). Signed-off-by: Thomas Haller <thaller@redhat.com>
* neigh: add function to look up neighbour (fdb) by ifindex, mac and vlanJonas Johansson2016-05-291-0/+2
| | | | | | | | | | | | | | | | | The rtnl_neigh_get() function can not be used to look up a fdb entry in the neigh cache. This is due to that the function searches among destination addresses (NDA_DST) and not among link layer addresses (NDA_LLADDR), which is used by fdb entries. A fdb entry can also exist in several vlans, so a vlan id parameter is also needed to find a unique entry. This commit adds a function, rtnl_neigh_get_by_vlan() which searches the neigh cache for a specific neighbour (fdb) entry by interface index, link layer address and vlan id. Signed-off-by: Jonas Johansson <jonas.johansson@westermo.se> Signed-off-by: Thomas Haller <thaller@redhat.com> http://lists.infradead.org/pipermail/libnl/2016-May/002124.html https://github.com/thom311/libnl/pull/98
* sit: add public API for sit 6RD supportThomas Haller2016-04-151-0/+12
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* sit: fix invalid declaration of rtnl_link_sit_get_proto() in sit.hThomas Haller2016-04-151-1/+1
| | | | | | Fixes: d715b8a5f6ec8faf205ae77950a1c625440be22f Signed-off-by: Thomas Haller <thaller@redhat.com>
* ipgre: add support for gretap tunnelHaishuang Yan2016-04-151-0/+2
| | | | | | | | | | | | | Since kernel support both gre/gretap tunnel, so add support for gretap appropriately. Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com> Signed-off-by: Thomas Haller <thaller@redhat.com> [thaller@redhat.com: modified original patch to move symbols in libnl-route-3.sym to proper section] http://lists.infradead.org/pipermail/libnl/2016-April/002102.html
* lib: add type casting for nla_for_each_nested macroPrzemyslaw Szczerbik2016-02-251-1/+1
| | | | | | | | | | | g++ is unable to compile code with nla_for_each_nested macro due to implicit type conversion from void* to nlattr*. This patch adds type casting for nla_for_each_nested macro to address this issue. Signed-off-by: Przemyslaw Szczerbik <przemek.szczerbik@gmail.com> Signed-off-by: Thomas Haller <thaller@redhat.com> http://lists.infradead.org/pipermail/libnl/2016-February/002095.html
* lib/utils: add NL_CAPABILITY_NL_OBJECT_DIFF64 capabilityThomas Haller2016-02-121-0/+6
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* lib: update ce-mask to uint64_tDavid Ahern2016-02-124-7/+11
| | | | | | | | | | | | | | | | | | | | 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>
* remove null dereference from netlink/link.hNick Lewycky2016-02-121-1/+3
| | | | | | | | | Replace a null pointer dereference with a use of the 'offsetof' macro in stddef.h. http://lists.infradead.org/pipermail/libnl/2016-January/002085.html Signed-off-by: Nick Lewycky <nlewycky@google.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/link/bridge: fixed return typeTobias Jungel2015-12-161-1/+1
| | | | | | Fixes: 6555b0d https://github.com/thom311/libnl/pull/94
* bridge: add support for VLANsDavid Ahern2015-12-071-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | Add operation for requesting VLAN data for AF_BRIDGE and parsing of IFLA_AF_SPEC for AF_BRIDGE. VLANs are saved in a bitmap. Also add dumping of vlan info to link list and neigh list. For example: $ nl-link-list --details --family=bridge br1 ether 8e:6e:0e:86:e5:86 master br1 <broadcast,multicast,up,running,lowerup> mtu 1500 txqlen 0 weight 0 index 18 mode default carrier down bridge: pvid 1 all vlans: 1 301-400 601-610 untagged vlans: 1 bond1 ether 46:ef:e1:c9:46:fe <broadcast,multicast,master> mtu 1500 txqlen 0 weight 0 index 20 state down mode default carrier down bridge: Signed-off-by: Wilson Kok <wkok@cumulusnetworks.com> Signed-off-by: David Ahern <dsa@cumulusnetworks.com> [thaller@redhat.com: modified original patch to use ao_parse_af_full(). Also renaming new API and drop some #defines] Signed-off-by: Thomas Haller <thaller@redhat.com>
* include/linux: update copy of kernel headersThomas Haller2015-12-075-12/+831
| | | | | | | Taken from upstream kernel commit 6a13feb9c82803e2b815eca72fa7a9f5561d7861 (v4.3)). Signed-off-by: Thomas Haller <thaller@redhat.com>
* lib: handle family-based parsing of IFLA_AF_SPEC attributeDavid Ahern2015-12-071-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The encoding of the IFLA_AF_SPEC attribute varies depending on the family used for the request (RTM_GETLINK) message. For AF_UNSPEC the encoding has another level of nesting for each address family with the type encoded first. i.e., af_spec = nla_nest_start(skb, IFLA_AF_SPEC) for each family: af = nla_nest_start(skb, af_ops->family) af_ops->fill_link_af(skb, dev, ext_filter_mask) nest_end nest_end This allows the parser to find the address family by looking at the first type. Whereas AF_BRIDGE encoding is just: af_spec = nla_nest_start(skb, IFLA_AF_SPEC) br_fill_ifvlaninfo{_compressed}(skb, vg) nest_end which means the parser can not use the attribute itself to know the family to which the attribute belongs. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> [thaller@redhat.com: refactor code by merging a later patch by tobias.jungel@bisdn.de and introduce new function ao_parse_af_full()] Signed-off-by: Thomas Haller <thaller@redhat.com>
* link: add AF operation to append attributes to a GETLINK messageDavid Ahern2015-12-071-0/+4
| | | | | | | | | | | Upcoming bridge patch wants to add IFLA_EXT_MASK attribute to RTM_GETLINK requests to retrieve VLAN data. Expand request message to a full ifinfomsg header and call to hook to append attributes if it exists for an address family. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> [thaller@redhat.com: fix memleak in link_request_update()] Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/link/vxlan: add support for link_info compareDavid Ahern2015-11-201-0/+6
| | | | | | | Signed-off-by: Balki Raman <ramanb@cumulusnetworks.com> Signed-off-by: David Ahern <dsa@cumulusnetworks.com> [thaller@redhat.com: whitespace, add capability, consider local6/group6] Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/link: add link info compare operationDavid Ahern2015-11-201-0/+6
| | | | | | Signed-off-by: Balki Raman <ramanb@cumulusnetworks.com> Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/link: fix dump of parent link for some link typesBeniamino Galvani2015-11-191-0/+1
| | | | | | | | Some link types incorrectly dump their own interface name as parent link; fix this. Signed-off-by: Beniamino Galvani <bgalvani@redhat.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/link: add macvtap supportBeniamino Galvani2015-11-192-0/+47
| | | | | | | | | This adds support for MAC-VLAN based tap interfaces (macvtap). http://lists.infradead.org/pipermail/libnl/2015-October/001976.html Signed-off-by: Beniamino Galvani <bgalvani@redhat.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* link/neigh: add flags option to link and neighbor cachesDavid Ahern2015-11-195-1/+16
| | | | | | | | | | | | | Both link and neighbor cache support specify multiple groups (nl_af_group), but the alloc_cache functions for both do not set the NL_CACHE_AF_ITER flag before populating the cache so only the first group is used by default. This patch adds an API to pass in flags to make that happen and updates the nl-neigh-list command to make use of it. http://lists.infradead.org/pipermail/libnl/2015-October/001996.html Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/vlan: allow clearing vlan ingress mapThomas Haller2015-11-191-0/+8
| | | | | | | | | | | | | | | | | | | | | An entry of the ingress map can be cleared by setting the "to" part to zero. Previously, vlan_put_attrs() would skip over zero "to" and thus the user cannot unset an ingress map entry. Add a modified-mask to record the state of each ingress map entry and also sent explicit zeros to kernel. when we receive a IFLA_VLAN_INGRESS_QOS message from kernel, vlan_parse() similarly sets the received entries as modified. This preserves previous behavior when using a received object to modify a vlan. Add a capability NL_CAPABILITY_RTNL_LINK_VLAN_INGRESS_MAP_CLEAR to indicate the behavioral change. Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/link: fix parsing of 'remote' attribute for GRE linksBeniamino Galvani2015-11-191-0/+6
| | | | | | | | | | Fixes: 57bdc4ff4895dd91cc723d22eecadcf48945e87c http://lists.infradead.org/pipermail/libnl/2015-November/002004.html Signed-off-by: Beniamino Galvani <bgalvani@redhat.com> [thaller@redhat.com: add capability to indicate bug-fix] Signed-off-by: Thomas Haller <thaller@redhat.com>
* neigh: add support for NTF_SELFDavid Ahern2015-11-011-0/+2
| | | | | | | | http://lists.infradead.org/pipermail/libnl/2015-October/001995.html Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/vrf: add VRF supportDavid Ahern2015-11-013-0/+42
| | | | | | | | http://lists.infradead.org/pipermail/libnl/2015-October/001991.html Signed-off-by: David Ahern <dsa@cumulusnetworks.com> [thaller@redhat.com: slightly modified original patch] Signed-off-by: Thomas Haller <thaller@redhat.com>
* rtnl/link: indicate capability NL_CAPABILITY_RTNL_LINK_VLAN_PROTOCOL_SERIALZEThomas Haller2015-10-211-0/+6
| | | | Related: 0aca70083e51d97d0102c73852d31625f75c942b
* libnl-3.2.27 releaselibnl3_2_27Thomas Haller2015-10-161-0/+6
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* lib/attr: add nla utility functions for signed integersThomas Haller2015-10-051-1/+41
| | | | | | | | | | | | | Commit 7bb956501ccd58ed3bbffc59de996f056e178683 added nla functions for s32. We preferibly add all signed integer operations at the same time. Thus, also add s8, s16, and s64. Also, previously the NLA_TYPE_MAX enum was not extended to have NLA_S32. Fix that too. Reported-By: Jiri Pirko <jiri@resnulli.us> Fixes: 7bb956501ccd58ed3bbffc59de996f056e178683 Signed-off-by: Thomas Haller <thaller@redhat.com>
* route: add capability indicating the behavior of rtnl_neigh_get()Thomas Haller2015-09-291-0/+8
| | | | | | | | | | | | | | | A wrong behavior for rtnl_neigh_get() was introduced between 3.2.14 and 3.2.15 (commit 64fcb47a36ec12d7e7f00605f6a8952ce985dd08). It was later fixed between 3.2.21 and 3.2.22 (commit 8571f58f23763d8db7365d02c9b27832ad3d7005). Add a capability NL_CAPABILITY_RTNL_NEIGH_GET_FILTER_AF_UNSPEC_FIX to indicate that this buggy behavior was fixed. https://bugzilla.redhat.com/show_bug.cgi?id=1261028 http://lists.infradead.org/pipermail/libnl/2015-August/001951.html Signed-off-by: Thomas Haller <thaller@redhat.com>
* vlan: add MVRP VLAN flagJiří Klimeš2015-09-031-0/+1
| | | | | | | | Kernel patch: http://patchwork.ozlabs.org/patch/219040/ iproute2 patch: http://patchwork.ozlabs.org/patch/219364/ Signed-off-by: Jiří Klimeš <jklimes@redhat.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* socket: fix assertion in nl_connect() when all ports are already in useThomas Haller2015-08-241-1/+1
| | | | | | | | | | | | | When generating a port fails a few times (because they are already in used outside of libnl's knowledge), we would back off generating a local port and instead let kernel decide. There was however a bug in nl_connect() that caused an assertion: BUG at file position socket.c:147:_nl_socket_used_ports_release_all app: socket.c:147: _nl_socket_used_ports_release_all: Assertion `0' failed. Fixes: 96e1e5bdc2e803700055395cc3c428fa2525d1ca
* route/link: make link_netnsid argument (signed) int32_tThomas Haller2015-08-172-3/+3
| | | | | | Fixes: 66aab65595fb20bf166936fcfa4c8568b58f7f68 Signed-off-by: Thomas Haller <thaller@redhat.com>
* lib/attr: add nla utility functions for s32Thomas Haller2015-08-171-0/+11
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/link: add support for IFLA_LINK_NETNSIDThomas Haller2015-08-172-1/+5
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>