summaryrefslogtreecommitdiff
path: root/src/ipcpd/shim-udp/main.c
Commit message (Collapse)AuthorAgeFilesLines
* ipcpd: fix deadlock in shim-udpdimitri staessens2016-06-281-13/+25
| | | | | shim UDP would deadlock upon a dealloc call. fd_clr cannot be called under wrlock.
* ipcpd: fixes to shim-udpdimitri staessens2016-06-271-48/+60
| | | | | getsockname() can give bad behaviour when haphazardly looping fd's, added check that the fd has a flow. Replaced LOG_DBGF with LOG_DBG.
* lib, irmd, ipcp: robust mutexesdimitri staessens2016-06-211-110/+109
| | | | | | | | Update to POSIX 200112L to allow use of robust mutexes in the shm_du_map. Removed the implementation of the rw_lock in favor of pthread_rwlock_t. Placeholder for the shm_du_map_sanitize function.
* ipcpd: fixed missing unlock in shim UDPdimitri staessens2016-06-161-1/+5
| | | | Unlock missing when compiled without DNS support.
* irmd: clean up stale pending flowsdimitri staessens2016-06-161-1/+1
| | | | | | | Adds a thread that cleans up stale pending flows. Compile time option IRMD_FLOW_TIMEOUT allows setting the timeout period. Default timeout is 5 seconds. The thread wakes up 20 times per period to check the flows.
* ipcpd: fixed locking and cleanupdimitri staessens2016-06-161-0/+1
| | | | | The ipcpds didn't unlock the flows lock when the dst_name is unbeknownst to the IRMd.
* lib, irmd, tools, ipcpd: updates to dev API.dimitri staessens2016-06-131-10/+2
| | | | | | | | | | | | | | | The registration function has been moved to the irm tool, applications now need to be registered by an administrator. Currently only supports one instance per registered name, and an AP can be registered under only one name. The irmd can now start a registered server application on demand. For the full functionality of the tool, execute "irm register". AP name removed from flow allocation. Flow allocation does not send the source ap name as it is quite useless. The accept() call now only returns the AE name.
* ipcpd: fixes shutdown lockup in local and shim-udpdimitri staessens2016-05-291-6/+5
|
* lib: shm_ap_rbuff: sleep when read on empty rbuffdimitri staessens2016-05-281-1/+0
| | | | | When the ring buffer is empty, a read call will sleep. A write call on an empty ring buffer will wake up sleeping readers.
* ipcpd: cleanup of IPC processesdimitri staessens2016-05-281-5/+10
| | | | | | | This stops IPC processes from hanging due to bad locks. It first informs all threads that the IPCP is shutting down, then cancels all threads. Cancellation is still required because threads may be in accept() or receivefrom().
* ipcpd: shim-udp changed to blocking writedimitri staessens2016-05-271-14/+11
| | | | | The shim UDP did a non-blocking write call, causing loss of SDU's. This has been changed to a blocking write call.
* ipcpd: fixed the shim-udp grinding the cpudimitri staessens2016-05-271-3/+4
| | | | | | | | In linux, the select call changes the timeout variable to the time not spent in sleep, causing the timeout to decrease and that loop to grind the cpu. The timeval is now reset to the correct value every loop. Also removed a LOG_ERR message that was hampering performance.
* ipcpd: shim-udp: fixed missing NULL checkdimitri staessens2016-05-221-0/+3
| | | | Conf was not checked on bootstrap.
* lib: removed fd cleaning functiondimitri staessens2016-05-221-3/+4
|
* ipcpd: homogenous debug messages for deallocationdimitri staessens2016-05-211-8/+1
|
* lib, irmd, ipcpd: Flow deallocation over shim UDPdimitri staessens2016-05-211-50/+150
| | | | | | The shim UDP now supports deallocating a flow end-to-end. Contains some stability fixes for flow allocation and some missing close() calls in lib/sockets.
* lib, ipcpd: fixes segfaults in dev.c and shim-udpdimitri staessens2016-05-201-2/+1
|
* ipcpd: shim-udp: read fd on client sidedimitri staessens2016-05-201-0/+13
| | | | | There could be a theoretical race condition that the server sends a message before the FD is set on the client side, which is resolved.
* ipcpd: shim-ipcp: fixed race conditionsdimitri staessens2016-05-201-40/+57
| | | | | | | | | | | There were two race conditions. The first was where client received the response message before the client UDP port was connected to the server UDP port and the first message of the client was sent to the LISTEN port instead of the server application port. This was solved by reordering the operations so the response is sent after the port is correctly connected. The second race condition is that the FD is not added to the set in time at the server side before the first SDU arrives. This was solved by adding a variable proteceted by a mutex.
* ipcpd: shim-udp: removed debug codedimitri staessens2016-05-191-12/+0
| | | | | some debug code for locking and a sleep check are removed from the shim-udp.
* Implementation of a full flow allocator for the shim UDP.dimitri staessens2016-05-181-246/+507
| | | | | | | | | It uses UDP port 0x0D1F on all hosts to send and receive flow allocation messages. It supports communication between server and client AP over a single shim IPCP. Implementation of full flow deallocation is pending. Both the client and the server still have to call flow_dealloc();
* lib: Add missing modulo calculationSander Vrijders2016-05-161-2/+1
| | | | | | Adds a missing modulo calculation that would result in index -1 being returned instead of zero when the ringbuffer skipped back to the beginning.
* fixed two unlocks, removed the thread_lock.dimitri staessens2016-05-151-13/+3
|
* ipcpd: shim-udp: Revised lockingdimitri staessens2016-05-151-94/+97
| | | | | | | | | | Simplified locking to take only two locks: the first lock guards the state of the ipcp. This lock must be held for writing on bootstrap and closing, and held for reading during all other operations. The second lock guards operations on flows, and must be held for writing during allocation and deallocation, and held for reading when sending sdu's. After adding a fd to FD_SET, the shim will wait for 1 ms to ensure that the FD is added to the select call.
* ipcpd: Move lock in ipcp_udp_listenerSander Vrijders2016-05-151-2/+2
| | | | | This takes a lock before notifying the IRMd of a new flow request, to avoid race conditions when trying to retrieve the fd by port-id.
* ipcpd: shim-udp: added missing checksdimitri staessens2016-05-151-10/+10
|
* ipcpd: shim-udp: fixed locking.dimitri staessens2016-05-141-15/+21
| | | | | The fd_to_port_id function has no internal locking and must now be called under lock.
* Merged in sandervrijders/ouroboros/be (pull request #84)dimitri staessens2016-05-141-7/+8
|\ | | | | | | lib, ipcpd, irmd: Add QoS cube definition
| * lib, ipcpd, irmd: Add QoS cube definitionSander Vrijders2016-05-141-7/+8
| | | | | | | | | | | | | | | | | | | | This adds the QoS cube definition, which is an enum to select which QoS is needed in the IPCP. An application has to use the qos_spec in qos.h to define what it needs. The IRMd will map this unto a qos cube definition. Some headers are now also no longer installed on the system, since they are only to be used within the irmd and ipcps.
* | ipcpd: shim-udp: log error when failed sending SDUdimitri staessens2016-05-141-1/+2
| |
* | ipcpd: shim-udp: complete lockingdimitri staessens2016-05-141-103/+352
|/ | | | | | | Added necessary locks for the shim-udp. This PR also improves thread management, the main thread now starts a mainloop thread, which spawns sdu handler threads when it the IPCP is enrolled. If the IPCP exits the enrolled state, the sdu loop is cancelled.
* ipcpd: threading and cleanup of ipcpd_udpdimitri staessens2016-05-111-98/+40
| | | | | The shim_udp now correctly destroys its ringbuffer on exit. Now handles sdu's in a single thread using select() with a 10 us timeout.
* ipcpd: Fix unitialized valueSander Vrijders2016-05-101-2/+2
| | | | | A value that was unitialized was being treated as an error in the release build with gcc.
* ipcpd: Add nslookup to shim UDPSander Vrijders2016-05-101-25/+143
| | | | | This adds nslookup support to the shim UDP, so that a custom DNS server can be queried.
* ipcpd: Allow disabling of DNSSander Vrijders2016-05-101-17/+23
| | | | | | This allows someone to disable the use of DNS in the shim UDP. It also adds a config file specific for the shim UDP (which holds the nsupdate location). Certain defines were also moved to the global config file.
* ipcpd-udp: fixed missing closedimitri staessens2016-05-081-0/+1
| | | | caused the shim to run out of file descriptors fast...
* lib: changed port_id to intdimitri staessens2016-05-081-12/+12
| | | | | returning -1 as uint32_t leads to bugs. also changed types in GPB to sint to use zigzag encoding.
* irmd: flow allocation and fast pathdimitri staessens2016-05-071-146/+378
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit has a first implementation of flow allocation (the "slow path") and read/write (the "fast path") for ouroboros. It provides basic but unstable communications over the shared memory. It required a lot of changes all over the stack, and fixes a number of previously undetected issues. This PR still need heavy revision regarding data model, locking and cleanup. lib/dev: modifications to the API. It now uses an ap_init() call to set the AP name and sets the Instance ID to the pid of the process. It also binds the AP to the shared memory and creates tables for mappings in the fast path. A call to ap_fini() releases the resources. lib/shm_ap_rbuff: added ring buffer for data exchange between processes in the fast path. It passes an index in the shm_du_map. lib/shm_du_map: rewrote API to work with calls from dev.c. Garbage collector added. Tests updated to new API. ipcpd/ipcp-data: removed everything related to flows, as these are universal for all ap's and kept in ap_data (dev.c), or similar structs for shim ipcps. shim-udp: added flow allocator and read/write functions and shm elements. irmd: revised data model and structures necessary for flow allocation. tools: echo updated to new dev.h API. messaging system was updated to comply with new flow allocation messages. All exchanges use pid and port_id to bootstrap the fast path.
* ipcpd: Add registration to DNS serverSander Vrijders2016-04-271-6/+97
| | | | | This adds support for adding the application name to a BIND DNS server through the nsupdate utility.
* lib: client-side flow allocationdimitri staessens2016-04-271-1/+12
| | | | | flow allocation now propagates on the client side up to the IPCP. added UNKNOWN_AP and UNKNOWN_AE definitions to dev.h
* ipcpd: Hide IRMd messages and fix formattingSander Vrijders2016-04-271-39/+14
| | | | | This abstracts away the IRMd messages by calling the functions from ipcp.h in the ouroboros library. It also fixes some formatting issues.
* shim-udp: resolve dst_name using DNSdimitri staessens2016-04-261-13/+15
| | | | | | This commits adds the gethostbyname call to resolve the dst_name for a flow allocation using DNS. The DNS server should be specified using the method mandated by the system (e.g. added to /etc/resolv.conf).
* lib: instance ID's are now set to the process PIDdimitri staessens2016-04-261-23/+6
| | | | | | | | All instance-id's in ouroboros will be set by the system to the pid of the process associated with this application process instance. This means that the user has no way to choose the instance id's. Function calls that assumed manually defined instance id's have been replaced throughout the system.
* irmd/shim-udp: formatting fixesdimitri staessens2016-04-251-12/+12
|
* irmd: reg/unreg whatevercast namesdimitri staessens2016-04-221-11/+13
| | | | | | | | | | | | Unregistering ap's now works. An AP now registers/unregisters its AP-I by sending its AP name and its pid to the IRMd. The IPCPs register whatevercast names. An AP name is currently mapped on a whatevercast name represented by the same string literal. The IRMd allows registration of only one AP-I per AP. A Name Space Management system is needed in the processing system so we can resolve this completely. Changing the stack to register whatevercast names required some changes all over the ipcpd implemented and in the library.
* ipcpd: fixes comments on 18c5da3dimitri staessens2016-04-211-7/+7
|
* irmd: application registrationdimitri staessens2016-04-211-8/+4
| | | | | | Initial code for application registration. Specifying "*" will (for now) register with the first IPCP available in the system. Modified the echo server not to barf messages on failed accept()
* ipdpd: shim UDP: listen to incoming SDUsdimitri staessens2016-04-201-28/+74
| | | | | | The shim UDP will listen to incoming SDU's for a flow. If the flow is FLOW_PENDING, it will set it to FLOW_ALLOCATED on the reception of the first SDU, and connect() to set the destination server_host:sp.
* ipdpd: defined ANONYMOUS_AP namedimitri staessens2016-04-201-23/+8
| | | | fixes comments on 38c4169 (memleaks)
* shim-udp: flow allocation addeddimitri staessens2016-04-191-7/+287
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the API for flow allocation. The shims currently does the following. The shim IPCP binds to an interface (IP address) and listens for flow allocation requests on UDP port 0x0D1F (3359), referenced as the listen port (lp). It will treat any datagram received on lp as a flow allocation request. Upon receiving an allocation request IRM_MSG_CODE__IPCP_FLOW_ALLOC from the IRMd, the shim IPCP will bind a UDP socket to a port (cp) allocated by the host OS. From that port it will send a UDP packet containing the destination ap_name to server_host:lp and wait for a response. Upon reception of a packet on server_host:lp, the shim_IPCP creates a UDP socket for the flow with a port set by the host os (sp), binds to it and echoes the received datagram back from server_host:sp to client_host:cp. It will also notify the IRMd of an incoming flow allocation request IRM_MSG_CODE__IPCP_FLOW_REQ_ARR, with as src_ap_name ("John Day"). It will get the port_id as a return value of that message and create a flow with status FLOW_PENDING with that port_id. If the server responds negatively to the flow allocation request (i.e. the shim IPCP on the server side receives a IRM_MSG_CODE__IPCP_FLOW_ALLOC_RESPONSE with a response != 0, it will delete the pending flow. If response == 0, it will set the status to FLOW_ALLOCATED. On the client machine the IPCP will learn sp upon reception of the echoed datagram. It will then create a flow with the port_id it received with the message from the IRMd and set it to ALLOCATED. Pending implementation: DNS support, this PR only supports local flows on the loopback adapter 127.0.0.1. A thread to listen for the echoed message, to avoid the entire IPCP to block when the echoed message is lost. This PR compiles but is untested pending necessary implementations elsewhere in the stack.