IPN notes on the code
Revision as of 18:37, 27 December 2012 by Renzo
- ipn_network_table: hash table, used to search networks by inode number (and dentry address)
- struct ipn_network: (from the slab ipn_network_cache + kalloc of connport)
- connport array of ipn_node (port number to node mapping)
- connectqueue/unconnectqueue lists of ipn_node (connectqueue: faster than scanning the array for broadcast, unconnectqueue, currently unused, can be used for future "close network")
- msgpool_cache: cache for messages (struct msgpool_item). It is not global as MTU can be different.
- struct msgpool_item: the kernel copy of the message waiting to be delivered. The message is always copied once. msgpool_item(s) are pointed by msgitem elements. Each receipient has two queues of pending msgs (normal and oob): these are actually queues of msgitem elements each one pointing to the correspondent msgpoll_item where the payload is stored. msgpool_item has a reference count to clean up the contents when there are no more receipients. There is a slab (ipnxxxx) for each MTU size (all networks with the same MTU share the same slab).
- struct ipn_node: (from the slab ipn_node_cache). It is logically an extension of the struct sock (ipn sock contains a pointer to it). When a permanent node is released, ipn_node is kept and ipn_sock is freed.
- msgqueue, oobmsgqueue: lists of struct msgitem for pending msgs
- dev: net_device (for grab and tap)
- pbp (temporary structurure for pre-bind-parameters)
IPN has several synchronization needs:
- frequent operations (send/recv) should work fast
- open/close operations may be slower
- it is better to have a safe solution first, maybe it will be optimized in the future.
- integrate with existing synchronization methods for tap and grab
IPN uses more synchronization means:
- ipn_glob_mutex: this mutex serializes bind/connect/release
- (ipn_network)->ipnn_mutex: this protects the membership tables (connport, connectqueue, unconnectqueue) and it serializes the call to the protocol functions.
- (ipn_network)->msglock: this spinlock protects the access to the msgqueue.
- ipn_table_lock: This spinlock protects the ipn_network_table. It is actually commented out, as all the access to the ipn_network_table are protected by ipn_global_mutex. It has been included ready for further optimizations.
Last Updated: 2007.12.18