Linux Kernel TIPC

Introduction

TIPC (Transparent Inter Process Communication) is a protocol that is speciallydesigned for intra-cluster communication. It can be configured to transmitmessages either on UDP or directly across Ethernet. Message delivery issequence guaranteed, loss free and flow controlled. Latency times are shorterthan with any other known protocol, while maximal throughput is comparable tothat of TCP.

TIPC Features

  • Cluster wide IPC service

    Have you ever wished you had the convenience of Unix Domain Sockets even whentransmitting data between cluster nodes? Where you yourself determine theaddresses you want to bind to and use? Where you don’t have to perform DNSlookups and worry about IP addresses? Where you don’t have to start timersto monitor the continuous existence of peer sockets? And yet without thedownsides of that socket type, such as the risk of lingering inodes?

    Welcome to the Transparent Inter Process Communication service, TIPC in short,which gives you all of this, and a lot more.

  • Service Addressing

    A fundamental concept in TIPC is that of Service Addressing which makes itpossible for a programmer to chose his own address, bind it to a serversocket and let client programs use only that address for sending messages.

  • Service Tracking

    A client wanting to wait for the availability of a server, uses the ServiceTracking mechanism to subscribe for binding and unbinding/close events forsockets with the associated service address.

    The service tracking mechanism can also be used for Cluster Topology Tracking,i.e., subscribing for availability/non-availability of cluster nodes.

    Likewise, the service tracking mechanism can be used for Cluster ConnectivityTracking, i.e., subscribing for up/down events for individual links betweencluster nodes.

  • Transmission Modes

    Using a service address, a client can send datagram messages to a server socket.

    Using the same address type, it can establish a connection towards an acceptingserver socket.

    It can also use a service address to create and join a Communication Group,which is the TIPC manifestation of a brokerless message bus.

    Multicast with very good performance and scalability is available both indatagram mode and in communication group mode.

  • Inter Node Links

    Communication between any two nodes in a cluster is maintained by one or twoInter Node Links, which both guarantee data traffic integrity and monitorthe peer node’s availability.

  • Cluster Scalability

    By applying the Overlapping Ring Monitoring algorithm on the inter node linksit is possible to scale TIPC clusters up to 1000 nodes with a maintainedneighbor failure discovery time of 1-2 seconds. For smaller clusters thistime can be made much shorter.

  • Neighbor Discovery

    Neighbor Node Discovery in the cluster is done by Ethernet broadcast or UDPmulticast, when any of those services are available. If not, configured peerIP addresses can be used.

  • Configuration

    When running TIPC in single node mode no configuration whatsoever is needed.When running in cluster mode TIPC must as a minimum be given a node address(before Linux 4.17) and told which interface to attach to. The “tipc”configuration tool makes is possible to add and maintain many moreconfiguration parameters.

  • Performance

    TIPC message transfer latency times are better than in any other known protocol.Maximal byte throughput for inter-node connections is still somewhat lower thanfor TCP, while they are superior for intra-node and inter-container throughputon the same host.

  • Language Support

    The TIPC user API has support for C, Python, Perl, Ruby, D and Go.

More Information

Implementation

TIPC is implemented as a kernel module in net/tipc/ directory.

TIPC Base Types

structtipc_subscription

TIPC network topology subscription object

Definition:

struct tipc_subscription {    struct tipc_subscr s;    struct tipc_event evt;    struct kref kref;    struct net *net;    struct timer_list timer;    struct list_head service_list;    struct list_head sub_list;    int conid;    bool inactive;    spinlock_t lock;};

Members

s

host-endian copy of the user subscription

evt

template for events generated by subscription

kref

reference count for this subscription

net

network namespace associated with subscription

timer

timer governing subscription duration (optional)

service_list

adjacent subscriptions in name sequence’s subscription list

sub_list

adjacent subscriptions in subscriber’s subscription list

conid

connection identifier of topology server

inactive

true if this subscription is inactive

lock

serialize up/down and timer events

structtipc_media_addr

destination address used by TIPC bearers

Definition:

struct tipc_media_addr {    u8 value[TIPC_MEDIA_INFO_SIZE];    u8 media_id;    u8 broadcast;};

Members

value

address info (format defined by media)

media_id

TIPC media type identifier

broadcast

non-zero if address is a broadcast address

structtipc_media

Media specific info exposed to generic bearer layer

Definition:

struct tipc_media {    int (*send_msg)(struct net *net, struct sk_buff *buf, struct tipc_bearer *b, struct tipc_media_addr *dest);    int (*enable_media)(struct net *net, struct tipc_bearer *b, struct nlattr *attr[]);    void (*disable_media)(struct tipc_bearer *b);    int (*addr2str)(struct tipc_media_addr *addr, char *strbuf, int bufsz);    int (*addr2msg)(char *msg, struct tipc_media_addr *addr);    int (*msg2addr)(struct tipc_bearer *b, struct tipc_media_addr *addr, char *msg);    int (*raw2addr)(struct tipc_bearer *b, struct tipc_media_addr *addr, const char *raw);    u32 priority;    u32 tolerance;    u32 min_win;    u32 max_win;    u32 mtu;    u32 type_id;    u32 hwaddr_len;    char name[TIPC_MAX_MEDIA_NAME];};

Members

send_msg

routine which handles buffer transmission

enable_media

routine which enables a media

disable_media

routine which disables a media

addr2str

convert media address format to string

addr2msg

convert from media addr format to discovery msg addr format

msg2addr

convert from discovery msg addr format to media addr format

raw2addr

convert from raw addr format to media addr format

priority

default link (and bearer) priority

tolerance

default time (in ms) before declaring link failure

min_win

minimum window (in packets) before declaring link congestion

max_win

maximum window (in packets) before declaring link congestion

mtu

max packet size bearer can support for media type not dependent onunderlying device MTU

type_id

TIPC media identifier

hwaddr_len

TIPC media address len

name

media name

structtipc_bearer

Generic TIPC bearer structure

Definition:

struct tipc_bearer {    void *media_ptr;    u32 mtu;    struct tipc_media_addr addr;    char name[TIPC_MAX_BEARER_NAME];    struct tipc_media *media;    struct tipc_media_addr bcast_addr;    struct packet_type pt;    struct rcu_head rcu;    u32 priority;    u32 min_win;    u32 max_win;    u32 tolerance;    u32 domain;    u32 identity;    struct tipc_discoverer *disc;    char net_plane;    u16 encap_hlen;    unsigned long up;    refcount_t refcnt;};

Members

media_ptr

pointer to additional media-specific information about bearer

mtu

max packet size bearer can support

addr

media-specific address associated with bearer

name

bearer name (format = media:interface)

media

ptr to media structure associated with bearer

bcast_addr

media address used in broadcasting

pt

packet type for bearer

rcu

rcu struct for tipc_bearer

priority

default link priority for bearer

min_win

minimum window (in packets) before declaring link congestion

max_win

maximum window (in packets) before declaring link congestion

tolerance

default link tolerance for bearer

domain

network domain to which links can be established

identity

array index of this bearer within TIPC bearer array

disc

ptr to link setup request

net_plane

network plane (‘A’ through ‘H’) currently associated with bearer

encap_hlen

encap headers length

up

bearer up flag (bit 0)

refcnt

tipc_bearer reference counter

Note

media-specific code is responsible for initialization of the fieldsindicated below when a bearer is enabled; TIPC’s generic bearer code takescare of initializing all other fields.

structpublication

info about a published service address or range

Definition:

struct publication {    struct tipc_service_range sr;    struct tipc_socket_addr sk;    u16 scope;    u32 key;    u32 id;    struct list_head binding_node;    struct list_head binding_sock;    struct list_head local_publ;    struct list_head all_publ;    struct list_head list;    struct rcu_head rcu;};

Members

sr

service range represented by this publication

sk

address of socket bound to this publication

scope

scope of publication, TIPC_NODE_SCOPE or TIPC_CLUSTER_SCOPE

key

publication key, unique across the cluster

id

publication id

binding_node

all publications from the same node which bound this one- Remote publications: in node->publ_list;Used by node/name distr to withdraw publications when node is lost- Local/node scope publications: in name_table->node_scope list- Local/cluster scope publications: in name_table->cluster_scope list

binding_sock

all publications from the same socket which bound this oneUsed by socket to withdraw publications when socket is unbound/released

local_publ

list of identical publications made from this nodeUsed by closest_first and multicast receive lookup algorithms

all_publ

all publications identical to this one, whatever node and scopeUsed by round-robin lookup algorithm

list

to form a list of publications in temporal order

rcu

RCU callback head used for deferred freeing

structname_table

table containing all existing port name publications

Definition:

struct name_table {    struct rcu_head rcu;    struct hlist_head services[TIPC_NAMETBL_SIZE];    struct list_head node_scope;    struct list_head cluster_scope;    rwlock_t cluster_scope_lock;    u32 local_publ_count;    u32 rc_dests;    u32 snd_nxt;};

Members

rcu

RCU callback head used for deferred freeing

services

name sequence hash lists

node_scope

all local publications with node scope- used by name_distr during re-init of name table

cluster_scope

all local publications with cluster scope- used by name_distr to send bulk updates to new nodes- used by name_distr during re-init of name table

cluster_scope_lock

lock for accessingcluster_scope

local_publ_count

number of publications issued by this node

rc_dests

destination node counter

snd_nxt

next sequence number to be used

structdistr_item

publication info distributed to other nodes

Definition:

struct distr_item {    __be32 type;    __be32 lower;    __be32 upper;    __be32 port;    __be32 key;};

Members

type

name sequence type

lower

name sequence lower bound

upper

name sequence upper bound

port

publishing port reference

key

publication key

Description

===> All fields are stored in network byte order. <===

First 3 fields identify (name or) name sequence being published.Reference field uniquely identifies port that published name sequence.Key field uniquely identifies publication, in the event a port hasmultiple publications of the same name sequence.

Note

There is no field that identifies the publishing node because it isthe same for all items contained within a publication message.

structtipc_bc_base

base structure for keeping broadcast send state

Definition:

struct tipc_bc_base {    struct tipc_link *link;    struct sk_buff_head inputq;    int dests[MAX_BEARERS];    int primary_bearer;    bool bcast_support;    bool force_bcast;    bool rcast_support;    bool force_rcast;    int rc_ratio;    int bc_threshold;};

