summaryrefslogtreecommitdiffstats
path: root/lib/route/link.c
Commit message (Collapse)AuthorAgeFilesLines
* pass flags through ->io_compare opSabrina Dubroca2016-06-251-1/+1
| | | | | | | | | | 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>
* link: allow overwriting IFLA_EXT_MASK flag in ao_get_af() functionThomas Haller2016-06-241-6/+8
| | | | | | | 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>
* link: support RTEXT_FILTER_VFJef Oliver2016-06-241-2/+16
| | | | | | | | | | | | | | | This patch adds RTEXT_FILTER_VF mask support for SRIOV VFs. Since SRIOV VFs don't have a defined address family (ie bridge), there are no new address family specific operations defined. Exposing this mask makes rtnl_link_get_num_vfs() properly return the number of loaded SRIOV VFs. Signed-off-by: Jef Oliver <jef.oliver@intel.com> Signed-off-by: Thomas Haller <thaller@redhat.com> http://lists.infradead.org/pipermail/libnl/2016-May/002115.html http://lists.infradead.org/pipermail/libnl/2016-May/002123.html
* lib: update ce-mask to uint64_tDavid Ahern2016-02-121-4/+5
| | | | | | | | | | | | | | | | | | | | 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>
* lib: handle family-based parsing of IFLA_AF_SPEC attributeDavid Ahern2015-12-071-13/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-1/+25
| | | | | | | | | | | 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: add link info compare operationDavid Ahern2015-11-201-0/+1
| | | | | | 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/+11
| | | | | | | | 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>
* link/neigh: add flags option to link and neighbor cachesDavid Ahern2015-11-191-2/+37
| | | | | | | | | | | | | 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/link: add missing link_attrs translationsTobias Klauser2015-08-311-0/+3
| | | | | | | | | | | | Add LINK_ATTR_NSFD, LINK_ATTR_NS_PID and LINK_ATTR_LINK_NETNSID to the link_attrs translation table after they were added in commits 760bfabad8cd ("add link netns support") and 66aab65595fb ("route/link: add support for IFLA_LINK_NETNSID") respectively. http://lists.infradead.org/pipermail/libnl/2015-August/001959.html Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/link: make link_netnsid argument (signed) int32_tThomas Haller2015-08-171-5/+5
| | | | | | Fixes: 66aab65595fb20bf166936fcfa4c8568b58f7f68 Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/link: add support for IFLA_LINK_NETNSIDThomas Haller2015-08-171-1/+48
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/link: Remove unnecessary NULL check before release_link_info()Tobias Klauser2015-08-141-6/+2
| | | | | | | | | | | release_link_info() already check whether link->l_info_ops is not NULL before accessing it, thus there is no need to do the same before calling it. http://lists.infradead.org/pipermail/libnl/2015-July/001929.html Signed-off-by: Tobias Klauser <tklauser@distanz.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* link: set ifi_change in link messagematben22015-07-091-0/+1
| | | | | | | | | | | The ifi_change field can be set with the mask of the flags that need to be changed as part of the link message to the kernel. This means only the specific flags that have been changed will be modified in the kernel, rather than the entire flags entry. [thaller@redhat.com: add capability to indicate the change in behavior] https://github.com/thom311/libnl/pull/86
* route/link: fix memleaks in link_msg_parser()Thomas Haller2015-06-041-4/+6
| | | | | | http://lists.infradead.org/pipermail/libnl/2015-May/001880.html Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/link: return -NLE_OPNOTSUPP in rtnl_link_get_kernel() for old kernelsThomas Haller2014-11-271-1/+17
| | | | | | | | | | | | Older kernels without patch a3d1289126e7b14307074b76bf1677015ea5036f do not support rtnl_getlink() by ifname. Detect this situation and fail with -NLE_OPNOTSUPP instead of -NLE_INVAL. This changes behavior in returning a different error code for this case. Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* style: require comma after __ADD() macroThomas Haller2014-07-271-119/+119
| | | | | | | $ sed -i 's/^\([\t ]\+\<__ADD\> \?([^)]\+)\) *$/\1,/' `git grep -w -l __ADD` Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/link: fix dangling pointer after rtnl_link_get_ifalias(link, NULL)Thomas Haller2014-06-101-1/+3
| | | | | | | | | | | | | Fixed bug that left a dangling pointer after clearing the ifalias property. This happened when calling 'rtnl_link_get_ifalias(link, NULL)' on a link that has already an ifalias set. This can cause a crash and/or a double-free. Error found by coverity. Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* link: call rtnl_link_set_type() in link_msg_parser()Cong Wang2014-04-091-7/+3
| | | | | | | | | We need to call link-specific ->io_alloc() to alloc addtional structures. Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* link: Catch missing io_free() implementationsThomas Graf2014-03-311-0/+4
| | | | | Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* route: update kernel header snmp.h and fix inet6_parse_protinfo() after ↵Thomas Haller2014-03-211-0/+6
| | | | | | | | | | | | | | | | | | | | kernel API breakage Take 'include/uapi/linux/snmp.h' from current kernel v3.13 (commit d8ec26d7f8287f5788a494f56e8814210f0e64be). The header file added new values for IPSTATS_MIB_* and ICMP6_MIB_*, but more importantly, the kernel broke user space API by reordering enum values in IPSTATS_MIB_*. Add a workaround when parsing IFLA_PROTINFO trying to be compatible with both older and newer kernels. Note that this workaround might fail for some specific kernel versions by assuming the old enum value mapping, although the kernel version already contains the API change. In this case rtnl_link_get_stat() mixes up values. Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* link: document sk == NULL case for rtnl_link_alloc_cache()Cong Wang2014-03-201-5/+6
| | | | | | | | | | When sk == NULL, rtnl_link_alloc_cache() returns 0 but the cache is still empty. We should document this behavior, otherwise it is confusing. Cc: Thomas Haller <thaller@redhat.com> Cc: Thomas Graf <tgraf@suug.ch> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* route: add libnl name prefix to global variable link_policyThomas Haller2014-01-021-2/+2
| | | | | | | | | | | | | | Public names should be prefixed with a libnl specific prefix to avoid name collisions. Rename link_policy to rtln_link_policy. Related bugs: https://github.com/thom311/libnl/issues/52 https://bugzilla.gnome.org/show_bug.cgi?id=720902 https://bugs.gentoo.org/show_bug.cgi?id=494986 https://bugs.gentoo.org/show_bug.cgi?id=494890 Signed-off-by: Thomas Haller <thaller@redhat.com>
* fix rtnl_link_info_parse() and rtnl_link_fill_info()Cong Wang2013-12-091-12/+18
| | | | | | | So that the veth peer could be parsed correctly. Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Fall back to global provisioned link cache if object is not a cache ↵Thomas Graf2013-11-091-8/+23
| | | | | | | | | resident ... if that fails, print ifindices directly. Reported-by: Dan Williams <dcbw@redhat.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* factor out rtnl_link_info_parse()Cong Wang2013-11-061-62/+63
| | | | | Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* add link netns supportCong Wang2013-11-061-0/+36
| | | | | Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* add veth link supportCong Wang2013-11-061-1/+1
| | | | | Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* factor out rtnl_link_fill_info()Cong Wang2013-11-061-12/+23
| | | | | Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* route/link: fixup link->l_af_ops must be set for some kind of linksNicolas PLANEL2013-10-221-0/+11
| | | | | | | | | | | 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>
* fix double free caused by freeing link af_data in rtnl_link_set_family()Jiri Pirko2013-08-211-1/+3
| | | | | | | | | | | | | | Introduced by commit 8026fe2e3a9089eff3f5a06ee6e3cc78d96334ed ("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>
* link: add support for IFLA_PHYS_PORT_IDJiri Pirko2013-08-051-0/+30
| | | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us> 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>
* 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>
* 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>
* Move private header files to <netlink-private/*>Thomas Graf2013-01-241-2/+2
| | | | | | | This clarifies the seperation between public and private header files. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Add af data compare to link objectsroopa2013-01-181-2/+20
| | | | | | | | | | | | | | | | | | | | | | Today the link compare function does not compare af data of a link. We have found a need for this to get approriate change callbacks when af_data of a link changes. This patch adds support to compare af_data to link_compare function. This patch today only adds support to compare af_data set by PROTINFO attributes. It can be extended to support compares of af_data set by AF_SPEC attributes It has been tested for AF_BRIDGE objects. In case of AF_BRIDGE objects, this helps with bridge port change notification callbacks. Signed-off-by: Wilson Kok <wkok@cumulusnetworks.com> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: add carrier supportFlavio Leitner2013-01-111-1/+58
| | | | | Signed-off-by: Flavio Leitner <fbl@redhat.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: provide safe variant of nl_cache_mngt_require() and use itThomas Graf2012-11-161-1/+1
| | | | | | | | This makes runtime removal of cache operations possible if non-safe API is not in use by application. The non-safe API will be removed in the next major version. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Add AF_BRIDGE support to link cacheroopa2012-11-141-19/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch was previously submitted as the first approach in RFC http://lists.infradead.org/pipermail/libnl/2012-November/000730.html It adds support for AF_BRIDGE family in link cache. And the key for link object lookups will now be ifindex and family. This allows for AF_UNSPEC rtnl link objects to co-exist with the AF_BRIDGE link objects in the same cache. I have changed some of the rtnl_link api's to explicitly check for AF_UNSPEC to not break existing apps. I will submit a new patch to introduce equivalent rtnl_bridge_link_* api's. We had also discussed updating the existing link objects with AF_BRIDGE attributes, but realized that the updates to link objects will be both AF_UNSPEC and AF_BRIDGE. And that would change link cache to always update existing objects, resulting in comparing and updating close to thirty attributes at cache_include time which seems like a overkill. 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>
* Add hash support to link cacheroopa2012-11-091-0/+23
| | | | | | | | | | This patch adds keygen function to link cache Signed-off-by: Shrijeet Mukherjee <shm@cumulusnetworks.com> Signed-off-by: Nolan Leake <nolan@cumulusnetworks.com> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Reviewed-by: Wilson Kok <wkok@cumulusnetworks.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Support link groupingThomas Graf2012-10-091-1/+38
| | | | | | | | | | New functions: rtnl_link_set_group(link, group) rtnl_link_get_group(link) The group identifier is printed in the brief section as "group N" Signed-off-by: Thomas Graf <tgraf@redhat.com>
* link: Include IFLA_NUM_TX_QUEUES and IFLA_NUM_RX_QUEUES when building messagesThomas Graf2012-10-091-0/+6
| | | | Signed-off-by: Thomas Graf <tgraf@redhat.com>
* link: Only print "promisc-mode" if users > 0Thomas Graf2012-10-091-1/+1
| | | | Signed-off-by: Thomas Graf <tgraf@redhat.com>
* link: Support IFLA_NUM_TX_QUEUES and IFLA_NUM_RX_QUEUESThomas Graf2012-10-091-0/+85
| | | | | | | | | | New functions: rtnl_link_set_num_tx_queues(link, nqueues) rtnl_link_get_num_tx_queues(link) rtnl_link_set_num_rx_queues(link, nqueues) rtnl_link_get_num_rx_queues(link) Signed-off-by: Thomas Graf <tgraf@redhat.com>
* link: correctly set LINK_ATTR_PROMISCUITYThomas Graf2012-10-091-2/+2
| | | | Signed-off-by: Thomas Graf <tgraf@redhat.com>