Branch: refs/heads/master Home: https://github.com/fabbione/kronosnet Commit: ad48ef94b64a9e45ede4396e7bd5ccf7adf2bbf5 https://github.com/fabbione/kronosnet/commit/ad48ef94b64a9e45ede4396e7bd5ccf... Author: Fabio M. Di Nitto fdinitto@redhat.com Date: 2017-01-09 (Mon, 09 Jan 2017)
Changed paths: M kronosnetd/vty_cli_cmds.c M libknet/Makefile.am M libknet/handle.c M libknet/host.c M libknet/internals.h M libknet/libknet.h M libknet/link.c R libknet/listener.c R libknet/listener.h M libknet/tests/api-check.mk M libknet/tests/api_knet_host_remove.c A libknet/tests/api_knet_link_clear_config.c M libknet/tests/api_knet_link_get_config.c M libknet/tests/api_knet_link_get_enable.c M libknet/tests/api_knet_link_get_link_list.c M libknet/tests/api_knet_link_get_ping_timers.c M libknet/tests/api_knet_link_get_pong_count.c M libknet/tests/api_knet_link_get_priority.c M libknet/tests/api_knet_link_get_status.c M libknet/tests/api_knet_link_set_config.c M libknet/tests/api_knet_link_set_enable.c M libknet/tests/api_knet_link_set_ping_timers.c M libknet/tests/api_knet_link_set_pong_count.c M libknet/tests/api_knet_link_set_priority.c M libknet/tests/api_knet_send.c M libknet/tests/api_knet_send_sync.c M libknet/tests/knet_bench.c M libknet/tests/test-common.c M libknet/threads_heartbeat.c M libknet/threads_send_recv.c M libknet/transport_common.c M libknet/transport_udp.c M libknet/transports.h
Log Message: ----------- [transports] major rework of APIs and ABIs!
This commit breaks APIs and ABIs and this changelog might be missing a bit or 5.
External visible changes:
- Change link initialization process API:
The old method: - link_set_config -> link_enable where link_set_config would simply store config data (sockaddr and such) in the link struct and link_enable would create sockets and do the magic. This method didn't work well for complex transports such as SCTP and introduced a series of race conditions and deadlocks.
The new method: - link_set_config would now store config in link struct AND create all related sockets and such. The link will not be used for data traffic till enabled. - link_set_enable will enable/disable the link for traffic (including heartbeat) and requires a link to be configured (as before) - link_clear_config (new API) can/has to be called after disabling a link to close all connections and sockets (free resources).
Internal changes:
- Drop the concept of listeners.* and delegate those to underlying transports.
- Add the concept of fd_tracker. Each transport is required and it is responsible to update the fd_tracking array for the fd that the transport itself is creating/using/clearing. The fd_tracker is required to perform fast lookups on socket errors and RX thread to determine what code is responsible to parse given conditions such as errors from the sockets or OOB data/notifications.
- Introduce the concept of link->transport_connected. In case the transport requires socket connection to the other end (SCTP for example), set to 0 while disconnected and set 1 once connected to the other side. This flag will avoid unnecessary errors generated from the TX threads. NOTE: still needs better plumbing around. For now it's only partially used in the heartbeat thread. UDP sets to 1 by default.
- Rework the transport API to be easier to use. - If a transport is not available, get_XXXX_transport() should return NULL. - A transport that provides &XXXX_transport_ops MUST have all operations implemented as described in internals.h. This is required to skip tons of if/else checks on fast code paths. - Improve documentation of the transport API in internals.h. - transport common: drop some unnecessary functions for now, they might can back later in better format once SCTP is working again. - provide a locked/unlocked version of _set_fd_tracker but this is an artifact of trying to fix SCTP deadlocking. _set_fd_tracker should always be locked. - cleanup transport_udp.c to match the new API and perform better error handling and better cleaning in case of errors. - switch mtu_overhead to constant from call into a function. - drop usage of _transport_addrtostr/_transport_addrtostr_free for all but accepting incoming SCTP connections. All other datas are already available and it's unnecessary to perform extra lookups. This will eventually move to a proper knet_api and avoid completely the need to build with --debug.
- RX thread: - use the new transport hooks to handle socket errors and determine if a packet is data or internal OOB info. - remove the last transport specific bits and move them into transport implementation itself.
- Test suite: - Update the test suite to deal with the new API changes - Fix a couple of shutdown problems in knet_bench - Fix a shutdown issue in test-common.c - Document the whole recvmmsg API in details, based on kernel implementation. recvmmsg man page is incorrect.
- Fix kronosnetd to use the new APIs
Signed-off-by: Fabio M. Di Nitto fdinitto@redhat.com