summaryrefslogtreecommitdiffstats
path: root/include/netlink-private
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-081-0/+12
| | | | | | | | | | | | | | 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>
* 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-081-0/+15
| | | | | | | | | | | | 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>
* 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>
* 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>
* 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>
* 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>
* lib: update ce-mask to uint64_tDavid Ahern2016-02-123-7/+9
| | | | | | | | | | | | | | | | | | | | 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-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: 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>
* 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-171-1/+1
| | | | | | Fixes: 66aab65595fb20bf166936fcfa4c8568b58f7f68 Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/link: add support for IFLA_LINK_NETNSIDThomas Haller2015-08-171-1/+2
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* neigh: add support for NDA_VLAN nl attributeJonas Johansson2015-03-231-0/+1
| | | | | | | | | [thaller@redhat.com: modified patch to parse NDA_VLAN and diff vlan] http://lists.infradead.org/pipermail/libnl/2015-March/001861.html Signed-off-by: Jonas Johansson <jonasj76@gmail.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* lib/socket: remove NL_SOCK_BUFSIZE_SET socket flagThomas Haller2015-03-051-1/+0
| | | | | | | | | | | | | | | | The flag was not actually used. NL_SOCK_BUFSIZE_SET was only set by nl_socket_set_buffer_size(). Note that you can only call nl_socket_set_buffer_size() on a socket that is already connected via nl_connect(). On first call, nl_connect() would always see NL_SOCK_BUFSIZE_SET unset, and call nl_socket_set_buffer_size(). Since the flag was never unset, when trying to connect a socket a second time, we would not set the buffer size again. Which was a bug. Signed-off-by: Thomas Haller <thaller@redhat.com>
* dbg: save errno from modification in NL_DBG()Thomas Haller2015-03-051-1/+4
| | | | | | | Evaluating the logging statement might overwrite the errno. Save and restore it so that NL_DBG() preserves the errno. Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/tc: add internal rtnl_tc_data_peek() functionThomas Haller2015-03-041-0/+1
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/act: add skbedit actionCong Wang2015-02-021-0/+10
| | | | | | | [thaller@redhat.com: changed whitespace and libnl-route.sym] Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* idiag: add a copy of linux/sock_diag.hCong Wang2014-11-241-1/+1
| | | | | | | | | | | | | | | | | | | | When we test idiag on 3.4 kernel, we always get ERANGE. This is because libnl has its own copy for SK_MEMINFO_*, which is actually newer than 3.4, where SK_MEMINFO_VARS is larger than kernel's. We add a copy from latest kernel, so on older kernel libnl should still compile. Note, for kernel < 3.6 we don't have SK_MEMINFO_BACKLOG, we have to relax the minlen. 'sock_diag.h' comes from v3.17 kernel sources (bfe01a5ba2490f299e1d2d5508cbbbadd897bbe9), file 'include/uapi/linux/sock_diag.h'. Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* route/cls: support 'match mark' u32 filtersSagi Lowenhardt2014-11-231-0/+1
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* qdisc: add hfsc qdisc supportCong Wang2014-07-301-0/+14
| | | | | | | | Cc: Thomas Graf <tgraf@suug.ch> Cc: Thomas Haller <thaller@redhat.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* tc: save error code for rtnl_tc_data_check()Cong Wang2014-07-301-1/+1
| | | | | | | | Cc: Thomas Graf <tgraf@suug.ch> Cc: Thomas Haller <thaller@redhat.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* style: require comma after __ADD() macroThomas Haller2014-07-271-1/+1
| | | | | | | $ 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>
* xfrm: style-fixesThomas Haller2014-07-201-147/+147
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* xfrm: add xfrm supportSruthi Yellamraju2014-07-202-0/+228
| | | | | Signed-off-by: Sruthi Yellamraju <ysruthi@gmail.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
* tc: add co_groups for tc qdisc and filterCong Wang2014-07-161-0/+2
| | | | | | | | | | | Otherwise these tc caches would not be able to be updated asynchronously. Cc: Thomas Haller <thaller@redhat.com> Cc: Thomas Graf <tgraf@suug.ch> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* lib/socket: retry generate local port in nl_connect on ADDRINUSEThomas Haller2014-05-061-0/+31
| | | | | | | | | | | | | | | | | | | | | It can easily happen that the generated local netlink port is alrady in use. In that case bind will fail with ADDRINUSE. Users of libnl3 could workaround this, by managing the local ports themselves, but sometimes these users are libraries too and they also don't know which ports might be used by other components. This patch changes that nl_socket_alloc() no longer initilizes the local port id immediately. Instead it will be initialized when the user calls nl_socket_get_local_port() the first time and thereby shows interest in the value. If bind() fails with ADDRINUSE, check if the user ever cared about the local port, i.e. whether the local port is still unset. If it is still unset, assume that libnl should choose a suitable port and retry until an unused port can be found. Signed-off-by: Thomas Haller <thaller@redhat.com>
* docs: add code comment to explain the meaning of the fields in ↵Thomas Haller2014-04-301-4/+4
| | | | | | rtnl_addr_cacheinfo Signed-off-by: Thomas Haller <thaller@redhat.com>
* link: Catch missing io_free() implementationsThomas Graf2014-03-311-0/+7
| | | | | Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* route: rename internal copy of kernel header file 'inetdevice.h' to 'ip.h'Thomas Haller2014-03-211-1/+1
| | | | | | | | | | libnl used 'inetdevice.h' for the IPV4_DEVCONF_* names, which the kernel in the meantime moved to public user space API and are now defined in 'ip.h'. As a first step, rename the file 'inetdevice.h'. Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Thomas Haller <thaller@redhat.com>
* doc: fix typo in documentationThomas Haller2014-01-211-1/+1
| | | | | | Also fix typo in source code comment. Signed-off-by: Thomas Haller <thaller@redhat.com>
* add support for IFA_FLAGS nl attributeJiri Pirko2014-01-031-1/+1
| | | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: Thomas Haller <thaller@redhat.com>
* add fq_codel qdiscCong Wang2013-11-221-0/+11
| | | | | | Cc: Thomas Graf <tgraf@suug.ch> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* fix linux/pkt_act.h inclusionCong Wang2013-11-111-0/+6
| | | | | | | We should copy and use the kernel header linux/tc_act/tc_mirred.h. Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* add u32 action supportCong Wang2013-11-091-1/+1
| | | | | Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* add initial tc action supportCong Wang2013-11-091-0/+6
| | | | | 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/+2
| | | | | Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* nl_cb: store nl_cb_type in struct nl_cbArend van Spriel2013-09-052-8/+15
| | | | | | | | | | | | | The application could use the same handler for multiple nl_cb_type events. This patch stores the nl_cb_type in the nl_cb struct during the callback. This allows the application to obtain that information using the new nl_cb_active_type() function. This way the callback signature remains as is so existing applications are not affected. Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* netfilter/ct: support optional CTA_ZONE attributeHolger Eitzenberger2013-09-051-0/+1
| | | | | | | | | | | | | | | | Newer kernels support conntrack zones, which help to partition the conntrack table into virtual conntrack tables. This patch is for adding support for the optional attribute, adds setters and getters, and adds support for the zone ID in the conntrack dumper. An example entry in NL_DUMP_LINE format looks like: tcp SYN_SENT 10.128.128.99:43354 <-> 10.128.129.20:22 zone 1 Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* netfilter/ct: support optional CTA_TIMESTAMP attributeHolger Eitzenberger2013-09-052-0/+5
| | | | | | | | | | | | | | | | | | | | Recent kernels support conntrack time stamping, which is a helpful feature to determine the duration of a flow without building a flow cache in your user space application, just to keep the 'start' time of your flow. Timestamps are recorded with nanosecond resolution once this feature is enabled. This patch adds optional support for the CTA_TIMESTAMP, then modifies the dump routine to write that info in a format similar to /proc/net/nf_conntrack. This is an example output when using NL_DUMP_LINE: udp 10.128.128.28:56836 <-> 10.128.129.255:8612 delta-time 30 Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: add support for IFLA_PHYS_PORT_IDJiri Pirko2013-08-051-0/+1
| | | | | Signed-off-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: Thomas Graf <tgraf@suug.ch>
* Add support for inet diag Netlink protocol.Joe Damato2013-07-191-0/+59
| | | | | | | | | | | | | - Inet diag allows users to gather low-level socket information. - This library provides a higher-level API for creating inetdiag requests (via idiagnl_connect and idiagnl_send_simple) and parsing the replies (via idiagnl_msg_parse). A cache is also provided (via idiagnl_msg_alloc_cache). - Request and message objects provide APIs for accessing and setting the various properties of each. - This library also allows the user to parse the inetdiag response attributes which contain information about traffic class, TOS, congestion, socket memory info, and more depending on the kernel version used. - Includes doxygen documentation.
* nl: Print file:line:func in debugging messages and provide --disable-debug ↵Thomas Graf2013-04-021-9/+14
| | | | | | | | | 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>
* genl: Provide internal function to resolve name to idThomas Graf2013-04-011-0/+2
| | | | | | Like genl_ops_resolve() but uses its own socket. Signed-off-by: Thomas Graf <tgraf@suug.ch>
* link: Keep reference to af_ops during lifetime of link objectThomas Graf2013-02-051-0/+2
| | | | Signed-off-by: Thomas Graf <tgraf@suug.ch>
* cache: Make NL_ACT_* and nl_cache_ops_(get|put)() availableThomas Graf2013-02-011-15/+0
| | | | | | | | Move NL_ACT_* definition and the functions nl_cache_ops_get() and nl_cache_ops_put() into the public facing API. They can be considered stable. Signed-off-by: Thomas Graf <tgraf@suug.ch>