Members

link

broadcast send link structure

inputq

data input queue; will only carry SOCK_WAKEUP messages

dests

array keeping number of reachable destinations per bearer

primary_bearer

a bearer having links to all broadcast destinations, if any

bcast_support

indicates if primary bearer, if any, supports broadcast

force_bcast

forces broadcast for multicast traffic

rcast_support

indicates if all peer nodes support replicast

force_rcast

forces replicast for multicast traffic

rc_ratio

dest count as percentage of cluster size where send method changes

bc_threshold

calculated from rc_ratio; if dests > threshold use broadcast

TIPC Bearer Interfaces

structtipc_media*tipc_media_find(constchar*name)

locates specified media object by name

Parameters

constchar*name

name to locate

structtipc_media*media_find_id(u8type)

locates specified media object by type identifier

Parameters

u8type

type identifier to locate

inttipc_media_addr_printf(char*buf,intlen,structtipc_media_addr*a)

record media address in print buffer

Parameters

char*buf

output buffer

intlen

output buffer size remaining

structtipc_media_addr*a

input media address

intbearer_name_validate(constchar*name,structtipc_bearer_names*name_parts)

validate & (optionally) deconstruct bearer name

Parameters

constchar*name

ptr to bearer name string

structtipc_bearer_names*name_parts

ptr to area for bearer name components (or NULL if not needed)

Return

1 if bearer name is valid, otherwise 0.

structtipc_bearer*tipc_bearer_find(structnet*net,constchar*name)

locates bearer object with matching bearer name

Parameters

structnet*net

the applicable net namespace

constchar*name

bearer name to locate

inttipc_enable_bearer(structnet*net,constchar*name,u32disc_domain,u32prio,structnlattr*attr[],structnetlink_ext_ack*extack)

enable bearer with the given name

Parameters

structnet*net

the applicable net namespace

constchar*name

bearer name to enable

u32disc_domain

bearer domain

u32prio

bearer priority

structnlattr*attr[]

nlattr array

structnetlink_ext_ack*extack

netlink extended ack

inttipc_reset_bearer(structnet*net,structtipc_bearer*b)

Reset all links established over this bearer

Parameters

structnet*net

the applicable net namespace

structtipc_bearer*b

the target bearer

voidbearer_disable(structnet*net,structtipc_bearer*b)

disable this bearer

Parameters

structnet*net

the applicable net namespace

structtipc_bearer*b

the bearer to disable

Note

This routine assumes caller holds RTNL lock.

inttipc_l2_send_msg(structnet*net,structsk_buff*skb,structtipc_bearer*b,structtipc_media_addr*dest)

send a TIPC packet out over an L2 interface

Parameters

structnet*net

the associated network namespace

structsk_buff*skb

the packet to be sent

structtipc_bearer*b

the bearer through which the packet is to be sent

structtipc_media_addr*dest

peer destination address

inttipc_l2_rcv_msg(structsk_buff*skb,structnet_device*dev,structpacket_type*pt,structnet_device*orig_dev)

handle incoming TIPC message from an interface

Parameters

structsk_buff*skb

the received message

structnet_device*dev

the net device that the packet was received on

structpacket_type*pt

the packet_type structure which was used to register this handler

structnet_device*orig_dev

the original receive net device in case the device is a bond

Description

Accept only packets explicitly sent to this node, or broadcast packets;ignores packets sent using interface multicast, and traffic sent to othernodes (which can happen if interface is running in promiscuous mode).

inttipc_l2_device_event(structnotifier_block*nb,unsignedlongevt,void*ptr)

handle device events from network device

Parameters

structnotifier_block*nb

the context of the notification

unsignedlongevt

the type of event

void*ptr

the net device that the event was on

Description

This function is called by the Ethernet driver in case of linkchange event.

structudp_media_addr

IP/UDP addressing information

Definition:

struct udp_media_addr {    __be16 proto;    __be16 port;    union {        struct in_addr ipv4;        struct in6_addr ipv6;    };};

Members

proto

Ethernet protocol in use

port

port being used

{unnamed_union}

anonymous

ipv4

IPv4 address of neighbor

ipv6

IPv6 address of neighbor

Description

This is the bearer level originating address used in neighbor discoverymessages, and all fields should be in network byte order

structudp_bearer

ip/udp bearer data structure

Definition:

struct udp_bearer {    struct tipc_bearer  *bearer;    struct socket *ubsock;    u32 ifindex;    struct work_struct work;    struct udp_replicast rcast;};

Members

bearer

associated generic tipc bearer

ubsock

bearer associated socket

ifindex

local address scope

work

used to schedule deferred work on a bearer

rcast

associated udp_replicast container

inttipc_parse_udp_addr(structnlattr*nla,structudp_media_addr*addr,u32*scope_id)

build udp media address from netlink data

Parameters

structnlattr*nla

netlink attribute containing sockaddr storage aligned address

structudp_media_addr*addr

tipc media address to fill with address, port and protocol type

u32*scope_id

IPv6 scope id pointer, not NULL indicates it’s required

inttipc_udp_enable(structnet*net,structtipc_bearer*b,structnlattr*attrs[])

callback to create a new udp bearer instance

Parameters

structnet*net

network namespace

structtipc_bearer*b

pointer to generic tipc_bearer

structnlattr*attrs[]

netlink bearer configuration

Description

validate the bearer parameters and initialize the udp bearerrtnl_lock should be held

TIPC Crypto Interfaces

structtipc_tfm

TIPC TFM structure to form a list of TFMs

Definition:

struct tipc_tfm {    struct crypto_aead *tfm;    struct list_head list;};

Members

tfm

cipher handle/key

list

linked list of TFMs

structtipc_aead

TIPC AEAD key structure

Definition:

struct tipc_aead {#define TIPC_AEAD_HINT_LEN (5);    struct tipc_tfm * __percpu *tfm_entry;    struct tipc_crypto *crypto;    struct tipc_aead *cloned;    atomic_t users;    u32 salt;    u8 authsize;    u8 mode;    char hint[2 * TIPC_AEAD_HINT_LEN + 1];    struct rcu_head rcu;    struct tipc_aead_key *key;    u16 gen;    atomic64_t seqno ;    refcount_t refcnt ;};

Members

tfm_entry

per-cpu pointer to one entry in TFM list

crypto

TIPC crypto owns this key

cloned

reference to the source key in case cloning

users

the number of the key users (TX/RX)

salt

the key’s SALT value

authsize

authentication tag size (max = 16)

mode

crypto mode is applied to the key

hint

a hint for user key

rcu

structrcu_head

key

the aead key

gen

the key’s generation

seqno

the key seqno (cluster scope)

refcnt

the key reference counter

structtipc_crypto_stats

TIPC Crypto statistics

Definition:

struct tipc_crypto_stats {    unsigned int stat[MAX_STATS];};

Members

stat

array of crypto statistics

structtipc_crypto

TIPC TX/RX crypto structure

Definition:

struct tipc_crypto {    struct net *net;    struct tipc_node *node;    struct tipc_aead  *aead[KEY_MAX + 1];    atomic_t peer_rx_active;    u16 key_gen;    struct tipc_key key;    u8 skey_mode;    struct tipc_aead_key *skey;    struct workqueue_struct *wq;    struct delayed_work work;#define KEY_DISTR_SCHED         1;#define KEY_DISTR_COMPL         2;    atomic_t key_distr;    u32 rekeying_intv;    struct tipc_crypto_stats __percpu *stats;    char name[48];    atomic64_t sndnxt ;    unsigned long timer1;    unsigned long timer2;    union {        struct {            u8 working:1;            u8 key_master:1;            u8 legacy_user:1;            u8 nokey: 1;        };        u8 flags;    };    spinlock_t lock;};

Members

net

structnet

node

TIPC node (RX)

aead

array of pointers to AEAD keys for encryption/decryption

peer_rx_active

replicated peer RX active key index

key_gen

TX/RX key generation

key

the key states

skey_mode

session key’s mode

skey

received session key

wq

common workqueue on TX crypto

work

delayed work sched for TX/RX

key_distr

key distributing state

rekeying_intv

rekeying interval (in minutes)

stats

the crypto statistics

name

the crypto name

sndnxt

the per-peer sndnxt (TX)

timer1

general timer 1 (jiffies)

timer2

general timer 2 (jiffies)

{unnamed_union}

anonymous

{unnamed_struct}

anonymous

working

the crypto is working or not

key_master

flag indicates if master key exists

legacy_user

flag indicates if a peer joins w/o master key (for bwd comp.)

nokey

no key indication

flags

combined flags field

lock

tipc_key lock

inttipc_aead_key_validate(structtipc_aead_key*ukey,structgenl_info*info)

Validate a AEAD user key

Parameters

structtipc_aead_key*ukey

pointer to user key data

structgenl_info*info

netlink info pointer

inttipc_aead_key_generate(structtipc_aead_key*skey)

Generate new session key

Parameters

structtipc_aead_key*skey

input/output key with new content

Return

0 in case of success, otherwise < 0

voidtipc_aead_free(structrcu_head*rp)

Release AEAD key incl. all the TFMs in the list

Parameters

structrcu_head*rp

rcu head pointer

structcrypto_aead*tipc_aead_tfm_next(structtipc_aead*aead)

Move TFM entry to the next one in list and return it

Parameters

structtipc_aead*aead

the AEAD key pointer

inttipc_aead_init(structtipc_aead**aead,structtipc_aead_key*ukey,u8mode)

Initiate TIPC AEAD

Parameters

structtipc_aead**aead

returned new TIPC AEAD key handle pointer

structtipc_aead_key*ukey

pointer to user key data

u8mode

the key mode

Description

Allocate a (list of) new cipher transformation (TFM) with the specific userkey data if valid. The number of the allocated TFMs can be set via the sysfs“net/tipc/max_tfms” first.Also, all the other AEAD data are also initialized.

Return

0 if the initiation is successful, otherwise: < 0

inttipc_aead_clone(structtipc_aead**dst,structtipc_aead*src)

Clone a TIPC AEAD key

Parameters

structtipc_aead**dst

dest key for the cloning

structtipc_aead*src

source key to clone from

Description

Make a “copy” of the source AEAD key data to the dest, the TFMs list iscommon for the keys.A reference to the source is hold in the “cloned” pointer for the laterfreeing purposes.

Note

this must be done in cluster-key mode only!

Return

0 in case of success, otherwise < 0

void*tipc_aead_mem_alloc(structcrypto_aead*tfm,unsignedintcrypto_ctx_size,u8**iv,structaead_request**req,structscatterlist**sg,intnsg)

Allocate memory for AEAD request operations

Parameters

structcrypto_aead*tfm

cipher handle to be registered with the request

unsignedintcrypto_ctx_size

size of crypto context for callback

u8**iv

returned pointer to IV data

structaead_request**req

returned pointer to AEAD request data

structscatterlist**sg

returned pointer to SG lists

intnsg

number of SG lists to be allocated

Description

Allocate memory to store the crypto context data, AEAD request, IV and SGlists, the memory layout is as follows:crypto_ctx || iv || aead_req || sg[]

Return

the pointer to the memory areas in case of success, otherwise NULL

inttipc_aead_encrypt(structtipc_aead*aead,structsk_buff*skb,structtipc_bearer*b,structtipc_media_addr*dst,structtipc_node*__dnode)

Encrypt a message

Parameters

structtipc_aead*aead

TIPC AEAD key for the message encryption

structsk_buff*skb

the input/output skb

structtipc_bearer*b

TIPC bearer where the message will be delivered after the encryption

structtipc_media_addr*dst

the destination media address

structtipc_node*__dnode

TIPC dest node if “known”

Return

