summaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* route/netem: merge branch 'pr/159'Thomas Haller2018-01-161-14/+38
|\ | | | | | | https://github.com/thom311/libnl/pull/159
| * route: free previous data in rtnl_netem_set_delay_distribution_data()Thomas Haller2018-01-161-1/+7
| | | | | | | | | | | | | | Otherwise, calling rtnl_netem_set_delay_distribution_data() will leak memory, and that should just be supported. Also, handle failure to allocate memory.
| * route: fix memleak in rtnl_netem_set_delay_distribution_data()Thomas Haller2018-01-161-1/+3
| |
| * route: mark data argument for rtnl_netem_set_delay_distribution_data() as constThomas Haller2018-01-161-1/+1
| |
| * route: add rtnl_netem_set_delay_distribution_data() to linker scriptThomas Haller2018-01-161-3/+5
| | | | | | | | And some style fixes.
| * route: add separate function to set netem qdisc delay distributionSteffen Vogel2017-12-201-10/+26
| | | | | | | | | | | | | | | | | | A new function rtnl_netem_set_delay_distribution_data() has been added to allow the user to pass the delay distribution directly without loading it from a file. In conjunction with the maketable code (see iproute2 / NISTnet) this can be used to generate and load custom delay distributions on the fly.
* | all: declare all variables at the beginning of scope ↵Thomas Haller2018-01-162-10/+17
|/ | | | | | | | (-Wdeclaration-after-statement) Avoid gcc warning: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
* Change rtnl_link_af_ops.ao_override_rtm behaviorJef Oliver2017-11-292-4/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rtnl_link_af_ops.ao_override_rtm allows for a link module to override the change request type being sent to the kernel. More specifically, the default change request type is RTM_NEWLINK. Some link change requests require the reqeust type to be set to RTM_SETLINK. This is the case for IFLA_PROTINFO specific attributes for a link that is slave to a bridge. Currently, ao_override_rtm is static to the address family type. So, all changes submitted to AF_BRIDGE override the link change request type. The override only needs to happen if IFLA_PROTINFO attributes are appended to the link change request. This patch changes ao_override_rtm from a const integer to a function pointer that allows for a link module to determine if the override needs to actually happen. Currently, only the bridge module uses this functionality. If bridge flags are applied to a link (bdpu blocking, learning, fast leave, etc...), these flags are nested in IFLA_PROTINFO. If the flags are present, the link change request type will be overridden as RTM_SETLINK. This fixes the ability to set a bridge link up or down by using the correct RTM_NEWLINK link change request type. $ sudo src/nl-link-set -n br2 --state=down Changed bridge br2 ether a6:e6:94:8c:61:ec <broadcast,multicast,up,running,lowerup> group 0 $ ip link show br2: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000 $ sudo src/nl-link-set -n br2 --state=up Changed bridge br2 ether a6:e6:94:8c:61:ec <broadcast,multicast> group 0 $ ip link show br2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 Signed-off-by: Jef Oliver <jef.oliver@intel.com> Fixes: 55bc931a7272e6ac8f555bcc2a373eb2b6b58377 http://lists.infradead.org/pipermail/libnl/2017-November/002382.html http://lists.infradead.org/pipermail/libnl/2017-November/002385.html
* route: fix handling old_nh in rtnl_route_parse() and avoid leakThomas Haller2017-11-061-8/+20
| | | | | | | | | | | The previous code would miss to release old_nh in the error path. Also, it relied on the present netlink attributes to have old_nh initialized. Don't do that. Also, fixup error codes by using "goto errout_nomem" where appropriate and keep @err as returned from rtnl_route_set_metric().
* route/vlan: add capability to indicate heap overflow fix in ↵Thomas Haller2017-10-231-1/+1
| | | | | | | rtnl_link_vlan_set_egress_map() Without this fix/capablity, adding more then 4 mappings in rtnl_link_vlan_set_egress_map() overflows the heap.
* route/vlan: grow buffer exponentially in rtnl_link_vlan_set_egress_map()Thomas Haller2017-10-231-2/+8
| | | | | | | By a factor of 1.5 instead of 2, to value wasted storage overhead higher then the number of operations. Also, check for integer overflows.
* route/vlan: fix cloning vlan link in vlan_clone()Thomas Haller2017-10-231-6/+15
| | | | | | | | | | We need to copy the entire source struct over from source to destination. The only thing that needs special handling is to deep-clone the vi_egress_qos buffer. Fixes: a7469ce758fac3631df6ce72eb3f89150070e7f8
* route/vlan: fix memory corruption in rtnl_link_vlan_set_egress_mapSebastian Bixl2017-10-231-1/+1
| | | | | | | | | | | | If you set more than four entries for the vlan egress map a memory corruption occurs because the reallocation does not reserve memory for more than four. Fixes: a7469ce758fac3631df6ce72eb3f89150070e7f8 https://github.com/thom311/libnl/pull/155 [thaller@redhat.com: squashed commits and updated commit message]
* route: neigh: print family in neigh dumpsRoopa Prabhu2017-10-121-1/+5
| | | | | | | | | Since the neigh cache can contain msgs from different families, print family id to distinguish neigh cache entries in the dump output Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* route: link: add family to dump messagesRoopa Prabhu2017-10-121-0/+3
| | | | | | | | | Since the link cache can contain msgs from different families, print family id to distinguish link cache entries in the dump output Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* nl: add "const" specifier for nla_policy argument of parse functionsThomas Haller2017-10-094-7/+7
| | | | | | | | | | | Adding const to a function argument is generally not an API break (at least, if the argument is a struct, like in this case). Usually we declare the policy as static variables. The user should be able to mark them as "const", so that the linker makes the policy array read-only. Adjust the API to allow for that. Signed-off-by: Thomas Haller <thaller@redhat.com>
* libnl-3.4.0 releaselibnl3_4_0Thomas Haller2017-10-091-1/+1
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* netconf: Put nc reference in msg_parserDavid Ahern2017-09-211-1/+4
| | | | | | | | | | netconf_msg_parser is leaking memory. Add the put in the newly allocated nc object to release the initial reference. Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com> Signed-off-by: David Ahern <dsa@cumulusnetworks.com> http://lists.infradead.org/pipermail/libnl/2017-September/002378.html
* Potential memory leak becaue of wrong variable check.Amit Khatri2017-09-011-1/+1
| | | | | | | | | | | | | in rtnl_link_vf_vlan_alloc() function allocating memory to vlans while checking NULL or not vf_vlans. it can cause memory leak. Signed-off-by: Amit Khatri <amit.khatri@samsung.com> Signed-off-by: Rohit Pratap Singh <rohit.s@samsung.com> Fixes: 5d6e43ebef12deadf31fccfa46c0b34892675d36 http://lists.infradead.org/pipermail/libnl/2017-August/002373.html
* route: Add support for MPLS encapDavid Ahern2017-08-182-1/+135
| | | | | | Add support for MPLS lwtunnel encapsulation. Signed-off-by: David Ahern <dsahern@gmail.com>
* route: Add support for lwtunnel encapsulationsDavid Ahern2017-08-183-0/+158
| | | | | | | | | | Add framework to support lwtunnel encapsulations per nexthop. Encapsulations types are expected to fill in the nh_encap_ops for building and parsing messages, compare encapsulations in routes, dumping the encapsulations and freeing memory. Signed-off-by: David Ahern <dsahern@gmail.com>
* route: Add support for ttl propagation in MPLS routesDavid Ahern2017-08-181-0/+33
| | | | | | | Add support for RTA_TTL_PROPAGATE attribute on a per-route basis. Used to enable/disable TTL propagation at LSP egress. Signed-off-by: David Ahern <dsahern@gmail.com>
* route: Add support for MPLS address familyDavid Ahern2017-08-183-10/+230
| | | | | | | | | | | | | | | | | Add support for route in MPLS family. New attributes: - RTA_NEWDST - label stack for a nexthop - RTA_VIA - nexthop address (e.g., IPv4 or IPv6) Other changes required: - scope has to be universe for MPLS routes so fixup rtnl_route_guess_scope - priority attribute can not be set for MPLS. Change rtnl_route_parse to not set the attribute by default for AF_MPLS. - table attribute should not be set unless something other than the default table. For MPLS this attribute can not be set. '/' is the separator in label stacks for consistency with iproute2. Signed-off-by: David Ahern <dsahern@gmail.com>
* addr: Add support for AF_MPLSDavid Ahern2017-08-181-11/+45
| | | | | | MPLS 'addresses' are 4-byte labels with a prefix length of 20. Signed-off-by: David Ahern <dsahern@gmail.com>
* addr: Add implementations for mpls_ntop and mpls_ptonDavid Ahern2017-08-181-0/+108
| | | | | | Implementations of mpls_ntop and mpls_pton taken from iproute2. Signed-off-by: David Ahern <dsahern@gmail.com>
* lib/route: add /usr/lib64/tc/ search path for netem dist fileThomas Haller2017-08-141-3/+9
| | | | https://github.com/thom311/libnl/issues/148
* all: avoid compiler warnings -Wimplicit-fallthroughThomas Haller2017-06-151-23/+23
|
* lib/genl/family.c: fix if (x) y; else y;Rasmus Villemoes2017-06-151-1/+1
| | | | | | | I'm not 100% sure this is the correct fix; maybe this really is supposed to return family->gf_maxattr, but this is an odd way of writing that. Anyway, comparing to the other genl_family_[gs]et functions, I suppose this is what was really meant.
* lib/xfrm/ae.c: fix memcpy(dst, dst) bugRasmus Villemoes2017-06-151-2/+2
| | | | | | This is clearly not what was intended. While at it, drop the pointless cast of the allocator's return value, and use plain malloc since we're explicitly populating all len bytes immediately afterwards.
* lib/route/qdisc/netem.c/trivial: don't use braces for one-line blocksThomas Haller2017-06-151-18/+11
|
* lib/route/qdisc/netem.c/trivial: fix whitespace and indentation in ↵Thomas Haller2017-06-151-39/+40
| | | | | | | | | | | | netem_msg_fill_raw() The indentation around if (netem->qnm_dist.dist_data && netem->qnm_dist.dist_size) { looked very wrong. Don't change the behavior, only the indentation. See also commit 861901c55bd9e2f84e7c8de0da5ea6179867907d which introduced the ill indentation.
* lib/route/cls/u32.c: use UCHAR_MAX define instead of numeric 255Thomas Haller2017-06-151-1/+1
|
* lib/route/qdisc/netem.c: avoid memory leak if realloc failsRasmus Villemoes2017-06-081-2/+3
| | | | | | PS: There's some serious whitespace damage in this vicinity (starting around line 269), making one wonder if the ifs and elses are matched as they should be.
* lib/route/cls/u32.c: remove bogus commentRasmus Villemoes2017-06-081-1/+0
|
* lib/route/cls/u32.c: let the compiler do pointer arithmeticRasmus Villemoes2017-06-081-1/+1
| | | | This is what ->, [] and & are for.
* lib/route/cls/u32.c: avoid overflowing an unsigned charRasmus Villemoes2017-06-081-0/+3
| | | | | | | | | If rtnl_u32_add_key is called too many times, sel->nkeys will wrap from 255 to 0, effectively killing all the previous rtnl_u32_add_key calls (while having an inaccessible chunk of memory sitting beyond the accessible part of the ->keys array). Not sure NOMEM is the best error code, but that's at least something users would already have to be prepared to handle.
* lib/route/cls/u32.c: remove pointless nl_data_append callsRasmus Villemoes2017-06-081-21/+0
| | | | | | | Increasing the size of the u->cu_selector item by the size of a struct tc_u32_key (i.e., making the flexible array member sel->keys one element bigger) is pointless when one doesn't update sel->nkeys or otherwise records the increased size, so these are effectively memory leaks.
* lib/data.c: avoid memleak if realloc failsRasmus Villemoes2017-06-081-4/+5
|
* lib/cache_mgr.c: remove pointless gotoRasmus Villemoes2017-06-081-2/+0
| | | | | | | | | The only way we can enter the block containing this goto is if i is equal to (the old value of) mngr->cm_nassocs, and that slot is now guaranteed to exist and be vacant after the succesful realloc call, while no earlier slots can have become available [there's no locking involved, so I assume that avoiding concurrent operations on a struct nl_cache_mngr is up to the caller].
* lib/cache_mngr.c: avoid memleak if realloc failsRasmus Villemoes2017-06-081-6/+9
| | | | | | | | | | | | foo = realloc(foo, ...) is almost always a bug - the only exceptions being if (a) one just exits the process in case of failure or (b) if one has made a copy of the foo pointer before the realloc call, and takes care to either reinstate it afterwards or free() it and make sure that the data structure is updated to handle foo now being NULL (in this case for example setting ->cm_nassocs to 0). (a) is not an option in libraries, and (b) is more cumbersome than just doing it the canonical way: use local variables for the new pointer and size, and only install them when realloc succeeds.
* genl: drop usage of GENL_ID_GENERATETobias Klauser2017-05-292-2/+2
| | | | | | | | | | | | After kernel commit a07ea4d9941a ("genetlink: no longer support using static family IDs"), GENL_ID_GENERATE is no longer exposed to userspace (and actually should never have been). Update the private header copy of linux/genetlink.h accordingly. And replace the two occurences of GENL_ID_GENERATE. Signed-off-by: Tobias Klauser <tklauser@distanz.ch> https://github.com/thom311/libnl/pull/144
* addr: add AF_VSOCK to translation tableTobias Klauser2017-05-121-0/+3
| | | | | | | | | Add AF_VSOCK to the address family translation table. https://github.com/thom311/libnl/pull/142 Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* rule: change API for setting/getting l3mdev rule propertyThomas Haller2017-05-121-4/+31
| | | | | | | | | | | | | | | | | | | | | | | - for rtnl_rule_set_l3mdev(), also allow unsetting the l3mdev field. In practice, kernel only allows for two options: either omit tb[FRA_L3MDEV] or set it to 1. As such, rtnl_rule_set_l3mdev() allows for both of these. In principle the setter could get extended to set other values. Such values are reserved. - for rtnl_rule_get_l3mdev() also return an error code. I think it is appropriate to mix value and negative error code, as long as the range of values cannot overlap with error codes. Arguably, the outcome is a bit awkward, as the function now is expected to return -NLE_MISSING_ATTR or 1. So, the best check is probably if (rtnl_rule_get_l3mdev(r) > 0) { ... } The reason for this change is that libnl should expose the netlink API without coercing uint8 to boolean. That way, future changes in kernel don't require update to libnl3. Signed-off-by: Thomas Haller <thaller@redhat.com>
* rule: Add support for l3mdev in FIB rulesDavid Ahern2017-05-121-3/+29
| | | | | | | | | | | | | | | | | | Add support for the l3mdev option in FIB rules. If l3mdev is set then the lookup is directed to the table associated with the l3mdev (e.g., VRF) device. If the l3mev attribute is set the table id is not, so update the table id attribute to make sure r_table is non-0. iproute2 shows the rule as: 1000: from all lookup [l3mdev-table] where [l3mdev-table] infers the dynamic nature of the table id. Keep that notation for libnl. Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* route: Add support for MPLS to netconfDavid Ahern2017-05-121-0/+40
| | | | | | | | | | | | Add support to netconf for MPLS address family. v2 - change get method to return 0/error and take 'int *val' which is set to the value requested - added rtnl_netconf_get_input to libnl-route-3.sym Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* route: Add support for netconfDavid Ahern2017-05-121-0/+540
| | | | | | | | | | | | Add route/netconf cache type to monitor RTM_*NETCONF messages. v2 - change get methods to return 0/error and take 'int *val' which is set to the value requested Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: Balakrishnan Raman <ramanb@cumulusnetworks.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* Do not increment refcount in rtnl_*_get_action APIs.Santhosh Kumar2017-05-032-6/+2
|
* Provide accessors for actions (rtnl_act).Santhosh Kumar2017-05-033-0/+39
| | | | | | Add accessor functions to retrieve actions on a tc object and provide additional function to navigate the collection of actions.
* route/link: add accessor API for IPv6 flagsMarkus Trapp2017-05-031-2/+49
| | | | | | | | Add functions to access the IPv6 specific flags of a link object. Also the functions for IPv6 link flags translation are now exported, similar to the non IPv6 specific translation functions. https://github.com/thom311/libnl/pull/136
* libnl-3.3.0 releaselibnl3_3_0Thomas Haller2017-05-031-1/+1
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>