summaryrefslogtreecommitdiff
path: root/src/ipcpd/normal/dht.c
Commit message (Collapse)AuthorAgeFilesLines
* include, src: Update copyright to 2018Dimitri Staessens2018-01-091-1/+1
| | | | | | | Happy New Year, Ouroboros. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
* ipcpd: Wait for DHT running state before accessDimitri Staessens2017-12-061-12/+13
| | | | | | | | | | The DHT will now wait for the DHT_RUNNING state before handling request messages, ensuring that the parameters are set correctly before they are read and sent at JOIN. Also fixes a re-introduced assertion failure when a JOIN fails. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
* ipcpd: Fix missing bracket in DHTDimitri Staessens2017-12-051-1/+1
| | | | | | | | ca2f47d had a missing bracket after a last-minute update to simplify the logic. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
* ipcpd: Update DHT buckets in JOINING stateDimitri Staessens2017-12-051-7/+31
| | | | | | | | | | The DHT buckets were not updated in JOINING state, which sometimes caused the DHT to miss its first peer update when joining and become isolated. This also checks if a name is already registered to avoid adding it multiple times. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
* ipcpd: Only update DHT buckets in running stateDimitri Staessens2017-11-281-1/+2
| | | | | | | This fixes accessing buckets when a DHT join fails. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
* ipcpd: Create new SDUs for DHT join retriesDimitri Staessens2017-11-071-15/+15
| | | | | | | | | | The DHT join operation left an SDU in the rdrbuff for a couple of seconds during retries, which may cause the system to block if there is heavy traffic. This patch releases the sdb when the write fails and creates a new packet for every retry. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
* lib: Deprecate ouroboros_init and ourboros_finidimitri staessens2017-10-141-4/+5
| | | | | | | | | | | | | | This commit deprecates ouroboros_init and ouroboros_fini and adds them as a constructor or destructor, causing these function to be run automatically when a program that links to the library calls and exits main(). For this to fully work, the library had to be split so that we can avoid the irmd calling these functions (the IRMd has to create the shm structures on which these calls depend). The library is split in 3 parts: libouroboros-dev, libouroboros-irm and libouroboros-common. The latter is linked to the other two so that including libouroboros-dev or libouroboros-irm will also link libouroboros-common.
* lib: Cancel tpm threads instead of marking exitdimitri staessens2017-09-301-48/+65
| | | | | | | | | This makes the threadpool use pthread_cancel instead of setting an exit flag that threadpool managed threads check periodically. This drastically reduces CPU consumption in the irmd when running a lot of applications. It requires cancellation handlers in the ipcp and irmd to be implemented to ensure safe cancellation during operation and shutdown.
* ipcpd: normal: Set clock to realtime clockSander Vrijders2017-09-261-3/+3
| | | | | | A pthread_cond_wait was using the pthread_cond_clock and thereby timing out constantly, consuming 100% CPU. This changes it to use the realtime clock.
* ipcpd: Fix deadlock in DHTdimitri staessens2017-09-241-27/+41
| | | | | | | | | | | | | The lookup_update was waiting for the LU_INIT state to resolve under dht->lock which prevented that update. This PR fixes this bug, but leaves a (very rare) bug when the lookup_destroy is called while the lookup_update is waiting for the LU_INIT state to resolve. The solution also is a (harmless) lock inversion, but this is also not the best. Fixes #51 Fixes #52
* ipcpd: Add threadpool manager to DHTdimitri staessens2017-09-241-136/+203
| | | | | | | | | | | This adds a threadpool manager to the DHT. This was needed because the detached thread could cause a data race on shutdown. The threadpool manager is revised to allow multiple instances in a single program. The irmd and ipcp now store commands in a buffer (list) instead of a single buffer before passing it to handler threads.
* Merged in dstaesse/ouroboros/be-bugfixes (pull request #614)dimitri staessens2017-09-231-30/+85
|\ | | | | | | Some bugfixes
| * ipcpd: Don't publish DHT entries under lockdimitri staessens2017-09-231-30/+85
| |
* | Merged in dstaesse/ouroboros/be-bugfixes (pull request #613)dimitri staessens2017-09-231-7/+14
|\| | | | | | | Some bugfixes
| * ipcpd: Lock dht before reading parametersdimitri staessens2017-09-231-7/+14
| |
* | ipcpd: Fix DHT recursive lookupdimitri staessens2017-09-221-1/+4
|/
* lib: Pass the fuse struct to the handling threaddimitri staessens2017-09-211-1/+1
| | | | This avoids potential data races on rib.fuse.
* ipcpd: Handle DHT SDUs in different threaddimitri staessens2017-09-201-15/+58
| | | | | | | The DHT will now spawn a thread when receiving SDUs to avoid starvation of sdu scheduler threads. Also fixes some locking issues.
* Merged in dstaesse/ouroboros/be-dht-query-refuse (pull request #601)dimitri staessens2017-09-191-0/+3
|\ | | | | | | ipcpd: Refuse query when DHT not in running state
| * ipcpd: Refuse query when DHT not in running statedimitri staessens2017-09-191-0/+3
| |
* | ipcpd: Fix contact list in DHTdimitri staessens2017-09-191-3/+3
|/
* ipcpd: Enroll DHT when creating dt connectiondimitri staessens2017-09-191-16/+110
| | | | | | | | | The DHT will now enroll or sync when a data transfer connection is added. This avoids the need to create a temporary data transfer connection during enrollment (and speeds it up considerably). The notifier system was modified to take an opaque pointer to the object that registers as a parameter.
* ipcpd: Revise internals of normal IPCPdimitri staessens2017-09-121-7/+7
| | | | | | | | This removes the RIB as a datastructure and CDAP as the protocol between IPCPs. CDAP, the rib and related sources are deprecated. The link-state protocol policy is udpated to use its own protocol based on a simple broadcast strategy along a tree. The neighbors struct is deprecated and moved to the library as a generic notifier component.
* ipcpd: Shutdown DHT work thread first at destroydimitri staessens2017-09-071-6/+4
| | | | This prevents a potential deadlock on the wrlock.
* ipcpd: Fix missing unlock in dhtdimitri staessens2017-08-291-1/+2
|
* ipcpd: Fix state in dht lookup at lookup_waitdimitri staessens2017-08-291-16/+23
| | | | | | | | | | | The correct state was returned but not set internally in the lookup_struct, causing lookup_wait to return a lookup in LU_PENDING if the wait timedout. This also unlocks the IRMd during register calls and fixes some cleanup if lookup_wait gets interrupted. Fixes #48
* lib, ipcpd, irmd: Fix bugs reported by static analysisSander Vrijders2017-08-291-1/+2
| | | | This fixes several bugs as reported by the clang static analyzer.
* lib, ipcpd, irmd: Fix several memleaksSander Vrijders2017-08-231-1/+1
| | | | | This fixes several memleaks as reported by valgrind. It also fixes some calls to close() with -1.
* build: Revise the build systemdimitri staessens2017-08-211-1/+4
| | | | | | | | | | This revises the build system to have configuration per system component. System settings can now be set using cmake. The standard compliance defines were removed from configuration header and are set in the sources where needed. Also some small code refactors, such as moving the data for shims out of the ipcp structure to the respective shims were performed.
* build: Replace fsf snail mail with contact URLdimitri staessens2017-08-131-2/+1
|
* Merged in dstaesse/ouroboros/be-tpm (pull request #550)dimitri staessens2017-08-131-7/+28
|\ | | | | | | lib: Fix instability in threadpool manager
| * ipcpd: Fix tracking of outstanding DHT requestsdimitri staessens2017-08-131-7/+28
| | | | | | | | | | | | The DHT failed when receiving multiple responses in a short timeframe. The lookup struct now keeps track of the number of outstanding requests.
* | build: Fix compilation on OS X Sierradimitri staessens2017-08-111-0/+4
|/
* lib, ipcpd, tools: Fix enum assignmentsSander Vrijders2017-08-101-1/+1
| | | | This fixes several assignments to the wrong enum type.
* ipcpd: Fix finding values in DHTDimitri Staessens2017-08-051-5/+18
| | | | | | | | | The DHT lookup would stop if a node returned no new useful information (i.e. the value for the key or unknown nodes closer to the key) without waiting for other pending requests that could still return useful information. Now it correctly tracks the number of outstanding requests or returns if it doesn't get a response for KAD_T_RESP seconds. This fixes multi-hop flow allocation over the normal.
* ipcpd: Fix registration bug in DHTdimitri staessens2017-07-291-2/+2
|
* ipcpd: Some fixes in DHTdimitri staessens2017-07-291-13/+10
| | | | | | | Fixes a memory leak when the DHT is destroyed during a send_msg. Fixes a deadlock when destroying the DHT with a pending lookup. Removes some debug logs that clutter output due to expected redundant FIND_VALUE responses.
* ipcpd: Retry sending DHT response messagesdimitri staessens2017-07-241-4/+16
| | | | | | | This will make the remote retry sending responses when the DT component can't send the message. This is most useful at enrollment, when the remote's routing table may need to wait a bit on the routing component for a path to the new member,
* ipcpd: Fix DHT lookup processingdimitri staessens2017-07-201-20/+25
| | | | | Not all returned contacts were processed when a FIND_NODE or FIND_VALUE message was returned.
* ipcpd: Add DHT as directory in normal IPCPdimitri staessens2017-07-181-0/+2369
This implements a Distributed Hash Table (DHT) based on the Kademlia protocol, with default parameters set as used in the BitTorrent Mainline DHT. This initial implementation is almost feature complete, except for some things to be done after a testing period: caching and stale peer bumping, and setting the expiration timeout via the IRM tool.