  • 0 : if the encryption has completed

  • -EINPROGRESS/-EBUSY : if a callback will be performed

  • < 0 : the encryption has failed

inttipc_aead_decrypt(structnet*net,structtipc_aead*aead,structsk_buff*skb,structtipc_bearer*b)

Decrypt an encrypted message

Parameters

structnet*net

structnet

structtipc_aead*aead

TIPC AEAD for the message decryption

structsk_buff*skb

the input/output skb

structtipc_bearer*b

TIPC bearer where the message has been received

Return

  • 0 : if the decryption has completed

  • -EINPROGRESS/-EBUSY : if a callback will be performed

  • < 0 : the decryption has failed

booltipc_ehdr_validate(structsk_buff*skb)

Validate an encryption message

Parameters

structsk_buff*skb

the message buffer

Return

“true” if this is a valid encryption message, otherwise “false”

inttipc_ehdr_build(structnet*net,structtipc_aead*aead,u8tx_key,structsk_buff*skb,structtipc_crypto*__rx)

Build TIPC encryption message header

Parameters

structnet*net

structnet

structtipc_aead*aead

TX AEAD key to be used for the message encryption

u8tx_key

key id used for the message encryption

structsk_buff*skb

input/output message skb

structtipc_crypto*__rx

RX crypto handle if dest is “known”

Return

the header size if the building is successful, otherwise < 0

inttipc_crypto_key_init(structtipc_crypto*c,structtipc_aead_key*ukey,u8mode,boolmaster_key)

Initiate a new user / AEAD key

Parameters

structtipc_crypto*c

TIPC crypto to which new key is attached

structtipc_aead_key*ukey

the user key

u8mode

the key mode (CLUSTER_KEY or PER_NODE_KEY)

boolmaster_key

specify this is a cluster master key

Description

A new TIPC AEAD key will be allocated and initiated with the specified userkey, then attached to the TIPC crypto.

Return

new key id in case of success, otherwise: < 0

inttipc_crypto_key_attach(structtipc_crypto*c,structtipc_aead*aead,u8pos,boolmaster_key)

Attach a new AEAD key to TIPC crypto

Parameters

structtipc_crypto*c

TIPC crypto to which the new AEAD key is attached

structtipc_aead*aead

the new AEAD key pointer

u8pos

desired slot in the crypto key array, = 0 if any!

boolmaster_key

specify this is a cluster master key

Return

new key id in case of success, otherwise: -EBUSY

booltipc_crypto_key_try_align(structtipc_crypto*rx,u8new_pending)

Align RX keys if possible

Parameters

structtipc_crypto*rx

RX crypto handle

u8new_pending

new pending slot if aligned (= TX key from peer)

Description

Peer has used an unknown key slot, this only happens when peer has left andrejoned, or we are newcomer.That means, there must be no active key but a pending key at unaligned slot.If so, we try to move the pending key to the new slot.

Note

A potential passive key can exist, it will be shifted correspondingly!

Return

“true” if key is successfully aligned, otherwise “false”

structtipc_aead*tipc_crypto_key_pick_tx(structtipc_crypto*tx,structtipc_crypto*rx,structsk_buff*skb,u8tx_key)

Pick one TX key for message decryption

Parameters

structtipc_crypto*tx

TX crypto handle

structtipc_crypto*rx

RX crypto handle (can be NULL)

structsk_buff*skb

the message skb which will be decrypted later

u8tx_key

peer TX key id

Description

This function looks up the existing TX keys and pick one which is suitablefor the message decryption, that must be a cluster key and not used beforeon the same message (i.e. recursive).

Return

the TX AEAD key handle in case of success, otherwise NULL

voidtipc_crypto_key_synch(structtipc_crypto*rx,structsk_buff*skb)

Synch own key data according to peer key status

Parameters

structtipc_crypto*rx

RX crypto handle

structsk_buff*skb

TIPCv2 message buffer (incl. the ehdr from peer)

Description

This function updates the peer node related data as the peer RX active keyhas changed, so the number of TX keys’ users on this node are increased anddecreased correspondingly.

It also considers if peer has no key, then we need to make own master key(if any) taking over i.e. starting grace period and also trigger keydistributing process.

The “per-peer” sndnxt is also reset when the peer key has switched.

inttipc_crypto_xmit(structnet*net,structsk_buff**skb,structtipc_bearer*b,structtipc_media_addr*dst,structtipc_node*__dnode)

Build & encrypt TIPC message for xmit

Parameters

structnet*net

structnet

structsk_buff**skb

input/output message skb pointer

structtipc_bearer*b

bearer used for xmit later

structtipc_media_addr*dst

destination media address

structtipc_node*__dnode

destination node for reference if any

Description

First, build an encryption message header on the top of the message, thenencrypt the original TIPC message by using the pending, master or activekey with this preference order.If the encryption is successful, the encrypted skb is returned directly orvia the callback.Otherwise, the skb is freed!

Return

  • 0 : the encryption has succeeded (or no encryption)

  • -EINPROGRESS/-EBUSY : the encryption is ongoing, a callback will be made

  • -ENOKEK

    : the encryption has failed due to no key

  • -EKEYREVOKED

    : the encryption has failed due to key revoked

  • -ENOMEM

    : the encryption has failed due to no memory

  • < 0 : the encryption has failed due to other reasons

inttipc_crypto_rcv(structnet*net,structtipc_crypto*rx,structsk_buff**skb,structtipc_bearer*b)

Decrypt an encrypted TIPC message from peer

Parameters

structnet*net

structnet

structtipc_crypto*rx

RX crypto handle

structsk_buff**skb

input/output message skb pointer

structtipc_bearer*b

bearer where the message has been received

Description

If the decryption is successful, the decrypted skb is returned directly oras the callback, the encryption header and auth tag will be trimmed outbefore forwarding totipc_rcv() via thetipc_crypto_rcv_complete().Otherwise, the skb will be freed!

Note

RX key(s) can be re-aligned, or in case of no key suitable, TXcluster key(s) can be taken for decryption (- recursive).

Return

  • 0 : the decryption has successfully completed

  • -EINPROGRESS/-EBUSY : the decryption is ongoing, a callback will be made

  • -ENOKEY

    : the decryption has failed due to no key

  • -EBADMSG

    : the decryption has failed due to bad message

  • -ENOMEM

    : the decryption has failed due to no memory

