summaryrefslogtreecommitdiffstats
path: root/lib/route
Commit message (Collapse)AuthorAgeFilesLines
...
* link: add Geneve support.Wang Jian2018-02-121-0/+810
| | | | Signed-off-by: Wang Jian <jianjian.wang1@gmail.com>
* Fix for cgroup filter addition problem.d0u92018-01-231-1/+4
| | | | | | | | | | Currently, due to the incomplete netlink datagram sent by libnl, cgroup filter addition is not fully functional. The datagram generated by `tc` command includes an empty attribute section, which is stripped off in the libnl counterpart. In this commit, a new `interface nla_nest_end_keep_empty()` is added. This function closes attribute without stripping off empty attribute.
* route: rename rtnl_cls_cache_set_tcm_params() and fix symbol versioningThomas Haller2018-01-181-2/+2
| | | | | | | | | After rethinking, "tcm_params" doesn't seem like a good name. Change it to "tc_params". Also, an already released section in the linker file must never be modified. It defeats the purpose of symbol versioning. Move the symbol to the right section.
* Add new function for setting ifindex and parent of a classifier cache.d0u92018-01-181-0/+18
| | | | | | | It is not good to give classifier cache users only one chance to set interface index and parent handle when allocte new cache. Sometimes we want to reuse classifier cache to reduce the overhead of allocating new memory everytime a new cache is created.
* Coding style formatd0u92018-01-161-1/+2
| | | | | | Fix incorrect code indent. https://github.com/thom311/libnl/pull/165
* lib/veth.c: Disassociate link name of peer nameMarcos Paulo de Souza2018-01-161-2/+2
| | | | | | | | | | Based in the function documentation, peer name could be set regardless of the link name being informed of not. These parameters should be checked independently. Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com> https://github.com/thom311/libnl/pull/162
* 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-161-9/+15
|/ | | | | | | | (-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: 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-091-1/+1
| | | | | | | | | | | 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>
* 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>
* lib/route: add /usr/lib64/tc/ search path for netem dist fileThomas Haller2017-08-141-3/+9
| | | | https://github.com/thom311/libnl/issues/148
* 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.
* 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
* include: don't include kernel headers in public libnl3 headersThomas Haller2017-03-029-0/+10
| | | | | | | | | | | | | | | | | It would be desirable not to include kernel headers in our public libnl3 headers. As a test, remove all those includes, and fix compilation by explicitly including the kernel headers where needed. In some cases, that requires forward declaration for kernel structures, as we use them as part of our own headers. Realistically, we cannot drop those includes as it probalby breaks compilation for users that expect to get a certain kernel header when including a libnl3 header. So, this will not be done and the includes will be restored in the next commit. Do this step to show how it would be and to verify that we could build with such a change. The reason not to do this is backward compatibility (at compile-time).
* route: neigh: use NDA_MASTER for neigh->n_master if availableRoopa Prabhu2017-02-271-10/+14
| | | | | | | | | | | | | | fdb cache is per bridge and hence hashed by: <bridge_ifindex, family, mac> newer kernels send bridge ifindex in NDA_MASTER. Use NDA_MASTER for neigh->n_master when available. Also imports a few more NDA_* attributes from upstream to keep linux/neighbour.h NDA_* attributes in sync with upstream. Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
* ematch: Add missing function prototypesTobias Klauser2017-01-201-0/+3
| | | | | | | | | Older versions of flex (namely the one used on Travis CI) don't properly emit function prototypes for ematch_get_column() and ematch_set_column(), leading to GCC -Wmissing-prototypes warnings. Fix them by manually adding these prototypes. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* pktloc: Add missing function prototypesTobias Klauser2017-01-201-0/+3
| | | | | | | | | Older versions of flex (namely the one used on Travis CI) don't properly emit function prototypes for pktloc_get_column() and pktloc_set_column(), leading to GCC -Wmissing-prototypes warnings. Fix them by manually adding these prototypes. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* link/ipgre: Add prototype for ABI-preserving wrapper rtnl_link_get_pmtudisc()Tobias Klauser2017-01-201-0/+4
| | | | | | | | | Avoid a GCC -Wmissing-prototypes warning by explicitely adding a prototype for the ABI-preserving wrapper added in commit 8d04ebf55400 ("lib/route: preserve old ABI for rtnl_link_get_pmtudisc()") and add an explanatory comment. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* link/macsec: Include own public header for function prototypesTobias Klauser2017-01-201-0/+1
| | | | | | | | | Include the own public header in order to get function prototypes for all public functions defined in this module. This fixes GCC -Wmissing-prototype warnings Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
* link/ipvti: Include own public header for function prototypesTobias Klauser2017-01-201-0/+1
| | | | | | | | | Include the own public header in order to get function prototypes for all public functions defined in this module. This fixes GCC -Wmissing-prototype warnings. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>