  • < 0 : the decryption has failed due to other reasons

voidtipc_crypto_msg_rcv(structnet*net,structsk_buff*skb)

Common ‘MSG_CRYPTO’ processing point

Parameters

structnet*net

thestructnet

structsk_buff*skb

the receiving message buffer

inttipc_crypto_key_distr(structtipc_crypto*tx,u8key,structtipc_node*dest)

Distribute a TX key

Parameters

structtipc_crypto*tx

the TX crypto

u8key

the key’s index

structtipc_node*dest

the destination tipc node, = NULL if distributing to all nodes

Return

0 in case of success, otherwise < 0

inttipc_crypto_key_xmit(structnet*net,structtipc_aead_key*skey,u16gen,u8mode,u32dnode)

Send a session key

Parameters

structnet*net

thestructnet

structtipc_aead_key*skey

the session key to be sent

u16gen

the key’s generation

u8mode

the key’s mode

u32dnode

the destination node address, = 0 if broadcasting to all nodes

Description

The session key ‘skey’ is packed in a TIPC v2 ‘MSG_CRYPTO/KEY_DISTR_MSG’as its data section, then xmit-ed through the uc/bc link.

Return

0 in case of success, otherwise < 0

booltipc_crypto_key_rcv(structtipc_crypto*rx,structtipc_msg*hdr)

Receive a session key

Parameters

structtipc_crypto*rx

the RX crypto

structtipc_msg*hdr

the TIPC v2 message incl. the receiving session key in its data

Description

This function retrieves the session key in the message from peer, thenschedules a RX work to attach the key to the corresponding RX crypto.

Return

“true” if the key has been scheduled for attaching, otherwise“false”.

voidtipc_crypto_work_rx(structwork_struct*work)

Scheduled RX works handler

Parameters

structwork_struct*work

thestructRX work

Description

The function processes the previous scheduled works i.e. distributing TX keyor attaching a received session key on RX crypto.

voidtipc_crypto_rekeying_sched(structtipc_crypto*tx,boolchanged,u32new_intv)

(Re)schedule rekeying w/o new interval

Parameters

structtipc_crypto*tx

TX crypto

boolchanged

if the rekeying needs to be rescheduled with new interval

u32new_intv

new rekeying interval (when “changed” = true)

voidtipc_crypto_work_tx(structwork_struct*work)

Scheduled TX works handler

Parameters

structwork_struct*work

thestructTX work

Description

The function processes the previous scheduled work, i.e. key rekeying, bygenerating a new session key based on current one, then attaching it to theTX crypto and finally distributing it to peers. It also re-schedules therekeying if needed.

TIPC Discoverer Interfaces

structtipc_discoverer

information about an ongoing link setup request

Definition:

struct tipc_discoverer {    u32 bearer_id;    struct tipc_media_addr dest;    struct net *net;    u32 domain;    int num_nodes;    spinlock_t lock;    struct sk_buff *skb;    struct timer_list timer;    unsigned long timer_intv;};

Members

bearer_id

identity of bearer issuing requests

dest

destination address for request messages

net

network namespace instance

domain

network domain to which links can be established

num_nodes

number of nodes currently discovered (i.e. with an active link)

lock

spinlock for controlling access to requests

skb

request message to be (repeatedly) sent

timer

timer governing period between requests

timer_intv

current interval between requests (in ms)

voidtipc_disc_init_msg(structnet*net,structsk_buff*skb,u32mtyp,structtipc_bearer*b)

initialize a link setup message

Parameters

structnet*net

the applicable net namespace

structsk_buff*skb

buffer containing message

u32mtyp

message type (request or response)

structtipc_bearer*b

ptr to bearer issuing message

voiddisc_dupl_alert(structtipc_bearer*b,u32node_addr,structtipc_media_addr*media_addr)

issue node address duplication alert

Parameters

structtipc_bearer*b

pointer to bearer detecting duplication

u32node_addr

duplicated node address

structtipc_media_addr*media_addr

media address advertised by duplicated node

voidtipc_disc_rcv(structnet*net,structsk_buff*skb,structtipc_bearer*b)

handle incoming discovery message (request or response)

Parameters

structnet*net

applicable net namespace

structsk_buff*skb

buffer containing message

structtipc_bearer*b

bearer that message arrived on

inttipc_disc_create(structnet*net,structtipc_bearer*b,structtipc_media_addr*dest,structsk_buff**skb)

create object to send periodic link setup requests

Parameters

structnet*net

the applicable net namespace

structtipc_bearer*b

ptr to bearer issuing requests

structtipc_media_addr*dest

destination address for request messages

structsk_buff**skb

pointer to created frame

Return

0 if successful, otherwise -errno.

voidtipc_disc_delete(structtipc_discoverer*d)

destroy object sending periodic link setup requests

Parameters

structtipc_discoverer*d

ptr to link dest structure

voidtipc_disc_reset(structnet*net,structtipc_bearer*b)

reset object to send periodic link setup requests

Parameters

structnet*net

the applicable net namespace

structtipc_bearer*b

ptr to bearer issuing requests

TIPC Link Interfaces

structtipc_link

TIPC link data structure

Definition:

struct tipc_link {    u32 addr;    char name[TIPC_MAX_LINK_NAME];    struct net *net;    u16 peer_session;    u16 session;    u16 snd_nxt_state;    u16 rcv_nxt_state;    u32 peer_bearer_id;    u32 bearer_id;    u32 tolerance;    u32 abort_limit;    u32 state;    u16 peer_caps;    bool in_session;    bool active;    u32 silent_intv_cnt;    char if_name[TIPC_MAX_IF_NAME];    u32 priority;    char net_plane;    struct tipc_mon_state mon_state;    u16 rst_cnt;    u16 drop_point;    struct sk_buff *failover_reasm_skb;    struct sk_buff_head failover_deferdq;    u16 mtu;    u16 advertised_mtu;    struct sk_buff_head transmq;    struct sk_buff_head backlogq;    struct {        u16 len;        u16 limit;        struct sk_buff *target_bskb;    } backlog[5];    u16 snd_nxt;    u16 rcv_nxt;    u32 rcv_unacked;    struct sk_buff_head deferdq;    struct sk_buff_head *inputq;    struct sk_buff_head *namedq;    struct sk_buff_head wakeupq;    u16 window;    u16 min_win;    u16 ssthresh;    u16 max_win;    u16 cong_acks;    u16 checkpoint;    struct sk_buff *reasm_buf;    struct sk_buff *reasm_tnlmsg;    u16 ackers;    u16 acked;    u16 last_gap;    struct tipc_gap_ack_blks *last_ga;    struct tipc_link *bc_rcvlink;    struct tipc_link *bc_sndlink;    u8 nack_state;    bool bc_peer_is_up;    struct tipc_stats stats;};

Members

addr

network address of link’s peer node

name

link name character string

net

pointer to namespace struct

peer_session

link session # being used by peer end of link

session

session to be used by link

snd_nxt_state

next send seq number

rcv_nxt_state

next rcv seq number

peer_bearer_id

bearer id used by link’s peer endpoint

bearer_id

local bearer id used by link

tolerance

minimum link continuity loss needed to reset link [in ms]

abort_limit

# of unacknowledged continuity probes needed to reset link

state

current state of link FSM

peer_caps

bitmap describing capabilities of peer node

in_session

have received ACTIVATE_MSG from peer

active

link is active

silent_intv_cnt

# of timer intervals without any reception from peer

if_name

associated interface name

priority

current link priority

net_plane

current link network plane (‘A’ through ‘H’)

mon_state

cookie with information needed by link monitor

rst_cnt

link reset counter

drop_point

seq number for failover handling (FIXME)

failover_reasm_skb

saved failover msg ptr (FIXME)

failover_deferdq

deferred message queue for failover processing (FIXME)

mtu

current maximum packet size for this link

advertised_mtu

advertised own mtu when link is being established

transmq

the link’s transmit queue

backlogq

queue for messages waiting to be sent

backlog

link’s backlog by priority (importance)

snd_nxt

next sequence number to be used

rcv_nxt

next sequence number to expect for inbound messages

rcv_unacked

# messages read by user, but not yet acked back to peer

deferdq

deferred receive queue

inputq

buffer queue for messages to be delivered upwards

namedq

buffer queue for name table messages to be delivered upwards

wakeupq

linked list of wakeup msgs waiting for link congestion to abate

window

sliding window size for congestion handling

min_win

minimal send window to be used by link

ssthresh

slow start threshold for congestion handling

max_win

maximal send window to be used by link

cong_acks

congestion acks for congestion avoidance (FIXME)

checkpoint

seq number for congestion window size handling

reasm_buf

head of partially reassembled inbound message fragments

reasm_tnlmsg

fragmentation/reassembly area for tunnel protocol message

ackers

# of peers that needs to ack each packet before it can be released

acked

# last packet acked by a certain peer. Used for broadcast.

last_gap

last gap ack blocks for bcast (FIXME)

last_ga

ptr to gap ack blocks

bc_rcvlink

the peer specific link used for broadcast reception

bc_sndlink

the namespace global link used for broadcast sending

nack_state

bcast nack state

bc_peer_is_up

peer has acked the bcast init msg

stats

collects statistics regarding link activity

booltipc_link_create(structnet*net,char*if_name,intbearer_id,inttolerance,charnet_plane,u32mtu,intpriority,u32min_win,u32max_win,u32session,u32self,u32peer,u8*peer_id,u16peer_caps,structtipc_link*bc_sndlink,structtipc_link*bc_rcvlink,structsk_buff_head*inputq,structsk_buff_head*namedq,structtipc_link**link)

create a new link

Parameters

structnet*net

pointer to associated network namespace

char*if_name

associated interface name

intbearer_id

id (index) of associated bearer

inttolerance

link tolerance to be used by link

charnet_plane

network plane (A,B,c..) this link belongs to

u32mtu

mtu to be advertised by link

intpriority

priority to be used by link

u32min_win

minimal send window to be used by link

u32max_win

maximal send window to be used by link

u32session

session to be used by link

u32self

local unicast link id

u32peer

node id of peer node

u8*peer_id

128-bit ID of peer

u16peer_caps

bitmap describing peer node capabilities

structtipc_link*bc_sndlink

the namespace global link used for broadcast sending

structtipc_link*bc_rcvlink

the peer specific link used for broadcast reception

structsk_buff_head*inputq

queue to put messages ready for delivery

structsk_buff_head*namedq

queue to put binding table update messages ready for delivery

structtipc_link**link

return value, pointer to put the created link

Return

true if link was created, otherwise false

booltipc_link_bc_create(structnet*net,u32ownnode,u32peer,u8*peer_id,intmtu,u32min_win,u32max_win,u16peer_caps,structsk_buff_head*inputq,structsk_buff_head*namedq,structtipc_link*bc_sndlink,structtipc_link**link)

create new link to be used for broadcast

Parameters

structnet*net

pointer to associated network namespace

u32ownnode

identity of own node

u32peer

node id of peer node

u8*peer_id

128-bit ID of peer

intmtu

mtu to be used initially if no peers

u32min_win

minimal send window to be used by link

u32max_win

maximal send window to be used by link

u16peer_caps

bitmap describing peer node capabilities

structsk_buff_head*inputq

queue to put messages ready for delivery

structsk_buff_head*namedq

queue to put binding table update messages ready for delivery

structtipc_link*bc_sndlink

the namespace global link used for broadcast sending

structtipc_link**link

return value, pointer to put the created link

Return

true if link was created, otherwise false

inttipc_link_fsm_evt(structtipc_link*l,intevt)

link finite state machine

Parameters

structtipc_link*l

pointer to link

intevt

state machine event to be processed

booltipc_link_too_silent(structtipc_link*l)

check if link is “too silent”

Parameters

structtipc_link*l

tipc link to be checked

Return

true if the link ‘silent_intv_cnt’ is about to reach the‘abort_limit’ value, otherwise false

intlink_schedule_user(structtipc_link*l,structtipc_msg*hdr)

schedule a message sender for wakeup after congestion

Parameters

structtipc_link*l

congested link

structtipc_msg*hdr

header of message that is being sentCreate pseudo msg to send back to user when congestion abates

voidlink_prepare_wakeup(structtipc_link*l)

prepare users for wakeup after congestion

Parameters

structtipc_link*l

congested linkWake up a number of waiting users, as permitted by available spacein the send queue

voidtipc_link_set_skb_retransmit_time(structsk_buff*skb,structtipc_link*l)

set the time at which retransmission of the given skb should be next attempted

Parameters

structsk_buff*skb

skb to set a future retransmission time for

structtipc_link*l

link the skb will be transmitted on

inttipc_link_xmit(structtipc_link*l,structsk_buff_head*list,structsk_buff_head*xmitq)

enqueue buffer list according to queue situation

Parameters

structtipc_link*l

link to use

structsk_buff_head*list

chain of buffers containing message

structsk_buff_head*xmitq

returned list of packets to be sent by caller

Description

Consumes the buffer chain.Messages at TIPC_SYSTEM_IMPORTANCE are always accepted

Return

0 if success, or errno: -ELINKCONG, -EMSGSIZE or -ENOBUFS

boollink_retransmit_failure(structtipc_link*l,structtipc_link*r,int*rc)

Detect repeated retransmit failures

Parameters

structtipc_link*l

tipc link sender

structtipc_link*r

tipc link receiver (= l in case of unicast)

int*rc

returned code

Return

true if the repeated retransmit failures happens, otherwisefalse

u16tipc_get_gap_ack_blks(structtipc_gap_ack_blks**ga,structtipc_link*l,structtipc_msg*hdr,booluc)

get Gap ACK blocks from PROTOCOL/STATE_MSG

Parameters

structtipc_gap_ack_blks**ga

returned pointer to the Gap ACK blocks if any

structtipc_link*l

the tipc link

structtipc_msg*hdr

the PROTOCOL/STATE_MSG header

booluc

desired Gap ACK blocks type, i.e. unicast (= 1) or broadcast (= 0)

Return

the total Gap ACK blocks size

voidtipc_link_failover_prepare(structtipc_link*l,structtipc_link*tnl,structsk_buff_head*xmitq)

prepare tnl for link failover

Parameters

structtipc_link*l

failover link

structtipc_link*tnl

tunnel link

structsk_buff_head*xmitq

queue for messages to be xmited

Description

This is a special version of the precursor -tipc_link_tnl_prepare(),see thetipc_node_link_failover() for details

voidtipc_link_reset_stats(structtipc_link*l)

reset link statistics

Parameters

structtipc_link*l

pointer to link

inttipc_link_dump(structtipc_link*l,u16dqueues,char*buf)

dump TIPC link data

Parameters

structtipc_link*l

tipc link to be dumped

u16dqueues

bitmask to decide if any link queue to be dumped?- TIPC_DUMP_NONE: don’t dump link queues- TIPC_DUMP_TRANSMQ: dump link transmq queue- TIPC_DUMP_BACKLOGQ: dump link backlog queue- TIPC_DUMP_DEFERDQ: dump link deferd queue- TIPC_DUMP_INPUTQ: dump link input queue- TIPC_DUMP_WAKEUP: dump link wakeup queue- TIPC_DUMP_ALL: dump all the link queues above

char*buf

returned buffer of dump data in format

TIPC msg Interfaces

structsk_buff*tipc_buf_acquire(u32size,gfp_tgfp)

creates a TIPC message buffer

Parameters

u32size

message size (including TIPC header)

gfp_tgfp

memory allocation flags

Return

a new buffer with data pointers set to the specified size.

NOTE

Headroom is reserved to allow prepending of a data link header.There may also be unrequested tailroom present at the buffer’s end.

inttipc_msg_append(structtipc_msg*_hdr,structmsghdr*m,intdlen,intmss,structsk_buff_head*txq)

Append data to tail of an existing buffer queue

Parameters

structtipc_msg*_hdr

header to be used

structmsghdr*m

the data to be appended

intdlen

size of data to be appended

intmss

max allowable size of buffer

structsk_buff_head*txq

queue to append to

Return

the number of 1k blocks appended or errno value

inttipc_msg_fragment(structsk_buff*skb,conststructtipc_msg*hdr,intpktmax,structsk_buff_head*frags)

build a fragment skb list for TIPC message

Parameters

structsk_buff*skb

TIPC message skb

conststructtipc_msg*hdr

internal msg header to be put on the top of the fragments

intpktmax

max size of a fragment incl. the header

structsk_buff_head*frags

returned fragment skb list

Return

0 if the fragmentation is successful, otherwise: -EINVALor -ENOMEM

inttipc_msg_build(structtipc_msg*mhdr,structmsghdr*m,intoffset,intdsz,intpktmax,structsk_buff_head*list)

create buffer chain containing specified header and data

Parameters

structtipc_msg*mhdr

Message header, to be prepended to data

structmsghdr*m

User message

intoffset

buffer offset for fragmented messages (FIXME)

intdsz

Total length of user data

intpktmax

Max packet size that can be used

structsk_buff_head*list

Buffer or chain of buffers to be returned to caller

Description

Note that the recursive call we are making here is safe, since it canlogically go only one further level down.

Return

message data size or errno: -ENOMEM, -EFAULT

booltipc_msg_bundle(structsk_buff*bskb,structtipc_msg*msg,u32max)

Append contents of a buffer to tail of an existing one

Parameters

structsk_buff*bskb

the bundle buffer to append to

structtipc_msg*msg

message to be appended

u32max

max allowable size for the bundle buffer

Return

“true” if bundling has been performed, otherwise “false”

booltipc_msg_try_bundle(structsk_buff*tskb,structsk_buff**skb,u32mss,u32dnode,bool*new_bundle)

Try to bundle a new message to the last one

Parameters

structsk_buff*tskb

the last/target message to which the new one will be appended

structsk_buff**skb

the new message skb pointer

u32mss

max message size (header inclusive)

u32dnode

destination node for the message

bool*new_bundle

if this call made a new bundle or not

Return

“true” if the new message skb is potential for bundling this time orlater, in the case a bundling has been done this time, the skb is consumed(the skb pointer = NULL).Otherwise, “false” if the skb cannot be bundled at all.

booltipc_msg_extract(structsk_buff*skb,structsk_buff**iskb,int*pos)

extract bundled inner packet from buffer

Parameters

structsk_buff*skb

buffer to be extracted from.

structsk_buff**iskb

extracted inner buffer, to be returned

int*pos

position in outer message of msg to be extracted.Returns position of next msg.Consumes outer buffer when last packet extracted

Return

true when there is an extracted buffer, otherwise false

booltipc_msg_reverse(u32own_node,structsk_buff**skb,interr)

swap source and destination addresses and add error code

Parameters

u32own_node

originating node id for reversed message

structsk_buff**skb

buffer containing message to be reversed; will be consumed

interr

error code to be set in message, if anyReplaces consumed buffer with new one when successful

Return

true if success, otherwise false

booltipc_msg_lookup_dest(structnet*net,structsk_buff*skb,int*err)

try to find new destination for named message

Parameters

structnet*net

pointer to associated network namespace

structsk_buff*skb

the buffer containing the message.

int*err

error code to be used by caller if lookup failsDoes not consume buffer

Return

true if a destination is found, false otherwise

TIPC Name Interfaces

structservice_range

container for all bindings of a service range

Definition:

struct service_range {    u32 lower;    u32 upper;    struct rb_node tree_node;    u32 max;    struct list_head local_publ;    struct list_head all_publ;};

Members

lower

service range lower bound

upper

service range upper bound

tree_node

member of service range RB tree

max

largest ‘upper’ in this node subtree

local_publ

list of identical publications made from this nodeUsed by closest_first lookup and multicast lookup algorithm

all_publ

all publications identical to this one, whatever node and scopeUsed by round-robin lookup algorithm

structtipc_service

container for all published instances of a service type

Definition:

struct tipc_service {    u32 type;    u32 publ_cnt;    struct rb_root ranges;    struct hlist_node service_list;    struct list_head subscriptions;    spinlock_t lock;    struct rcu_head rcu;};

Members

type

32 bit ‘type’ value for service

publ_cnt

increasing counter for publications in this service

ranges

rb tree containing all service ranges for this service

service_list

links to adjacent name ranges in hash chain

subscriptions

list of subscriptions for this service type

lock

spinlock controlling access to pertaining service ranges/publications

rcu

RCU callback head used for deferred freeing

service_range_foreach_match

service_range_foreach_match(sr,sc,start,end)

iterate over tipc service rbtree for each range match

Parameters

sr

the service range pointer as a loop cursor

sc

the pointer to tipc service which holds the service range rbtree

start

beginning of the search range (end >= start) for matching

end

end of the search range (end >= start) for matching

structservice_range*service_range_match_first(structrb_node*n,u32start,u32end)

find first service range matching a range

Parameters

structrb_node*n

the root node of service range rbtree for searching

u32start

beginning of the search range (end >= start) for matching

u32end

end of the search range (end >= start) for matching

Return

the leftmost service range node in the rbtree that overlaps thespecific range if any. Otherwise, returns NULL.

structservice_range*service_range_match_next(structrb_node*n,u32start,u32end)

find next service range matching a range

Parameters

structrb_node*n

a node in service range rbtree from which the searching starts

u32start

beginning of the search range (end >= start) for matching

u32end

end of the search range (end >= start) for matching

Return

the next service range node to the given node in the rbtree thatoverlaps the specific range if any. Otherwise, returns NULL.

structpublication*tipc_publ_create(structtipc_uaddr*ua,structtipc_socket_addr*sk,u32key)

create a publication structure

Parameters

structtipc_uaddr*ua

the service range the user is binding to

structtipc_socket_addr*sk

the address of the socket that is bound

u32key

publication key

structtipc_service*tipc_service_create(structnet*net,structtipc_uaddr*ua)

create a service structure for the specified ‘type’

Parameters

structnet*net

network namespace

structtipc_uaddr*ua

address representing the service to be bound

Description

Allocates a single range structure and sets it to all 0’s.

structpublication*tipc_service_remove_publ(structservice_range*r,structtipc_socket_addr*sk,u32key)

remove a publication from a service

Parameters

structservice_range*r

service_range to remove publication from

structtipc_socket_addr*sk

address publishing socket

u32key

target publication key

voidtipc_service_subscribe(structtipc_service*service,structtipc_subscription*sub)

attach a subscription, and optionally issue the prescribed number of events if there is any service range overlapping with the requested range

Parameters

structtipc_service*service

the tipc_service to attach thesub to

structtipc_subscription*sub

the subscription to attach

booltipc_nametbl_lookup_anycast(structnet*net,structtipc_uaddr*ua,structtipc_socket_addr*sk)

perform service instance to socket translation

Parameters

structnet*net

network namespace

structtipc_uaddr*ua

service address to look up

structtipc_socket_addr*sk

address to socket we want to find

Description

On entry, a non-zero ‘sk->node’ indicates the node where we want lookup to beperformed, which may not be this one.

On exit:

  • If lookup is deferred to another node, leave ‘sk->node’ unchanged andreturn ‘true’.

  • If lookup is successful, set the ‘sk->node’ and ‘sk->ref’ (== portid) whichrepresent the bound socket and return ‘true’.

  • If lookup fails, return ‘false’

Note that for legacy users (node configured with Z.C.N address format) the‘closest-first’ lookup algorithm must be maintained, i.e., if sk.node is 0we must look in the local binding list first

voidtipc_nametbl_withdraw(structnet*net,structtipc_uaddr*ua,structtipc_socket_addr*sk,u32key)

withdraw a service binding

Parameters

structnet*net

network namespace

structtipc_uaddr*ua

service address/range being unbound

structtipc_socket_addr*sk

address of the socket being unbound from

u32key

target publication key

booltipc_nametbl_subscribe(structtipc_subscription*sub)

add a subscription object to the name table

Parameters

structtipc_subscription*sub

subscription to add

voidtipc_nametbl_unsubscribe(structtipc_subscription*sub)

remove a subscription object from name table

Parameters

structtipc_subscription*sub

subscription to remove

voidtipc_service_delete(structnet*net,structtipc_service*sc)

purge all publications for a service and delete it

Parameters

structnet*net

the associated network namespace

structtipc_service*sc

tipc_service to delete

voidpubl_to_item(structdistr_item*i,structpublication*p)

add publication info to a publication message

Parameters

structdistr_item*i

location of item in the message

structpublication*p

publication info

structsk_buff*named_prepare_buf(structnet*net,u32type,u32size,u32dest)

allocate & initialize a publication message

Parameters

structnet*net

the associated network namespace

u32type

message type

u32size

payload size

u32dest

destination node

Description

The buffer returned is of size INT_H_SIZE + payload size

structsk_buff*tipc_named_publish(structnet*net,structpublication*p)

tell other nodes about a new publication by this node

Parameters

structnet*net

the associated network namespace

structpublication*p

the new publication

structsk_buff*tipc_named_withdraw(structnet*net,structpublication*p)

tell other nodes about a withdrawn publication by this node

Parameters

structnet*net

the associated network namespace

structpublication*p

the withdrawn publication

voidnamed_distribute(structnet*net,structsk_buff_head*list,u32dnode,structlist_head*pls,u16seqno)

prepare name info for bulk distribution to another node

Parameters

structnet*net

the associated network namespace

structsk_buff_head*list

list of messages (buffers) to be returned from this function

u32dnode

node to be updated

structlist_head*pls

linked list of publication items to be packed into buffer chain

u16seqno

sequence number for this message

voidtipc_named_node_up(structnet*net,u32dnode,u16capabilities)

tell specified node about all publications by this node

Parameters

structnet*net

the associated network namespace

u32dnode

destination node

u16capabilities

peer node’s capabilities

voidtipc_publ_purge(structnet*net,structpublication*p,u32addr)

remove publication associated with a failed node

Parameters

structnet*net

the associated network namespace

structpublication*p

the publication to remove

u32addr

failed node’s address

Description

Invoked for each publication issued by a newly failed node.Removes publication structure from name table & deletes it.

booltipc_update_nametbl(structnet*net,structdistr_item*i,u32node,u32dtype)

try to process a nametable update and notify subscribers

Parameters

structnet*net

the associated network namespace

structdistr_item*i

location of item in the message

u32node

node address

u32dtype

name distributor message type

Description

tipc_nametbl_lock must be held.

Return

the publication item if successful, otherwise NULL.

voidtipc_named_rcv(structnet*net,structsk_buff_head*namedq,u16*rcv_nxt,bool*open)

process name table update messages sent by another node

Parameters

structnet*net

the associated network namespace

structsk_buff_head*namedq

queue to receive from

u16*rcv_nxt

store last received seqno here

bool*open

last bulk msg was received (FIXME)

voidtipc_named_reinit(structnet*net)

re-initialize local publications

Parameters

structnet*net

the associated network namespace

Description

This routine is called whenever TIPC networking is enabled.All name table entries published by this node are updated to reflectthe node’s new network address.

TIPC Node Management Interfaces

structtipc_node

TIPC node structure

Definition:

struct tipc_node {    u32 addr;    struct kref kref;    rwlock_t lock;    struct net *net;    struct hlist_node hash;    int active_links[2];    struct tipc_link_entry links[MAX_BEARERS];    struct tipc_bclink_entry bc_entry;    int action_flags;    struct list_head list;    int state;    bool preliminary;    bool failover_sent;    u16 sync_point;    int link_cnt;    u16 working_links;    u16 capabilities;    u32 signature;    u32 link_id;    u8 peer_id[16];    char peer_id_string[NODE_ID_STR_LEN];    struct list_head publ_list;    struct list_head conn_sks;    unsigned long keepalive_intv;    struct timer_list timer;    struct rcu_head rcu;    unsigned long delete_at;    struct net *peer_net;    u32 peer_hash_mix;#ifdef CONFIG_TIPC_CRYPTO;    struct tipc_crypto *crypto_rx;#endif;};

Members

addr

network address of node

kref

reference counter to node object

lock

rwlock governing access to structure

net

the applicable net namespace

hash

links to adjacent nodes in unsorted hash chain

active_links

bearer ids of active links, used as index into links[] array

links

array containing references to all links to node

bc_entry

broadcast link entry

action_flags

bit mask of different types of node actions

list

links to adjacent nodes in sorted list of cluster’s nodes

state

connectivity state vs peer node

preliminary

a preliminary node or not

failover_sent

failover sent or not

sync_point

sequence number where synch/failover is finished

link_cnt

number of links to node

working_links

number of working links to node (both active and standby)

capabilities

bitmap, indicating peer node’s functional capabilities

signature

node instance identifier

link_id

local and remote bearer ids of changing link, if any

peer_id

128-bit ID of peer

peer_id_string

ID string of peer

publ_list

list of publications

conn_sks

list of connections (FIXME)

keepalive_intv

keepalive interval in milliseconds

timer

node’s keepalive timer

rcu

rcu struct for tipc_node

delete_at

indicates the time for deleting a down node

peer_net

peer’s net namespace

peer_hash_mix

hash for this peer (FIXME)

crypto_rx

RX crypto handler

structtipc_crypto*tipc_node_crypto_rx(structtipc_node*__n)

Retrieve crypto RX handle from node

Parameters

structtipc_node*__n

target tipc_node

Note

node ref counter must be held first!

void__tipc_node_link_up(structtipc_node*n,intbearer_id,structsk_buff_head*xmitq)

handle addition of link

Parameters

structtipc_node*n

target tipc_node

intbearer_id

id of the bearer

structsk_buff_head*xmitq

queue for messages to be xmited onNode lock must be held by callerLink becomes active (alone or shared) or standby, depending on its priority.

voidtipc_node_link_up(structtipc_node*n,intbearer_id,structsk_buff_head*xmitq)

handle addition of link

Parameters

structtipc_node*n

target tipc_node

intbearer_id

id of the bearer

structsk_buff_head*xmitq

queue for messages to be xmited on

Description

Link becomes active (alone or shared) or standby, depending on its priority.

voidtipc_node_link_failover(structtipc_node*n,structtipc_link*l,structtipc_link*tnl,structsk_buff_head*xmitq)

start failover in case “half-failover”

Parameters

structtipc_node*n

tipc node structure

structtipc_link*l

link peer endpoint failingover (- can be NULL)

structtipc_link*tnl

tunnel link

structsk_buff_head*xmitq

queue for messages to be xmited on tnl link later

Description

This function is only called in a very special situation where linkfailover can be already started on peer node but not on this node.This can happen when e.g.:

1. Both links <1A-2A>, <1B-2B> down2. Link endpoint 2A up, but 1A still down (e.g. due to networkdisturbance, wrong session, etc.)3. Link <1B-2B> up4. Link endpoint 2A down (e.g. due to link tolerance timeout)5. Node 2 starts failover onto link <1B-2B>==> Node 1 does never start link/node failover!
void__tipc_node_link_down(structtipc_node*n,int*bearer_id,structsk_buff_head*xmitq,structtipc_media_addr**maddr)

handle loss of link

Parameters

structtipc_node*n

target tipc_node

int*bearer_id

id of the bearer

structsk_buff_head*xmitq

queue for messages to be xmited on

structtipc_media_addr**maddr

output media address of the bearer

inttipc_node_get_linkname(structnet*net,u32bearer_id,u32addr,char*linkname,size_tlen)

get the name of a link

Parameters

structnet*net

the applicable net namespace

u32bearer_id

id of the bearer

u32addr

peer node address

char*linkname

link name output buffer

size_tlen

size oflinkname output buffer

Return

0 on success

inttipc_node_xmit(structnet*net,structsk_buff_head*list,u32dnode,intselector)

general link level function for message sending

Parameters

structnet*net

the applicable net namespace

structsk_buff_head*list

chain of buffers containing message

u32dnode

address of destination node

intselector

a number used for deterministic link selectionConsumes the buffer chain.

Return

0 if success, otherwise: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE,-ENOBUF

voidtipc_node_bc_rcv(structnet*net,structsk_buff*skb,intbearer_id)

process TIPC broadcast packet arriving from off-node

Parameters

structnet*net

the applicable net namespace

structsk_buff*skb

TIPC packet

intbearer_id

id of bearer message arrived on

Description

Invoked with no locks held.

booltipc_node_check_state(structtipc_node*n,structsk_buff*skb,intbearer_id,structsk_buff_head*xmitq)

check and if necessary update node state

Parameters

structtipc_node*n

target tipc_node

structsk_buff*skb

TIPC packet

intbearer_id

identity of bearer delivering the packet

structsk_buff_head*xmitq

queue for messages to be xmited on

Return

true if state and msg are ok, otherwise false

voidtipc_rcv(structnet*net,structsk_buff*skb,structtipc_bearer*b)

process TIPC packets/messages arriving from off-node

Parameters

structnet*net

the applicable net namespace

structsk_buff*skb

TIPC packet

structtipc_bearer*b

pointer to bearer message arrived on

Description

Invoked with no locks held. Bearer pointer must point to a valid bearerstructure (i.e. cannot be NULL), but bearer can be inactive.

inttipc_node_dump(structtipc_node*n,boolmore,char*buf)

dump TIPC node data

Parameters

structtipc_node*n

tipc node to be dumped

boolmore

dump more?- false: dump only tipc node data- true: dump node link data as well

char*buf

returned buffer of dump data in format

TIPC Socket Interfaces

structtipc_sock

TIPC socket structure

Definition:

struct tipc_sock {    struct sock sk;    u32 max_pkt;    u32 maxnagle;    u32 portid;    struct tipc_msg phdr;    struct list_head cong_links;    struct list_head publications;    u32 pub_count;    atomic_t dupl_rcvcnt;    u16 conn_timeout;    bool probe_unacked;    u16 cong_link_cnt;    u16 snt_unacked;    u16 snd_win;    u16 peer_caps;    u16 rcv_unacked;    u16 rcv_win;    struct sockaddr_tipc peer;    struct rhash_head node;    struct tipc_mc_method mc_method;    struct rcu_head rcu;    struct tipc_group *group;    u32 oneway;    u32 nagle_start;    u16 snd_backlog;    u16 msg_acc;    u16 pkt_cnt;    bool expect_ack;    bool nodelay;    bool group_is_open;    bool published;    u8 conn_addrtype;};

Members

sk

socket - interacts with ‘port’ and with user via the socket API

max_pkt

maximum packet size “hint” used when building messages sent by port

maxnagle

maximum size of msg which can be subject to nagle

portid

unique port identity in TIPC socket hash table

phdr

preformatted message header used when sending messages

cong_links

list of congested links

publications

list of publications for port

pub_count

total # of publications port has made during its lifetime

dupl_rcvcnt

number of bytes counted twice, in both backlog and rcv queue

conn_timeout

the time we can wait for an unresponded setup request

probe_unacked

probe has not received ack yet

cong_link_cnt

number of congested links

snt_unacked

# messages sent by socket, and not yet acked by peer

snd_win

send window size

peer_caps

peer capabilities mask

rcv_unacked

# messages read by user, but not yet acked back to peer

rcv_win

receive window size

peer

‘connected’ peer for dgram/rdm

node

hash table node

mc_method

cookie for use between socket and broadcast layer

rcu

rcu struct for tipc_sock

group

TIPC communications group

oneway

message count in one direction (FIXME)

nagle_start

current nagle value

snd_backlog

send backlog count

msg_acc

messages accepted; used in managing backlog and nagle

pkt_cnt

TIPC socket packet count

expect_ack

whether this TIPC socket is expecting an ack

nodelay

setsockopt() TIPC_NODELAY setting

group_is_open

TIPC socket group is fully open (FIXME)

published

true if port has one or more associated names

conn_addrtype

address type used when establishing connection

voidtsk_advance_rx_queue(structsock*sk)

discard first buffer in socket receive queue

Parameters

structsock*sk

network socket

Description

Caller must hold socket lock

voidtsk_rej_rx_queue(structsock*sk,interror)

reject all buffers in socket receive queue

Parameters

structsock*sk

network socket

interror

response error code

Description

Caller must hold socket lock

inttipc_sk_create(structnet*net,structsocket*sock,intprotocol,intkern)

create a TIPC socket

Parameters

structnet*net

network namespace (must be default network)

structsocket*sock

pre-allocated socket structure

intprotocol

protocol indicator (must be 0)

intkern

caused by kernel or by userspace?

Description

This routine creates additional data structures used by the TIPC socket,initializes them, and links them together.

Return

0 on success, errno otherwise

inttipc_release(structsocket*sock)

destroy a TIPC socket

Parameters

structsocket*sock

socket to destroy

Description

This routine cleans up any messages that are still queued on the socket.For DGRAM and RDM socket types, all queued messages are rejected.For SEQPACKET and STREAM socket types, the first message is rejectedand any others are discarded. (If the first message on a STREAM socketis partially-read, it is discarded and the next one is rejected instead.)

NOTE

Rejected messages are not necessarily returned to the sender! Theyare returned or discarded according to the “destination droppable” settingspecified for the message by the sender.

Return

0 on success, errno otherwise

int__tipc_bind(structsocket*sock,structsockaddr*skaddr,intalen)

associate or disassociate TIPC name(s) with a socket

Parameters

structsocket*sock

socket structure

structsockaddr*skaddr

socket address describing name(s) and desired operation

intalen

size of socket address data structure

Description

Name and name sequence binding are indicated using a positive scope value;a negative scope value unbinds the specified name. Specifying no name(i.e. a socket address length of 0) unbinds all names from the socket.

Return

0 on success, errno otherwise

NOTE

This routine doesn’t need to take the socket lock since it doesn’t

access any non-constant socket information.

inttipc_getname(structsocket*sock,structsockaddr*uaddr,intpeer)

get port ID of socket or peer socket

Parameters

structsocket*sock

socket structure

structsockaddr*uaddr

area for returned socket address

intpeer

0 = own ID, 1 = current peer ID, 2 = current/former peer ID

Return

0 on success, errno otherwise

NOTE

This routine doesn’t need to take the socket lock since it only

accesses socket information that is unchanging (or which changes ina completely predictable manner).

__poll_ttipc_poll(structfile*file,structsocket*sock,poll_table*wait)

read and possibly block on pollmask

Parameters

structfile*file

file structure associated with the socket

structsocket*sock

socket for which to calculate the poll bits

poll_table*wait

???

Return

pollmask value

Description

COMMENTARY:It appears that the usual socket locking mechanisms are not useful heresince the pollmask info is potentially out-of-date the moment this routineexits. TCP and other protocols seem to rely on higher level poll routinesto handle any preventable race conditions, so TIPC will do the same ...

IMPORTANT: The fact that a read or write operation is indicated does NOTimply that the operation will succeed, merely that it should be performedand will not block.

inttipc_sendmcast(structsocket*sock,structtipc_uaddr*ua,structmsghdr*msg,size_tdlen,longtimeout)

send multicast message

Parameters

structsocket*sock

socket structure

structtipc_uaddr*ua

destination address struct

structmsghdr*msg

message to send

size_tdlen

length of data to send

longtimeout

timeout to wait for wakeup

Description

Called from functiontipc_sendmsg(), which has done all sanity checks

Return

the number of bytes sent on success, or errno

inttipc_send_group_msg(structnet*net,structtipc_sock*tsk,structmsghdr*m,structtipc_member*mb,u32dnode,u32dport,intdlen)

send a message to a member in the group

Parameters

structnet*net

network namespace

structtipc_sock*tsk

tipc socket

structmsghdr*m

message to send

structtipc_member*mb

group member

u32dnode

destination node

u32dport

destination port

intdlen

total length of message data

inttipc_send_group_unicast(structsocket*sock,structmsghdr*m,intdlen,longtimeout)

send message to a member in the group

Parameters

structsocket*sock

socket structure

structmsghdr*m

message to send

intdlen

total length of message data

longtimeout

timeout to wait for wakeup

Description

Called from functiontipc_sendmsg(), which has done all sanity checks

Return

the number of bytes sent on success, or errno

inttipc_send_group_anycast(structsocket*sock,structmsghdr*m,intdlen,longtimeout)

send message to any member with given identity

Parameters

structsocket*sock

socket structure

structmsghdr*m

message to send

intdlen

total length of message data

longtimeout

timeout to wait for wakeup

Description

Called from functiontipc_sendmsg(), which has done all sanity checks

Return

the number of bytes sent on success, or errno

inttipc_send_group_bcast(structsocket*sock,structmsghdr*m,intdlen,longtimeout)

send message to all members in communication group

Parameters

structsocket*sock

socket structure

structmsghdr*m

message to send

intdlen

total length of message data

longtimeout

timeout to wait for wakeup

Description

Called from functiontipc_sendmsg(), which has done all sanity checks

Return

the number of bytes sent on success, or errno

inttipc_send_group_mcast(structsocket*sock,structmsghdr*m,intdlen,longtimeout)

send message to all members with given identity

Parameters

structsocket*sock

socket structure

structmsghdr*m

message to send

intdlen

total length of message data

longtimeout

timeout to wait for wakeup

Description

Called from functiontipc_sendmsg(), which has done all sanity checks

Return

the number of bytes sent on success, or errno

voidtipc_sk_mcast_rcv(structnet*net,structsk_buff_head*arrvq,structsk_buff_head*inputq)

Deliver multicast messages to all destination sockets

Parameters

structnet*net

the associated network namespace

structsk_buff_head*arrvq

queue with arriving messages, to be cloned after destination lookup

structsk_buff_head*inputq

queue with cloned messages, delivered to socket after dest lookup

Description

Multi-threaded: parallel calls with reference to same queues may occur

voidtipc_sk_conn_proto_rcv(structtipc_sock*tsk,structsk_buff*skb,structsk_buff_head*inputq,structsk_buff_head*xmitq)

receive a connection mng protocol message

Parameters

structtipc_sock*tsk

receiving socket

structsk_buff*skb

pointer to message buffer.

structsk_buff_head*inputq

buffer list containing the buffers

structsk_buff_head*xmitq

output message area

inttipc_sendmsg(structsocket*sock,structmsghdr*m,size_tdsz)

send message in connectionless manner

Parameters

structsocket*sock

socket structure

structmsghdr*m

message to send

size_tdsz

amount of user data to be sent

Description

Message must have an destination specified explicitly.Used for SOCK_RDM and SOCK_DGRAM messages,and for ‘SYN’ messages on SOCK_SEQPACKET and SOCK_STREAM connections.(Note: ‘SYN+’ is prohibited on SOCK_STREAM.)

Return

the number of bytes sent on success, or errno otherwise

inttipc_sendstream(structsocket*sock,structmsghdr*m,size_tdsz)

send stream-oriented data

Parameters

structsocket*sock

socket structure

structmsghdr*m

data to send

size_tdsz

total length of data to be transmitted

Description

Used for SOCK_STREAM data.

Return

the number of bytes sent on success (or partial success),or errno if no data sent

inttipc_send_packet(structsocket*sock,structmsghdr*m,size_tdsz)

send a connection-oriented message

Parameters

structsocket*sock

socket structure

structmsghdr*m

message to send

size_tdsz

length of data to be transmitted

Description

Used for SOCK_SEQPACKET messages.

Return

the number of bytes sent on success, or errno otherwise

voidtipc_sk_set_orig_addr(structmsghdr*m,structsk_buff*skb)

capture sender’s address for received message

Parameters

structmsghdr*m

descriptor for message info

structsk_buff*skb

received message

Note

Address is not captured if not requested by receiver.

inttipc_sk_anc_data_recv(structmsghdr*m,structsk_buff*skb,structtipc_sock*tsk)

optionally capture ancillary data for received message

Parameters

structmsghdr*m

descriptor for message info

structsk_buff*skb

received message buffer

structtipc_sock*tsk

TIPC port associated with message

Note

Ancillary data is not captured if not requested by receiver.

Return

0 if successful, otherwise errno

inttipc_recvmsg(structsocket*sock,structmsghdr*m,size_tbuflen,intflags)

receive packet-oriented message

Parameters

structsocket*sock

network socket

structmsghdr*m

descriptor for message info

size_tbuflen

length of user buffer area

intflags

receive flags

Description

Used for SOCK_DGRAM, SOCK_RDM, and SOCK_SEQPACKET messages.If the complete message doesn’t fit in user area, truncate it.

Return

size of returned message data, errno otherwise

inttipc_recvstream(structsocket*sock,structmsghdr*m,size_tbuflen,intflags)

receive stream-oriented data

Parameters

structsocket*sock

network socket

structmsghdr*m

descriptor for message info

size_tbuflen

total size of user buffer area

intflags

receive flags

Description

Used for SOCK_STREAM messages only. If not enough data is availablewill optionally wait for more; never truncates data.

Return

size of returned message data, errno otherwise

voidtipc_write_space(structsock*sk)

wake up thread if port congestion is released

Parameters

structsock*sk

socket

voidtipc_data_ready(structsock*sk)

wake up threads to indicate messages have been received

Parameters

structsock*sk

socket

booltipc_sk_filter_connect(structtipc_sock*tsk,structsk_buff*skb,structsk_buff_head*xmitq)

check incoming message for a connection-based socket

Parameters

structtipc_sock*tsk

TIPC socket

structsk_buff*skb

pointer to message buffer.

structsk_buff_head*xmitq

for Nagle ACK if any

Return

true if message should be added to receive queue, false otherwise

unsignedintrcvbuf_limit(structsock*sk,structsk_buff*skb)

get proper overload limit of socket receive queue

Parameters

structsock*sk

socket

structsk_buff*skb

message

Description

For connection oriented messages, irrespective of importance,default queue limit is 2 MB.

For connectionless messages, queue limits are based on messageimportance as follows:

TIPC_LOW_IMPORTANCE (2 MB)TIPC_MEDIUM_IMPORTANCE (4 MB)TIPC_HIGH_IMPORTANCE (8 MB)TIPC_CRITICAL_IMPORTANCE (16 MB)

Return

overload limit according to corresponding message importance

voidtipc_sk_filter_rcv(structsock*sk,structsk_buff*skb,structsk_buff_head*xmitq)

validate incoming message

Parameters

structsock*sk

socket

structsk_buff*skb

pointer to message.

structsk_buff_head*xmitq

output message area (FIXME)

Description

Enqueues message on receive queue if acceptable; optionally handlesdisconnect indication for a connected socket.

Called with socket lock already taken

inttipc_sk_backlog_rcv(structsock*sk,structsk_buff*skb)

handle incoming message from backlog queue

Parameters

structsock*sk

socket

structsk_buff*skb

message

Description

Caller must hold socket lock

voidtipc_sk_enqueue(structsk_buff_head*inputq,structsock*sk,u32dport,structsk_buff_head*xmitq)

extract all buffers with destination ‘dport’ from inputq and try adding them to socket or backlog queue

Parameters

structsk_buff_head*inputq

list of incoming buffers with potentially different destinations

structsock*sk

socket where the buffers should be enqueued

u32dport

port number for the socket

structsk_buff_head*xmitq

output queue

Description

Caller must hold socket lock

voidtipc_sk_rcv(structnet*net,structsk_buff_head*inputq)

handle a chain of incoming buffers

Parameters

structnet*net

the associated network namespace

structsk_buff_head*inputq

buffer list containing the buffersConsumes all buffers in list until inputq is empty

Note

may be called in multiple threads referring to the same queue

inttipc_connect(structsocket*sock,structsockaddr_unsized*dest,intdestlen,intflags)

establish a connection to another TIPC port

Parameters

structsocket*sock

socket structure

structsockaddr_unsized*dest

socket address for destination port

intdestlen

size of socket address data structure

intflags

file-related flags associated with socket

Return

0 on success, errno otherwise

inttipc_listen(structsocket*sock,intlen)

allow socket to listen for incoming connections

Parameters

structsocket*sock

socket structure

intlen

(unused)

Return

0 on success, errno otherwise

inttipc_accept(structsocket*sock,structsocket*new_sock,structproto_accept_arg*arg)

wait for connection request

Parameters

structsocket*sock

listening socket

structsocket*new_sock

new socket that is to be connected

structproto_accept_arg*arg

arguments for accept

Return

0 on success, errno otherwise

inttipc_shutdown(structsocket*sock,inthow)

shutdown socket connection

Parameters

structsocket*sock

socket structure

inthow

direction to close (must be SHUT_RDWR)

Description

Terminates connection (if necessary), then purges socket’s receive queue.

Return

0 on success, errno otherwise

inttipc_setsockopt(structsocket*sock,intlvl,intopt,sockptr_tov,unsignedintol)

set socket option

Parameters

structsocket*sock

socket structure

intlvl

option level

intopt

option identifier

sockptr_tov

pointer to new option value

unsignedintol

length of option value

Description

For stream sockets only, accepts and ignores all IPPROTO_TCP options(to ease compatibility).

Return

0 on success, errno otherwise

inttipc_getsockopt(structsocket*sock,intlvl,intopt,char__user*ov,int__user*ol)

get socket option

Parameters

structsocket*sock

socket structure

intlvl

option level

intopt

option identifier

char__user*ov

receptacle for option value

int__user*ol

receptacle for length of option value

Description

For stream sockets only, returns 0 length result for all IPPROTO_TCP options(to ease compatibility).

Return

0 on success, errno otherwise

inttipc_socket_init(void)

initialize TIPC socket interface

Parameters

void

no arguments

Return

0 on success, errno otherwise

voidtipc_socket_stop(void)

stop TIPC socket interface

Parameters

void

no arguments

booltipc_sk_filtering(structsock*sk)

check if a socket should be traced

Parameters

structsock*sk

the socket to be examined

Description

sysctl_tipc_sk_filter is used as the socket tuple for filtering:(portid, sock type, name type, name lower, name upper)

Return

true if the socket meets the socket tuple data(value 0 = ‘any’) or when there is no tuple set (all = 0),otherwise false

booltipc_sk_overlimit1(structsock*sk,structsk_buff*skb)

check if socket rx queue is about to be overloaded, both the rcv and backlog queues are considered

Parameters

structsock*sk

tipc sk to be checked

structsk_buff*skb

tipc msg to be checked

Return

true if the socket rx queue allocation is > 90%, otherwise false

booltipc_sk_overlimit2(structsock*sk,structsk_buff*skb)

check if socket rx queue is about to be overloaded, only the rcv queue is considered

Parameters

structsock*sk

tipc sk to be checked

structsk_buff*skb

tipc msg to be checked

Return

true if the socket rx queue allocation is > 90%, otherwise false

inttipc_sk_dump(structsock*sk,u16dqueues,char*buf)

dump TIPC socket

Parameters

structsock*sk

tipc sk to be dumped

u16dqueues

bitmask to decide if any socket queue to be dumped?- TIPC_DUMP_NONE: don’t dump socket queues- TIPC_DUMP_SK_SNDQ: dump socket send queue- TIPC_DUMP_SK_RCVQ: dump socket rcv queue- TIPC_DUMP_SK_BKLGQ: dump socket backlog queue- TIPC_DUMP_ALL: dump all the socket queues above

char*buf

returned buffer of dump data in format

TIPC Network Topology Interfaces

booltipc_sub_check_overlap(structtipc_service_range*subscribed,structtipc_service_range*found)

test for subscription overlap with the given values

Parameters

structtipc_service_range*subscribed

the service range subscribed for

structtipc_service_range*found

the service range we are checking for match

Description

Returns true if there is overlap, otherwise false.

TIPC Server Interfaces

structtipc_topsrv

TIPC server structure

Definition:

struct tipc_topsrv {    struct idr conn_idr;    spinlock_t idr_lock;    int idr_in_use;    struct net *net;    struct work_struct awork;    struct workqueue_struct *rcv_wq;    struct workqueue_struct *send_wq;    struct socket *listener;    char name[TIPC_SERVER_NAME_LEN];};

Members

conn_idr

identifier set of connection

idr_lock

protect the connection identifier set

idr_in_use

amount of allocated identifier entry

net

network namespace instance

awork

accept work item

rcv_wq

receive workqueue

send_wq

send workqueue

listener

topsrv listener socket

name

server name

structtipc_conn

TIPC connection structure

Definition:

struct tipc_conn {    struct kref kref;    int conid;    struct socket *sock;    unsigned long flags;    struct tipc_topsrv *server;    struct list_head sub_list;    spinlock_t sub_lock;    struct work_struct rwork;    struct list_head outqueue;    spinlock_t outqueue_lock;    struct work_struct swork;};

Members

kref

reference counter to connection object

conid

connection identifier

sock

socket handler associated with connection

flags

indicates connection state

server

pointer to connected server

sub_list

list to all pertaining subscriptions

sub_lock

lock protecting the subscription list

rwork

receive work item

outqueue

pointer to first outbound message in queue

outqueue_lock

control access to the outqueue

swork

send work item

TIPC Trace Interfaces

inttipc_skb_dump(structsk_buff*skb,boolmore,char*buf)

dump TIPC skb data

Parameters

structsk_buff*skb

skb to be dumped

boolmore

dump more?- false: dump only tipc msg data- true: dump kernel-related skb data and tipc cb[] array as well

char*buf

returned buffer of dump data in format

inttipc_list_dump(structsk_buff_head*list,boolmore,char*buf)

dump TIPC skb list/queue

Parameters

structsk_buff_head*list

list of skbs to be dumped

boolmore

dump more?- false: dump only the head & tail skbs- true: dump the first & last 5 skbs

char*buf

returned buffer of dump data in format