Commit c4307285 authored by YOSHIFUJI Hideaki's avatar YOSHIFUJI Hideaki Committed by David S. Miller

[NET] TIPC: Fix whitespace errors.

Signed-off-by: default avatarYOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cca5172a
/* /*
* net/tipc/addr.c: TIPC address utility routines * net/tipc/addr.c: TIPC address utility routines
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2004-2005, Wind River Systems * Copyright (c) 2004-2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -48,10 +48,10 @@ u32 tipc_get_addr(void) ...@@ -48,10 +48,10 @@ u32 tipc_get_addr(void)
/** /**
* tipc_addr_domain_valid - validates a network domain address * tipc_addr_domain_valid - validates a network domain address
* *
* Accepts <Z.C.N>, <Z.C.0>, <Z.0.0>, and <0.0.0>, * Accepts <Z.C.N>, <Z.C.0>, <Z.0.0>, and <0.0.0>,
* where Z, C, and N are non-zero and do not exceed the configured limits. * where Z, C, and N are non-zero and do not exceed the configured limits.
* *
* Returns 1 if domain address is valid, otherwise 0 * Returns 1 if domain address is valid, otherwise 0
*/ */
...@@ -80,10 +80,10 @@ int tipc_addr_domain_valid(u32 addr) ...@@ -80,10 +80,10 @@ int tipc_addr_domain_valid(u32 addr)
/** /**
* tipc_addr_node_valid - validates a proposed network address for this node * tipc_addr_node_valid - validates a proposed network address for this node
* *
* Accepts <Z.C.N>, where Z, C, and N are non-zero and do not exceed * Accepts <Z.C.N>, where Z, C, and N are non-zero and do not exceed
* the configured limits. * the configured limits.
* *
* Returns 1 if address can be used, otherwise 0 * Returns 1 if address can be used, otherwise 0
*/ */
......
/* /*
* net/tipc/addr.h: Include file for TIPC address utility routines * net/tipc/addr.h: Include file for TIPC address utility routines
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2004-2005, Wind River Systems * Copyright (c) 2004-2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -100,8 +100,8 @@ static inline int addr_scope(u32 domain) ...@@ -100,8 +100,8 @@ static inline int addr_scope(u32 domain)
/** /**
* addr_domain - convert 2-bit scope value to equivalent message lookup domain * addr_domain - convert 2-bit scope value to equivalent message lookup domain
* *
* Needed when address of a named message must be looked up a second time * Needed when address of a named message must be looked up a second time
* after a network hop. * after a network hop.
*/ */
......
/* /*
* net/tipc/bcast.c: TIPC broadcast code * net/tipc/bcast.c: TIPC broadcast code
* *
* Copyright (c) 2004-2006, Ericsson AB * Copyright (c) 2004-2006, Ericsson AB
* Copyright (c) 2004, Intel Corporation. * Copyright (c) 2004, Intel Corporation.
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
...@@ -59,15 +59,15 @@ ...@@ -59,15 +59,15 @@
* Loss rate for incoming broadcast frames; used to test retransmission code. * Loss rate for incoming broadcast frames; used to test retransmission code.
* Set to N to cause every N'th frame to be discarded; 0 => don't discard any. * Set to N to cause every N'th frame to be discarded; 0 => don't discard any.
*/ */
#define TIPC_BCAST_LOSS_RATE 0 #define TIPC_BCAST_LOSS_RATE 0
/** /**
* struct bcbearer_pair - a pair of bearers used by broadcast link * struct bcbearer_pair - a pair of bearers used by broadcast link
* @primary: pointer to primary bearer * @primary: pointer to primary bearer
* @secondary: pointer to secondary bearer * @secondary: pointer to secondary bearer
* *
* Bearers must have same priority and same set of reachable destinations * Bearers must have same priority and same set of reachable destinations
* to be paired. * to be paired.
*/ */
...@@ -84,7 +84,7 @@ struct bcbearer_pair { ...@@ -84,7 +84,7 @@ struct bcbearer_pair {
* @bpairs_temp: temporary array of bearer pairs used by tipc_bcbearer_sort() * @bpairs_temp: temporary array of bearer pairs used by tipc_bcbearer_sort()
* @remains: temporary node map used by tipc_bcbearer_send() * @remains: temporary node map used by tipc_bcbearer_send()
* @remains_new: temporary node map used tipc_bcbearer_send() * @remains_new: temporary node map used tipc_bcbearer_send()
* *
* Note: The fields labelled "temporary" are incorporated into the bearer * Note: The fields labelled "temporary" are incorporated into the bearer
* to avoid consuming potentially limited stack space through the use of * to avoid consuming potentially limited stack space through the use of
* large local variables within multicast routines. Concurrent access is * large local variables within multicast routines. Concurrent access is
...@@ -104,7 +104,7 @@ struct bcbearer { ...@@ -104,7 +104,7 @@ struct bcbearer {
* struct bclink - link used for broadcast messages * struct bclink - link used for broadcast messages
* @link: (non-standard) broadcast link structure * @link: (non-standard) broadcast link structure
* @node: (non-standard) node structure representing b'cast link's peer node * @node: (non-standard) node structure representing b'cast link's peer node
* *
* Handles sequence numbering, fragmentation, bundling, etc. * Handles sequence numbering, fragmentation, bundling, etc.
*/ */
...@@ -125,7 +125,7 @@ char tipc_bclink_name[] = "multicast-link"; ...@@ -125,7 +125,7 @@ char tipc_bclink_name[] = "multicast-link";
static u32 buf_seqno(struct sk_buff *buf) static u32 buf_seqno(struct sk_buff *buf)
{ {
return msg_seqno(buf_msg(buf)); return msg_seqno(buf_msg(buf));
} }
static u32 bcbuf_acks(struct sk_buff *buf) static u32 bcbuf_acks(struct sk_buff *buf)
{ {
...@@ -143,9 +143,9 @@ static void bcbuf_decr_acks(struct sk_buff *buf) ...@@ -143,9 +143,9 @@ static void bcbuf_decr_acks(struct sk_buff *buf)
} }
/** /**
* bclink_set_gap - set gap according to contents of current deferred pkt queue * bclink_set_gap - set gap according to contents of current deferred pkt queue
* *
* Called with 'node' locked, bc_lock unlocked * Called with 'node' locked, bc_lock unlocked
*/ */
...@@ -159,14 +159,14 @@ static void bclink_set_gap(struct node *n_ptr) ...@@ -159,14 +159,14 @@ static void bclink_set_gap(struct node *n_ptr)
n_ptr->bclink.gap_to = mod(buf_seqno(buf) - 1); n_ptr->bclink.gap_to = mod(buf_seqno(buf) - 1);
} }
/** /**
* bclink_ack_allowed - test if ACK or NACK message can be sent at this moment * bclink_ack_allowed - test if ACK or NACK message can be sent at this moment
* *
* This mechanism endeavours to prevent all nodes in network from trying * This mechanism endeavours to prevent all nodes in network from trying
* to ACK or NACK at the same time. * to ACK or NACK at the same time.
* *
* Note: TIPC uses a different trigger to distribute ACKs than it does to * Note: TIPC uses a different trigger to distribute ACKs than it does to
* distribute NACKs, but tries to use the same spacing (divide by 16). * distribute NACKs, but tries to use the same spacing (divide by 16).
*/ */
static int bclink_ack_allowed(u32 n) static int bclink_ack_allowed(u32 n)
...@@ -175,11 +175,11 @@ static int bclink_ack_allowed(u32 n) ...@@ -175,11 +175,11 @@ static int bclink_ack_allowed(u32 n)
} }
/** /**
* bclink_retransmit_pkt - retransmit broadcast packets * bclink_retransmit_pkt - retransmit broadcast packets
* @after: sequence number of last packet to *not* retransmit * @after: sequence number of last packet to *not* retransmit
* @to: sequence number of last packet to retransmit * @to: sequence number of last packet to retransmit
* *
* Called with bc_lock locked * Called with bc_lock locked
*/ */
...@@ -189,16 +189,16 @@ static void bclink_retransmit_pkt(u32 after, u32 to) ...@@ -189,16 +189,16 @@ static void bclink_retransmit_pkt(u32 after, u32 to)
buf = bcl->first_out; buf = bcl->first_out;
while (buf && less_eq(buf_seqno(buf), after)) { while (buf && less_eq(buf_seqno(buf), after)) {
buf = buf->next; buf = buf->next;
} }
tipc_link_retransmit(bcl, buf, mod(to - after)); tipc_link_retransmit(bcl, buf, mod(to - after));
} }
/** /**
* tipc_bclink_acknowledge - handle acknowledgement of broadcast packets * tipc_bclink_acknowledge - handle acknowledgement of broadcast packets
* @n_ptr: node that sent acknowledgement info * @n_ptr: node that sent acknowledgement info
* @acked: broadcast sequence # that has been acknowledged * @acked: broadcast sequence # that has been acknowledged
* *
* Node is locked, bc_lock unlocked. * Node is locked, bc_lock unlocked.
*/ */
...@@ -244,9 +244,9 @@ void tipc_bclink_acknowledge(struct node *n_ptr, u32 acked) ...@@ -244,9 +244,9 @@ void tipc_bclink_acknowledge(struct node *n_ptr, u32 acked)
spin_unlock_bh(&bc_lock); spin_unlock_bh(&bc_lock);
} }
/** /**
* bclink_send_ack - unicast an ACK msg * bclink_send_ack - unicast an ACK msg
* *
* tipc_net_lock and node lock set * tipc_net_lock and node lock set
*/ */
...@@ -258,9 +258,9 @@ static void bclink_send_ack(struct node *n_ptr) ...@@ -258,9 +258,9 @@ static void bclink_send_ack(struct node *n_ptr)
tipc_link_send_proto_msg(l_ptr, STATE_MSG, 0, 0, 0, 0, 0); tipc_link_send_proto_msg(l_ptr, STATE_MSG, 0, 0, 0, 0, 0);
} }
/** /**
* bclink_send_nack- broadcast a NACK msg * bclink_send_nack- broadcast a NACK msg
* *
* tipc_net_lock and node lock set * tipc_net_lock and node lock set
*/ */
...@@ -278,7 +278,7 @@ static void bclink_send_nack(struct node *n_ptr) ...@@ -278,7 +278,7 @@ static void bclink_send_nack(struct node *n_ptr)
msg_init(msg, BCAST_PROTOCOL, STATE_MSG, msg_init(msg, BCAST_PROTOCOL, STATE_MSG,
TIPC_OK, INT_H_SIZE, n_ptr->addr); TIPC_OK, INT_H_SIZE, n_ptr->addr);
msg_set_mc_netid(msg, tipc_net_id); msg_set_mc_netid(msg, tipc_net_id);
msg_set_bcast_ack(msg, mod(n_ptr->bclink.last_in)); msg_set_bcast_ack(msg, mod(n_ptr->bclink.last_in));
msg_set_bcgap_after(msg, n_ptr->bclink.gap_after); msg_set_bcgap_after(msg, n_ptr->bclink.gap_after);
msg_set_bcgap_to(msg, n_ptr->bclink.gap_to); msg_set_bcgap_to(msg, n_ptr->bclink.gap_to);
msg_set_bcast_tag(msg, tipc_own_tag); msg_set_bcast_tag(msg, tipc_own_tag);
...@@ -292,17 +292,17 @@ static void bclink_send_nack(struct node *n_ptr) ...@@ -292,17 +292,17 @@ static void bclink_send_nack(struct node *n_ptr)
bcl->stats.bearer_congs++; bcl->stats.bearer_congs++;
} }
/* /*
* Ensure we doesn't send another NACK msg to the node * Ensure we doesn't send another NACK msg to the node
* until 16 more deferred messages arrive from it * until 16 more deferred messages arrive from it
* (i.e. helps prevent all nodes from NACK'ing at same time) * (i.e. helps prevent all nodes from NACK'ing at same time)
*/ */
n_ptr->bclink.nack_sync = tipc_own_tag; n_ptr->bclink.nack_sync = tipc_own_tag;
} }
} }
/** /**
* tipc_bclink_check_gap - send a NACK if a sequence gap exists * tipc_bclink_check_gap - send a NACK if a sequence gap exists
* *
* tipc_net_lock and node lock set * tipc_net_lock and node lock set
...@@ -320,9 +320,9 @@ void tipc_bclink_check_gap(struct node *n_ptr, u32 last_sent) ...@@ -320,9 +320,9 @@ void tipc_bclink_check_gap(struct node *n_ptr, u32 last_sent)
bclink_send_nack(n_ptr); bclink_send_nack(n_ptr);
} }
/** /**
* tipc_bclink_peek_nack - process a NACK msg meant for another node * tipc_bclink_peek_nack - process a NACK msg meant for another node
* *
* Only tipc_net_lock set. * Only tipc_net_lock set.
*/ */
...@@ -349,7 +349,7 @@ static void tipc_bclink_peek_nack(u32 dest, u32 sender_tag, u32 gap_after, u32 g ...@@ -349,7 +349,7 @@ static void tipc_bclink_peek_nack(u32 dest, u32 sender_tag, u32 gap_after, u32 g
if (less_eq(my_to, gap_to)) if (less_eq(my_to, gap_to))
n_ptr->bclink.gap_to = gap_after; n_ptr->bclink.gap_to = gap_after;
} else { } else {
/* /*
* Expand gap if missing bufs not in deferred queue: * Expand gap if missing bufs not in deferred queue:
*/ */
struct sk_buff *buf = n_ptr->bclink.deferred_head; struct sk_buff *buf = n_ptr->bclink.deferred_head;
...@@ -371,7 +371,7 @@ static void tipc_bclink_peek_nack(u32 dest, u32 sender_tag, u32 gap_after, u32 g ...@@ -371,7 +371,7 @@ static void tipc_bclink_peek_nack(u32 dest, u32 sender_tag, u32 gap_after, u32 g
} }
/* /*
* Some nodes may send a complementary NACK now: * Some nodes may send a complementary NACK now:
*/ */
if (bclink_ack_allowed(sender_tag + 1)) { if (bclink_ack_allowed(sender_tag + 1)) {
if (n_ptr->bclink.gap_to != n_ptr->bclink.gap_after) { if (n_ptr->bclink.gap_to != n_ptr->bclink.gap_after) {
bclink_send_nack(n_ptr); bclink_send_nack(n_ptr);
...@@ -408,7 +408,7 @@ int tipc_bclink_send_msg(struct sk_buff *buf) ...@@ -408,7 +408,7 @@ int tipc_bclink_send_msg(struct sk_buff *buf)
/** /**
* tipc_bclink_recv_pkt - receive a broadcast packet, and deliver upwards * tipc_bclink_recv_pkt - receive a broadcast packet, and deliver upwards
* *
* tipc_net_lock is read_locked, no other locks set * tipc_net_lock is read_locked, no other locks set
*/ */
...@@ -425,7 +425,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) ...@@ -425,7 +425,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf)
msg_dbg(msg, "<BC<<<"); msg_dbg(msg, "<BC<<<");
if (unlikely(!node || !tipc_node_is_up(node) || !node->bclink.supported || if (unlikely(!node || !tipc_node_is_up(node) || !node->bclink.supported ||
(msg_mc_netid(msg) != tipc_net_id))) { (msg_mc_netid(msg) != tipc_net_id))) {
buf_discard(buf); buf_discard(buf);
return; return;
...@@ -443,7 +443,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) ...@@ -443,7 +443,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf)
bclink_retransmit_pkt(msg_bcgap_after(msg), bclink_retransmit_pkt(msg_bcgap_after(msg),
msg_bcgap_to(msg)); msg_bcgap_to(msg));
bcl->owner->next = NULL; bcl->owner->next = NULL;
spin_unlock_bh(&bc_lock); spin_unlock_bh(&bc_lock);
} else { } else {
tipc_bclink_peek_nack(msg_destnode(msg), tipc_bclink_peek_nack(msg_destnode(msg),
msg_bcast_tag(msg), msg_bcast_tag(msg),
...@@ -547,10 +547,10 @@ u32 tipc_bclink_acks_missing(struct node *n_ptr) ...@@ -547,10 +547,10 @@ u32 tipc_bclink_acks_missing(struct node *n_ptr)
/** /**
* tipc_bcbearer_send - send a packet through the broadcast pseudo-bearer * tipc_bcbearer_send - send a packet through the broadcast pseudo-bearer
* *
* Send through as many bearers as necessary to reach all nodes * Send through as many bearers as necessary to reach all nodes
* that support TIPC multicasting. * that support TIPC multicasting.
* *
* Returns 0 if packet sent successfully, non-zero if not * Returns 0 if packet sent successfully, non-zero if not
*/ */
...@@ -581,7 +581,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf, ...@@ -581,7 +581,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
send_count = 0; send_count = 0;
/* Send buffer over bearers until all targets reached */ /* Send buffer over bearers until all targets reached */
bcbearer->remains = tipc_cltr_bcast_nodes; bcbearer->remains = tipc_cltr_bcast_nodes;
for (bp_index = 0; bp_index < MAX_BEARERS; bp_index++) { for (bp_index = 0; bp_index < MAX_BEARERS; bp_index++) {
...@@ -615,7 +615,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf, ...@@ -615,7 +615,7 @@ static int tipc_bcbearer_send(struct sk_buff *buf,
bcbearer->remains = bcbearer->remains_new; bcbearer->remains = bcbearer->remains_new;
} }
/* Unable to reach all targets */ /* Unable to reach all targets */
bcbearer->bearer.publ.blocked = 1; bcbearer->bearer.publ.blocked = 1;
...@@ -682,7 +682,7 @@ void tipc_bcbearer_sort(void) ...@@ -682,7 +682,7 @@ void tipc_bcbearer_sort(void)
/** /**
* tipc_bcbearer_push - resolve bearer congestion * tipc_bcbearer_push - resolve bearer congestion
* *
* Forces bclink to push out any unsent packets, until all packets are gone * Forces bclink to push out any unsent packets, until all packets are gone
* or congestion reoccurs. * or congestion reoccurs.
* No locks set when function called * No locks set when function called
...@@ -714,27 +714,27 @@ int tipc_bclink_stats(char *buf, const u32 buf_size) ...@@ -714,27 +714,27 @@ int tipc_bclink_stats(char *buf, const u32 buf_size)
spin_lock_bh(&bc_lock); spin_lock_bh(&bc_lock);
tipc_printf(&pb, "Link <%s>\n" tipc_printf(&pb, "Link <%s>\n"
" Window:%u packets\n", " Window:%u packets\n",
bcl->name, bcl->queue_limit[0]); bcl->name, bcl->queue_limit[0]);
tipc_printf(&pb, " RX packets:%u fragments:%u/%u bundles:%u/%u\n", tipc_printf(&pb, " RX packets:%u fragments:%u/%u bundles:%u/%u\n",
bcl->stats.recv_info, bcl->stats.recv_info,
bcl->stats.recv_fragments, bcl->stats.recv_fragments,
bcl->stats.recv_fragmented, bcl->stats.recv_fragmented,
bcl->stats.recv_bundles, bcl->stats.recv_bundles,
bcl->stats.recv_bundled); bcl->stats.recv_bundled);
tipc_printf(&pb, " TX packets:%u fragments:%u/%u bundles:%u/%u\n", tipc_printf(&pb, " TX packets:%u fragments:%u/%u bundles:%u/%u\n",
bcl->stats.sent_info, bcl->stats.sent_info,
bcl->stats.sent_fragments, bcl->stats.sent_fragments,
bcl->stats.sent_fragmented, bcl->stats.sent_fragmented,
bcl->stats.sent_bundles, bcl->stats.sent_bundles,
bcl->stats.sent_bundled); bcl->stats.sent_bundled);
tipc_printf(&pb, " RX naks:%u defs:%u dups:%u\n", tipc_printf(&pb, " RX naks:%u defs:%u dups:%u\n",
bcl->stats.recv_nacks, bcl->stats.recv_nacks,
bcl->stats.deferred_recv, bcl->stats.deferred_recv,
bcl->stats.duplicates); bcl->stats.duplicates);
tipc_printf(&pb, " TX naks:%u acks:%u dups:%u\n", tipc_printf(&pb, " TX naks:%u acks:%u dups:%u\n",
bcl->stats.sent_nacks, bcl->stats.sent_nacks,
bcl->stats.sent_acks, bcl->stats.sent_acks,
bcl->stats.retransmitted); bcl->stats.retransmitted);
tipc_printf(&pb, " Congestion bearer:%u link:%u Send queue max:%u avg:%u\n", tipc_printf(&pb, " Congestion bearer:%u link:%u Send queue max:%u avg:%u\n",
bcl->stats.bearer_congs, bcl->stats.bearer_congs,
...@@ -778,7 +778,7 @@ int tipc_bclink_init(void) ...@@ -778,7 +778,7 @@ int tipc_bclink_init(void)
bclink = kzalloc(sizeof(*bclink), GFP_ATOMIC); bclink = kzalloc(sizeof(*bclink), GFP_ATOMIC);
if (!bcbearer || !bclink) { if (!bcbearer || !bclink) {
nomem: nomem:
warn("Multicast link creation failed, no memory\n"); warn("Multicast link creation failed, no memory\n");
kfree(bcbearer); kfree(bcbearer);
bcbearer = NULL; bcbearer = NULL;
kfree(bclink); kfree(bclink);
...@@ -796,7 +796,7 @@ int tipc_bclink_init(void) ...@@ -796,7 +796,7 @@ int tipc_bclink_init(void)
bcl->next_out_no = 1; bcl->next_out_no = 1;
spin_lock_init(&bclink->node.lock); spin_lock_init(&bclink->node.lock);
bcl->owner = &bclink->node; bcl->owner = &bclink->node;
bcl->max_pkt = MAX_PKT_DEFAULT_MCAST; bcl->max_pkt = MAX_PKT_DEFAULT_MCAST;
tipc_link_set_queue_limits(bcl, BCLINK_WIN_DEFAULT); tipc_link_set_queue_limits(bcl, BCLINK_WIN_DEFAULT);
bcl->b_ptr = &bcbearer->bearer; bcl->b_ptr = &bcbearer->bearer;
bcl->state = WORKING_WORKING; bcl->state = WORKING_WORKING;
......
/* /*
* net/tipc/bcast.h: Include file for TIPC broadcast code * net/tipc/bcast.h: Include file for TIPC broadcast code
* *
* Copyright (c) 2003-2006, Ericsson AB * Copyright (c) 2003-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -102,7 +102,7 @@ static inline void tipc_nmap_add(struct node_map *nm_ptr, u32 node) ...@@ -102,7 +102,7 @@ static inline void tipc_nmap_add(struct node_map *nm_ptr, u32 node)
} }
} }
/** /**
* nmap_remove - remove a node from a node map * nmap_remove - remove a node from a node map
*/ */
...@@ -190,7 +190,7 @@ static inline void tipc_port_list_add(struct port_list *pl_ptr, u32 port) ...@@ -190,7 +190,7 @@ static inline void tipc_port_list_add(struct port_list *pl_ptr, u32 port)
/** /**
* port_list_free - free dynamically created entries in port_list chain * port_list_free - free dynamically created entries in port_list chain
* *
* Note: First item is on stack, so it doesn't need to be released * Note: First item is on stack, so it doesn't need to be released
*/ */
......
/* /*
* net/tipc/bearer.c: TIPC bearer code * net/tipc/bearer.c: TIPC bearer code
* *
* Copyright (c) 1996-2006, Ericsson AB * Copyright (c) 1996-2006, Ericsson AB
* Copyright (c) 2004-2006, Wind River Systems * Copyright (c) 2004-2006, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -52,7 +52,7 @@ struct bearer *tipc_bearers = NULL; ...@@ -52,7 +52,7 @@ struct bearer *tipc_bearers = NULL;
/** /**
* media_name_valid - validate media name * media_name_valid - validate media name
* *
* Returns 1 if media name is valid, otherwise 0. * Returns 1 if media name is valid, otherwise 0.
*/ */
...@@ -84,17 +84,17 @@ static struct media *media_find(const char *name) ...@@ -84,17 +84,17 @@ static struct media *media_find(const char *name)
/** /**
* tipc_register_media - register a media type * tipc_register_media - register a media type
* *
* Bearers for this media type must be activated separately at a later stage. * Bearers for this media type must be activated separately at a later stage.
*/ */
int tipc_register_media(u32 media_type, int tipc_register_media(u32 media_type,
char *name, char *name,
int (*enable)(struct tipc_bearer *), int (*enable)(struct tipc_bearer *),
void (*disable)(struct tipc_bearer *), void (*disable)(struct tipc_bearer *),
int (*send_msg)(struct sk_buff *, int (*send_msg)(struct sk_buff *,
struct tipc_bearer *, struct tipc_bearer *,
struct tipc_media_addr *), struct tipc_media_addr *),
char *(*addr2str)(struct tipc_media_addr *a, char *(*addr2str)(struct tipc_media_addr *a,
char *str_buf, int str_size), char *str_buf, int str_size),
struct tipc_media_addr *bcast_addr, struct tipc_media_addr *bcast_addr,
...@@ -121,11 +121,11 @@ int tipc_register_media(u32 media_type, ...@@ -121,11 +121,11 @@ int tipc_register_media(u32 media_type,
} }
if ((bearer_priority < TIPC_MIN_LINK_PRI) && if ((bearer_priority < TIPC_MIN_LINK_PRI) &&
(bearer_priority > TIPC_MAX_LINK_PRI)) { (bearer_priority > TIPC_MAX_LINK_PRI)) {
warn("Media <%s> rejected, illegal priority (%u)\n", name, warn("Media <%s> rejected, illegal priority (%u)\n", name,
bearer_priority); bearer_priority);
goto exit; goto exit;
} }
if ((link_tolerance < TIPC_MIN_LINK_TOL) || if ((link_tolerance < TIPC_MIN_LINK_TOL) ||
(link_tolerance > TIPC_MAX_LINK_TOL)) { (link_tolerance > TIPC_MAX_LINK_TOL)) {
warn("Media <%s> rejected, illegal tolerance (%u)\n", name, warn("Media <%s> rejected, illegal tolerance (%u)\n", name,
link_tolerance); link_tolerance);
...@@ -219,7 +219,7 @@ struct sk_buff *tipc_media_get_names(void) ...@@ -219,7 +219,7 @@ struct sk_buff *tipc_media_get_names(void)
read_lock_bh(&tipc_net_lock); read_lock_bh(&tipc_net_lock);
for (i = 0, m_ptr = media_list; i < media_count; i++, m_ptr++) { for (i = 0, m_ptr = media_list; i < media_count; i++, m_ptr++) {
tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME, m_ptr->name, tipc_cfg_append_tlv(buf, TIPC_TLV_MEDIA_NAME, m_ptr->name,
strlen(m_ptr->name) + 1); strlen(m_ptr->name) + 1);
} }
read_unlock_bh(&tipc_net_lock); read_unlock_bh(&tipc_net_lock);
...@@ -230,11 +230,11 @@ struct sk_buff *tipc_media_get_names(void) ...@@ -230,11 +230,11 @@ struct sk_buff *tipc_media_get_names(void)
* bearer_name_validate - validate & (optionally) deconstruct bearer name * bearer_name_validate - validate & (optionally) deconstruct bearer name
* @name - ptr to bearer name string * @name - ptr to bearer name string
* @name_parts - ptr to area for bearer name components (or NULL if not needed) * @name_parts - ptr to area for bearer name components (or NULL if not needed)
* *
* Returns 1 if bearer name is valid, otherwise 0. * Returns 1 if bearer name is valid, otherwise 0.
*/ */
static int bearer_name_validate(const char *name, static int bearer_name_validate(const char *name,
struct bearer_name *name_parts) struct bearer_name *name_parts)
{ {
char name_copy[TIPC_MAX_BEARER_NAME]; char name_copy[TIPC_MAX_BEARER_NAME];
...@@ -262,8 +262,8 @@ static int bearer_name_validate(const char *name, ...@@ -262,8 +262,8 @@ static int bearer_name_validate(const char *name,
/* validate component parts of bearer name */ /* validate component parts of bearer name */
if ((media_len <= 1) || (media_len > TIPC_MAX_MEDIA_NAME) || if ((media_len <= 1) || (media_len > TIPC_MAX_MEDIA_NAME) ||
(if_len <= 1) || (if_len > TIPC_MAX_IF_NAME) || (if_len <= 1) || (if_len > TIPC_MAX_IF_NAME) ||
(strspn(media_name, tipc_alphabet) != (media_len - 1)) || (strspn(media_name, tipc_alphabet) != (media_len - 1)) ||
(strspn(if_name, tipc_alphabet) != (if_len - 1))) (strspn(if_name, tipc_alphabet) != (if_len - 1)))
return 0; return 0;
...@@ -336,8 +336,8 @@ struct sk_buff *tipc_bearer_get_names(void) ...@@ -336,8 +336,8 @@ struct sk_buff *tipc_bearer_get_names(void)
for (j = 0; j < MAX_BEARERS; j++) { for (j = 0; j < MAX_BEARERS; j++) {
b_ptr = &tipc_bearers[j]; b_ptr = &tipc_bearers[j];
if (b_ptr->active && (b_ptr->media == m_ptr)) { if (b_ptr->active && (b_ptr->media == m_ptr)) {
tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME, tipc_cfg_append_tlv(buf, TIPC_TLV_BEARER_NAME,
b_ptr->publ.name, b_ptr->publ.name,
strlen(b_ptr->publ.name) + 1); strlen(b_ptr->publ.name) + 1);
} }
} }
...@@ -401,8 +401,8 @@ void tipc_bearer_lock_push(struct bearer *b_ptr) ...@@ -401,8 +401,8 @@ void tipc_bearer_lock_push(struct bearer *b_ptr)
/* /*
* Interrupt enabling new requests after bearer congestion or blocking: * Interrupt enabling new requests after bearer congestion or blocking:
* See bearer_send(). * See bearer_send().
*/ */
void tipc_continue(struct tipc_bearer *tb_ptr) void tipc_continue(struct tipc_bearer *tb_ptr)
{ {
...@@ -417,9 +417,9 @@ void tipc_continue(struct tipc_bearer *tb_ptr) ...@@ -417,9 +417,9 @@ void tipc_continue(struct tipc_bearer *tb_ptr)
} }
/* /*
* Schedule link for sending of messages after the bearer * Schedule link for sending of messages after the bearer
* has been deblocked by 'continue()'. This method is called * has been deblocked by 'continue()'. This method is called
* when somebody tries to send a message via this link while * when somebody tries to send a message via this link while
* the bearer is congested. 'tipc_net_lock' is in read_lock here * the bearer is congested. 'tipc_net_lock' is in read_lock here
* bearer.lock is busy * bearer.lock is busy
*/ */
...@@ -430,9 +430,9 @@ static void tipc_bearer_schedule_unlocked(struct bearer *b_ptr, struct link *l_p ...@@ -430,9 +430,9 @@ static void tipc_bearer_schedule_unlocked(struct bearer *b_ptr, struct link *l_p
} }
/* /*
* Schedule link for sending of messages after the bearer * Schedule link for sending of messages after the bearer
* has been deblocked by 'continue()'. This method is called * has been deblocked by 'continue()'. This method is called
* when somebody tries to send a message via this link while * when somebody tries to send a message via this link while
* the bearer is congested. 'tipc_net_lock' is in read_lock here, * the bearer is congested. 'tipc_net_lock' is in read_lock here,
* bearer.lock is free * bearer.lock is free
*/ */
...@@ -468,7 +468,7 @@ int tipc_bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr) ...@@ -468,7 +468,7 @@ int tipc_bearer_resolve_congestion(struct bearer *b_ptr, struct link *l_ptr)
/** /**
* tipc_enable_bearer - enable bearer with the given name * tipc_enable_bearer - enable bearer with the given name
*/ */
int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority) int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
{ {
...@@ -490,7 +490,7 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority) ...@@ -490,7 +490,7 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
warn("Bearer <%s> rejected, illegal name\n", name); warn("Bearer <%s> rejected, illegal name\n", name);
return -EINVAL; return -EINVAL;
} }
if (!tipc_addr_domain_valid(bcast_scope) || if (!tipc_addr_domain_valid(bcast_scope) ||
!in_scope(bcast_scope, tipc_own_addr)) { !in_scope(bcast_scope, tipc_own_addr)) {
warn("Bearer <%s> rejected, illegal broadcast scope\n", name); warn("Bearer <%s> rejected, illegal broadcast scope\n", name);
return -EINVAL; return -EINVAL;
...@@ -539,7 +539,7 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority) ...@@ -539,7 +539,7 @@ int tipc_enable_bearer(const char *name, u32 bcast_scope, u32 priority)
} }
} }
if (bearer_id >= MAX_BEARERS) { if (bearer_id >= MAX_BEARERS) {
warn("Bearer <%s> rejected, bearer limit reached (%u)\n", warn("Bearer <%s> rejected, bearer limit reached (%u)\n",
name, MAX_BEARERS); name, MAX_BEARERS);
goto failed; goto failed;
} }
...@@ -612,7 +612,7 @@ int tipc_block_bearer(const char *name) ...@@ -612,7 +612,7 @@ int tipc_block_bearer(const char *name)
/** /**
* bearer_disable - * bearer_disable -
* *
* Note: This routine assumes caller holds tipc_net_lock. * Note: This routine assumes caller holds tipc_net_lock.
*/ */
......
/* /*
* net/tipc/bearer.h: Include file for TIPC bearer code * net/tipc/bearer.h: Include file for TIPC bearer code
* *
* Copyright (c) 1996-2006, Ericsson AB * Copyright (c) 1996-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -58,14 +58,14 @@ ...@@ -58,14 +58,14 @@
* @type_id: TIPC media identifier [defined in tipc_bearer.h] * @type_id: TIPC media identifier [defined in tipc_bearer.h]
* @name: media name * @name: media name
*/ */
struct media { struct media {
int (*send_msg)(struct sk_buff *buf, int (*send_msg)(struct sk_buff *buf,
struct tipc_bearer *b_ptr, struct tipc_bearer *b_ptr,
struct tipc_media_addr *dest); struct tipc_media_addr *dest);
int (*enable_bearer)(struct tipc_bearer *b_ptr); int (*enable_bearer)(struct tipc_bearer *b_ptr);
void (*disable_bearer)(struct tipc_bearer *b_ptr); void (*disable_bearer)(struct tipc_bearer *b_ptr);
char *(*addr2str)(struct tipc_media_addr *a, char *(*addr2str)(struct tipc_media_addr *a,
char *str_buf, int str_size); char *str_buf, int str_size);
struct tipc_media_addr bcast_addr; struct tipc_media_addr bcast_addr;
int bcast; int bcast;
...@@ -91,7 +91,7 @@ struct media { ...@@ -91,7 +91,7 @@ struct media {
* @net_plane: network plane ('A' through 'H') currently associated with bearer * @net_plane: network plane ('A' through 'H') currently associated with bearer
* @nodes: indicates which nodes in cluster can be reached through bearer * @nodes: indicates which nodes in cluster can be reached through bearer
*/ */
struct bearer { struct bearer {
struct tipc_bearer publ; struct tipc_bearer publ;
struct media *media; struct media *media;
...@@ -131,21 +131,21 @@ void tipc_bearer_lock_push(struct bearer *b_ptr); ...@@ -131,21 +131,21 @@ void tipc_bearer_lock_push(struct bearer *b_ptr);
/** /**
* tipc_bearer_send- sends buffer to destination over bearer * tipc_bearer_send- sends buffer to destination over bearer
* *
* Returns true (1) if successful, or false (0) if unable to send * Returns true (1) if successful, or false (0) if unable to send
* *
* IMPORTANT: * IMPORTANT:
* The media send routine must not alter the buffer being passed in * The media send routine must not alter the buffer being passed in
* as it may be needed for later retransmission! * as it may be needed for later retransmission!
* *
* If the media send routine returns a non-zero value (indicating that * If the media send routine returns a non-zero value (indicating that
* it was unable to send the buffer), it must: * it was unable to send the buffer), it must:
* 1) mark the bearer as blocked, * 1) mark the bearer as blocked,
* 2) call tipc_continue() once the bearer is able to send again. * 2) call tipc_continue() once the bearer is able to send again.
* Media types that are unable to meet these two critera must ensure their * Media types that are unable to meet these two critera must ensure their
* send routine always returns success -- even if the buffer was not sent -- * send routine always returns success -- even if the buffer was not sent --
* and let TIPC's link code deal with the undelivered message. * and let TIPC's link code deal with the undelivered message.
*/ */
static inline int tipc_bearer_send(struct bearer *b_ptr, struct sk_buff *buf, static inline int tipc_bearer_send(struct bearer *b_ptr, struct sk_buff *buf,
......
/* /*
* net/tipc/cluster.c: TIPC cluster management routines * net/tipc/cluster.c: TIPC cluster management routines
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -56,7 +56,7 @@ struct cluster *tipc_cltr_create(u32 addr) ...@@ -56,7 +56,7 @@ struct cluster *tipc_cltr_create(u32 addr)
{ {
struct _zone *z_ptr; struct _zone *z_ptr;
struct cluster *c_ptr; struct cluster *c_ptr;
int max_nodes; int max_nodes;
c_ptr = kzalloc(sizeof(*c_ptr), GFP_ATOMIC); c_ptr = kzalloc(sizeof(*c_ptr), GFP_ATOMIC);
if (c_ptr == NULL) { if (c_ptr == NULL) {
...@@ -81,7 +81,7 @@ struct cluster *tipc_cltr_create(u32 addr) ...@@ -81,7 +81,7 @@ struct cluster *tipc_cltr_create(u32 addr)
tipc_local_nodes = c_ptr->nodes; tipc_local_nodes = c_ptr->nodes;
c_ptr->highest_slave = LOWEST_SLAVE - 1; c_ptr->highest_slave = LOWEST_SLAVE - 1;
c_ptr->highest_node = 0; c_ptr->highest_node = 0;
z_ptr = tipc_zone_find(tipc_zone(addr)); z_ptr = tipc_zone_find(tipc_zone(addr));
if (!z_ptr) { if (!z_ptr) {
z_ptr = tipc_zone_create(addr); z_ptr = tipc_zone_create(addr);
...@@ -150,7 +150,7 @@ void tipc_cltr_attach_node(struct cluster *c_ptr, struct node *n_ptr) ...@@ -150,7 +150,7 @@ void tipc_cltr_attach_node(struct cluster *c_ptr, struct node *n_ptr)
/** /**
* tipc_cltr_select_router - select router to a cluster * tipc_cltr_select_router - select router to a cluster
* *
* Uses deterministic and fair algorithm. * Uses deterministic and fair algorithm.
*/ */
...@@ -192,7 +192,7 @@ u32 tipc_cltr_select_router(struct cluster *c_ptr, u32 ref) ...@@ -192,7 +192,7 @@ u32 tipc_cltr_select_router(struct cluster *c_ptr, u32 ref)
/** /**
* tipc_cltr_select_node - select destination node within a remote cluster * tipc_cltr_select_node - select destination node within a remote cluster
* *
* Uses deterministic and fair algorithm. * Uses deterministic and fair algorithm.
*/ */
...@@ -295,7 +295,7 @@ void tipc_cltr_send_slave_routes(struct cluster *c_ptr, u32 dest) ...@@ -295,7 +295,7 @@ void tipc_cltr_send_slave_routes(struct cluster *c_ptr, u32 dest)
msg_set_remote_node(msg, c_ptr->addr); msg_set_remote_node(msg, c_ptr->addr);
msg_set_type(msg, SLAVE_ROUTING_TABLE); msg_set_type(msg, SLAVE_ROUTING_TABLE);
for (n_num = LOWEST_SLAVE; n_num <= highest; n_num++) { for (n_num = LOWEST_SLAVE; n_num <= highest; n_num++) {
if (c_ptr->nodes[n_num] && if (c_ptr->nodes[n_num] &&
tipc_node_has_active_links(c_ptr->nodes[n_num])) { tipc_node_has_active_links(c_ptr->nodes[n_num])) {
send = 1; send = 1;
msg_set_dataoctet(msg, n_num); msg_set_dataoctet(msg, n_num);
...@@ -329,7 +329,7 @@ void tipc_cltr_send_ext_routes(struct cluster *c_ptr, u32 dest) ...@@ -329,7 +329,7 @@ void tipc_cltr_send_ext_routes(struct cluster *c_ptr, u32 dest)
msg_set_remote_node(msg, c_ptr->addr); msg_set_remote_node(msg, c_ptr->addr);
msg_set_type(msg, EXT_ROUTING_TABLE); msg_set_type(msg, EXT_ROUTING_TABLE);
for (n_num = 1; n_num <= highest; n_num++) { for (n_num = 1; n_num <= highest; n_num++) {
if (c_ptr->nodes[n_num] && if (c_ptr->nodes[n_num] &&
tipc_node_has_active_links(c_ptr->nodes[n_num])) { tipc_node_has_active_links(c_ptr->nodes[n_num])) {
send = 1; send = 1;
msg_set_dataoctet(msg, n_num); msg_set_dataoctet(msg, n_num);
...@@ -360,7 +360,7 @@ void tipc_cltr_send_local_routes(struct cluster *c_ptr, u32 dest) ...@@ -360,7 +360,7 @@ void tipc_cltr_send_local_routes(struct cluster *c_ptr, u32 dest)
msg_set_remote_node(msg, c_ptr->addr); msg_set_remote_node(msg, c_ptr->addr);
msg_set_type(msg, LOCAL_ROUTING_TABLE); msg_set_type(msg, LOCAL_ROUTING_TABLE);
for (n_num = 1; n_num <= highest; n_num++) { for (n_num = 1; n_num <= highest; n_num++) {
if (c_ptr->nodes[n_num] && if (c_ptr->nodes[n_num] &&
tipc_node_has_active_links(c_ptr->nodes[n_num])) { tipc_node_has_active_links(c_ptr->nodes[n_num])) {
send = 1; send = 1;
msg_set_dataoctet(msg, n_num); msg_set_dataoctet(msg, n_num);
...@@ -492,7 +492,7 @@ void tipc_cltr_remove_as_router(struct cluster *c_ptr, u32 router) ...@@ -492,7 +492,7 @@ void tipc_cltr_remove_as_router(struct cluster *c_ptr, u32 router)
} }
/** /**
* tipc_cltr_multicast - multicast message to local nodes * tipc_cltr_multicast - multicast message to local nodes
*/ */
static void tipc_cltr_multicast(struct cluster *c_ptr, struct sk_buff *buf, static void tipc_cltr_multicast(struct cluster *c_ptr, struct sk_buff *buf,
...@@ -554,9 +554,9 @@ void tipc_cltr_broadcast(struct sk_buff *buf) ...@@ -554,9 +554,9 @@ void tipc_cltr_broadcast(struct sk_buff *buf)
buf_copy = skb_copy(buf, GFP_ATOMIC); buf_copy = skb_copy(buf, GFP_ATOMIC);
if (buf_copy == NULL) if (buf_copy == NULL)
goto exit; goto exit;
msg_set_destnode(buf_msg(buf_copy), msg_set_destnode(buf_msg(buf_copy),
n_ptr->addr); n_ptr->addr);
tipc_link_send(buf_copy, n_ptr->addr, tipc_link_send(buf_copy, n_ptr->addr,
n_ptr->addr); n_ptr->addr);
} }
} }
......
/* /*
* net/tipc/cluster.h: Include file for TIPC cluster management routines * net/tipc/cluster.h: Include file for TIPC cluster management routines
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
* @highest_node: id of highest numbered node within cluster * @highest_node: id of highest numbered node within cluster
* @highest_slave: (used for secondary node support) * @highest_slave: (used for secondary node support)
*/ */
struct cluster { struct cluster {
u32 addr; u32 addr;
struct _zone *owner; struct _zone *owner;
......
/* /*
* net/tipc/config.c: TIPC configuration management code * net/tipc/config.c: TIPC configuration management code
* *
* Copyright (c) 2002-2006, Ericsson AB * Copyright (c) 2002-2006, Ericsson AB
* Copyright (c) 2004-2006, Wind River Systems * Copyright (c) 2004-2006, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -86,7 +86,7 @@ struct sk_buff *tipc_cfg_reply_alloc(int payload_size) ...@@ -86,7 +86,7 @@ struct sk_buff *tipc_cfg_reply_alloc(int payload_size)
return buf; return buf;
} }
int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type, int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type,
void *tlv_data, int tlv_data_size) void *tlv_data, int tlv_data_size)
{ {
struct tlv_desc *tlv = (struct tlv_desc *)buf->tail; struct tlv_desc *tlv = (struct tlv_desc *)buf->tail;
...@@ -112,7 +112,7 @@ struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value) ...@@ -112,7 +112,7 @@ struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value)
buf = tipc_cfg_reply_alloc(TLV_SPACE(sizeof(value))); buf = tipc_cfg_reply_alloc(TLV_SPACE(sizeof(value)));
if (buf) { if (buf) {
value_net = htonl(value); value_net = htonl(value);
tipc_cfg_append_tlv(buf, tlv_type, &value_net, tipc_cfg_append_tlv(buf, tlv_type, &value_net,
sizeof(value_net)); sizeof(value_net));
} }
return buf; return buf;
...@@ -182,7 +182,7 @@ int tipc_cfg_cmd(const struct tipc_cmd_msg * msg, ...@@ -182,7 +182,7 @@ int tipc_cfg_cmd(const struct tipc_cmd_msg * msg,
static void cfg_cmd_event(struct tipc_cmd_msg *msg, static void cfg_cmd_event(struct tipc_cmd_msg *msg,
char *data, char *data,
u32 sz, u32 sz,
struct tipc_portid const *orig) struct tipc_portid const *orig)
{ {
int rv = -EINVAL; int rv = -EINVAL;
...@@ -192,7 +192,7 @@ static void cfg_cmd_event(struct tipc_cmd_msg *msg, ...@@ -192,7 +192,7 @@ static void cfg_cmd_event(struct tipc_cmd_msg *msg,
msg->cmd = ntohl(msg->cmd); msg->cmd = ntohl(msg->cmd);
cfg_prepare_res_msg(msg->cmd, msg->usr_handle, rv, &rmsg, msg_sect, cfg_prepare_res_msg(msg->cmd, msg->usr_handle, rv, &rmsg, msg_sect,
data, 0); data, 0);
if (ntohl(msg->magic) != TIPC_MAGIC) if (ntohl(msg->magic) != TIPC_MAGIC)
goto exit; goto exit;
...@@ -295,7 +295,7 @@ static struct sk_buff *cfg_set_own_addr(void) ...@@ -295,7 +295,7 @@ static struct sk_buff *cfg_set_own_addr(void)
" (cannot change node address once assigned)"); " (cannot change node address once assigned)");
tipc_own_addr = addr; tipc_own_addr = addr;
/* /*
* Must release all spinlocks before calling start_net() because * Must release all spinlocks before calling start_net() because
* Linux version of TIPC calls eth_media_start() which calls * Linux version of TIPC calls eth_media_start() which calls
* register_netdevice_notifier() which may block! * register_netdevice_notifier() which may block!
...@@ -619,7 +619,7 @@ static void cfg_named_msg_event(void *userdata, ...@@ -619,7 +619,7 @@ static void cfg_named_msg_event(void *userdata,
struct sk_buff **buf, struct sk_buff **buf,
const unchar *msg, const unchar *msg,
u32 size, u32 size,
u32 importance, u32 importance,
struct tipc_portid const *orig, struct tipc_portid const *orig,
struct tipc_name_seq const *dest) struct tipc_name_seq const *dest)
{ {
...@@ -640,7 +640,7 @@ static void cfg_named_msg_event(void *userdata, ...@@ -640,7 +640,7 @@ static void cfg_named_msg_event(void *userdata,
/* Generate reply for request (if can't, return request) */ /* Generate reply for request (if can't, return request) */
rep_buf = tipc_cfg_do_cmd(orig->node, rep_buf = tipc_cfg_do_cmd(orig->node,
ntohs(req_hdr->tcm_type), ntohs(req_hdr->tcm_type),
msg + sizeof(*req_hdr), msg + sizeof(*req_hdr),
size - sizeof(*req_hdr), size - sizeof(*req_hdr),
BUF_HEADROOM + MAX_H_SIZE + sizeof(*rep_hdr)); BUF_HEADROOM + MAX_H_SIZE + sizeof(*rep_hdr));
......
/* /*
* net/tipc/config.h: Include file for TIPC configuration service code * net/tipc/config.h: Include file for TIPC configuration service code
* *
* Copyright (c) 2003-2006, Ericsson AB * Copyright (c) 2003-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
#include "link.h" #include "link.h"
struct sk_buff *tipc_cfg_reply_alloc(int payload_size); struct sk_buff *tipc_cfg_reply_alloc(int payload_size);
int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type, int tipc_cfg_append_tlv(struct sk_buff *buf, int tlv_type,
void *tlv_data, int tlv_data_size); void *tlv_data, int tlv_data_size);
struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value); struct sk_buff *tipc_cfg_reply_unsigned_type(u16 tlv_type, u32 value);
struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string); struct sk_buff *tipc_cfg_reply_string_type(u16 tlv_type, char *string);
...@@ -68,8 +68,8 @@ static inline struct sk_buff *tipc_cfg_reply_ultra_string(char *string) ...@@ -68,8 +68,8 @@ static inline struct sk_buff *tipc_cfg_reply_ultra_string(char *string)
return tipc_cfg_reply_string_type(TIPC_TLV_ULTRA_STRING, string); return tipc_cfg_reply_string_type(TIPC_TLV_ULTRA_STRING, string);
} }
struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd,
const void *req_tlv_area, int req_tlv_space, const void *req_tlv_area, int req_tlv_space,
int headroom); int headroom);
void tipc_cfg_link_event(u32 addr, char *name, int up); void tipc_cfg_link_event(u32 addr, char *name, int up);
......
...@@ -89,7 +89,7 @@ int tipc_mode = TIPC_NOT_RUNNING; ...@@ -89,7 +89,7 @@ int tipc_mode = TIPC_NOT_RUNNING;
int tipc_random; int tipc_random;
atomic_t tipc_user_count = ATOMIC_INIT(0); atomic_t tipc_user_count = ATOMIC_INIT(0);
const char tipc_alphabet[] = const char tipc_alphabet[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_."; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.";
/* configurable TIPC parameters */ /* configurable TIPC parameters */
...@@ -171,13 +171,13 @@ int tipc_core_start(void) ...@@ -171,13 +171,13 @@ int tipc_core_start(void)
get_random_bytes(&tipc_random, sizeof(tipc_random)); get_random_bytes(&tipc_random, sizeof(tipc_random));
tipc_mode = TIPC_NODE_MODE; tipc_mode = TIPC_NODE_MODE;
if ((res = tipc_handler_start()) || if ((res = tipc_handler_start()) ||
(res = tipc_ref_table_init(tipc_max_ports + tipc_max_subscriptions, (res = tipc_ref_table_init(tipc_max_ports + tipc_max_subscriptions,
tipc_random)) || tipc_random)) ||
(res = tipc_reg_start()) || (res = tipc_reg_start()) ||
(res = tipc_nametbl_init()) || (res = tipc_nametbl_init()) ||
(res = tipc_k_signal((Handler)tipc_subscr_start, 0)) || (res = tipc_k_signal((Handler)tipc_subscr_start, 0)) ||
(res = tipc_k_signal((Handler)tipc_cfg_init, 0)) || (res = tipc_k_signal((Handler)tipc_cfg_init, 0)) ||
(res = tipc_netlink_start()) || (res = tipc_netlink_start()) ||
(res = tipc_socket_init())) { (res = tipc_socket_init())) {
tipc_core_stop(); tipc_core_stop();
...@@ -191,7 +191,7 @@ static int __init tipc_init(void) ...@@ -191,7 +191,7 @@ static int __init tipc_init(void)
int res; int res;
tipc_log_reinit(CONFIG_TIPC_LOG); tipc_log_reinit(CONFIG_TIPC_LOG);
info("Activated (version " TIPC_MOD_VER info("Activated (version " TIPC_MOD_VER
" compiled " __DATE__ " " __TIME__ ")\n"); " compiled " __DATE__ " " __TIME__ ")\n");
tipc_own_addr = 0; tipc_own_addr = 0;
...@@ -207,9 +207,9 @@ static int __init tipc_init(void) ...@@ -207,9 +207,9 @@ static int __init tipc_init(void)
if ((res = tipc_core_start())) if ((res = tipc_core_start()))
err("Unable to start in single node mode\n"); err("Unable to start in single node mode\n");
else else
info("Started in single node mode\n"); info("Started in single node mode\n");
return res; return res;
} }
static void __exit tipc_exit(void) static void __exit tipc_exit(void)
...@@ -268,11 +268,11 @@ EXPORT_SYMBOL(tipc_available_nodes); ...@@ -268,11 +268,11 @@ EXPORT_SYMBOL(tipc_available_nodes);
/* TIPC API for external bearers (see tipc_bearer.h) */ /* TIPC API for external bearers (see tipc_bearer.h) */
EXPORT_SYMBOL(tipc_block_bearer); EXPORT_SYMBOL(tipc_block_bearer);
EXPORT_SYMBOL(tipc_continue); EXPORT_SYMBOL(tipc_continue);
EXPORT_SYMBOL(tipc_disable_bearer); EXPORT_SYMBOL(tipc_disable_bearer);
EXPORT_SYMBOL(tipc_enable_bearer); EXPORT_SYMBOL(tipc_enable_bearer);
EXPORT_SYMBOL(tipc_recv_msg); EXPORT_SYMBOL(tipc_recv_msg);
EXPORT_SYMBOL(tipc_register_media); EXPORT_SYMBOL(tipc_register_media);
/* TIPC API for external APIs (see tipc_port.h) */ /* TIPC API for external APIs (see tipc_port.h) */
......
/* /*
* net/tipc/core.h: Include file for TIPC global declarations * net/tipc/core.h: Include file for TIPC global declarations
* *
* Copyright (c) 2005-2006, Ericsson AB * Copyright (c) 2005-2006, Ericsson AB
* Copyright (c) 2005-2006, Wind River Systems * Copyright (c) 2005-2006, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
#include <asm/atomic.h> #include <asm/atomic.h>
#include <asm/hardirq.h> #include <asm/hardirq.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/in.h> #include <linux/in.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
...@@ -88,7 +88,7 @@ void tipc_dump(struct print_buf*,const char *fmt, ...); ...@@ -88,7 +88,7 @@ void tipc_dump(struct print_buf*,const char *fmt, ...);
#define dump(fmt, arg...) do {if (DBG_OUTPUT != TIPC_NULL) tipc_dump(DBG_OUTPUT, fmt, ##arg);} while(0) #define dump(fmt, arg...) do {if (DBG_OUTPUT != TIPC_NULL) tipc_dump(DBG_OUTPUT, fmt, ##arg);} while(0)
/* /*
* By default, TIPC_OUTPUT is defined to be system console and TIPC log buffer, * By default, TIPC_OUTPUT is defined to be system console and TIPC log buffer,
* while DBG_OUTPUT is the null print buffer. These defaults can be changed * while DBG_OUTPUT is the null print buffer. These defaults can be changed
* here, or on a per .c file basis, by redefining these symbols. The following * here, or on a per .c file basis, by redefining these symbols. The following
...@@ -126,9 +126,9 @@ void tipc_dump(struct print_buf*,const char *fmt, ...); ...@@ -126,9 +126,9 @@ void tipc_dump(struct print_buf*,const char *fmt, ...);
#define dump(fmt,arg...) do {} while (0) #define dump(fmt,arg...) do {} while (0)
/* /*
* TIPC_OUTPUT is defined to be the system console, while DBG_OUTPUT is * TIPC_OUTPUT is defined to be the system console, while DBG_OUTPUT is
* the null print buffer. Thes ensures that any system or debug messages * the null print buffer. Thes ensures that any system or debug messages
* that are generated without using the above macros are handled correctly. * that are generated without using the above macros are handled correctly.
*/ */
...@@ -138,10 +138,10 @@ void tipc_dump(struct print_buf*,const char *fmt, ...); ...@@ -138,10 +138,10 @@ void tipc_dump(struct print_buf*,const char *fmt, ...);
#undef DBG_OUTPUT #undef DBG_OUTPUT
#define DBG_OUTPUT TIPC_NULL #define DBG_OUTPUT TIPC_NULL
#endif #endif
/* /*
* TIPC-specific error codes * TIPC-specific error codes
*/ */
...@@ -204,11 +204,11 @@ u32 tipc_k_signal(Handler routine, unsigned long argument); ...@@ -204,11 +204,11 @@ u32 tipc_k_signal(Handler routine, unsigned long argument);
* @timer: pointer to timer structure * @timer: pointer to timer structure
* @routine: pointer to routine to invoke when timer expires * @routine: pointer to routine to invoke when timer expires
* @argument: value to pass to routine when timer expires * @argument: value to pass to routine when timer expires
* *
* Timer must be initialized before use (and terminated when no longer needed). * Timer must be initialized before use (and terminated when no longer needed).
*/ */
static inline void k_init_timer(struct timer_list *timer, Handler routine, static inline void k_init_timer(struct timer_list *timer, Handler routine,
unsigned long argument) unsigned long argument)
{ {
dbg("initializing timer %p\n", timer); dbg("initializing timer %p\n", timer);
...@@ -221,13 +221,13 @@ static inline void k_init_timer(struct timer_list *timer, Handler routine, ...@@ -221,13 +221,13 @@ static inline void k_init_timer(struct timer_list *timer, Handler routine,
* k_start_timer - start a timer * k_start_timer - start a timer
* @timer: pointer to timer structure * @timer: pointer to timer structure
* @msec: time to delay (in ms) * @msec: time to delay (in ms)
* *
* Schedules a previously initialized timer for later execution. * Schedules a previously initialized timer for later execution.
* If timer is already running, the new timeout overrides the previous request. * If timer is already running, the new timeout overrides the previous request.
* *
* To ensure the timer doesn't expire before the specified delay elapses, * To ensure the timer doesn't expire before the specified delay elapses,
* the amount of delay is rounded up when converting to the jiffies * the amount of delay is rounded up when converting to the jiffies
* then an additional jiffy is added to account for the fact that * then an additional jiffy is added to account for the fact that
* the starting time may be in the middle of the current jiffy. * the starting time may be in the middle of the current jiffy.
*/ */
...@@ -240,10 +240,10 @@ static inline void k_start_timer(struct timer_list *timer, unsigned long msec) ...@@ -240,10 +240,10 @@ static inline void k_start_timer(struct timer_list *timer, unsigned long msec)
/** /**
* k_cancel_timer - cancel a timer * k_cancel_timer - cancel a timer
* @timer: pointer to timer structure * @timer: pointer to timer structure
* *
* Cancels a previously initialized timer. * Cancels a previously initialized timer.
* Can be called safely even if the timer is already inactive. * Can be called safely even if the timer is already inactive.
* *
* WARNING: Must not be called when holding locks required by the timer's * WARNING: Must not be called when holding locks required by the timer's
* timeout routine, otherwise deadlock can occur on SMP systems! * timeout routine, otherwise deadlock can occur on SMP systems!
*/ */
...@@ -257,11 +257,11 @@ static inline void k_cancel_timer(struct timer_list *timer) ...@@ -257,11 +257,11 @@ static inline void k_cancel_timer(struct timer_list *timer)
/** /**
* k_term_timer - terminate a timer * k_term_timer - terminate a timer
* @timer: pointer to timer structure * @timer: pointer to timer structure
* *
* Prevents further use of a previously initialized timer. * Prevents further use of a previously initialized timer.
* *
* WARNING: Caller must ensure timer isn't currently running. * WARNING: Caller must ensure timer isn't currently running.
* *
* (Do not "enhance" this routine to automatically cancel an active timer, * (Do not "enhance" this routine to automatically cancel an active timer,
* otherwise deadlock can arise when a timeout routine calls k_term_timer.) * otherwise deadlock can arise when a timeout routine calls k_term_timer.)
*/ */
...@@ -302,7 +302,7 @@ static inline struct tipc_msg *buf_msg(struct sk_buff *skb) ...@@ -302,7 +302,7 @@ static inline struct tipc_msg *buf_msg(struct sk_buff *skb)
* @size: message size (including TIPC header) * @size: message size (including TIPC header)
* *
* Returns a new buffer with data pointers set to the specified size. * Returns a new buffer with data pointers set to the specified size.
* *
* NOTE: Headroom is reserved to allow prepending of a data link header. * NOTE: Headroom is reserved to allow prepending of a data link header.
* There may also be unrequested tailroom present at the buffer's end. * There may also be unrequested tailroom present at the buffer's end.
*/ */
...@@ -334,4 +334,4 @@ static inline void buf_discard(struct sk_buff *skb) ...@@ -334,4 +334,4 @@ static inline void buf_discard(struct sk_buff *skb)
kfree_skb(skb); kfree_skb(skb);
} }
#endif #endif
/* /*
* net/tipc/dbg.c: TIPC print buffer routines for debugging * net/tipc/dbg.c: TIPC print buffer routines for debugging
* *
* Copyright (c) 1996-2006, Ericsson AB * Copyright (c) 1996-2006, Ericsson AB
* Copyright (c) 2005-2006, Wind River Systems * Copyright (c) 2005-2006, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -123,34 +123,34 @@ int tipc_printbuf_empty(struct print_buf *pb) ...@@ -123,34 +123,34 @@ int tipc_printbuf_empty(struct print_buf *pb)
/** /**
* tipc_printbuf_validate - check for print buffer overflow * tipc_printbuf_validate - check for print buffer overflow
* @pb: pointer to print buffer structure * @pb: pointer to print buffer structure
* *
* Verifies that a print buffer has captured all data written to it. * Verifies that a print buffer has captured all data written to it.
* If data has been lost, linearize buffer and prepend an error message * If data has been lost, linearize buffer and prepend an error message
* *
* Returns length of print buffer data string (including trailing NUL) * Returns length of print buffer data string (including trailing NUL)
*/ */
int tipc_printbuf_validate(struct print_buf *pb) int tipc_printbuf_validate(struct print_buf *pb)
{ {
char *err = "\n\n*** PRINT BUFFER OVERFLOW ***\n\n"; char *err = "\n\n*** PRINT BUFFER OVERFLOW ***\n\n";
char *cp_buf; char *cp_buf;
struct print_buf cb; struct print_buf cb;
if (!pb->buf) if (!pb->buf)
return 0; return 0;
if (pb->buf[pb->size - 1] == 0) { if (pb->buf[pb->size - 1] == 0) {
cp_buf = kmalloc(pb->size, GFP_ATOMIC); cp_buf = kmalloc(pb->size, GFP_ATOMIC);
if (cp_buf != NULL){ if (cp_buf != NULL){
tipc_printbuf_init(&cb, cp_buf, pb->size); tipc_printbuf_init(&cb, cp_buf, pb->size);
tipc_printbuf_move(&cb, pb); tipc_printbuf_move(&cb, pb);
tipc_printbuf_move(pb, &cb); tipc_printbuf_move(pb, &cb);
kfree(cp_buf); kfree(cp_buf);
memcpy(pb->buf, err, strlen(err)); memcpy(pb->buf, err, strlen(err));
} else { } else {
tipc_printbuf_reset(pb); tipc_printbuf_reset(pb);
tipc_printf(pb, err); tipc_printf(pb, err);
} }
} }
return (pb->crs - pb->buf + 1); return (pb->crs - pb->buf + 1);
} }
...@@ -159,7 +159,7 @@ int tipc_printbuf_validate(struct print_buf *pb) ...@@ -159,7 +159,7 @@ int tipc_printbuf_validate(struct print_buf *pb)
* tipc_printbuf_move - move print buffer contents to another print buffer * tipc_printbuf_move - move print buffer contents to another print buffer
* @pb_to: pointer to destination print buffer structure * @pb_to: pointer to destination print buffer structure
* @pb_from: pointer to source print buffer structure * @pb_from: pointer to source print buffer structure
* *
* Current contents of destination print buffer (if any) are discarded. * Current contents of destination print buffer (if any) are discarded.
* Source print buffer becomes empty if a successful move occurs. * Source print buffer becomes empty if a successful move occurs.
*/ */
...@@ -234,13 +234,13 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...) ...@@ -234,13 +234,13 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...)
pb->crs = pb->buf + pb->size - 1; pb->crs = pb->buf + pb->size - 1;
} else { } else {
strcpy(pb->buf, print_string + chars_left); strcpy(pb->buf, print_string + chars_left);
save_char = print_string[chars_left]; save_char = print_string[chars_left];
print_string[chars_left] = 0; print_string[chars_left] = 0;
strcpy(pb->crs, print_string); strcpy(pb->crs, print_string);
print_string[chars_left] = save_char; print_string[chars_left] = save_char;
pb->crs = pb->buf + chars_to_add - chars_left; pb->crs = pb->buf + chars_to_add - chars_left;
} }
} }
pb_next = pb->next; pb_next = pb->next;
pb->next = NULL; pb->next = NULL;
pb = pb_next; pb = pb_next;
...@@ -249,7 +249,7 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...) ...@@ -249,7 +249,7 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...)
} }
/** /**
* TIPC_TEE - perform next output operation on both print buffers * TIPC_TEE - perform next output operation on both print buffers
* @b0: pointer to chain of print buffers (may be NULL) * @b0: pointer to chain of print buffers (may be NULL)
* @b1: pointer to print buffer to add to chain * @b1: pointer to print buffer to add to chain
* *
...@@ -350,7 +350,7 @@ void tipc_dump(struct print_buf *pb, const char *fmt, ...) ...@@ -350,7 +350,7 @@ void tipc_dump(struct print_buf *pb, const char *fmt, ...)
} }
/** /**
* tipc_log_stop - free up TIPC log print buffer * tipc_log_stop - free up TIPC log print buffer
*/ */
void tipc_log_stop(void) void tipc_log_stop(void)
......
/* /*
* net/tipc/dbg.h: Include file for TIPC print buffer routines * net/tipc/dbg.h: Include file for TIPC print buffer routines
* *
* Copyright (c) 1997-2006, Ericsson AB * Copyright (c) 1997-2006, Ericsson AB
* Copyright (c) 2005-2006, Wind River Systems * Copyright (c) 2005-2006, Wind River Systems
* All rights reserved. * All rights reserved.
......
/* /*
* net/tipc/discover.c * net/tipc/discover.c
* *
* Copyright (c) 2003-2006, Ericsson AB * Copyright (c) 2003-2006, Ericsson AB
* Copyright (c) 2005-2006, Wind River Systems * Copyright (c) 2005-2006, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -56,10 +56,10 @@ ...@@ -56,10 +56,10 @@
#define CHECK_LINK_COUNT 306 #define CHECK_LINK_COUNT 306
#endif #endif
/* /*
* TODO: Most of the inter-cluster setup stuff should be * TODO: Most of the inter-cluster setup stuff should be
* rewritten, and be made conformant with specification. * rewritten, and be made conformant with specification.
*/ */
/** /**
...@@ -80,10 +80,10 @@ struct link_req { ...@@ -80,10 +80,10 @@ struct link_req {
#if 0 #if 0
int disc_create_link(const struct tipc_link_create *argv) int disc_create_link(const struct tipc_link_create *argv)
{ {
/* /*
* Code for inter cluster link setup here * Code for inter cluster link setup here
*/ */
return TIPC_OK; return TIPC_OK;
} }
...@@ -93,16 +93,16 @@ int disc_create_link(const struct tipc_link_create *argv) ...@@ -93,16 +93,16 @@ int disc_create_link(const struct tipc_link_create *argv)
* disc_lost_link(): A link has lost contact * disc_lost_link(): A link has lost contact
*/ */
void tipc_disc_link_event(u32 addr, char *name, int up) void tipc_disc_link_event(u32 addr, char *name, int up)
{ {
if (in_own_cluster(addr)) if (in_own_cluster(addr))
return; return;
/* /*
* Code for inter cluster link setup here * Code for inter cluster link setup here
*/ */
} }
/** /**
* tipc_disc_init_msg - initialize a link setup message * tipc_disc_init_msg - initialize a link setup message
* @type: message type (request or response) * @type: message type (request or response)
* @req_links: number of links associated with message * @req_links: number of links associated with message
...@@ -210,7 +210,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf) ...@@ -210,7 +210,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf)
dbg("creating link\n"); dbg("creating link\n");
link = tipc_link_create(b_ptr, orig, &media_addr); link = tipc_link_create(b_ptr, orig, &media_addr);
if (!link) { if (!link) {
spin_unlock_bh(&n_ptr->lock); spin_unlock_bh(&n_ptr->lock);
return; return;
} }
} }
...@@ -224,10 +224,10 @@ void tipc_disc_recv_msg(struct sk_buff *buf) ...@@ -224,10 +224,10 @@ void tipc_disc_recv_msg(struct sk_buff *buf)
warn("Resetting link <%s>, peer interface address changed\n", warn("Resetting link <%s>, peer interface address changed\n",
link->name); link->name);
memcpy(addr, &media_addr, sizeof(*addr)); memcpy(addr, &media_addr, sizeof(*addr));
tipc_link_reset(link); tipc_link_reset(link);
} }
link_fully_up = (link->state == WORKING_WORKING); link_fully_up = (link->state == WORKING_WORKING);
spin_unlock_bh(&n_ptr->lock); spin_unlock_bh(&n_ptr->lock);
if ((type == DSC_RESP_MSG) || link_fully_up) if ((type == DSC_RESP_MSG) || link_fully_up)
return; return;
rbuf = tipc_disc_init_msg(DSC_RESP_MSG, 1, orig, b_ptr); rbuf = tipc_disc_init_msg(DSC_RESP_MSG, 1, orig, b_ptr);
...@@ -244,23 +244,23 @@ void tipc_disc_recv_msg(struct sk_buff *buf) ...@@ -244,23 +244,23 @@ void tipc_disc_recv_msg(struct sk_buff *buf)
* @req: ptr to link request structure * @req: ptr to link request structure
*/ */
void tipc_disc_stop_link_req(struct link_req *req) void tipc_disc_stop_link_req(struct link_req *req)
{ {
if (!req) if (!req)
return; return;
k_cancel_timer(&req->timer); k_cancel_timer(&req->timer);
k_term_timer(&req->timer); k_term_timer(&req->timer);
buf_discard(req->buf); buf_discard(req->buf);
kfree(req); kfree(req);
} }
/** /**
* tipc_disc_update_link_req - update frequency of periodic link setup requests * tipc_disc_update_link_req - update frequency of periodic link setup requests
* @req: ptr to link request structure * @req: ptr to link request structure
*/ */
void tipc_disc_update_link_req(struct link_req *req) void tipc_disc_update_link_req(struct link_req *req)
{ {
if (!req) if (!req)
return; return;
...@@ -278,16 +278,16 @@ void tipc_disc_update_link_req(struct link_req *req) ...@@ -278,16 +278,16 @@ void tipc_disc_update_link_req(struct link_req *req)
} else { } else {
/* leave timer "as is" if haven't yet reached a "normal" rate */ /* leave timer "as is" if haven't yet reached a "normal" rate */
} }
} }
/** /**
* disc_timeout - send a periodic link setup request * disc_timeout - send a periodic link setup request
* @req: ptr to link request structure * @req: ptr to link request structure
* *
* Called whenever a link setup request timer associated with a bearer expires. * Called whenever a link setup request timer associated with a bearer expires.
*/ */
static void disc_timeout(struct link_req *req) static void disc_timeout(struct link_req *req)
{ {
spin_lock_bh(&req->bearer->publ.lock); spin_lock_bh(&req->bearer->publ.lock);
...@@ -300,7 +300,7 @@ static void disc_timeout(struct link_req *req) ...@@ -300,7 +300,7 @@ static void disc_timeout(struct link_req *req)
req->timer_intv *= 2; req->timer_intv *= 2;
if (req->timer_intv > TIPC_LINK_REQ_FAST) if (req->timer_intv > TIPC_LINK_REQ_FAST)
req->timer_intv = TIPC_LINK_REQ_FAST; req->timer_intv = TIPC_LINK_REQ_FAST;
if ((req->timer_intv == TIPC_LINK_REQ_FAST) && if ((req->timer_intv == TIPC_LINK_REQ_FAST) &&
(req->bearer->nodes.count)) (req->bearer->nodes.count))
req->timer_intv = TIPC_LINK_REQ_SLOW; req->timer_intv = TIPC_LINK_REQ_SLOW;
} }
...@@ -315,14 +315,14 @@ static void disc_timeout(struct link_req *req) ...@@ -315,14 +315,14 @@ static void disc_timeout(struct link_req *req)
* @dest: destination address for request messages * @dest: destination address for request messages
* @dest_domain: network domain of node(s) which should respond to message * @dest_domain: network domain of node(s) which should respond to message
* @req_links: max number of desired links * @req_links: max number of desired links
* *
* Returns pointer to link request structure, or NULL if unable to create. * Returns pointer to link request structure, or NULL if unable to create.
*/ */
struct link_req *tipc_disc_init_link_req(struct bearer *b_ptr, struct link_req *tipc_disc_init_link_req(struct bearer *b_ptr,
const struct tipc_media_addr *dest, const struct tipc_media_addr *dest,
u32 dest_domain, u32 dest_domain,
u32 req_links) u32 req_links)
{ {
struct link_req *req; struct link_req *req;
...@@ -342,5 +342,5 @@ struct link_req *tipc_disc_init_link_req(struct bearer *b_ptr, ...@@ -342,5 +342,5 @@ struct link_req *tipc_disc_init_link_req(struct bearer *b_ptr,
k_init_timer(&req->timer, (Handler)disc_timeout, (unsigned long)req); k_init_timer(&req->timer, (Handler)disc_timeout, (unsigned long)req);
k_start_timer(&req->timer, req->timer_intv); k_start_timer(&req->timer, req->timer_intv);
return req; return req;
} }
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
struct link_req; struct link_req;
struct link_req *tipc_disc_init_link_req(struct bearer *b_ptr, struct link_req *tipc_disc_init_link_req(struct bearer *b_ptr,
const struct tipc_media_addr *dest, const struct tipc_media_addr *dest,
u32 dest_domain, u32 dest_domain,
u32 req_links); u32 req_links);
......
/* /*
* net/tipc/eth_media.c: Ethernet bearer support for TIPC * net/tipc/eth_media.c: Ethernet bearer support for TIPC
* *
* Copyright (c) 2001-2006, Ericsson AB * Copyright (c) 2001-2006, Ericsson AB
* Copyright (c) 2005-2006, Wind River Systems * Copyright (c) 2005-2006, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
* @dev: ptr to associated Ethernet network device * @dev: ptr to associated Ethernet network device
* @tipc_packet_type: used in binding TIPC to Ethernet driver * @tipc_packet_type: used in binding TIPC to Ethernet driver
*/ */
struct eth_bearer { struct eth_bearer {
struct tipc_bearer *bearer; struct tipc_bearer *bearer;
struct net_device *dev; struct net_device *dev;
...@@ -62,10 +62,10 @@ static int eth_started = 0; ...@@ -62,10 +62,10 @@ static int eth_started = 0;
static struct notifier_block notifier; static struct notifier_block notifier;
/** /**
* send_msg - send a TIPC message out over an Ethernet interface * send_msg - send a TIPC message out over an Ethernet interface
*/ */
static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
struct tipc_media_addr *dest) struct tipc_media_addr *dest)
{ {
struct sk_buff *clone; struct sk_buff *clone;
...@@ -76,7 +76,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, ...@@ -76,7 +76,7 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
clone->nh.raw = clone->data; clone->nh.raw = clone->data;
dev = ((struct eth_bearer *)(tb_ptr->usr_handle))->dev; dev = ((struct eth_bearer *)(tb_ptr->usr_handle))->dev;
clone->dev = dev; clone->dev = dev;
dev->hard_header(clone, dev, ETH_P_TIPC, dev->hard_header(clone, dev, ETH_P_TIPC,
&dest->dev_addr.eth_addr, &dest->dev_addr.eth_addr,
dev->dev_addr, clone->len); dev->dev_addr, clone->len);
dev_queue_xmit(clone); dev_queue_xmit(clone);
...@@ -86,12 +86,12 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr, ...@@ -86,12 +86,12 @@ static int send_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr,
/** /**
* recv_msg - handle incoming TIPC message from an Ethernet interface * recv_msg - handle incoming TIPC message from an Ethernet interface
* *
* Routine truncates any Ethernet padding/CRC appended to the message, * Routine truncates any Ethernet padding/CRC appended to the message,
* and ensures message size matches actual length * and ensures message size matches actual length
*/ */
static int recv_msg(struct sk_buff *buf, struct net_device *dev, static int recv_msg(struct sk_buff *buf, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev) struct packet_type *pt, struct net_device *orig_dev)
{ {
struct eth_bearer *eb_ptr = (struct eth_bearer *)pt->af_packet_priv; struct eth_bearer *eb_ptr = (struct eth_bearer *)pt->af_packet_priv;
...@@ -99,14 +99,14 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev, ...@@ -99,14 +99,14 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
if (likely(eb_ptr->bearer)) { if (likely(eb_ptr->bearer)) {
if (likely(!dev->promiscuity) || if (likely(!dev->promiscuity) ||
!memcmp(buf->mac.raw,dev->dev_addr,ETH_ALEN) || !memcmp(buf->mac.raw,dev->dev_addr,ETH_ALEN) ||
!memcmp(buf->mac.raw,dev->broadcast,ETH_ALEN)) { !memcmp(buf->mac.raw,dev->broadcast,ETH_ALEN)) {
size = msg_size((struct tipc_msg *)buf->data); size = msg_size((struct tipc_msg *)buf->data);
skb_trim(buf, size); skb_trim(buf, size);
if (likely(buf->len == size)) { if (likely(buf->len == size)) {
buf->next = NULL; buf->next = NULL;
tipc_recv_msg(buf, eb_ptr->bearer); tipc_recv_msg(buf, eb_ptr->bearer);
return TIPC_OK; return TIPC_OK;
} }
} }
} }
...@@ -115,7 +115,7 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev, ...@@ -115,7 +115,7 @@ static int recv_msg(struct sk_buff *buf, struct net_device *dev,
} }
/** /**
* enable_bearer - attach TIPC bearer to an Ethernet interface * enable_bearer - attach TIPC bearer to an Ethernet interface
*/ */
static int enable_bearer(struct tipc_bearer *tb_ptr) static int enable_bearer(struct tipc_bearer *tb_ptr)
...@@ -127,7 +127,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) ...@@ -127,7 +127,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
/* Find device with specified name */ /* Find device with specified name */
while (dev && dev->name && strncmp(dev->name, driver_name, IFNAMSIZ)) { while (dev && dev->name && strncmp(dev->name, driver_name, IFNAMSIZ)) {
dev = dev->next; dev = dev->next;
} }
if (!dev) if (!dev)
...@@ -154,14 +154,14 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) ...@@ -154,14 +154,14 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
eb_ptr->bearer = tb_ptr; eb_ptr->bearer = tb_ptr;
tb_ptr->usr_handle = (void *)eb_ptr; tb_ptr->usr_handle = (void *)eb_ptr;
tb_ptr->mtu = dev->mtu; tb_ptr->mtu = dev->mtu;
tb_ptr->blocked = 0; tb_ptr->blocked = 0;
tb_ptr->addr.type = htonl(TIPC_MEDIA_TYPE_ETH); tb_ptr->addr.type = htonl(TIPC_MEDIA_TYPE_ETH);
memcpy(&tb_ptr->addr.dev_addr, &dev->dev_addr, ETH_ALEN); memcpy(&tb_ptr->addr.dev_addr, &dev->dev_addr, ETH_ALEN);
return 0; return 0;
} }
/** /**
* disable_bearer - detach TIPC bearer from an Ethernet interface * disable_bearer - detach TIPC bearer from an Ethernet interface
* *
* We really should do dev_remove_pack() here, but this function can not be * We really should do dev_remove_pack() here, but this function can not be
* called at tasklet level. => Use eth_bearer->bearer as a flag to throw away * called at tasklet level. => Use eth_bearer->bearer as a flag to throw away
...@@ -176,11 +176,11 @@ static void disable_bearer(struct tipc_bearer *tb_ptr) ...@@ -176,11 +176,11 @@ static void disable_bearer(struct tipc_bearer *tb_ptr)
/** /**
* recv_notification - handle device updates from OS * recv_notification - handle device updates from OS
* *
* Change the state of the Ethernet bearer (if any) associated with the * Change the state of the Ethernet bearer (if any) associated with the
* specified device. * specified device.
*/ */
static int recv_notification(struct notifier_block *nb, unsigned long evt, static int recv_notification(struct notifier_block *nb, unsigned long evt,
void *dv) void *dv)
{ {
struct net_device *dev = (struct net_device *)dv; struct net_device *dev = (struct net_device *)dv;
...@@ -194,7 +194,7 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt, ...@@ -194,7 +194,7 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
if (!eb_ptr->bearer) if (!eb_ptr->bearer)
return NOTIFY_DONE; /* bearer had been disabled */ return NOTIFY_DONE; /* bearer had been disabled */
eb_ptr->bearer->mtu = dev->mtu; eb_ptr->bearer->mtu = dev->mtu;
switch (evt) { switch (evt) {
case NETDEV_CHANGE: case NETDEV_CHANGE:
...@@ -210,12 +210,12 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt, ...@@ -210,12 +210,12 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
tipc_block_bearer(eb_ptr->bearer->name); tipc_block_bearer(eb_ptr->bearer->name);
break; break;
case NETDEV_CHANGEMTU: case NETDEV_CHANGEMTU:
case NETDEV_CHANGEADDR: case NETDEV_CHANGEADDR:
tipc_block_bearer(eb_ptr->bearer->name); tipc_block_bearer(eb_ptr->bearer->name);
tipc_continue(eb_ptr->bearer); tipc_continue(eb_ptr->bearer);
break; break;
case NETDEV_UNREGISTER: case NETDEV_UNREGISTER:
case NETDEV_CHANGENAME: case NETDEV_CHANGENAME:
tipc_disable_bearer(eb_ptr->bearer->name); tipc_disable_bearer(eb_ptr->bearer->name);
break; break;
} }
...@@ -227,7 +227,7 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt, ...@@ -227,7 +227,7 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
*/ */
static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size) static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size)
{ {
unchar *addr = (unchar *)&a->dev_addr; unchar *addr = (unchar *)&a->dev_addr;
if (str_size < 18) if (str_size < 18)
...@@ -246,7 +246,7 @@ static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size ...@@ -246,7 +246,7 @@ static char *eth_addr2str(struct tipc_media_addr *a, char *str_buf, int str_size
*/ */
int tipc_eth_media_start(void) int tipc_eth_media_start(void)
{ {
struct tipc_media_addr bcast_addr; struct tipc_media_addr bcast_addr;
int res; int res;
...@@ -259,8 +259,8 @@ int tipc_eth_media_start(void) ...@@ -259,8 +259,8 @@ int tipc_eth_media_start(void)
memset(eth_bearers, 0, sizeof(eth_bearers)); memset(eth_bearers, 0, sizeof(eth_bearers));
res = tipc_register_media(TIPC_MEDIA_TYPE_ETH, "eth", res = tipc_register_media(TIPC_MEDIA_TYPE_ETH, "eth",
enable_bearer, disable_bearer, send_msg, enable_bearer, disable_bearer, send_msg,
eth_addr2str, &bcast_addr, ETH_LINK_PRIORITY, eth_addr2str, &bcast_addr, ETH_LINK_PRIORITY,
ETH_LINK_TOLERANCE, ETH_LINK_WINDOW); ETH_LINK_TOLERANCE, ETH_LINK_WINDOW);
if (res) if (res)
return res; return res;
......
/* /*
* net/tipc/handler.c: TIPC signal handling * net/tipc/handler.c: TIPC signal handling
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -95,7 +95,7 @@ static void process_signal_queue(unsigned long dummy) ...@@ -95,7 +95,7 @@ static void process_signal_queue(unsigned long dummy)
int tipc_handler_start(void) int tipc_handler_start(void)
{ {
tipc_queue_item_cache = tipc_queue_item_cache =
kmem_cache_create("tipc_queue_items", sizeof(struct queue_item), kmem_cache_create("tipc_queue_items", sizeof(struct queue_item),
0, SLAB_HWCACHE_ALIGN, NULL, NULL); 0, SLAB_HWCACHE_ALIGN, NULL, NULL);
if (!tipc_queue_item_cache) if (!tipc_queue_item_cache)
...@@ -110,7 +110,7 @@ int tipc_handler_start(void) ...@@ -110,7 +110,7 @@ int tipc_handler_start(void)
void tipc_handler_stop(void) void tipc_handler_stop(void)
{ {
struct list_head *l, *n; struct list_head *l, *n;
struct queue_item *item; struct queue_item *item;
if (!handler_enabled) if (!handler_enabled)
return; return;
......
/* /*
* net/tipc/link.c: TIPC link code * net/tipc/link.c: TIPC link code
* *
* Copyright (c) 1996-2006, Ericsson AB * Copyright (c) 1996-2006, Ericsson AB
* Copyright (c) 2004-2006, Wind River Systems * Copyright (c) 2004-2006, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -50,29 +50,29 @@ ...@@ -50,29 +50,29 @@
#include "bcast.h" #include "bcast.h"
/* /*
* Limit for deferred reception queue: * Limit for deferred reception queue:
*/ */
#define DEF_QUEUE_LIMIT 256u #define DEF_QUEUE_LIMIT 256u
/* /*
* Link state events: * Link state events:
*/ */
#define STARTING_EVT 856384768 /* link processing trigger */ #define STARTING_EVT 856384768 /* link processing trigger */
#define TRAFFIC_MSG_EVT 560815u /* rx'd ??? */ #define TRAFFIC_MSG_EVT 560815u /* rx'd ??? */
#define TIMEOUT_EVT 560817u /* link timer expired */ #define TIMEOUT_EVT 560817u /* link timer expired */
/* /*
* The following two 'message types' is really just implementation * The following two 'message types' is really just implementation
* data conveniently stored in the message header. * data conveniently stored in the message header.
* They must not be considered part of the protocol * They must not be considered part of the protocol
*/ */
#define OPEN_MSG 0 #define OPEN_MSG 0
#define CLOSED_MSG 1 #define CLOSED_MSG 1
/* /*
* State value stored in 'exp_msg_count' * State value stored in 'exp_msg_count'
*/ */
...@@ -97,7 +97,7 @@ struct link_name { ...@@ -97,7 +97,7 @@ struct link_name {
/* LINK EVENT CODE IS NOT SUPPORTED AT PRESENT */ /* LINK EVENT CODE IS NOT SUPPORTED AT PRESENT */
/** /**
* struct link_event - link up/down event notification * struct link_event - link up/down event notification
*/ */
...@@ -121,7 +121,7 @@ static int link_send_sections_long(struct port *sender, ...@@ -121,7 +121,7 @@ static int link_send_sections_long(struct port *sender,
static void link_check_defragm_bufs(struct link *l_ptr); static void link_check_defragm_bufs(struct link *l_ptr);
static void link_state_event(struct link *l_ptr, u32 event); static void link_state_event(struct link *l_ptr, u32 event);
static void link_reset_statistics(struct link *l_ptr); static void link_reset_statistics(struct link *l_ptr);
static void link_print(struct link *l_ptr, struct print_buf *buf, static void link_print(struct link *l_ptr, struct print_buf *buf,
const char *str); const char *str);
/* /*
...@@ -136,13 +136,13 @@ static void link_print(struct link *l_ptr, struct print_buf *buf, ...@@ -136,13 +136,13 @@ static void link_print(struct link *l_ptr, struct print_buf *buf,
* *
* To enable per-link debugging, use LINK_LOG_BUF_SIZE to specify the size * To enable per-link debugging, use LINK_LOG_BUF_SIZE to specify the size
* of the print buffer used by each link. If LINK_LOG_BUF_SIZE is set to 0, * of the print buffer used by each link. If LINK_LOG_BUF_SIZE is set to 0,
* the dbg_link_XXX() routines simply send their output to the standard * the dbg_link_XXX() routines simply send their output to the standard
* debug print buffer (DBG_OUTPUT), if it has been defined; this can be useful * debug print buffer (DBG_OUTPUT), if it has been defined; this can be useful
* when there is only a single link in the system being debugged. * when there is only a single link in the system being debugged.
* *
* Notes: * Notes:
* - When enabled, LINK_LOG_BUF_SIZE should be set to at least TIPC_PB_MIN_SIZE * - When enabled, LINK_LOG_BUF_SIZE should be set to at least TIPC_PB_MIN_SIZE
* - "l_ptr" must be valid when using dbg_link_XXX() macros * - "l_ptr" must be valid when using dbg_link_XXX() macros
*/ */
#define LINK_LOG_BUF_SIZE 0 #define LINK_LOG_BUF_SIZE 0
...@@ -222,18 +222,18 @@ static u32 link_max_pkt(struct link *l_ptr) ...@@ -222,18 +222,18 @@ static u32 link_max_pkt(struct link *l_ptr)
static void link_init_max_pkt(struct link *l_ptr) static void link_init_max_pkt(struct link *l_ptr)
{ {
u32 max_pkt; u32 max_pkt;
max_pkt = (l_ptr->b_ptr->publ.mtu & ~3); max_pkt = (l_ptr->b_ptr->publ.mtu & ~3);
if (max_pkt > MAX_MSG_SIZE) if (max_pkt > MAX_MSG_SIZE)
max_pkt = MAX_MSG_SIZE; max_pkt = MAX_MSG_SIZE;
l_ptr->max_pkt_target = max_pkt; l_ptr->max_pkt_target = max_pkt;
if (l_ptr->max_pkt_target < MAX_PKT_DEFAULT) if (l_ptr->max_pkt_target < MAX_PKT_DEFAULT)
l_ptr->max_pkt = l_ptr->max_pkt_target; l_ptr->max_pkt = l_ptr->max_pkt_target;
else else
l_ptr->max_pkt = MAX_PKT_DEFAULT; l_ptr->max_pkt = MAX_PKT_DEFAULT;
l_ptr->max_pkt_probes = 0; l_ptr->max_pkt_probes = 0;
} }
static u32 link_next_sent(struct link *l_ptr) static u32 link_next_sent(struct link *l_ptr)
...@@ -269,7 +269,7 @@ int tipc_link_is_active(struct link *l_ptr) ...@@ -269,7 +269,7 @@ int tipc_link_is_active(struct link *l_ptr)
* link_name_validate - validate & (optionally) deconstruct link name * link_name_validate - validate & (optionally) deconstruct link name
* @name - ptr to link name string * @name - ptr to link name string
* @name_parts - ptr to area for link name components (or NULL if not needed) * @name_parts - ptr to area for link name components (or NULL if not needed)
* *
* Returns 1 if link name is valid, otherwise 0. * Returns 1 if link name is valid, otherwise 0.
*/ */
...@@ -317,8 +317,8 @@ static int link_name_validate(const char *name, struct link_name *name_parts) ...@@ -317,8 +317,8 @@ static int link_name_validate(const char *name, struct link_name *name_parts)
&z_peer, &c_peer, &n_peer, &dummy) != 3) || &z_peer, &c_peer, &n_peer, &dummy) != 3) ||
(z_local > 255) || (c_local > 4095) || (n_local > 4095) || (z_local > 255) || (c_local > 4095) || (n_local > 4095) ||
(z_peer > 255) || (c_peer > 4095) || (n_peer > 4095) || (z_peer > 255) || (c_peer > 4095) || (n_peer > 4095) ||
(if_local_len <= 1) || (if_local_len > TIPC_MAX_IF_NAME) || (if_local_len <= 1) || (if_local_len > TIPC_MAX_IF_NAME) ||
(if_peer_len <= 1) || (if_peer_len > TIPC_MAX_IF_NAME) || (if_peer_len <= 1) || (if_peer_len > TIPC_MAX_IF_NAME) ||
(strspn(if_local, tipc_alphabet) != (if_local_len - 1)) || (strspn(if_local, tipc_alphabet) != (if_local_len - 1)) ||
(strspn(if_peer, tipc_alphabet) != (if_peer_len - 1))) (strspn(if_peer, tipc_alphabet) != (if_peer_len - 1)))
return 0; return 0;
...@@ -337,7 +337,7 @@ static int link_name_validate(const char *name, struct link_name *name_parts) ...@@ -337,7 +337,7 @@ static int link_name_validate(const char *name, struct link_name *name_parts)
/** /**
* link_timeout - handle expiration of link timer * link_timeout - handle expiration of link timer
* @l_ptr: pointer to link * @l_ptr: pointer to link
* *
* This routine must not grab "tipc_net_lock" to avoid a potential deadlock conflict * This routine must not grab "tipc_net_lock" to avoid a potential deadlock conflict
* with tipc_link_delete(). (There is no risk that the node will be deleted by * with tipc_link_delete(). (There is no risk that the node will be deleted by
* another thread because tipc_link_delete() always cancels the link timer before * another thread because tipc_link_delete() always cancels the link timer before
...@@ -406,7 +406,7 @@ static void link_set_timer(struct link *l_ptr, u32 time) ...@@ -406,7 +406,7 @@ static void link_set_timer(struct link *l_ptr, u32 time)
* @b_ptr: pointer to associated bearer * @b_ptr: pointer to associated bearer
* @peer: network address of node at other end of link * @peer: network address of node at other end of link
* @media_addr: media address to use when sending messages over link * @media_addr: media address to use when sending messages over link
* *
* Returns pointer to link. * Returns pointer to link.
*/ */
...@@ -427,7 +427,7 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer, ...@@ -427,7 +427,7 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
if_name = strchr(b_ptr->publ.name, ':') + 1; if_name = strchr(b_ptr->publ.name, ':') + 1;
sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:", sprintf(l_ptr->name, "%u.%u.%u:%s-%u.%u.%u:",
tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr), tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr),
tipc_node(tipc_own_addr), tipc_node(tipc_own_addr),
if_name, if_name,
tipc_zone(peer), tipc_cluster(peer), tipc_node(peer)); tipc_zone(peer), tipc_cluster(peer), tipc_node(peer));
/* note: peer i/f is appended to link name by reset/activate */ /* note: peer i/f is appended to link name by reset/activate */
...@@ -478,17 +478,17 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer, ...@@ -478,17 +478,17 @@ struct link *tipc_link_create(struct bearer *b_ptr, const u32 peer,
dbg("tipc_link_create(): tolerance = %u,cont intv = %u, abort_limit = %u\n", dbg("tipc_link_create(): tolerance = %u,cont intv = %u, abort_limit = %u\n",
l_ptr->tolerance, l_ptr->continuity_interval, l_ptr->abort_limit); l_ptr->tolerance, l_ptr->continuity_interval, l_ptr->abort_limit);
return l_ptr; return l_ptr;
} }
/** /**
* tipc_link_delete - delete a link * tipc_link_delete - delete a link
* @l_ptr: pointer to link * @l_ptr: pointer to link
* *
* Note: 'tipc_net_lock' is write_locked, bearer is locked. * Note: 'tipc_net_lock' is write_locked, bearer is locked.
* This routine must not grab the node lock until after link timer cancellation * This routine must not grab the node lock until after link timer cancellation
* to avoid a potential deadlock situation. * to avoid a potential deadlock situation.
*/ */
void tipc_link_delete(struct link *l_ptr) void tipc_link_delete(struct link *l_ptr)
...@@ -501,7 +501,7 @@ void tipc_link_delete(struct link *l_ptr) ...@@ -501,7 +501,7 @@ void tipc_link_delete(struct link *l_ptr)
dbg("tipc_link_delete()\n"); dbg("tipc_link_delete()\n");
k_cancel_timer(&l_ptr->timer); k_cancel_timer(&l_ptr->timer);
tipc_node_lock(l_ptr->owner); tipc_node_lock(l_ptr->owner);
tipc_link_reset(l_ptr); tipc_link_reset(l_ptr);
tipc_node_detach_link(l_ptr->owner, l_ptr); tipc_node_detach_link(l_ptr->owner, l_ptr);
...@@ -521,12 +521,12 @@ void tipc_link_start(struct link *l_ptr) ...@@ -521,12 +521,12 @@ void tipc_link_start(struct link *l_ptr)
} }
/** /**
* link_schedule_port - schedule port for deferred sending * link_schedule_port - schedule port for deferred sending
* @l_ptr: pointer to link * @l_ptr: pointer to link
* @origport: reference to sending port * @origport: reference to sending port
* @sz: amount of data to be sent * @sz: amount of data to be sent
* *
* Schedules port for renewed sending of messages after link congestion * Schedules port for renewed sending of messages after link congestion
* has abated. * has abated.
*/ */
...@@ -567,7 +567,7 @@ void tipc_link_wakeup_ports(struct link *l_ptr, int all) ...@@ -567,7 +567,7 @@ void tipc_link_wakeup_ports(struct link *l_ptr, int all)
return; return;
if (link_congested(l_ptr)) if (link_congested(l_ptr))
goto exit; goto exit;
list_for_each_entry_safe(p_ptr, temp_p_ptr, &l_ptr->waiting_ports, list_for_each_entry_safe(p_ptr, temp_p_ptr, &l_ptr->waiting_ports,
wait_list) { wait_list) {
if (win <= 0) if (win <= 0)
break; break;
...@@ -584,7 +584,7 @@ void tipc_link_wakeup_ports(struct link *l_ptr, int all) ...@@ -584,7 +584,7 @@ void tipc_link_wakeup_ports(struct link *l_ptr, int all)
spin_unlock_bh(&tipc_port_list_lock); spin_unlock_bh(&tipc_port_list_lock);
} }
/** /**
* link_release_outqueue - purge link's outbound message queue * link_release_outqueue - purge link's outbound message queue
* @l_ptr: pointer to link * @l_ptr: pointer to link
*/ */
...@@ -621,7 +621,7 @@ void tipc_link_reset_fragments(struct link *l_ptr) ...@@ -621,7 +621,7 @@ void tipc_link_reset_fragments(struct link *l_ptr)
l_ptr->defragm_buf = NULL; l_ptr->defragm_buf = NULL;
} }
/** /**
* tipc_link_stop - purge all inbound and outbound messages associated with link * tipc_link_stop - purge all inbound and outbound messages associated with link
* @l_ptr: pointer to link * @l_ptr: pointer to link
*/ */
...@@ -665,7 +665,7 @@ static void link_send_event(void (*fcn)(u32 a, char *n, int up), ...@@ -665,7 +665,7 @@ static void link_send_event(void (*fcn)(u32 a, char *n, int up),
struct link *l_ptr, int up) struct link *l_ptr, int up)
{ {
struct link_event *ev; struct link_event *ev;
ev = kmalloc(sizeof(*ev), GFP_ATOMIC); ev = kmalloc(sizeof(*ev), GFP_ATOMIC);
if (!ev) { if (!ev) {
warn("Link event allocation failure\n"); warn("Link event allocation failure\n");
...@@ -690,15 +690,15 @@ void tipc_link_reset(struct link *l_ptr) ...@@ -690,15 +690,15 @@ void tipc_link_reset(struct link *l_ptr)
u32 prev_state = l_ptr->state; u32 prev_state = l_ptr->state;
u32 checkpoint = l_ptr->next_in_no; u32 checkpoint = l_ptr->next_in_no;
int was_active_link = tipc_link_is_active(l_ptr); int was_active_link = tipc_link_is_active(l_ptr);
msg_set_session(l_ptr->pmsg, msg_session(l_ptr->pmsg) + 1); msg_set_session(l_ptr->pmsg, msg_session(l_ptr->pmsg) + 1);
/* Link is down, accept any session: */ /* Link is down, accept any session: */
l_ptr->peer_session = 0; l_ptr->peer_session = 0;
/* Prepare for max packet size negotiation */ /* Prepare for max packet size negotiation */
link_init_max_pkt(l_ptr); link_init_max_pkt(l_ptr);
l_ptr->state = RESET_UNKNOWN; l_ptr->state = RESET_UNKNOWN;
dbg_link_state("Resetting Link\n"); dbg_link_state("Resetting Link\n");
...@@ -770,7 +770,7 @@ static void link_activate(struct link *l_ptr) ...@@ -770,7 +770,7 @@ static void link_activate(struct link *l_ptr)
static void link_state_event(struct link *l_ptr, unsigned event) static void link_state_event(struct link *l_ptr, unsigned event)
{ {
struct link *other; struct link *other;
u32 cont_intv = l_ptr->continuity_interval; u32 cont_intv = l_ptr->continuity_interval;
if (!l_ptr->started && (event != STARTING_EVT)) if (!l_ptr->started && (event != STARTING_EVT))
...@@ -799,11 +799,11 @@ static void link_state_event(struct link *l_ptr, unsigned event) ...@@ -799,11 +799,11 @@ static void link_state_event(struct link *l_ptr, unsigned event)
if (l_ptr->next_in_no != l_ptr->checkpoint) { if (l_ptr->next_in_no != l_ptr->checkpoint) {
l_ptr->checkpoint = l_ptr->next_in_no; l_ptr->checkpoint = l_ptr->next_in_no;
if (tipc_bclink_acks_missing(l_ptr->owner)) { if (tipc_bclink_acks_missing(l_ptr->owner)) {
tipc_link_send_proto_msg(l_ptr, STATE_MSG, tipc_link_send_proto_msg(l_ptr, STATE_MSG,
0, 0, 0, 0, 0); 0, 0, 0, 0, 0);
l_ptr->fsm_msg_cnt++; l_ptr->fsm_msg_cnt++;
} else if (l_ptr->max_pkt < l_ptr->max_pkt_target) { } else if (l_ptr->max_pkt < l_ptr->max_pkt_target) {
tipc_link_send_proto_msg(l_ptr, STATE_MSG, tipc_link_send_proto_msg(l_ptr, STATE_MSG,
1, 0, 0, 0, 0); 1, 0, 0, 0, 0);
l_ptr->fsm_msg_cnt++; l_ptr->fsm_msg_cnt++;
} }
...@@ -819,7 +819,7 @@ static void link_state_event(struct link *l_ptr, unsigned event) ...@@ -819,7 +819,7 @@ static void link_state_event(struct link *l_ptr, unsigned event)
break; break;
case RESET_MSG: case RESET_MSG:
dbg_link("RES -> RR\n"); dbg_link("RES -> RR\n");
info("Resetting link <%s>, requested by peer\n", info("Resetting link <%s>, requested by peer\n",
l_ptr->name); l_ptr->name);
tipc_link_reset(l_ptr); tipc_link_reset(l_ptr);
l_ptr->state = RESET_RESET; l_ptr->state = RESET_RESET;
...@@ -871,7 +871,7 @@ static void link_state_event(struct link *l_ptr, unsigned event) ...@@ -871,7 +871,7 @@ static void link_state_event(struct link *l_ptr, unsigned event)
dbg_link("Probing %u/%u,timer = %u ms)\n", dbg_link("Probing %u/%u,timer = %u ms)\n",
l_ptr->fsm_msg_cnt, l_ptr->abort_limit, l_ptr->fsm_msg_cnt, l_ptr->abort_limit,
cont_intv / 4); cont_intv / 4);
tipc_link_send_proto_msg(l_ptr, STATE_MSG, tipc_link_send_proto_msg(l_ptr, STATE_MSG,
1, 0, 0, 0, 0); 1, 0, 0, 0, 0);
l_ptr->fsm_msg_cnt++; l_ptr->fsm_msg_cnt++;
link_set_timer(l_ptr, cont_intv / 4); link_set_timer(l_ptr, cont_intv / 4);
...@@ -977,11 +977,11 @@ static void link_state_event(struct link *l_ptr, unsigned event) ...@@ -977,11 +977,11 @@ static void link_state_event(struct link *l_ptr, unsigned event)
/* /*
* link_bundle_buf(): Append contents of a buffer to * link_bundle_buf(): Append contents of a buffer to
* the tail of an existing one. * the tail of an existing one.
*/ */
static int link_bundle_buf(struct link *l_ptr, static int link_bundle_buf(struct link *l_ptr,
struct sk_buff *bundler, struct sk_buff *bundler,
struct sk_buff *buf) struct sk_buff *buf)
{ {
struct tipc_msg *bundler_msg = buf_msg(bundler); struct tipc_msg *bundler_msg = buf_msg(bundler);
...@@ -1030,8 +1030,8 @@ static void link_add_to_outqueue(struct link *l_ptr, ...@@ -1030,8 +1030,8 @@ static void link_add_to_outqueue(struct link *l_ptr,
l_ptr->out_queue_size++; l_ptr->out_queue_size++;
} }
/* /*
* tipc_link_send_buf() is the 'full path' for messages, called from * tipc_link_send_buf() is the 'full path' for messages, called from
* inside TIPC when the 'fast path' in tipc_send_buf * inside TIPC when the 'fast path' in tipc_send_buf
* has failed, and from link_send() * has failed, and from link_send()
*/ */
...@@ -1074,7 +1074,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf) ...@@ -1074,7 +1074,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
if (queue_size > l_ptr->stats.max_queue_sz) if (queue_size > l_ptr->stats.max_queue_sz)
l_ptr->stats.max_queue_sz = queue_size; l_ptr->stats.max_queue_sz = queue_size;
if (likely(!tipc_bearer_congested(l_ptr->b_ptr, l_ptr) && if (likely(!tipc_bearer_congested(l_ptr->b_ptr, l_ptr) &&
!link_congested(l_ptr))) { !link_congested(l_ptr))) {
link_add_to_outqueue(l_ptr, buf, msg); link_add_to_outqueue(l_ptr, buf, msg);
...@@ -1094,7 +1094,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf) ...@@ -1094,7 +1094,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
/* Try adding message to an existing bundle */ /* Try adding message to an existing bundle */
if (l_ptr->next_out && if (l_ptr->next_out &&
link_bundle_buf(l_ptr, l_ptr->last_out, buf)) { link_bundle_buf(l_ptr, l_ptr->last_out, buf)) {
tipc_bearer_resolve_congestion(l_ptr->b_ptr, l_ptr); tipc_bearer_resolve_congestion(l_ptr->b_ptr, l_ptr);
return dsz; return dsz;
...@@ -1109,7 +1109,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf) ...@@ -1109,7 +1109,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
if (bundler) { if (bundler) {
msg_init(&bundler_hdr, MSG_BUNDLER, OPEN_MSG, msg_init(&bundler_hdr, MSG_BUNDLER, OPEN_MSG,
TIPC_OK, INT_H_SIZE, l_ptr->addr); TIPC_OK, INT_H_SIZE, l_ptr->addr);
memcpy(bundler->data, (unchar *)&bundler_hdr, memcpy(bundler->data, (unchar *)&bundler_hdr,
INT_H_SIZE); INT_H_SIZE);
skb_trim(bundler, INT_H_SIZE); skb_trim(bundler, INT_H_SIZE);
link_bundle_buf(l_ptr, bundler, buf); link_bundle_buf(l_ptr, bundler, buf);
...@@ -1126,8 +1126,8 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf) ...@@ -1126,8 +1126,8 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf)
return dsz; return dsz;
} }
/* /*
* tipc_link_send(): same as tipc_link_send_buf(), but the link to use has * tipc_link_send(): same as tipc_link_send_buf(), but the link to use has
* not been selected yet, and the the owner node is not locked * not been selected yet, and the the owner node is not locked
* Called by TIPC internal users, e.g. the name distributor * Called by TIPC internal users, e.g. the name distributor
*/ */
...@@ -1161,8 +1161,8 @@ int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) ...@@ -1161,8 +1161,8 @@ int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector)
return res; return res;
} }
/* /*
* link_send_buf_fast: Entry for data messages where the * link_send_buf_fast: Entry for data messages where the
* destination link is known and the header is complete, * destination link is known and the header is complete,
* inclusive total message length. Very time critical. * inclusive total message length. Very time critical.
* Link is locked. Returns user data length. * Link is locked. Returns user data length.
...@@ -1197,8 +1197,8 @@ static int link_send_buf_fast(struct link *l_ptr, struct sk_buff *buf, ...@@ -1197,8 +1197,8 @@ static int link_send_buf_fast(struct link *l_ptr, struct sk_buff *buf,
return tipc_link_send_buf(l_ptr, buf); /* All other cases */ return tipc_link_send_buf(l_ptr, buf); /* All other cases */
} }
/* /*
* tipc_send_buf_fast: Entry for data messages where the * tipc_send_buf_fast: Entry for data messages where the
* destination node is known and the header is complete, * destination node is known and the header is complete,
* inclusive total message length. * inclusive total message length.
* Returns user data length. * Returns user data length.
...@@ -1236,15 +1236,15 @@ int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode) ...@@ -1236,15 +1236,15 @@ int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode)
} }
/* /*
* tipc_link_send_sections_fast: Entry for messages where the * tipc_link_send_sections_fast: Entry for messages where the
* destination processor is known and the header is complete, * destination processor is known and the header is complete,
* except for total message length. * except for total message length.
* Returns user data length or errno. * Returns user data length or errno.
*/ */
int tipc_link_send_sections_fast(struct port *sender, int tipc_link_send_sections_fast(struct port *sender,
struct iovec const *msg_sect, struct iovec const *msg_sect,
const u32 num_sect, const u32 num_sect,
u32 destaddr) u32 destaddr)
{ {
struct tipc_msg *hdr = &sender->publ.phdr; struct tipc_msg *hdr = &sender->publ.phdr;
...@@ -1287,14 +1287,14 @@ int tipc_link_send_sections_fast(struct port *sender, ...@@ -1287,14 +1287,14 @@ int tipc_link_send_sections_fast(struct port *sender,
/* Exit if link (or bearer) is congested */ /* Exit if link (or bearer) is congested */
if (link_congested(l_ptr) || if (link_congested(l_ptr) ||
!list_empty(&l_ptr->b_ptr->cong_links)) { !list_empty(&l_ptr->b_ptr->cong_links)) {
res = link_schedule_port(l_ptr, res = link_schedule_port(l_ptr,
sender->publ.ref, res); sender->publ.ref, res);
goto exit; goto exit;
} }
/* /*
* Message size exceeds max_pkt hint; update hint, * Message size exceeds max_pkt hint; update hint,
* then re-try fast path or fragment the message * then re-try fast path or fragment the message
*/ */
...@@ -1324,10 +1324,10 @@ int tipc_link_send_sections_fast(struct port *sender, ...@@ -1324,10 +1324,10 @@ int tipc_link_send_sections_fast(struct port *sender,
return res; return res;
} }
/* /*
* link_send_sections_long(): Entry for long messages where the * link_send_sections_long(): Entry for long messages where the
* destination node is known and the header is complete, * destination node is known and the header is complete,
* inclusive total message length. * inclusive total message length.
* Link and bearer congestion status have been checked to be ok, * Link and bearer congestion status have been checked to be ok,
* and are ignored if they change. * and are ignored if they change.
* *
...@@ -1357,9 +1357,9 @@ static int link_send_sections_long(struct port *sender, ...@@ -1357,9 +1357,9 @@ static int link_send_sections_long(struct port *sender,
again: again:
fragm_no = 1; fragm_no = 1;
max_pkt = sender->max_pkt - INT_H_SIZE; max_pkt = sender->max_pkt - INT_H_SIZE;
/* leave room for tunnel header in case of link changeover */ /* leave room for tunnel header in case of link changeover */
fragm_sz = max_pkt - INT_H_SIZE; fragm_sz = max_pkt - INT_H_SIZE;
/* leave room for fragmentation header in each fragment */ /* leave room for fragmentation header in each fragment */
rest = dsz; rest = dsz;
fragm_crs = 0; fragm_crs = 0;
...@@ -1440,7 +1440,7 @@ static int link_send_sections_long(struct port *sender, ...@@ -1440,7 +1440,7 @@ static int link_send_sections_long(struct port *sender,
if (!buf) if (!buf)
goto error; goto error;
buf->next = NULL; buf->next = NULL;
prev->next = buf; prev->next = buf;
memcpy(buf->data, (unchar *)&fragm_hdr, INT_H_SIZE); memcpy(buf->data, (unchar *)&fragm_hdr, INT_H_SIZE);
fragm_crs = INT_H_SIZE; fragm_crs = INT_H_SIZE;
...@@ -1450,7 +1450,7 @@ static int link_send_sections_long(struct port *sender, ...@@ -1450,7 +1450,7 @@ static int link_send_sections_long(struct port *sender,
} }
while (rest > 0); while (rest > 0);
/* /*
* Now we have a buffer chain. Select a link and check * Now we have a buffer chain. Select a link and check
* that packet size is still OK * that packet size is still OK
*/ */
...@@ -1506,7 +1506,7 @@ static int link_send_sections_long(struct port *sender, ...@@ -1506,7 +1506,7 @@ static int link_send_sections_long(struct port *sender,
return dsz; return dsz;
} }
/* /*
* tipc_link_push_packet: Push one unsent packet to the media * tipc_link_push_packet: Push one unsent packet to the media
*/ */
u32 tipc_link_push_packet(struct link *l_ptr) u32 tipc_link_push_packet(struct link *l_ptr)
...@@ -1519,7 +1519,7 @@ u32 tipc_link_push_packet(struct link *l_ptr) ...@@ -1519,7 +1519,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
/* consider that buffers may have been released in meantime */ /* consider that buffers may have been released in meantime */
if (r_q_size && buf) { if (r_q_size && buf) {
u32 last = lesser(mod(r_q_head + r_q_size), u32 last = lesser(mod(r_q_head + r_q_size),
link_last_sent(l_ptr)); link_last_sent(l_ptr));
u32 first = msg_seqno(buf_msg(buf)); u32 first = msg_seqno(buf_msg(buf));
...@@ -1535,7 +1535,7 @@ u32 tipc_link_push_packet(struct link *l_ptr) ...@@ -1535,7 +1535,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
if (r_q_size && buf && !skb_cloned(buf)) { if (r_q_size && buf && !skb_cloned(buf)) {
msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1)); msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1));
msg_set_bcast_ack(buf_msg(buf), l_ptr->owner->bclink.last_in); msg_set_bcast_ack(buf_msg(buf), l_ptr->owner->bclink.last_in);
if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
msg_dbg(buf_msg(buf), ">DEF-RETR>"); msg_dbg(buf_msg(buf), ">DEF-RETR>");
l_ptr->retransm_queue_head = mod(++r_q_head); l_ptr->retransm_queue_head = mod(++r_q_head);
...@@ -1554,7 +1554,7 @@ u32 tipc_link_push_packet(struct link *l_ptr) ...@@ -1554,7 +1554,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
buf = l_ptr->proto_msg_queue; buf = l_ptr->proto_msg_queue;
if (buf) { if (buf) {
msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1)); msg_set_ack(buf_msg(buf), mod(l_ptr->next_in_no - 1));
msg_set_bcast_ack(buf_msg(buf),l_ptr->owner->bclink.last_in); msg_set_bcast_ack(buf_msg(buf),l_ptr->owner->bclink.last_in);
if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
msg_dbg(buf_msg(buf), ">DEF-PROT>"); msg_dbg(buf_msg(buf), ">DEF-PROT>");
l_ptr->unacked_window = 0; l_ptr->unacked_window = 0;
...@@ -1578,7 +1578,7 @@ u32 tipc_link_push_packet(struct link *l_ptr) ...@@ -1578,7 +1578,7 @@ u32 tipc_link_push_packet(struct link *l_ptr)
if (mod(next - first) < l_ptr->queue_limit[0]) { if (mod(next - first) < l_ptr->queue_limit[0]) {
msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); msg_set_ack(msg, mod(l_ptr->next_in_no - 1));
msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in);
if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
if (msg_user(msg) == MSG_BUNDLER) if (msg_user(msg) == MSG_BUNDLER)
msg_set_type(msg, CLOSED_MSG); msg_set_type(msg, CLOSED_MSG);
...@@ -1629,12 +1629,12 @@ static void link_reset_all(unsigned long addr) ...@@ -1629,12 +1629,12 @@ static void link_reset_all(unsigned long addr)
tipc_node_lock(n_ptr); tipc_node_lock(n_ptr);
warn("Resetting all links to %s\n", warn("Resetting all links to %s\n",
addr_string_fill(addr_string, n_ptr->addr)); addr_string_fill(addr_string, n_ptr->addr));
for (i = 0; i < MAX_BEARERS; i++) { for (i = 0; i < MAX_BEARERS; i++) {
if (n_ptr->links[i]) { if (n_ptr->links[i]) {
link_print(n_ptr->links[i], TIPC_OUTPUT, link_print(n_ptr->links[i], TIPC_OUTPUT,
"Resetting link\n"); "Resetting link\n");
tipc_link_reset(n_ptr->links[i]); tipc_link_reset(n_ptr->links[i]);
} }
...@@ -1689,7 +1689,7 @@ static void link_retransmit_failure(struct link *l_ptr, struct sk_buff *buf) ...@@ -1689,7 +1689,7 @@ static void link_retransmit_failure(struct link *l_ptr, struct sk_buff *buf)
} }
} }
void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf, void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
u32 retransmits) u32 retransmits)
{ {
struct tipc_msg *msg; struct tipc_msg *msg;
...@@ -1698,7 +1698,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf, ...@@ -1698,7 +1698,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
return; return;
msg = buf_msg(buf); msg = buf_msg(buf);
dbg("Retransmitting %u in link %x\n", retransmits, l_ptr); dbg("Retransmitting %u in link %x\n", retransmits, l_ptr);
if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) { if (tipc_bearer_congested(l_ptr->b_ptr, l_ptr)) {
...@@ -1728,7 +1728,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf, ...@@ -1728,7 +1728,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
while (retransmits && (buf != l_ptr->next_out) && buf && !skb_cloned(buf)) { while (retransmits && (buf != l_ptr->next_out) && buf && !skb_cloned(buf)) {
msg = buf_msg(buf); msg = buf_msg(buf);
msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); msg_set_ack(msg, mod(l_ptr->next_in_no - 1));
msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in);
if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
msg_dbg(buf_msg(buf), ">RETR>"); msg_dbg(buf_msg(buf), ">RETR>");
buf = buf->next; buf = buf->next;
...@@ -1746,7 +1746,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf, ...@@ -1746,7 +1746,7 @@ void tipc_link_retransmit(struct link *l_ptr, struct sk_buff *buf,
l_ptr->retransm_queue_head = l_ptr->retransm_queue_size = 0; l_ptr->retransm_queue_head = l_ptr->retransm_queue_size = 0;
} }
/* /*
* link_recv_non_seq: Receive packets which are outside * link_recv_non_seq: Receive packets which are outside
* the link sequence flow * the link sequence flow
*/ */
...@@ -1761,11 +1761,11 @@ static void link_recv_non_seq(struct sk_buff *buf) ...@@ -1761,11 +1761,11 @@ static void link_recv_non_seq(struct sk_buff *buf)
tipc_bclink_recv_pkt(buf); tipc_bclink_recv_pkt(buf);
} }
/** /**
* link_insert_deferred_queue - insert deferred messages back into receive chain * link_insert_deferred_queue - insert deferred messages back into receive chain
*/ */
static struct sk_buff *link_insert_deferred_queue(struct link *l_ptr, static struct sk_buff *link_insert_deferred_queue(struct link *l_ptr,
struct sk_buff *buf) struct sk_buff *buf)
{ {
u32 seq_no; u32 seq_no;
...@@ -1813,11 +1813,11 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) ...@@ -1813,11 +1813,11 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
link_recv_non_seq(buf); link_recv_non_seq(buf);
continue; continue;
} }
if (unlikely(!msg_short(msg) && if (unlikely(!msg_short(msg) &&
(msg_destnode(msg) != tipc_own_addr))) (msg_destnode(msg) != tipc_own_addr)))
goto cont; goto cont;
n_ptr = tipc_node_find(msg_prevnode(msg)); n_ptr = tipc_node_find(msg_prevnode(msg));
if (unlikely(!n_ptr)) if (unlikely(!n_ptr))
goto cont; goto cont;
...@@ -1828,8 +1828,8 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) ...@@ -1828,8 +1828,8 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
tipc_node_unlock(n_ptr); tipc_node_unlock(n_ptr);
goto cont; goto cont;
} }
/* /*
* Release acked messages * Release acked messages
*/ */
if (less(n_ptr->bclink.acked, msg_bcast_ack(msg))) { if (less(n_ptr->bclink.acked, msg_bcast_ack(msg))) {
if (tipc_node_is_up(n_ptr) && n_ptr->bclink.supported) if (tipc_node_is_up(n_ptr) && n_ptr->bclink.supported)
...@@ -1837,7 +1837,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) ...@@ -1837,7 +1837,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
} }
crs = l_ptr->first_out; crs = l_ptr->first_out;
while ((crs != l_ptr->next_out) && while ((crs != l_ptr->next_out) &&
less_eq(msg_seqno(buf_msg(crs)), ackd)) { less_eq(msg_seqno(buf_msg(crs)), ackd)) {
struct sk_buff *next = crs->next; struct sk_buff *next = crs->next;
...@@ -1875,7 +1875,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) ...@@ -1875,7 +1875,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
switch (msg_user(msg)) { switch (msg_user(msg)) {
case MSG_BUNDLER: case MSG_BUNDLER:
l_ptr->stats.recv_bundles++; l_ptr->stats.recv_bundles++;
l_ptr->stats.recv_bundled += l_ptr->stats.recv_bundled +=
msg_msgcnt(msg); msg_msgcnt(msg);
tipc_node_unlock(n_ptr); tipc_node_unlock(n_ptr);
tipc_link_recv_bundle(buf); tipc_link_recv_bundle(buf);
...@@ -1894,7 +1894,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) ...@@ -1894,7 +1894,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
continue; continue;
case MSG_FRAGMENTER: case MSG_FRAGMENTER:
l_ptr->stats.recv_fragments++; l_ptr->stats.recv_fragments++;
if (tipc_link_recv_fragment(&l_ptr->defragm_buf, if (tipc_link_recv_fragment(&l_ptr->defragm_buf,
&buf, &msg)) { &buf, &msg)) {
l_ptr->stats.recv_fragmented++; l_ptr->stats.recv_fragmented++;
goto deliver; goto deliver;
...@@ -1905,7 +1905,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) ...@@ -1905,7 +1905,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
if (link_recv_changeover_msg(&l_ptr, &buf)) { if (link_recv_changeover_msg(&l_ptr, &buf)) {
msg = buf_msg(buf); msg = buf_msg(buf);
seq_no = msg_seqno(msg); seq_no = msg_seqno(msg);
TIPC_SKB_CB(buf)->handle TIPC_SKB_CB(buf)->handle
= b_ptr; = b_ptr;
if (type == ORIGINAL_MSG) if (type == ORIGINAL_MSG)
goto deliver; goto deliver;
...@@ -1948,8 +1948,8 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) ...@@ -1948,8 +1948,8 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr)
read_unlock_bh(&tipc_net_lock); read_unlock_bh(&tipc_net_lock);
} }
/* /*
* link_defer_buf(): Sort a received out-of-sequence packet * link_defer_buf(): Sort a received out-of-sequence packet
* into the deferred reception queue. * into the deferred reception queue.
* Returns the increase of the queue length,i.e. 0 or 1 * Returns the increase of the queue length,i.e. 0 or 1
*/ */
...@@ -1986,7 +1986,7 @@ u32 tipc_link_defer_pkt(struct sk_buff **head, ...@@ -1986,7 +1986,7 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
if (prev) if (prev)
prev->next = buf; prev->next = buf;
else else
*head = buf; *head = buf;
return 1; return 1;
} }
if (seq_no == msg_seqno(msg)) { if (seq_no == msg_seqno(msg)) {
...@@ -2003,11 +2003,11 @@ u32 tipc_link_defer_pkt(struct sk_buff **head, ...@@ -2003,11 +2003,11 @@ u32 tipc_link_defer_pkt(struct sk_buff **head,
return 0; return 0;
} }
/** /**
* link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet * link_handle_out_of_seq_msg - handle arrival of out-of-sequence packet
*/ */
static void link_handle_out_of_seq_msg(struct link *l_ptr, static void link_handle_out_of_seq_msg(struct link *l_ptr,
struct sk_buff *buf) struct sk_buff *buf)
{ {
u32 seq_no = msg_seqno(buf_msg(buf)); u32 seq_no = msg_seqno(buf_msg(buf));
...@@ -2017,14 +2017,14 @@ static void link_handle_out_of_seq_msg(struct link *l_ptr, ...@@ -2017,14 +2017,14 @@ static void link_handle_out_of_seq_msg(struct link *l_ptr,
return; return;
} }
dbg("rx OOS msg: seq_no %u, expecting %u (%u)\n", dbg("rx OOS msg: seq_no %u, expecting %u (%u)\n",
seq_no, mod(l_ptr->next_in_no), l_ptr->next_in_no); seq_no, mod(l_ptr->next_in_no), l_ptr->next_in_no);
/* Record OOS packet arrival (force mismatch on next timeout) */ /* Record OOS packet arrival (force mismatch on next timeout) */
l_ptr->checkpoint--; l_ptr->checkpoint--;
/* /*
* Discard packet if a duplicate; otherwise add it to deferred queue * Discard packet if a duplicate; otherwise add it to deferred queue
* and notify peer of gap as per protocol specification * and notify peer of gap as per protocol specification
*/ */
...@@ -2053,13 +2053,13 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg, ...@@ -2053,13 +2053,13 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
{ {
struct sk_buff *buf = NULL; struct sk_buff *buf = NULL;
struct tipc_msg *msg = l_ptr->pmsg; struct tipc_msg *msg = l_ptr->pmsg;
u32 msg_size = sizeof(l_ptr->proto_msg); u32 msg_size = sizeof(l_ptr->proto_msg);
if (link_blocked(l_ptr)) if (link_blocked(l_ptr))
return; return;
msg_set_type(msg, msg_typ); msg_set_type(msg, msg_typ);
msg_set_net_plane(msg, l_ptr->b_ptr->net_plane); msg_set_net_plane(msg, l_ptr->b_ptr->net_plane);
msg_set_bcast_ack(msg, mod(l_ptr->owner->bclink.last_in)); msg_set_bcast_ack(msg, mod(l_ptr->owner->bclink.last_in));
msg_set_last_bcast(msg, tipc_bclink_get_last_sent()); msg_set_last_bcast(msg, tipc_bclink_get_last_sent());
if (msg_typ == STATE_MSG) { if (msg_typ == STATE_MSG) {
...@@ -2082,23 +2082,23 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg, ...@@ -2082,23 +2082,23 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
msg_set_max_pkt(msg, ack_mtu); msg_set_max_pkt(msg, ack_mtu);
msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); msg_set_ack(msg, mod(l_ptr->next_in_no - 1));
msg_set_probe(msg, probe_msg != 0); msg_set_probe(msg, probe_msg != 0);
if (probe_msg) { if (probe_msg) {
u32 mtu = l_ptr->max_pkt; u32 mtu = l_ptr->max_pkt;
if ((mtu < l_ptr->max_pkt_target) && if ((mtu < l_ptr->max_pkt_target) &&
link_working_working(l_ptr) && link_working_working(l_ptr) &&
l_ptr->fsm_msg_cnt) { l_ptr->fsm_msg_cnt) {
msg_size = (mtu + (l_ptr->max_pkt_target - mtu)/2 + 2) & ~3; msg_size = (mtu + (l_ptr->max_pkt_target - mtu)/2 + 2) & ~3;
if (l_ptr->max_pkt_probes == 10) { if (l_ptr->max_pkt_probes == 10) {
l_ptr->max_pkt_target = (msg_size - 4); l_ptr->max_pkt_target = (msg_size - 4);
l_ptr->max_pkt_probes = 0; l_ptr->max_pkt_probes = 0;
msg_size = (mtu + (l_ptr->max_pkt_target - mtu)/2 + 2) & ~3; msg_size = (mtu + (l_ptr->max_pkt_target - mtu)/2 + 2) & ~3;
} }
l_ptr->max_pkt_probes++; l_ptr->max_pkt_probes++;
} }
l_ptr->stats.sent_probes++; l_ptr->stats.sent_probes++;
} }
l_ptr->stats.sent_states++; l_ptr->stats.sent_states++;
} else { /* RESET_MSG or ACTIVATE_MSG */ } else { /* RESET_MSG or ACTIVATE_MSG */
msg_set_ack(msg, mod(l_ptr->reset_checkpoint - 1)); msg_set_ack(msg, mod(l_ptr->reset_checkpoint - 1));
...@@ -2144,7 +2144,7 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg, ...@@ -2144,7 +2144,7 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
return; return;
memcpy(buf->data, (unchar *)msg, sizeof(l_ptr->proto_msg)); memcpy(buf->data, (unchar *)msg, sizeof(l_ptr->proto_msg));
msg_set_size(buf_msg(buf), msg_size); msg_set_size(buf_msg(buf), msg_size);
if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) { if (tipc_bearer_send(l_ptr->b_ptr, buf, &l_ptr->media_addr)) {
l_ptr->unacked_window = 0; l_ptr->unacked_window = 0;
...@@ -2160,15 +2160,15 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg, ...@@ -2160,15 +2160,15 @@ void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int probe_msg,
/* /*
* Receive protocol message : * Receive protocol message :
* Note that network plane id propagates through the network, and may * Note that network plane id propagates through the network, and may
* change at any time. The node with lowest address rules * change at any time. The node with lowest address rules
*/ */
static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf) static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
{ {
u32 rec_gap = 0; u32 rec_gap = 0;
u32 max_pkt_info; u32 max_pkt_info;
u32 max_pkt_ack; u32 max_pkt_ack;
u32 msg_tol; u32 msg_tol;
struct tipc_msg *msg = buf_msg(buf); struct tipc_msg *msg = buf_msg(buf);
...@@ -2188,12 +2188,12 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf) ...@@ -2188,12 +2188,12 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
l_ptr->owner->permit_changeover = msg_redundant_link(msg); l_ptr->owner->permit_changeover = msg_redundant_link(msg);
switch (msg_type(msg)) { switch (msg_type(msg)) {
case RESET_MSG: case RESET_MSG:
if (!link_working_unknown(l_ptr) && l_ptr->peer_session) { if (!link_working_unknown(l_ptr) && l_ptr->peer_session) {
if (msg_session(msg) == l_ptr->peer_session) { if (msg_session(msg) == l_ptr->peer_session) {
dbg("Duplicate RESET: %u<->%u\n", dbg("Duplicate RESET: %u<->%u\n",
msg_session(msg), l_ptr->peer_session); msg_session(msg), l_ptr->peer_session);
break; /* duplicate: ignore */ break; /* duplicate: ignore */
} }
} }
...@@ -2211,13 +2211,13 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf) ...@@ -2211,13 +2211,13 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
l_ptr->priority = msg_linkprio(msg); l_ptr->priority = msg_linkprio(msg);
max_pkt_info = msg_max_pkt(msg); max_pkt_info = msg_max_pkt(msg);
if (max_pkt_info) { if (max_pkt_info) {
if (max_pkt_info < l_ptr->max_pkt_target) if (max_pkt_info < l_ptr->max_pkt_target)
l_ptr->max_pkt_target = max_pkt_info; l_ptr->max_pkt_target = max_pkt_info;
if (l_ptr->max_pkt > l_ptr->max_pkt_target) if (l_ptr->max_pkt > l_ptr->max_pkt_target)
l_ptr->max_pkt = l_ptr->max_pkt_target; l_ptr->max_pkt = l_ptr->max_pkt_target;
} else { } else {
l_ptr->max_pkt = l_ptr->max_pkt_target; l_ptr->max_pkt = l_ptr->max_pkt_target;
} }
l_ptr->owner->bclink.supported = (max_pkt_info != 0); l_ptr->owner->bclink.supported = (max_pkt_info != 0);
...@@ -2235,8 +2235,8 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf) ...@@ -2235,8 +2235,8 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
if ((msg_tol = msg_link_tolerance(msg))) if ((msg_tol = msg_link_tolerance(msg)))
link_set_supervision_props(l_ptr, msg_tol); link_set_supervision_props(l_ptr, msg_tol);
if (msg_linkprio(msg) && if (msg_linkprio(msg) &&
(msg_linkprio(msg) != l_ptr->priority)) { (msg_linkprio(msg) != l_ptr->priority)) {
warn("Resetting link <%s>, priority change %u->%u\n", warn("Resetting link <%s>, priority change %u->%u\n",
l_ptr->name, l_ptr->priority, msg_linkprio(msg)); l_ptr->name, l_ptr->priority, msg_linkprio(msg));
...@@ -2250,25 +2250,25 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf) ...@@ -2250,25 +2250,25 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
break; break;
if (less_eq(mod(l_ptr->next_in_no), msg_next_sent(msg))) { if (less_eq(mod(l_ptr->next_in_no), msg_next_sent(msg))) {
rec_gap = mod(msg_next_sent(msg) - rec_gap = mod(msg_next_sent(msg) -
mod(l_ptr->next_in_no)); mod(l_ptr->next_in_no));
} }
max_pkt_ack = msg_max_pkt(msg); max_pkt_ack = msg_max_pkt(msg);
if (max_pkt_ack > l_ptr->max_pkt) { if (max_pkt_ack > l_ptr->max_pkt) {
dbg("Link <%s> updated MTU %u -> %u\n", dbg("Link <%s> updated MTU %u -> %u\n",
l_ptr->name, l_ptr->max_pkt, max_pkt_ack); l_ptr->name, l_ptr->max_pkt, max_pkt_ack);
l_ptr->max_pkt = max_pkt_ack; l_ptr->max_pkt = max_pkt_ack;
l_ptr->max_pkt_probes = 0; l_ptr->max_pkt_probes = 0;
} }
max_pkt_ack = 0; max_pkt_ack = 0;
if (msg_probe(msg)) { if (msg_probe(msg)) {
l_ptr->stats.recv_probes++; l_ptr->stats.recv_probes++;
if (msg_size(msg) > sizeof(l_ptr->proto_msg)) { if (msg_size(msg) > sizeof(l_ptr->proto_msg)) {
max_pkt_ack = msg_size(msg); max_pkt_ack = msg_size(msg);
} }
} }
/* Protocol message before retransmits, reduce loss risk */ /* Protocol message before retransmits, reduce loss risk */
...@@ -2294,11 +2294,11 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf) ...@@ -2294,11 +2294,11 @@ static void link_recv_proto_msg(struct link *l_ptr, struct sk_buff *buf)
/* /*
* tipc_link_tunnel(): Send one message via a link belonging to * tipc_link_tunnel(): Send one message via a link belonging to
* another bearer. Owner node is locked. * another bearer. Owner node is locked.
*/ */
void tipc_link_tunnel(struct link *l_ptr, void tipc_link_tunnel(struct link *l_ptr,
struct tipc_msg *tunnel_hdr, struct tipc_msg *tunnel_hdr,
struct tipc_msg *msg, struct tipc_msg *msg,
u32 selector) u32 selector)
{ {
...@@ -2374,7 +2374,7 @@ void tipc_link_changeover(struct link *l_ptr) ...@@ -2374,7 +2374,7 @@ void tipc_link_changeover(struct link *l_ptr)
return; return;
} }
split_bundles = (l_ptr->owner->active_links[0] != split_bundles = (l_ptr->owner->active_links[0] !=
l_ptr->owner->active_links[1]); l_ptr->owner->active_links[1]);
while (crs) { while (crs) {
...@@ -2418,7 +2418,7 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel) ...@@ -2418,7 +2418,7 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel)
if (msg_user(msg) == MSG_BUNDLER) if (msg_user(msg) == MSG_BUNDLER)
msg_set_type(msg, CLOSED_MSG); msg_set_type(msg, CLOSED_MSG);
msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); /* Update */ msg_set_ack(msg, mod(l_ptr->next_in_no - 1)); /* Update */
msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in);
msg_set_size(&tunnel_hdr, length + INT_H_SIZE); msg_set_size(&tunnel_hdr, length + INT_H_SIZE);
outbuf = buf_acquire(length + INT_H_SIZE); outbuf = buf_acquire(length + INT_H_SIZE);
if (outbuf == NULL) { if (outbuf == NULL) {
...@@ -2445,7 +2445,7 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel) ...@@ -2445,7 +2445,7 @@ void tipc_link_send_duplicate(struct link *l_ptr, struct link *tunnel)
* @skb: encapsulating message buffer * @skb: encapsulating message buffer
* @from_pos: offset to extract from * @from_pos: offset to extract from
* *
* Returns a new message buffer containing an embedded message. The * Returns a new message buffer containing an embedded message. The
* encapsulating message itself is left unchanged. * encapsulating message itself is left unchanged.
*/ */
...@@ -2461,7 +2461,7 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos) ...@@ -2461,7 +2461,7 @@ static struct sk_buff *buf_extract(struct sk_buff *skb, u32 from_pos)
return eb; return eb;
} }
/* /*
* link_recv_changeover_msg(): Receive tunneled packet sent * link_recv_changeover_msg(): Receive tunneled packet sent
* via other link. Node is locked. Return extracted buffer. * via other link. Node is locked. Return extracted buffer.
*/ */
...@@ -2482,7 +2482,7 @@ static int link_recv_changeover_msg(struct link **l_ptr, ...@@ -2482,7 +2482,7 @@ static int link_recv_changeover_msg(struct link **l_ptr,
goto exit; goto exit;
} }
if (dest_link == *l_ptr) { if (dest_link == *l_ptr) {
err("Unexpected changeover message on link <%s>\n", err("Unexpected changeover message on link <%s>\n",
(*l_ptr)->name); (*l_ptr)->name);
goto exit; goto exit;
} }
...@@ -2582,9 +2582,9 @@ void tipc_link_recv_bundle(struct sk_buff *buf) ...@@ -2582,9 +2582,9 @@ void tipc_link_recv_bundle(struct sk_buff *buf)
*/ */
/* /*
* tipc_link_send_long_buf: Entry for buffers needing fragmentation. * tipc_link_send_long_buf: Entry for buffers needing fragmentation.
* The buffer is complete, inclusive total message length. * The buffer is complete, inclusive total message length.
* Returns user data length. * Returns user data length.
*/ */
int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf) int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf)
...@@ -2650,9 +2650,9 @@ int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf) ...@@ -2650,9 +2650,9 @@ int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf)
return dsz; return dsz;
} }
/* /*
* A pending message being re-assembled must store certain values * A pending message being re-assembled must store certain values
* to handle subsequent fragments correctly. The following functions * to handle subsequent fragments correctly. The following functions
* help storing these values in unused, available fields in the * help storing these values in unused, available fields in the
* pending message. This makes dynamic memory allocation unecessary. * pending message. This makes dynamic memory allocation unecessary.
*/ */
...@@ -2692,11 +2692,11 @@ static void incr_timer_cnt(struct sk_buff *buf) ...@@ -2692,11 +2692,11 @@ static void incr_timer_cnt(struct sk_buff *buf)
msg_incr_reroute_cnt(buf_msg(buf)); msg_incr_reroute_cnt(buf_msg(buf));
} }
/* /*
* tipc_link_recv_fragment(): Called with node lock on. Returns * tipc_link_recv_fragment(): Called with node lock on. Returns
* the reassembled buffer if message is complete. * the reassembled buffer if message is complete.
*/ */
int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
struct tipc_msg **m) struct tipc_msg **m)
{ {
struct sk_buff *prev = NULL; struct sk_buff *prev = NULL;
...@@ -2737,9 +2737,9 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, ...@@ -2737,9 +2737,9 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
/* Prepare buffer for subsequent fragments. */ /* Prepare buffer for subsequent fragments. */
set_long_msg_seqno(pbuf, long_msg_seq_no); set_long_msg_seqno(pbuf, long_msg_seq_no);
set_fragm_size(pbuf,fragm_sz); set_fragm_size(pbuf,fragm_sz);
set_expected_frags(pbuf,exp_fragm_cnt - 1); set_expected_frags(pbuf,exp_fragm_cnt - 1);
} else { } else {
warn("Link unable to reassemble fragmented message\n"); warn("Link unable to reassemble fragmented message\n");
} }
...@@ -2765,7 +2765,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb, ...@@ -2765,7 +2765,7 @@ int tipc_link_recv_fragment(struct sk_buff **pending, struct sk_buff **fb,
*m = buf_msg(pbuf); *m = buf_msg(pbuf);
return 1; return 1;
} }
set_expected_frags(pbuf,exp_frags); set_expected_frags(pbuf,exp_frags);
return 0; return 0;
} }
dbg(" Discarding orphan fragment %x\n",fbuf); dbg(" Discarding orphan fragment %x\n",fbuf);
...@@ -2849,10 +2849,10 @@ void tipc_link_set_queue_limits(struct link *l_ptr, u32 window) ...@@ -2849,10 +2849,10 @@ void tipc_link_set_queue_limits(struct link *l_ptr, u32 window)
* link_find_link - locate link by name * link_find_link - locate link by name
* @name - ptr to link name string * @name - ptr to link name string
* @node - ptr to area to be filled with ptr to associated node * @node - ptr to area to be filled with ptr to associated node
* *
* Caller must hold 'tipc_net_lock' to ensure node and bearer are not deleted; * Caller must hold 'tipc_net_lock' to ensure node and bearer are not deleted;
* this also prevents link deletion. * this also prevents link deletion.
* *
* Returns pointer to link (or 0 if invalid link name). * Returns pointer to link (or 0 if invalid link name).
*/ */
...@@ -2860,7 +2860,7 @@ static struct link *link_find_link(const char *name, struct node **node) ...@@ -2860,7 +2860,7 @@ static struct link *link_find_link(const char *name, struct node **node)
{ {
struct link_name link_name_parts; struct link_name link_name_parts;
struct bearer *b_ptr; struct bearer *b_ptr;
struct link *l_ptr; struct link *l_ptr;
if (!link_name_validate(name, &link_name_parts)) if (!link_name_validate(name, &link_name_parts))
return NULL; return NULL;
...@@ -2869,7 +2869,7 @@ static struct link *link_find_link(const char *name, struct node **node) ...@@ -2869,7 +2869,7 @@ static struct link *link_find_link(const char *name, struct node **node)
if (!b_ptr) if (!b_ptr)
return NULL; return NULL;
*node = tipc_node_find(link_name_parts.addr_peer); *node = tipc_node_find(link_name_parts.addr_peer);
if (!*node) if (!*node)
return NULL; return NULL;
...@@ -2880,14 +2880,14 @@ static struct link *link_find_link(const char *name, struct node **node) ...@@ -2880,14 +2880,14 @@ static struct link *link_find_link(const char *name, struct node **node)
return l_ptr; return l_ptr;
} }
struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space, struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space,
u16 cmd) u16 cmd)
{ {
struct tipc_link_config *args; struct tipc_link_config *args;
u32 new_value; u32 new_value;
struct link *l_ptr; struct link *l_ptr;
struct node *node; struct node *node;
int res; int res;
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG)) if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG))
return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR);
...@@ -2899,40 +2899,40 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space ...@@ -2899,40 +2899,40 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space
if ((cmd == TIPC_CMD_SET_LINK_WINDOW) && if ((cmd == TIPC_CMD_SET_LINK_WINDOW) &&
(tipc_bclink_set_queue_limits(new_value) == 0)) (tipc_bclink_set_queue_limits(new_value) == 0))
return tipc_cfg_reply_none(); return tipc_cfg_reply_none();
return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
" (cannot change setting on broadcast link)"); " (cannot change setting on broadcast link)");
} }
read_lock_bh(&tipc_net_lock); read_lock_bh(&tipc_net_lock);
l_ptr = link_find_link(args->name, &node); l_ptr = link_find_link(args->name, &node);
if (!l_ptr) { if (!l_ptr) {
read_unlock_bh(&tipc_net_lock); read_unlock_bh(&tipc_net_lock);
return tipc_cfg_reply_error_string("link not found"); return tipc_cfg_reply_error_string("link not found");
} }
tipc_node_lock(node); tipc_node_lock(node);
res = -EINVAL; res = -EINVAL;
switch (cmd) { switch (cmd) {
case TIPC_CMD_SET_LINK_TOL: case TIPC_CMD_SET_LINK_TOL:
if ((new_value >= TIPC_MIN_LINK_TOL) && if ((new_value >= TIPC_MIN_LINK_TOL) &&
(new_value <= TIPC_MAX_LINK_TOL)) { (new_value <= TIPC_MAX_LINK_TOL)) {
link_set_supervision_props(l_ptr, new_value); link_set_supervision_props(l_ptr, new_value);
tipc_link_send_proto_msg(l_ptr, STATE_MSG, tipc_link_send_proto_msg(l_ptr, STATE_MSG,
0, 0, new_value, 0, 0); 0, 0, new_value, 0, 0);
res = TIPC_OK; res = TIPC_OK;
} }
break; break;
case TIPC_CMD_SET_LINK_PRI: case TIPC_CMD_SET_LINK_PRI:
if ((new_value >= TIPC_MIN_LINK_PRI) && if ((new_value >= TIPC_MIN_LINK_PRI) &&
(new_value <= TIPC_MAX_LINK_PRI)) { (new_value <= TIPC_MAX_LINK_PRI)) {
l_ptr->priority = new_value; l_ptr->priority = new_value;
tipc_link_send_proto_msg(l_ptr, STATE_MSG, tipc_link_send_proto_msg(l_ptr, STATE_MSG,
0, 0, 0, new_value, 0); 0, 0, 0, new_value, 0);
res = TIPC_OK; res = TIPC_OK;
} }
break; break;
case TIPC_CMD_SET_LINK_WINDOW: case TIPC_CMD_SET_LINK_WINDOW:
if ((new_value >= TIPC_MIN_LINK_WIN) && if ((new_value >= TIPC_MIN_LINK_WIN) &&
(new_value <= TIPC_MAX_LINK_WIN)) { (new_value <= TIPC_MAX_LINK_WIN)) {
tipc_link_set_queue_limits(l_ptr, new_value); tipc_link_set_queue_limits(l_ptr, new_value);
res = TIPC_OK; res = TIPC_OK;
...@@ -2943,7 +2943,7 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space ...@@ -2943,7 +2943,7 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space
read_unlock_bh(&tipc_net_lock); read_unlock_bh(&tipc_net_lock);
if (res) if (res)
return tipc_cfg_reply_error_string("cannot change link setting"); return tipc_cfg_reply_error_string("cannot change link setting");
return tipc_cfg_reply_none(); return tipc_cfg_reply_none();
} }
...@@ -2963,7 +2963,7 @@ static void link_reset_statistics(struct link *l_ptr) ...@@ -2963,7 +2963,7 @@ static void link_reset_statistics(struct link *l_ptr)
struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space) struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_space)
{ {
char *link_name; char *link_name;
struct link *l_ptr; struct link *l_ptr;
struct node *node; struct node *node;
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME))
...@@ -2977,7 +2977,7 @@ struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_ ...@@ -2977,7 +2977,7 @@ struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_
} }
read_lock_bh(&tipc_net_lock); read_lock_bh(&tipc_net_lock);
l_ptr = link_find_link(link_name, &node); l_ptr = link_find_link(link_name, &node);
if (!l_ptr) { if (!l_ptr) {
read_unlock_bh(&tipc_net_lock); read_unlock_bh(&tipc_net_lock);
return tipc_cfg_reply_error_string("link not found"); return tipc_cfg_reply_error_string("link not found");
...@@ -3004,14 +3004,14 @@ static u32 percent(u32 count, u32 total) ...@@ -3004,14 +3004,14 @@ static u32 percent(u32 count, u32 total)
* @name: link name * @name: link name
* @buf: print buffer area * @buf: print buffer area
* @buf_size: size of print buffer area * @buf_size: size of print buffer area
* *
* Returns length of print buffer data string (or 0 if error) * Returns length of print buffer data string (or 0 if error)
*/ */
static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
{ {
struct print_buf pb; struct print_buf pb;
struct link *l_ptr; struct link *l_ptr;
struct node *node; struct node *node;
char *status; char *status;
u32 profile_total = 0; u32 profile_total = 0;
...@@ -3022,7 +3022,7 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) ...@@ -3022,7 +3022,7 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
tipc_printbuf_init(&pb, buf, buf_size); tipc_printbuf_init(&pb, buf, buf_size);
read_lock_bh(&tipc_net_lock); read_lock_bh(&tipc_net_lock);
l_ptr = link_find_link(name, &node); l_ptr = link_find_link(name, &node);
if (!l_ptr) { if (!l_ptr) {
read_unlock_bh(&tipc_net_lock); read_unlock_bh(&tipc_net_lock);
return 0; return 0;
...@@ -3036,28 +3036,28 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) ...@@ -3036,28 +3036,28 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
else else
status = "DEFUNCT"; status = "DEFUNCT";
tipc_printf(&pb, "Link <%s>\n" tipc_printf(&pb, "Link <%s>\n"
" %s MTU:%u Priority:%u Tolerance:%u ms" " %s MTU:%u Priority:%u Tolerance:%u ms"
" Window:%u packets\n", " Window:%u packets\n",
l_ptr->name, status, link_max_pkt(l_ptr), l_ptr->name, status, link_max_pkt(l_ptr),
l_ptr->priority, l_ptr->tolerance, l_ptr->queue_limit[0]); l_ptr->priority, l_ptr->tolerance, l_ptr->queue_limit[0]);
tipc_printf(&pb, " RX packets:%u fragments:%u/%u bundles:%u/%u\n", tipc_printf(&pb, " RX packets:%u fragments:%u/%u bundles:%u/%u\n",
l_ptr->next_in_no - l_ptr->stats.recv_info, l_ptr->next_in_no - l_ptr->stats.recv_info,
l_ptr->stats.recv_fragments, l_ptr->stats.recv_fragments,
l_ptr->stats.recv_fragmented, l_ptr->stats.recv_fragmented,
l_ptr->stats.recv_bundles, l_ptr->stats.recv_bundles,
l_ptr->stats.recv_bundled); l_ptr->stats.recv_bundled);
tipc_printf(&pb, " TX packets:%u fragments:%u/%u bundles:%u/%u\n", tipc_printf(&pb, " TX packets:%u fragments:%u/%u bundles:%u/%u\n",
l_ptr->next_out_no - l_ptr->stats.sent_info, l_ptr->next_out_no - l_ptr->stats.sent_info,
l_ptr->stats.sent_fragments, l_ptr->stats.sent_fragments,
l_ptr->stats.sent_fragmented, l_ptr->stats.sent_fragmented,
l_ptr->stats.sent_bundles, l_ptr->stats.sent_bundles,
l_ptr->stats.sent_bundled); l_ptr->stats.sent_bundled);
profile_total = l_ptr->stats.msg_length_counts; profile_total = l_ptr->stats.msg_length_counts;
if (!profile_total) if (!profile_total)
profile_total = 1; profile_total = 1;
tipc_printf(&pb, " TX profile sample:%u packets average:%u octets\n" tipc_printf(&pb, " TX profile sample:%u packets average:%u octets\n"
" 0-64:%u%% -256:%u%% -1024:%u%% -4096:%u%% " " 0-64:%u%% -256:%u%% -1024:%u%% -4096:%u%% "
"-16354:%u%% -32768:%u%% -66000:%u%%\n", "-16354:%u%% -32768:%u%% -66000:%u%%\n",
l_ptr->stats.msg_length_counts, l_ptr->stats.msg_length_counts,
l_ptr->stats.msg_lengths_total / profile_total, l_ptr->stats.msg_lengths_total / profile_total,
percent(l_ptr->stats.msg_length_profile[0], profile_total), percent(l_ptr->stats.msg_length_profile[0], profile_total),
...@@ -3067,21 +3067,21 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) ...@@ -3067,21 +3067,21 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size)
percent(l_ptr->stats.msg_length_profile[4], profile_total), percent(l_ptr->stats.msg_length_profile[4], profile_total),
percent(l_ptr->stats.msg_length_profile[5], profile_total), percent(l_ptr->stats.msg_length_profile[5], profile_total),
percent(l_ptr->stats.msg_length_profile[6], profile_total)); percent(l_ptr->stats.msg_length_profile[6], profile_total));
tipc_printf(&pb, " RX states:%u probes:%u naks:%u defs:%u dups:%u\n", tipc_printf(&pb, " RX states:%u probes:%u naks:%u defs:%u dups:%u\n",
l_ptr->stats.recv_states, l_ptr->stats.recv_states,
l_ptr->stats.recv_probes, l_ptr->stats.recv_probes,
l_ptr->stats.recv_nacks, l_ptr->stats.recv_nacks,
l_ptr->stats.deferred_recv, l_ptr->stats.deferred_recv,
l_ptr->stats.duplicates); l_ptr->stats.duplicates);
tipc_printf(&pb, " TX states:%u probes:%u naks:%u acks:%u dups:%u\n", tipc_printf(&pb, " TX states:%u probes:%u naks:%u acks:%u dups:%u\n",
l_ptr->stats.sent_states, l_ptr->stats.sent_states,
l_ptr->stats.sent_probes, l_ptr->stats.sent_probes,
l_ptr->stats.sent_nacks, l_ptr->stats.sent_nacks,
l_ptr->stats.sent_acks, l_ptr->stats.sent_acks,
l_ptr->stats.retransmitted); l_ptr->stats.retransmitted);
tipc_printf(&pb, " Congestion bearer:%u link:%u Send queue max:%u avg:%u\n", tipc_printf(&pb, " Congestion bearer:%u link:%u Send queue max:%u avg:%u\n",
l_ptr->stats.bearer_congs, l_ptr->stats.bearer_congs,
l_ptr->stats.link_congs, l_ptr->stats.link_congs,
l_ptr->stats.max_queue_sz, l_ptr->stats.max_queue_sz,
l_ptr->stats.queue_sz_counts l_ptr->stats.queue_sz_counts
? (l_ptr->stats.accu_queue_sz / l_ptr->stats.queue_sz_counts) ? (l_ptr->stats.accu_queue_sz / l_ptr->stats.queue_sz_counts)
...@@ -3113,7 +3113,7 @@ struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_s ...@@ -3113,7 +3113,7 @@ struct sk_buff *tipc_link_cmd_show_stats(const void *req_tlv_area, int req_tlv_s
(char *)TLV_DATA(rep_tlv), MAX_LINK_STATS_INFO); (char *)TLV_DATA(rep_tlv), MAX_LINK_STATS_INFO);
if (!str_len) { if (!str_len) {
buf_discard(buf); buf_discard(buf);
return tipc_cfg_reply_error_string("link not found"); return tipc_cfg_reply_error_string("link not found");
} }
skb_put(buf, TLV_SPACE(str_len)); skb_put(buf, TLV_SPACE(str_len));
...@@ -3164,7 +3164,7 @@ int link_control(const char *name, u32 op, u32 val) ...@@ -3164,7 +3164,7 @@ int link_control(const char *name, u32 op, u32 val)
* tipc_link_get_max_pkt - get maximum packet size to use when sending to destination * tipc_link_get_max_pkt - get maximum packet size to use when sending to destination
* @dest: network address of destination node * @dest: network address of destination node
* @selector: used to select from set of active links * @selector: used to select from set of active links
* *
* If no active link can be found, uses default maximum packet size. * If no active link can be found, uses default maximum packet size.
*/ */
...@@ -3173,11 +3173,11 @@ u32 tipc_link_get_max_pkt(u32 dest, u32 selector) ...@@ -3173,11 +3173,11 @@ u32 tipc_link_get_max_pkt(u32 dest, u32 selector)
struct node *n_ptr; struct node *n_ptr;
struct link *l_ptr; struct link *l_ptr;
u32 res = MAX_PKT_DEFAULT; u32 res = MAX_PKT_DEFAULT;
if (dest == tipc_own_addr) if (dest == tipc_own_addr)
return MAX_MSG_SIZE; return MAX_MSG_SIZE;
read_lock_bh(&tipc_net_lock); read_lock_bh(&tipc_net_lock);
n_ptr = tipc_node_select(dest, selector); n_ptr = tipc_node_select(dest, selector);
if (n_ptr) { if (n_ptr) {
tipc_node_lock(n_ptr); tipc_node_lock(n_ptr);
...@@ -3186,7 +3186,7 @@ u32 tipc_link_get_max_pkt(u32 dest, u32 selector) ...@@ -3186,7 +3186,7 @@ u32 tipc_link_get_max_pkt(u32 dest, u32 selector)
res = link_max_pkt(l_ptr); res = link_max_pkt(l_ptr);
tipc_node_unlock(n_ptr); tipc_node_unlock(n_ptr);
} }
read_unlock_bh(&tipc_net_lock); read_unlock_bh(&tipc_net_lock);
return res; return res;
} }
...@@ -3244,8 +3244,8 @@ static void link_print(struct link *l_ptr, struct print_buf *buf, ...@@ -3244,8 +3244,8 @@ static void link_print(struct link *l_ptr, struct print_buf *buf,
tipc_printf(buf, "%u]", tipc_printf(buf, "%u]",
msg_seqno(buf_msg msg_seqno(buf_msg
(l_ptr->last_out)), l_ptr->out_queue_size); (l_ptr->last_out)), l_ptr->out_queue_size);
if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) - if ((mod(msg_seqno(buf_msg(l_ptr->last_out)) -
msg_seqno(buf_msg(l_ptr->first_out))) msg_seqno(buf_msg(l_ptr->first_out)))
!= (l_ptr->out_queue_size - 1)) != (l_ptr->out_queue_size - 1))
|| (l_ptr->last_out->next != 0)) { || (l_ptr->last_out->next != 0)) {
tipc_printf(buf, "\nSend queue inconsistency\n"); tipc_printf(buf, "\nSend queue inconsistency\n");
......
/* /*
* net/tipc/link.h: Include file for TIPC link code * net/tipc/link.h: Include file for TIPC link code
* *
* Copyright (c) 1995-2006, Ericsson AB * Copyright (c) 1995-2006, Ericsson AB
* Copyright (c) 2004-2005, Wind River Systems * Copyright (c) 2004-2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
#define PUSH_FAILED 1 #define PUSH_FAILED 1
#define PUSH_FINISHED 2 #define PUSH_FINISHED 2
/* /*
* Link states * Link states
*/ */
#define WORKING_WORKING 560810u #define WORKING_WORKING 560810u
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
#define RESET_UNKNOWN 560812u #define RESET_UNKNOWN 560812u
#define RESET_RESET 560813u #define RESET_RESET 560813u
/* /*
* Starting value for maximum packet size negotiation on unicast links * Starting value for maximum packet size negotiation on unicast links
* (unless bearer MTU is less) * (unless bearer MTU is less)
*/ */
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
* @peer_session: link session # being used by peer end of link * @peer_session: link session # being used by peer end of link
* @peer_bearer_id: bearer id used by link's peer endpoint * @peer_bearer_id: bearer id used by link's peer endpoint
* @b_ptr: pointer to bearer used by link * @b_ptr: pointer to bearer used by link
* @tolerance: minimum link continuity loss needed to reset link [in ms] * @tolerance: minimum link continuity loss needed to reset link [in ms]
* @continuity_interval: link continuity testing interval [in ms] * @continuity_interval: link continuity testing interval [in ms]
* @abort_limit: # of unacknowledged continuity probes needed to reset link * @abort_limit: # of unacknowledged continuity probes needed to reset link
* @state: current state of link FSM * @state: current state of link FSM
...@@ -110,7 +110,7 @@ ...@@ -110,7 +110,7 @@
* @stats: collects statistics regarding link activity * @stats: collects statistics regarding link activity
* @print_buf: print buffer used to log link activity * @print_buf: print buffer used to log link activity
*/ */
struct link { struct link {
u32 addr; u32 addr;
char name[TIPC_MAX_LINK_NAME]; char name[TIPC_MAX_LINK_NAME];
...@@ -143,18 +143,18 @@ struct link { ...@@ -143,18 +143,18 @@ struct link {
u32 exp_msg_count; u32 exp_msg_count;
u32 reset_checkpoint; u32 reset_checkpoint;
/* Max packet negotiation */ /* Max packet negotiation */
u32 max_pkt; u32 max_pkt;
u32 max_pkt_target; u32 max_pkt_target;
u32 max_pkt_probes; u32 max_pkt_probes;
/* Sending */ /* Sending */
u32 out_queue_size; u32 out_queue_size;
struct sk_buff *first_out; struct sk_buff *first_out;
struct sk_buff *last_out; struct sk_buff *last_out;
u32 next_out_no; u32 next_out_no;
u32 last_retransmitted; u32 last_retransmitted;
u32 stale_count; u32 stale_count;
/* Reception */ /* Reception */
u32 next_in_no; u32 next_in_no;
...@@ -174,7 +174,7 @@ struct link { ...@@ -174,7 +174,7 @@ struct link {
u32 long_msg_seq_no; u32 long_msg_seq_no;
struct sk_buff *defragm_buf; struct sk_buff *defragm_buf;
/* Statistics */ /* Statistics */
struct { struct {
u32 sent_info; /* used in counting # sent packets */ u32 sent_info; /* used in counting # sent packets */
u32 recv_info; /* used in counting # recv'd packets */ u32 recv_info; /* used in counting # recv'd packets */
...@@ -239,9 +239,9 @@ void tipc_link_reset(struct link *l_ptr); ...@@ -239,9 +239,9 @@ void tipc_link_reset(struct link *l_ptr);
int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector); int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector);
int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf); int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf);
u32 tipc_link_get_max_pkt(u32 dest,u32 selector); u32 tipc_link_get_max_pkt(u32 dest,u32 selector);
int tipc_link_send_sections_fast(struct port* sender, int tipc_link_send_sections_fast(struct port* sender,
struct iovec const *msg_sect, struct iovec const *msg_sect,
const u32 num_sect, const u32 num_sect,
u32 destnode); u32 destnode);
int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf); int tipc_link_send_long_buf(struct link *l_ptr, struct sk_buff *buf);
void tipc_link_tunnel(struct link *l_ptr, struct tipc_msg *tnl_hdr, void tipc_link_tunnel(struct link *l_ptr, struct tipc_msg *tnl_hdr,
...@@ -250,7 +250,7 @@ void tipc_link_recv_bundle(struct sk_buff *buf); ...@@ -250,7 +250,7 @@ void tipc_link_recv_bundle(struct sk_buff *buf);
int tipc_link_recv_fragment(struct sk_buff **pending, int tipc_link_recv_fragment(struct sk_buff **pending,
struct sk_buff **fb, struct sk_buff **fb,
struct tipc_msg **msg); struct tipc_msg **msg);
void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int prob, u32 gap, void tipc_link_send_proto_msg(struct link *l_ptr, u32 msg_typ, int prob, u32 gap,
u32 tolerance, u32 priority, u32 acked_mtu); u32 tolerance, u32 priority, u32 acked_mtu);
void tipc_link_push_queue(struct link *l_ptr); void tipc_link_push_queue(struct link *l_ptr);
u32 tipc_link_defer_pkt(struct sk_buff **head, struct sk_buff **tail, u32 tipc_link_defer_pkt(struct sk_buff **head, struct sk_buff **tail,
......
/* /*
* net/tipc/msg.c: TIPC message header routines * net/tipc/msg.c: TIPC message header routines
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
......
/* /*
* net/tipc/msg.h: Include file for TIPC message header routines * net/tipc/msg.h: Include file for TIPC message header routines
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -56,10 +56,10 @@ ...@@ -56,10 +56,10 @@
/* /*
TIPC user data message header format, version 2 TIPC user data message header format, version 2
- Fundamental definitions available to privileged TIPC users - Fundamental definitions available to privileged TIPC users
are located in tipc_msg.h. are located in tipc_msg.h.
- Remaining definitions available to TIPC internal users appear below. - Remaining definitions available to TIPC internal users appear below.
*/ */
...@@ -75,7 +75,7 @@ static inline void msg_set_bits(struct tipc_msg *m, u32 w, ...@@ -75,7 +75,7 @@ static inline void msg_set_bits(struct tipc_msg *m, u32 w,
msg_set_word(m, w, (word |= (val << pos))); msg_set_word(m, w, (word |= (val << pos)));
} }
/* /*
* Word 0 * Word 0
*/ */
...@@ -84,7 +84,7 @@ static inline u32 msg_version(struct tipc_msg *m) ...@@ -84,7 +84,7 @@ static inline u32 msg_version(struct tipc_msg *m)
return msg_bits(m, 0, 29, 7); return msg_bits(m, 0, 29, 7);
} }
static inline void msg_set_version(struct tipc_msg *m) static inline void msg_set_version(struct tipc_msg *m)
{ {
msg_set_bits(m, 0, 29, 0xf, TIPC_VERSION); msg_set_bits(m, 0, 29, 0xf, TIPC_VERSION);
} }
...@@ -99,47 +99,47 @@ static inline u32 msg_isdata(struct tipc_msg *m) ...@@ -99,47 +99,47 @@ static inline u32 msg_isdata(struct tipc_msg *m)
return (msg_user(m) <= DATA_CRITICAL); return (msg_user(m) <= DATA_CRITICAL);
} }
static inline void msg_set_user(struct tipc_msg *m, u32 n) static inline void msg_set_user(struct tipc_msg *m, u32 n)
{ {
msg_set_bits(m, 0, 25, 0xf, n); msg_set_bits(m, 0, 25, 0xf, n);
} }
static inline void msg_set_importance(struct tipc_msg *m, u32 i) static inline void msg_set_importance(struct tipc_msg *m, u32 i)
{ {
msg_set_user(m, i); msg_set_user(m, i);
} }
static inline void msg_set_hdr_sz(struct tipc_msg *m,u32 n) static inline void msg_set_hdr_sz(struct tipc_msg *m,u32 n)
{ {
msg_set_bits(m, 0, 21, 0xf, n>>2); msg_set_bits(m, 0, 21, 0xf, n>>2);
} }
static inline int msg_non_seq(struct tipc_msg *m) static inline int msg_non_seq(struct tipc_msg *m)
{ {
return msg_bits(m, 0, 20, 1); return msg_bits(m, 0, 20, 1);
} }
static inline void msg_set_non_seq(struct tipc_msg *m) static inline void msg_set_non_seq(struct tipc_msg *m)
{ {
msg_set_bits(m, 0, 20, 1, 1); msg_set_bits(m, 0, 20, 1, 1);
} }
static inline int msg_dest_droppable(struct tipc_msg *m) static inline int msg_dest_droppable(struct tipc_msg *m)
{ {
return msg_bits(m, 0, 19, 1); return msg_bits(m, 0, 19, 1);
} }
static inline void msg_set_dest_droppable(struct tipc_msg *m, u32 d) static inline void msg_set_dest_droppable(struct tipc_msg *m, u32 d)
{ {
msg_set_bits(m, 0, 19, 1, d); msg_set_bits(m, 0, 19, 1, d);
} }
static inline int msg_src_droppable(struct tipc_msg *m) static inline int msg_src_droppable(struct tipc_msg *m)
{ {
return msg_bits(m, 0, 18, 1); return msg_bits(m, 0, 18, 1);
} }
static inline void msg_set_src_droppable(struct tipc_msg *m, u32 d) static inline void msg_set_src_droppable(struct tipc_msg *m, u32 d)
{ {
msg_set_bits(m, 0, 18, 1, d); msg_set_bits(m, 0, 18, 1, d);
} }
...@@ -150,31 +150,31 @@ static inline void msg_set_size(struct tipc_msg *m, u32 sz) ...@@ -150,31 +150,31 @@ static inline void msg_set_size(struct tipc_msg *m, u32 sz)
} }
/* /*
* Word 1 * Word 1
*/ */
static inline void msg_set_type(struct tipc_msg *m, u32 n) static inline void msg_set_type(struct tipc_msg *m, u32 n)
{ {
msg_set_bits(m, 1, 29, 0x7, n); msg_set_bits(m, 1, 29, 0x7, n);
} }
static inline void msg_set_errcode(struct tipc_msg *m, u32 err) static inline void msg_set_errcode(struct tipc_msg *m, u32 err)
{ {
msg_set_bits(m, 1, 25, 0xf, err); msg_set_bits(m, 1, 25, 0xf, err);
} }
static inline u32 msg_reroute_cnt(struct tipc_msg *m) static inline u32 msg_reroute_cnt(struct tipc_msg *m)
{ {
return msg_bits(m, 1, 21, 0xf); return msg_bits(m, 1, 21, 0xf);
} }
static inline void msg_incr_reroute_cnt(struct tipc_msg *m) static inline void msg_incr_reroute_cnt(struct tipc_msg *m)
{ {
msg_set_bits(m, 1, 21, 0xf, msg_reroute_cnt(m) + 1); msg_set_bits(m, 1, 21, 0xf, msg_reroute_cnt(m) + 1);
} }
static inline void msg_reset_reroute_cnt(struct tipc_msg *m) static inline void msg_reset_reroute_cnt(struct tipc_msg *m)
{ {
msg_set_bits(m, 1, 21, 0xf, 0); msg_set_bits(m, 1, 21, 0xf, 0);
} }
...@@ -184,12 +184,12 @@ static inline u32 msg_lookup_scope(struct tipc_msg *m) ...@@ -184,12 +184,12 @@ static inline u32 msg_lookup_scope(struct tipc_msg *m)
return msg_bits(m, 1, 19, 0x3); return msg_bits(m, 1, 19, 0x3);
} }
static inline void msg_set_lookup_scope(struct tipc_msg *m, u32 n) static inline void msg_set_lookup_scope(struct tipc_msg *m, u32 n)
{ {
msg_set_bits(m, 1, 19, 0x3, n); msg_set_bits(m, 1, 19, 0x3, n);
} }
static inline void msg_set_options(struct tipc_msg *m, const char *opt, u32 sz) static inline void msg_set_options(struct tipc_msg *m, const char *opt, u32 sz)
{ {
u32 hsz = msg_hdr_sz(m); u32 hsz = msg_hdr_sz(m);
char *to = (char *)&m->hdr[hsz/4]; char *to = (char *)&m->hdr[hsz/4];
...@@ -206,13 +206,13 @@ static inline u32 msg_bcast_ack(struct tipc_msg *m) ...@@ -206,13 +206,13 @@ static inline u32 msg_bcast_ack(struct tipc_msg *m)
return msg_bits(m, 1, 0, 0xffff); return msg_bits(m, 1, 0, 0xffff);
} }
static inline void msg_set_bcast_ack(struct tipc_msg *m, u32 n) static inline void msg_set_bcast_ack(struct tipc_msg *m, u32 n)
{ {
msg_set_bits(m, 1, 0, 0xffff, n); msg_set_bits(m, 1, 0, 0xffff, n);
} }
/* /*
* Word 2 * Word 2
*/ */
...@@ -221,7 +221,7 @@ static inline u32 msg_ack(struct tipc_msg *m) ...@@ -221,7 +221,7 @@ static inline u32 msg_ack(struct tipc_msg *m)
return msg_bits(m, 2, 16, 0xffff); return msg_bits(m, 2, 16, 0xffff);
} }
static inline void msg_set_ack(struct tipc_msg *m, u32 n) static inline void msg_set_ack(struct tipc_msg *m, u32 n)
{ {
msg_set_bits(m, 2, 16, 0xffff, n); msg_set_bits(m, 2, 16, 0xffff, n);
} }
...@@ -231,48 +231,48 @@ static inline u32 msg_seqno(struct tipc_msg *m) ...@@ -231,48 +231,48 @@ static inline u32 msg_seqno(struct tipc_msg *m)
return msg_bits(m, 2, 0, 0xffff); return msg_bits(m, 2, 0, 0xffff);
} }
static inline void msg_set_seqno(struct tipc_msg *m, u32 n) static inline void msg_set_seqno(struct tipc_msg *m, u32 n)
{ {
msg_set_bits(m, 2, 0, 0xffff, n); msg_set_bits(m, 2, 0, 0xffff, n);
} }
/* /*
* Words 3-10 * Words 3-10
*/ */
static inline void msg_set_prevnode(struct tipc_msg *m, u32 a) static inline void msg_set_prevnode(struct tipc_msg *m, u32 a)
{ {
msg_set_word(m, 3, a); msg_set_word(m, 3, a);
} }
static inline void msg_set_origport(struct tipc_msg *m, u32 p) static inline void msg_set_origport(struct tipc_msg *m, u32 p)
{ {
msg_set_word(m, 4, p); msg_set_word(m, 4, p);
} }
static inline void msg_set_destport(struct tipc_msg *m, u32 p) static inline void msg_set_destport(struct tipc_msg *m, u32 p)
{ {
msg_set_word(m, 5, p); msg_set_word(m, 5, p);
} }
static inline void msg_set_mc_netid(struct tipc_msg *m, u32 p) static inline void msg_set_mc_netid(struct tipc_msg *m, u32 p)
{ {
msg_set_word(m, 5, p); msg_set_word(m, 5, p);
} }
static inline void msg_set_orignode(struct tipc_msg *m, u32 a) static inline void msg_set_orignode(struct tipc_msg *m, u32 a)
{ {
msg_set_word(m, 6, a); msg_set_word(m, 6, a);
} }
static inline void msg_set_destnode(struct tipc_msg *m, u32 a) static inline void msg_set_destnode(struct tipc_msg *m, u32 a)
{ {
msg_set_word(m, 7, a); msg_set_word(m, 7, a);
} }
static inline int msg_is_dest(struct tipc_msg *m, u32 d) static inline int msg_is_dest(struct tipc_msg *m, u32 d)
{ {
return(msg_short(m) || (msg_destnode(m) == d)); return(msg_short(m) || (msg_destnode(m) == d));
} }
...@@ -284,7 +284,7 @@ static inline u32 msg_routed(struct tipc_msg *m) ...@@ -284,7 +284,7 @@ static inline u32 msg_routed(struct tipc_msg *m)
return(msg_destnode(m) ^ msg_orignode(m)) >> 11; return(msg_destnode(m) ^ msg_orignode(m)) >> 11;
} }
static inline void msg_set_nametype(struct tipc_msg *m, u32 n) static inline void msg_set_nametype(struct tipc_msg *m, u32 n)
{ {
msg_set_word(m, 8, n); msg_set_word(m, 8, n);
} }
...@@ -309,17 +309,17 @@ static inline void msg_set_transp_seqno(struct tipc_msg *m, u32 n) ...@@ -309,17 +309,17 @@ static inline void msg_set_transp_seqno(struct tipc_msg *m, u32 n)
msg_set_word(m, 8, n); msg_set_word(m, 8, n);
} }
static inline void msg_set_namelower(struct tipc_msg *m, u32 n) static inline void msg_set_namelower(struct tipc_msg *m, u32 n)
{ {
msg_set_word(m, 9, n); msg_set_word(m, 9, n);
} }
static inline void msg_set_nameinst(struct tipc_msg *m, u32 n) static inline void msg_set_nameinst(struct tipc_msg *m, u32 n)
{ {
msg_set_namelower(m, n); msg_set_namelower(m, n);
} }
static inline void msg_set_nameupper(struct tipc_msg *m, u32 n) static inline void msg_set_nameupper(struct tipc_msg *m, u32 n)
{ {
msg_set_word(m, 10, n); msg_set_word(m, 10, n);
} }
...@@ -329,7 +329,7 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) ...@@ -329,7 +329,7 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
return (struct tipc_msg *)msg_data(m); return (struct tipc_msg *)msg_data(m);
} }
static inline void msg_expand(struct tipc_msg *m, u32 destnode) static inline void msg_expand(struct tipc_msg *m, u32 destnode)
{ {
if (!msg_short(m)) if (!msg_short(m))
return; return;
...@@ -344,7 +344,7 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode) ...@@ -344,7 +344,7 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode)
/* /*
TIPC internal message header format, version 2 TIPC internal message header format, version 2
1 0 9 8 7 6 5 4|3 2 1 0 9 8 7 6|5 4 3 2 1 0 9 8|7 6 5 4 3 2 1 0 1 0 9 8 7 6 5 4|3 2 1 0 9 8 7 6|5 4 3 2 1 0 9 8|7 6 5 4 3 2 1 0
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
w0:|vers |msg usr|hdr sz |n|resrv| packet size | w0:|vers |msg usr|hdr sz |n|resrv| packet size |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
...@@ -372,9 +372,9 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode) ...@@ -372,9 +372,9 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode)
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
NB: CONN_MANAGER use data message format. LINK_CONFIG has own format. NB: CONN_MANAGER use data message format. LINK_CONFIG has own format.
*/ */
/* /*
* Internal users * Internal users
*/ */
...@@ -390,7 +390,7 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode) ...@@ -390,7 +390,7 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode)
#define INT_H_SIZE 40 #define INT_H_SIZE 40
#define DSC_H_SIZE 40 #define DSC_H_SIZE 40
/* /*
* Connection management protocol messages * Connection management protocol messages
*/ */
...@@ -398,7 +398,7 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode) ...@@ -398,7 +398,7 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode)
#define CONN_PROBE_REPLY 1 #define CONN_PROBE_REPLY 1
#define CONN_ACK 2 #define CONN_ACK 2
/* /*
* Name distributor messages * Name distributor messages
*/ */
...@@ -406,7 +406,7 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode) ...@@ -406,7 +406,7 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode)
#define WITHDRAWAL 1 #define WITHDRAWAL 1
/* /*
* Word 1 * Word 1
*/ */
...@@ -425,13 +425,13 @@ static inline u32 msg_req_links(struct tipc_msg *m) ...@@ -425,13 +425,13 @@ static inline u32 msg_req_links(struct tipc_msg *m)
return msg_bits(m, 1, 16, 0xfff); return msg_bits(m, 1, 16, 0xfff);
} }
static inline void msg_set_req_links(struct tipc_msg *m, u32 n) static inline void msg_set_req_links(struct tipc_msg *m, u32 n)
{ {
msg_set_bits(m, 1, 16, 0xfff, n); msg_set_bits(m, 1, 16, 0xfff, n);
} }
/* /*
* Word 2 * Word 2
*/ */
...@@ -440,7 +440,7 @@ static inline u32 msg_dest_domain(struct tipc_msg *m) ...@@ -440,7 +440,7 @@ static inline u32 msg_dest_domain(struct tipc_msg *m)
return msg_word(m, 2); return msg_word(m, 2);
} }
static inline void msg_set_dest_domain(struct tipc_msg *m, u32 n) static inline void msg_set_dest_domain(struct tipc_msg *m, u32 n)
{ {
msg_set_word(m, 2, n); msg_set_word(m, 2, n);
} }
...@@ -460,13 +460,13 @@ static inline u32 msg_bcgap_to(struct tipc_msg *m) ...@@ -460,13 +460,13 @@ static inline u32 msg_bcgap_to(struct tipc_msg *m)
return msg_bits(m, 2, 0, 0xffff); return msg_bits(m, 2, 0, 0xffff);
} }
static inline void msg_set_bcgap_to(struct tipc_msg *m, u32 n) static inline void msg_set_bcgap_to(struct tipc_msg *m, u32 n)
{ {
msg_set_bits(m, 2, 0, 0xffff, n); msg_set_bits(m, 2, 0, 0xffff, n);
} }
/* /*
* Word 4 * Word 4
*/ */
...@@ -533,7 +533,7 @@ static inline void msg_set_link_selector(struct tipc_msg *m, u32 n) ...@@ -533,7 +533,7 @@ static inline void msg_set_link_selector(struct tipc_msg *m, u32 n)
msg_set_bits(m, 4, 0, 1, (n & 1)); msg_set_bits(m, 4, 0, 1, (n & 1));
} }
/* /*
* Word 5 * Word 5
*/ */
...@@ -603,7 +603,7 @@ static inline void msg_clear_redundant_link(struct tipc_msg *m) ...@@ -603,7 +603,7 @@ static inline void msg_clear_redundant_link(struct tipc_msg *m)
} }
/* /*
* Word 9 * Word 9
*/ */
...@@ -627,12 +627,12 @@ static inline void msg_set_bcast_tag(struct tipc_msg *m, u32 n) ...@@ -627,12 +627,12 @@ static inline void msg_set_bcast_tag(struct tipc_msg *m, u32 n)
msg_set_bits(m, 9, 16, 0xffff, n); msg_set_bits(m, 9, 16, 0xffff, n);
} }
static inline u32 msg_max_pkt(struct tipc_msg *m) static inline u32 msg_max_pkt(struct tipc_msg *m)
{ {
return (msg_bits(m, 9, 16, 0xffff) * 4); return (msg_bits(m, 9, 16, 0xffff) * 4);
} }
static inline void msg_set_max_pkt(struct tipc_msg *m, u32 n) static inline void msg_set_max_pkt(struct tipc_msg *m, u32 n)
{ {
msg_set_bits(m, 9, 16, 0xffff, (n / 4)); msg_set_bits(m, 9, 16, 0xffff, (n / 4));
} }
...@@ -647,7 +647,7 @@ static inline void msg_set_link_tolerance(struct tipc_msg *m, u32 n) ...@@ -647,7 +647,7 @@ static inline void msg_set_link_tolerance(struct tipc_msg *m, u32 n)
msg_set_bits(m, 9, 0, 0xffff, n); msg_set_bits(m, 9, 0, 0xffff, n);
} }
/* /*
* Routing table message data * Routing table message data
*/ */
...@@ -672,7 +672,7 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos) ...@@ -672,7 +672,7 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos)
msg_data(m)[pos + 4] = 1; msg_data(m)[pos + 4] = 1;
} }
/* /*
* Segmentation message types * Segmentation message types
*/ */
...@@ -680,7 +680,7 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos) ...@@ -680,7 +680,7 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos)
#define FRAGMENT 1 #define FRAGMENT 1
#define LAST_FRAGMENT 2 #define LAST_FRAGMENT 2
/* /*
* Link management protocol message types * Link management protocol message types
*/ */
...@@ -688,13 +688,13 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos) ...@@ -688,13 +688,13 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos)
#define RESET_MSG 1 #define RESET_MSG 1
#define ACTIVATE_MSG 2 #define ACTIVATE_MSG 2
/* /*
* Changeover tunnel message types * Changeover tunnel message types
*/ */
#define DUPLICATE_MSG 0 #define DUPLICATE_MSG 0
#define ORIGINAL_MSG 1 #define ORIGINAL_MSG 1
/* /*
* Routing table message types * Routing table message types
*/ */
#define EXT_ROUTING_TABLE 0 #define EXT_ROUTING_TABLE 0
...@@ -703,7 +703,7 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos) ...@@ -703,7 +703,7 @@ static inline void msg_set_dataoctet(struct tipc_msg *m, u32 pos)
#define ROUTE_ADDITION 3 #define ROUTE_ADDITION 3
#define ROUTE_REMOVAL 4 #define ROUTE_REMOVAL 4
/* /*
* Config protocol message types * Config protocol message types
*/ */
...@@ -724,7 +724,7 @@ static inline u32 msg_tot_importance(struct tipc_msg *m) ...@@ -724,7 +724,7 @@ static inline u32 msg_tot_importance(struct tipc_msg *m)
} }
static inline void msg_init(struct tipc_msg *m, u32 user, u32 type, static inline void msg_init(struct tipc_msg *m, u32 user, u32 type,
u32 err, u32 hsize, u32 destnode) u32 err, u32 hsize, u32 destnode)
{ {
memset(m, 0, hsize); memset(m, 0, hsize);
...@@ -741,7 +741,7 @@ static inline void msg_init(struct tipc_msg *m, u32 user, u32 type, ...@@ -741,7 +741,7 @@ static inline void msg_init(struct tipc_msg *m, u32 user, u32 type,
} }
} }
/** /**
* msg_calc_data_size - determine total data size for message * msg_calc_data_size - determine total data size for message
*/ */
...@@ -755,15 +755,15 @@ static inline int msg_calc_data_size(struct iovec const *msg_sect, u32 num_sect) ...@@ -755,15 +755,15 @@ static inline int msg_calc_data_size(struct iovec const *msg_sect, u32 num_sect)
return dsz; return dsz;
} }
/** /**
* msg_build - create message using specified header and data * msg_build - create message using specified header and data
* *
* Note: Caller must not hold any locks in case copy_from_user() is interrupted! * Note: Caller must not hold any locks in case copy_from_user() is interrupted!
* *
* Returns message data size or errno * Returns message data size or errno
*/ */
static inline int msg_build(struct tipc_msg *hdr, static inline int msg_build(struct tipc_msg *hdr,
struct iovec const *msg_sect, u32 num_sect, struct iovec const *msg_sect, u32 num_sect,
int max_size, int usrmem, struct sk_buff** buf) int max_size, int usrmem, struct sk_buff** buf)
{ {
...@@ -789,11 +789,11 @@ static inline int msg_build(struct tipc_msg *hdr, ...@@ -789,11 +789,11 @@ static inline int msg_build(struct tipc_msg *hdr,
memcpy((*buf)->data, (unchar *)hdr, hsz); memcpy((*buf)->data, (unchar *)hdr, hsz);
for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) { for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
if (likely(usrmem)) if (likely(usrmem))
res = !copy_from_user((*buf)->data + pos, res = !copy_from_user((*buf)->data + pos,
msg_sect[cnt].iov_base, msg_sect[cnt].iov_base,
msg_sect[cnt].iov_len); msg_sect[cnt].iov_len);
else else
memcpy((*buf)->data + pos, msg_sect[cnt].iov_base, memcpy((*buf)->data + pos, msg_sect[cnt].iov_base,
msg_sect[cnt].iov_len); msg_sect[cnt].iov_len);
pos += msg_sect[cnt].iov_len; pos += msg_sect[cnt].iov_len;
} }
......
/* /*
* net/tipc/name_distr.c: TIPC name distribution code * net/tipc/name_distr.c: TIPC name distribution code
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -53,15 +53,15 @@ ...@@ -53,15 +53,15 @@
* @upper: name sequence upper bound * @upper: name sequence upper bound
* @ref: publishing port reference * @ref: publishing port reference
* @key: publication key * @key: publication key
* *
* ===> All fields are stored in network byte order. <=== * ===> All fields are stored in network byte order. <===
* *
* First 3 fields identify (name or) name sequence being published. * First 3 fields identify (name or) name sequence being published.
* Reference field uniquely identifies port that published name sequence. * Reference field uniquely identifies port that published name sequence.
* Key field uniquely identifies publication, in the event a port has * Key field uniquely identifies publication, in the event a port has
* multiple publications of the same name sequence. * multiple publications of the same name sequence.
* *
* Note: There is no field that identifies the publishing node because it is * Note: There is no field that identifies the publishing node because it is
* the same for all items contained within a publication message. * the same for all items contained within a publication message.
*/ */
...@@ -74,12 +74,12 @@ struct distr_item { ...@@ -74,12 +74,12 @@ struct distr_item {
}; };
/** /**
* List of externally visible publications by this node -- * List of externally visible publications by this node --
* that is, all publications having scope > TIPC_NODE_SCOPE. * that is, all publications having scope > TIPC_NODE_SCOPE.
*/ */
static LIST_HEAD(publ_root); static LIST_HEAD(publ_root);
static u32 publ_cnt = 0; static u32 publ_cnt = 0;
/** /**
* publ_to_item - add publication info to a publication message * publ_to_item - add publication info to a publication message
...@@ -101,12 +101,12 @@ static void publ_to_item(struct distr_item *i, struct publication *p) ...@@ -101,12 +101,12 @@ static void publ_to_item(struct distr_item *i, struct publication *p)
static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest) static struct sk_buff *named_prepare_buf(u32 type, u32 size, u32 dest)
{ {
struct sk_buff *buf = buf_acquire(LONG_H_SIZE + size); struct sk_buff *buf = buf_acquire(LONG_H_SIZE + size);
struct tipc_msg *msg; struct tipc_msg *msg;
if (buf != NULL) { if (buf != NULL) {
msg = buf_msg(buf); msg = buf_msg(buf);
msg_init(msg, NAME_DISTRIBUTOR, type, TIPC_OK, msg_init(msg, NAME_DISTRIBUTOR, type, TIPC_OK,
LONG_H_SIZE, dest); LONG_H_SIZE, dest);
msg_set_size(msg, LONG_H_SIZE + size); msg_set_size(msg, LONG_H_SIZE + size);
} }
...@@ -174,7 +174,7 @@ void tipc_named_node_up(unsigned long node) ...@@ -174,7 +174,7 @@ void tipc_named_node_up(unsigned long node)
u32 rest; u32 rest;
u32 max_item_buf; u32 max_item_buf;
read_lock_bh(&tipc_nametbl_lock); read_lock_bh(&tipc_nametbl_lock);
max_item_buf = TIPC_MAX_USER_MSG_SIZE / ITEM_SIZE; max_item_buf = TIPC_MAX_USER_MSG_SIZE / ITEM_SIZE;
max_item_buf *= ITEM_SIZE; max_item_buf *= ITEM_SIZE;
rest = publ_cnt * ITEM_SIZE; rest = publ_cnt * ITEM_SIZE;
...@@ -183,7 +183,7 @@ void tipc_named_node_up(unsigned long node) ...@@ -183,7 +183,7 @@ void tipc_named_node_up(unsigned long node)
if (!buf) { if (!buf) {
left = (rest <= max_item_buf) ? rest : max_item_buf; left = (rest <= max_item_buf) ? rest : max_item_buf;
rest -= left; rest -= left;
buf = named_prepare_buf(PUBLICATION, left, node); buf = named_prepare_buf(PUBLICATION, left, node);
if (!buf) { if (!buf) {
warn("Bulk publication distribution failure\n"); warn("Bulk publication distribution failure\n");
goto exit; goto exit;
...@@ -196,20 +196,20 @@ void tipc_named_node_up(unsigned long node) ...@@ -196,20 +196,20 @@ void tipc_named_node_up(unsigned long node)
if (!left) { if (!left) {
msg_set_link_selector(buf_msg(buf), node); msg_set_link_selector(buf_msg(buf), node);
dbg("tipc_named_node_up: sending publish msg to " dbg("tipc_named_node_up: sending publish msg to "
"<%u.%u.%u>\n", tipc_zone(node), "<%u.%u.%u>\n", tipc_zone(node),
tipc_cluster(node), tipc_node(node)); tipc_cluster(node), tipc_node(node));
tipc_link_send(buf, node, node); tipc_link_send(buf, node, node);
buf = NULL; buf = NULL;
} }
} }
exit: exit:
read_unlock_bh(&tipc_nametbl_lock); read_unlock_bh(&tipc_nametbl_lock);
} }
/** /**
* node_is_down - remove publication associated with a failed node * node_is_down - remove publication associated with a failed node
* *
* Invoked for each publication issued by a newly failed node. * Invoked for each publication issued by a newly failed node.
* Removes publication structure from name table & deletes it. * Removes publication structure from name table & deletes it.
* In rare cases the link may have come back up again when this * In rare cases the link may have come back up again when this
* function is called, and we have two items representing the same * function is called, and we have two items representing the same
...@@ -221,15 +221,15 @@ static void node_is_down(struct publication *publ) ...@@ -221,15 +221,15 @@ static void node_is_down(struct publication *publ)
{ {
struct publication *p; struct publication *p;
write_lock_bh(&tipc_nametbl_lock); write_lock_bh(&tipc_nametbl_lock);
dbg("node_is_down: withdrawing %u, %u, %u\n", dbg("node_is_down: withdrawing %u, %u, %u\n",
publ->type, publ->lower, publ->upper); publ->type, publ->lower, publ->upper);
publ->key += 1222345; publ->key += 1222345;
p = tipc_nametbl_remove_publ(publ->type, publ->lower, p = tipc_nametbl_remove_publ(publ->type, publ->lower,
publ->node, publ->ref, publ->key); publ->node, publ->ref, publ->key);
write_unlock_bh(&tipc_nametbl_lock); write_unlock_bh(&tipc_nametbl_lock);
if (p != publ) { if (p != publ) {
err("Unable to remove publication from failed node\n" err("Unable to remove publication from failed node\n"
"(type=%u, lower=%u, node=0x%x, ref=%u, key=%u)\n", "(type=%u, lower=%u, node=0x%x, ref=%u, key=%u)\n",
publ->type, publ->lower, publ->node, publ->ref, publ->key); publ->type, publ->lower, publ->node, publ->ref, publ->key);
...@@ -251,27 +251,27 @@ void tipc_named_recv(struct sk_buff *buf) ...@@ -251,27 +251,27 @@ void tipc_named_recv(struct sk_buff *buf)
struct distr_item *item = (struct distr_item *)msg_data(msg); struct distr_item *item = (struct distr_item *)msg_data(msg);
u32 count = msg_data_sz(msg) / ITEM_SIZE; u32 count = msg_data_sz(msg) / ITEM_SIZE;
write_lock_bh(&tipc_nametbl_lock); write_lock_bh(&tipc_nametbl_lock);
while (count--) { while (count--) {
if (msg_type(msg) == PUBLICATION) { if (msg_type(msg) == PUBLICATION) {
dbg("tipc_named_recv: got publication for %u, %u, %u\n", dbg("tipc_named_recv: got publication for %u, %u, %u\n",
ntohl(item->type), ntohl(item->lower), ntohl(item->type), ntohl(item->lower),
ntohl(item->upper)); ntohl(item->upper));
publ = tipc_nametbl_insert_publ(ntohl(item->type), publ = tipc_nametbl_insert_publ(ntohl(item->type),
ntohl(item->lower), ntohl(item->lower),
ntohl(item->upper), ntohl(item->upper),
TIPC_CLUSTER_SCOPE, TIPC_CLUSTER_SCOPE,
msg_orignode(msg), msg_orignode(msg),
ntohl(item->ref), ntohl(item->ref),
ntohl(item->key)); ntohl(item->key));
if (publ) { if (publ) {
tipc_nodesub_subscribe(&publ->subscr, tipc_nodesub_subscribe(&publ->subscr,
msg_orignode(msg), msg_orignode(msg),
publ, publ,
(net_ev_handler)node_is_down); (net_ev_handler)node_is_down);
} }
} else if (msg_type(msg) == WITHDRAWAL) { } else if (msg_type(msg) == WITHDRAWAL) {
dbg("tipc_named_recv: got withdrawl for %u, %u, %u\n", dbg("tipc_named_recv: got withdrawl for %u, %u, %u\n",
ntohl(item->type), ntohl(item->lower), ntohl(item->type), ntohl(item->lower),
ntohl(item->upper)); ntohl(item->upper));
publ = tipc_nametbl_remove_publ(ntohl(item->type), publ = tipc_nametbl_remove_publ(ntohl(item->type),
...@@ -282,7 +282,7 @@ void tipc_named_recv(struct sk_buff *buf) ...@@ -282,7 +282,7 @@ void tipc_named_recv(struct sk_buff *buf)
if (publ) { if (publ) {
tipc_nodesub_unsubscribe(&publ->subscr); tipc_nodesub_unsubscribe(&publ->subscr);
kfree(publ); kfree(publ);
} else { } else {
err("Unable to remove publication by node 0x%x\n" err("Unable to remove publication by node 0x%x\n"
"(type=%u, lower=%u, ref=%u, key=%u)\n", "(type=%u, lower=%u, ref=%u, key=%u)\n",
...@@ -295,13 +295,13 @@ void tipc_named_recv(struct sk_buff *buf) ...@@ -295,13 +295,13 @@ void tipc_named_recv(struct sk_buff *buf)
} }
item++; item++;
} }
write_unlock_bh(&tipc_nametbl_lock); write_unlock_bh(&tipc_nametbl_lock);
buf_discard(buf); buf_discard(buf);
} }
/** /**
* tipc_named_reinit - re-initialize local publication list * tipc_named_reinit - re-initialize local publication list
* *
* This routine is called whenever TIPC networking is (re)enabled. * This routine is called whenever TIPC networking is (re)enabled.
* All existing publications by this node that have "cluster" or "zone" scope * All existing publications by this node that have "cluster" or "zone" scope
* are updated to reflect the node's current network address. * are updated to reflect the node's current network address.
...@@ -312,11 +312,11 @@ void tipc_named_reinit(void) ...@@ -312,11 +312,11 @@ void tipc_named_reinit(void)
{ {
struct publication *publ; struct publication *publ;
write_lock_bh(&tipc_nametbl_lock); write_lock_bh(&tipc_nametbl_lock);
list_for_each_entry(publ, &publ_root, local_list) { list_for_each_entry(publ, &publ_root, local_list) {
if (publ->node == tipc_own_addr) if (publ->node == tipc_own_addr)
break; break;
publ->node = tipc_own_addr; publ->node = tipc_own_addr;
} }
write_unlock_bh(&tipc_nametbl_lock); write_unlock_bh(&tipc_nametbl_lock);
} }
/* /*
* net/tipc/name_distr.h: Include file for TIPC name distribution code * net/tipc/name_distr.h: Include file for TIPC name distribution code
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
......
/* /*
* net/tipc/name_table.c: TIPC name table code * net/tipc/name_table.c: TIPC name table code
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2004-2005, Wind River Systems * Copyright (c) 2004-2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -65,7 +65,7 @@ struct sub_seq { ...@@ -65,7 +65,7 @@ struct sub_seq {
struct publication *zone_list; struct publication *zone_list;
}; };
/** /**
* struct name_seq - container for all published instances of a name type * struct name_seq - container for all published instances of a name type
* @type: 32 bit 'type' value for name sequence * @type: 32 bit 'type' value for name sequence
* @sseq: pointer to dynamically-sized array of sub-sequences of this 'type'; * @sseq: pointer to dynamically-sized array of sub-sequences of this 'type';
...@@ -89,7 +89,7 @@ struct name_seq { ...@@ -89,7 +89,7 @@ struct name_seq {
/** /**
* struct name_table - table containing all existing port name publications * struct name_table - table containing all existing port name publications
* @types: pointer to fixed-sized array of name sequence lists, * @types: pointer to fixed-sized array of name sequence lists,
* accessed via hashing on 'type'; name sequence lists are *not* sorted * accessed via hashing on 'type'; name sequence lists are *not* sorted
* @local_publ_count: number of publications issued by this node * @local_publ_count: number of publications issued by this node
*/ */
...@@ -113,8 +113,8 @@ static int hash(int x) ...@@ -113,8 +113,8 @@ static int hash(int x)
* publ_create - create a publication structure * publ_create - create a publication structure
*/ */
static struct publication *publ_create(u32 type, u32 lower, u32 upper, static struct publication *publ_create(u32 type, u32 lower, u32 upper,
u32 scope, u32 node, u32 port_ref, u32 scope, u32 node, u32 port_ref,
u32 key) u32 key)
{ {
struct publication *publ = kzalloc(sizeof(*publ), GFP_ATOMIC); struct publication *publ = kzalloc(sizeof(*publ), GFP_ATOMIC);
...@@ -148,7 +148,7 @@ static struct sub_seq *tipc_subseq_alloc(u32 cnt) ...@@ -148,7 +148,7 @@ static struct sub_seq *tipc_subseq_alloc(u32 cnt)
/** /**
* tipc_nameseq_create - create a name sequence structure for the specified 'type' * tipc_nameseq_create - create a name sequence structure for the specified 'type'
* *
* Allocates a single sub-sequence structure and sets it to all 0's. * Allocates a single sub-sequence structure and sets it to all 0's.
*/ */
...@@ -178,7 +178,7 @@ static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_hea ...@@ -178,7 +178,7 @@ static struct name_seq *tipc_nameseq_create(u32 type, struct hlist_head *seq_hea
/** /**
* nameseq_find_subseq - find sub-sequence (if any) matching a name instance * nameseq_find_subseq - find sub-sequence (if any) matching a name instance
* *
* Very time-critical, so binary searches through sub-sequence array. * Very time-critical, so binary searches through sub-sequence array.
*/ */
...@@ -204,7 +204,7 @@ static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq, ...@@ -204,7 +204,7 @@ static struct sub_seq *nameseq_find_subseq(struct name_seq *nseq,
/** /**
* nameseq_locate_subseq - determine position of name instance in sub-sequence * nameseq_locate_subseq - determine position of name instance in sub-sequence
* *
* Returns index in sub-sequence array of the entry that contains the specified * Returns index in sub-sequence array of the entry that contains the specified
* instance value; if no entry contains that value, returns the position * instance value; if no entry contains that value, returns the position
* where a new entry for it would be inserted in the array. * where a new entry for it would be inserted in the array.
...@@ -232,7 +232,7 @@ static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance) ...@@ -232,7 +232,7 @@ static u32 nameseq_locate_subseq(struct name_seq *nseq, u32 instance)
} }
/** /**
* tipc_nameseq_insert_publ - * tipc_nameseq_insert_publ -
*/ */
static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
...@@ -343,8 +343,8 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, ...@@ -343,8 +343,8 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
} }
} }
/* /*
* Any subscriptions waiting for notification? * Any subscriptions waiting for notification?
*/ */
list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) { list_for_each_entry_safe(s, st, &nseq->subscriptions, nameseq_list) {
dbg("calling report_overlap()\n"); dbg("calling report_overlap()\n");
...@@ -352,7 +352,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, ...@@ -352,7 +352,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
publ->lower, publ->lower,
publ->upper, publ->upper,
TIPC_PUBLISHED, TIPC_PUBLISHED,
publ->ref, publ->ref,
publ->node, publ->node,
created_subseq); created_subseq);
} }
...@@ -361,7 +361,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq, ...@@ -361,7 +361,7 @@ static struct publication *tipc_nameseq_insert_publ(struct name_seq *nseq,
/** /**
* tipc_nameseq_remove_publ - * tipc_nameseq_remove_publ -
* *
* NOTE: There may be cases where TIPC is asked to remove a publication * NOTE: There may be cases where TIPC is asked to remove a publication
* that is not in the name table. For example, if another node issues a * that is not in the name table. For example, if another node issues a
* publication for a name sequence that overlaps an existing name sequence * publication for a name sequence that overlaps an existing name sequence
...@@ -392,12 +392,12 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i ...@@ -392,12 +392,12 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
prev = sseq->zone_list; prev = sseq->zone_list;
publ = sseq->zone_list->zone_list_next; publ = sseq->zone_list->zone_list_next;
while ((publ->key != key) || (publ->ref != ref) || while ((publ->key != key) || (publ->ref != ref) ||
(publ->node && (publ->node != node))) { (publ->node && (publ->node != node))) {
prev = publ; prev = publ;
publ = publ->zone_list_next; publ = publ->zone_list_next;
if (prev == sseq->zone_list) { if (prev == sseq->zone_list) {
/* Prevent endless loop if publication not found */ /* Prevent endless loop if publication not found */
return NULL; return NULL;
...@@ -426,7 +426,7 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i ...@@ -426,7 +426,7 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
err("Unable to de-list cluster publication\n" err("Unable to de-list cluster publication\n"
"{%u%u}, node=0x%x, ref=%u, key=%u)\n", "{%u%u}, node=0x%x, ref=%u, key=%u)\n",
publ->type, publ->lower, publ->node, publ->type, publ->lower, publ->node,
publ->ref, publ->key); publ->ref, publ->key);
goto end_cluster; goto end_cluster;
} }
...@@ -456,7 +456,7 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i ...@@ -456,7 +456,7 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
err("Unable to de-list node publication\n" err("Unable to de-list node publication\n"
"{%u%u}, node=0x%x, ref=%u, key=%u)\n", "{%u%u}, node=0x%x, ref=%u, key=%u)\n",
publ->type, publ->lower, publ->node, publ->type, publ->lower, publ->node,
publ->ref, publ->key); publ->ref, publ->key);
goto end_node; goto end_node;
} }
...@@ -486,8 +486,8 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i ...@@ -486,8 +486,8 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
tipc_subscr_report_overlap(s, tipc_subscr_report_overlap(s,
publ->lower, publ->lower,
publ->upper, publ->upper,
TIPC_WITHDRAWN, TIPC_WITHDRAWN,
publ->ref, publ->ref,
publ->node, publ->node,
removed_subseq); removed_subseq);
} }
...@@ -517,8 +517,8 @@ void tipc_nameseq_subscribe(struct name_seq *nseq, struct subscription *s) ...@@ -517,8 +517,8 @@ void tipc_nameseq_subscribe(struct name_seq *nseq, struct subscription *s)
int must_report = 1; int must_report = 1;
do { do {
tipc_subscr_report_overlap(s, tipc_subscr_report_overlap(s,
sseq->lower, sseq->lower,
sseq->upper, sseq->upper,
TIPC_PUBLISHED, TIPC_PUBLISHED,
crs->ref, crs->ref,
...@@ -576,7 +576,7 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, ...@@ -576,7 +576,7 @@ struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
scope, node, port, key); scope, node, port, key);
} }
struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
u32 node, u32 ref, u32 key) u32 node, u32 ref, u32 key)
{ {
struct publication *publ; struct publication *publ;
...@@ -676,14 +676,14 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode) ...@@ -676,14 +676,14 @@ u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *destnode)
/** /**
* tipc_nametbl_mc_translate - find multicast destinations * tipc_nametbl_mc_translate - find multicast destinations
* *
* Creates list of all local ports that overlap the given multicast address; * Creates list of all local ports that overlap the given multicast address;
* also determines if any off-node ports overlap. * also determines if any off-node ports overlap.
* *
* Note: Publications with a scope narrower than 'limit' are ignored. * Note: Publications with a scope narrower than 'limit' are ignored.
* (i.e. local node-scope publications mustn't receive messages arriving * (i.e. local node-scope publications mustn't receive messages arriving
* from another node, even if the multcast link brought it here) * from another node, even if the multcast link brought it here)
* *
* Returns non-zero if any off-node ports overlap * Returns non-zero if any off-node ports overlap
*/ */
...@@ -730,7 +730,7 @@ int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, ...@@ -730,7 +730,7 @@ int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
* tipc_nametbl_publish_rsv - publish port name using a reserved name type * tipc_nametbl_publish_rsv - publish port name using a reserved name type
*/ */
int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope, int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope,
struct tipc_name_seq const *seq) struct tipc_name_seq const *seq)
{ {
int res; int res;
...@@ -745,13 +745,13 @@ int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope, ...@@ -745,13 +745,13 @@ int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope,
* tipc_nametbl_publish - add name publication to network name tables * tipc_nametbl_publish - add name publication to network name tables
*/ */
struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
u32 scope, u32 port_ref, u32 key) u32 scope, u32 port_ref, u32 key)
{ {
struct publication *publ; struct publication *publ;
if (table.local_publ_count >= tipc_max_publications) { if (table.local_publ_count >= tipc_max_publications) {
warn("Publication failed, local publication limit reached (%u)\n", warn("Publication failed, local publication limit reached (%u)\n",
tipc_max_publications); tipc_max_publications);
return NULL; return NULL;
} }
...@@ -808,22 +808,22 @@ void tipc_nametbl_subscribe(struct subscription *s) ...@@ -808,22 +808,22 @@ void tipc_nametbl_subscribe(struct subscription *s)
u32 type = s->seq.type; u32 type = s->seq.type;
struct name_seq *seq; struct name_seq *seq;
write_lock_bh(&tipc_nametbl_lock); write_lock_bh(&tipc_nametbl_lock);
seq = nametbl_find_seq(type); seq = nametbl_find_seq(type);
if (!seq) { if (!seq) {
seq = tipc_nameseq_create(type, &table.types[hash(type)]); seq = tipc_nameseq_create(type, &table.types[hash(type)]);
} }
if (seq){ if (seq){
spin_lock_bh(&seq->lock); spin_lock_bh(&seq->lock);
dbg("tipc_nametbl_subscribe:found %p for {%u,%u,%u}\n", dbg("tipc_nametbl_subscribe:found %p for {%u,%u,%u}\n",
seq, type, s->seq.lower, s->seq.upper); seq, type, s->seq.lower, s->seq.upper);
tipc_nameseq_subscribe(seq, s); tipc_nameseq_subscribe(seq, s);
spin_unlock_bh(&seq->lock); spin_unlock_bh(&seq->lock);
} else { } else {
warn("Failed to create subscription for {%u,%u,%u}\n", warn("Failed to create subscription for {%u,%u,%u}\n",
s->seq.type, s->seq.lower, s->seq.upper); s->seq.type, s->seq.lower, s->seq.upper);
} }
write_unlock_bh(&tipc_nametbl_lock); write_unlock_bh(&tipc_nametbl_lock);
} }
/** /**
...@@ -834,19 +834,19 @@ void tipc_nametbl_unsubscribe(struct subscription *s) ...@@ -834,19 +834,19 @@ void tipc_nametbl_unsubscribe(struct subscription *s)
{ {
struct name_seq *seq; struct name_seq *seq;
write_lock_bh(&tipc_nametbl_lock); write_lock_bh(&tipc_nametbl_lock);
seq = nametbl_find_seq(s->seq.type); seq = nametbl_find_seq(s->seq.type);
if (seq != NULL){ if (seq != NULL){
spin_lock_bh(&seq->lock); spin_lock_bh(&seq->lock);
list_del_init(&s->nameseq_list); list_del_init(&s->nameseq_list);
spin_unlock_bh(&seq->lock); spin_unlock_bh(&seq->lock);
if ((seq->first_free == 0) && list_empty(&seq->subscriptions)) { if ((seq->first_free == 0) && list_empty(&seq->subscriptions)) {
hlist_del_init(&seq->ns_list); hlist_del_init(&seq->ns_list);
kfree(seq->sseqs); kfree(seq->sseqs);
kfree(seq); kfree(seq);
} }
} }
write_unlock_bh(&tipc_nametbl_lock); write_unlock_bh(&tipc_nametbl_lock);
} }
...@@ -952,7 +952,7 @@ static void nametbl_header(struct print_buf *buf, u32 depth) ...@@ -952,7 +952,7 @@ static void nametbl_header(struct print_buf *buf, u32 depth)
* nametbl_list - print specified name table contents into the given buffer * nametbl_list - print specified name table contents into the given buffer
*/ */
static void nametbl_list(struct print_buf *buf, u32 depth_info, static void nametbl_list(struct print_buf *buf, u32 depth_info,
u32 type, u32 lowbound, u32 upbound) u32 type, u32 lowbound, u32 upbound)
{ {
struct hlist_head *seq_head; struct hlist_head *seq_head;
...@@ -976,7 +976,7 @@ static void nametbl_list(struct print_buf *buf, u32 depth_info, ...@@ -976,7 +976,7 @@ static void nametbl_list(struct print_buf *buf, u32 depth_info,
for (i = 0; i < tipc_nametbl_size; i++) { for (i = 0; i < tipc_nametbl_size; i++) {
seq_head = &table.types[i]; seq_head = &table.types[i];
hlist_for_each_entry(seq, seq_node, seq_head, ns_list) { hlist_for_each_entry(seq, seq_node, seq_head, ns_list) {
nameseq_list(seq, buf, depth, seq->type, nameseq_list(seq, buf, depth, seq->type,
lowbound, upbound, i); lowbound, upbound, i);
} }
} }
...@@ -991,7 +991,7 @@ static void nametbl_list(struct print_buf *buf, u32 depth_info, ...@@ -991,7 +991,7 @@ static void nametbl_list(struct print_buf *buf, u32 depth_info,
seq_head = &table.types[i]; seq_head = &table.types[i];
hlist_for_each_entry(seq, seq_node, seq_head, ns_list) { hlist_for_each_entry(seq, seq_node, seq_head, ns_list) {
if (seq->type == type) { if (seq->type == type) {
nameseq_list(seq, buf, depth, type, nameseq_list(seq, buf, depth, type,
lowbound, upbound, i); lowbound, upbound, i);
break; break;
} }
...@@ -1030,7 +1030,7 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space) ...@@ -1030,7 +1030,7 @@ struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space)
tipc_printbuf_init(&b, TLV_DATA(rep_tlv), MAX_NAME_TBL_QUERY); tipc_printbuf_init(&b, TLV_DATA(rep_tlv), MAX_NAME_TBL_QUERY);
argv = (struct tipc_name_table_query *)TLV_DATA(req_tlv_area); argv = (struct tipc_name_table_query *)TLV_DATA(req_tlv_area);
read_lock_bh(&tipc_nametbl_lock); read_lock_bh(&tipc_nametbl_lock);
nametbl_list(&b, ntohl(argv->depth), ntohl(argv->type), nametbl_list(&b, ntohl(argv->depth), ntohl(argv->type),
ntohl(argv->lowbound), ntohl(argv->upbound)); ntohl(argv->lowbound), ntohl(argv->upbound));
read_unlock_bh(&tipc_nametbl_lock); read_unlock_bh(&tipc_nametbl_lock);
str_len = tipc_printbuf_validate(&b); str_len = tipc_printbuf_validate(&b);
......
/* /*
* net/tipc/name_table.h: Include file for TIPC name table code * net/tipc/name_table.h: Include file for TIPC name table code
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2004-2005, Wind River Systems * Copyright (c) 2004-2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -64,7 +64,7 @@ struct port_list; ...@@ -64,7 +64,7 @@ struct port_list;
* @node_list: next matching name seq publication with >= node scope * @node_list: next matching name seq publication with >= node scope
* @cluster_list: next matching name seq publication with >= cluster scope * @cluster_list: next matching name seq publication with >= cluster scope
* @zone_list: next matching name seq publication with >= zone scope * @zone_list: next matching name seq publication with >= zone scope
* *
* Note that the node list, cluster list, and zone list are circular lists. * Note that the node list, cluster list, and zone list are circular lists.
*/ */
...@@ -89,16 +89,16 @@ extern rwlock_t tipc_nametbl_lock; ...@@ -89,16 +89,16 @@ extern rwlock_t tipc_nametbl_lock;
struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space); struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space);
u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node); u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node);
int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
struct port_list *dports); struct port_list *dports);
int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope, int tipc_nametbl_publish_rsv(u32 ref, unsigned int scope,
struct tipc_name_seq const *seq); struct tipc_name_seq const *seq);
struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
u32 scope, u32 port_ref, u32 key); u32 scope, u32 port_ref, u32 key);
int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key); int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key);
struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
u32 scope, u32 node, u32 ref, u32 key); u32 scope, u32 node, u32 ref, u32 key);
struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower,
u32 node, u32 ref, u32 key); u32 node, u32 ref, u32 key);
void tipc_nametbl_subscribe(struct subscription *s); void tipc_nametbl_subscribe(struct subscription *s);
void tipc_nametbl_unsubscribe(struct subscription *s); void tipc_nametbl_unsubscribe(struct subscription *s);
......
/* /*
* net/tipc/net.c: TIPC network routing code * net/tipc/net.c: TIPC network routing code
* *
* Copyright (c) 1995-2006, Ericsson AB * Copyright (c) 1995-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -49,63 +49,63 @@ ...@@ -49,63 +49,63 @@
#include "discover.h" #include "discover.h"
#include "config.h" #include "config.h"
/* /*
* The TIPC locking policy is designed to ensure a very fine locking * The TIPC locking policy is designed to ensure a very fine locking
* granularity, permitting complete parallel access to individual * granularity, permitting complete parallel access to individual
* port and node/link instances. The code consists of three major * port and node/link instances. The code consists of three major
* locking domains, each protected with their own disjunct set of locks. * locking domains, each protected with their own disjunct set of locks.
* *
* 1: The routing hierarchy. * 1: The routing hierarchy.
* Comprises the structures 'zone', 'cluster', 'node', 'link' * Comprises the structures 'zone', 'cluster', 'node', 'link'
* and 'bearer'. The whole hierarchy is protected by a big * and 'bearer'. The whole hierarchy is protected by a big
* read/write lock, tipc_net_lock, to enssure that nothing is added * read/write lock, tipc_net_lock, to enssure that nothing is added
* or removed while code is accessing any of these structures. * or removed while code is accessing any of these structures.
* This layer must not be called from the two others while they * This layer must not be called from the two others while they
* hold any of their own locks. * hold any of their own locks.
* Neither must it itself do any upcalls to the other two before * Neither must it itself do any upcalls to the other two before
* it has released tipc_net_lock and other protective locks. * it has released tipc_net_lock and other protective locks.
* *
* Within the tipc_net_lock domain there are two sub-domains;'node' and * Within the tipc_net_lock domain there are two sub-domains;'node' and
* 'bearer', where local write operations are permitted, * 'bearer', where local write operations are permitted,
* provided that those are protected by individual spin_locks * provided that those are protected by individual spin_locks
* per instance. Code holding tipc_net_lock(read) and a node spin_lock * per instance. Code holding tipc_net_lock(read) and a node spin_lock
* is permitted to poke around in both the node itself and its * is permitted to poke around in both the node itself and its
* subordinate links. I.e, it can update link counters and queues, * subordinate links. I.e, it can update link counters and queues,
* change link state, send protocol messages, and alter the * change link state, send protocol messages, and alter the
* "active_links" array in the node; but it can _not_ remove a link * "active_links" array in the node; but it can _not_ remove a link
* or a node from the overall structure. * or a node from the overall structure.
* Correspondingly, individual bearers may change status within a * Correspondingly, individual bearers may change status within a
* tipc_net_lock(read), protected by an individual spin_lock ber bearer * tipc_net_lock(read), protected by an individual spin_lock ber bearer
* instance, but it needs tipc_net_lock(write) to remove/add any bearers. * instance, but it needs tipc_net_lock(write) to remove/add any bearers.
*
* *
* 2: The transport level of the protocol. *
* This consists of the structures port, (and its user level * 2: The transport level of the protocol.
* representations, such as user_port and tipc_sock), reference and * This consists of the structures port, (and its user level
* tipc_user (port.c, reg.c, socket.c). * representations, such as user_port and tipc_sock), reference and
* tipc_user (port.c, reg.c, socket.c).
* *
* This layer has four different locks: * This layer has four different locks:
* - The tipc_port spin_lock. This is protecting each port instance * - The tipc_port spin_lock. This is protecting each port instance
* from parallel data access and removal. Since we can not place * from parallel data access and removal. Since we can not place
* this lock in the port itself, it has been placed in the * this lock in the port itself, it has been placed in the
* corresponding reference table entry, which has the same life * corresponding reference table entry, which has the same life
* cycle as the module. This entry is difficult to access from * cycle as the module. This entry is difficult to access from
* outside the TIPC core, however, so a pointer to the lock has * outside the TIPC core, however, so a pointer to the lock has
* been added in the port instance, -to be used for unlocking * been added in the port instance, -to be used for unlocking
* only. * only.
* - A read/write lock to protect the reference table itself (teg.c). * - A read/write lock to protect the reference table itself (teg.c).
* (Nobody is using read-only access to this, so it can just as * (Nobody is using read-only access to this, so it can just as
* well be changed to a spin_lock) * well be changed to a spin_lock)
* - A spin lock to protect the registry of kernel/driver users (reg.c) * - A spin lock to protect the registry of kernel/driver users (reg.c)
* - A global spin_lock (tipc_port_lock), which only task is to ensure * - A global spin_lock (tipc_port_lock), which only task is to ensure
* consistency where more than one port is involved in an operation, * consistency where more than one port is involved in an operation,
* i.e., whe a port is part of a linked list of ports. * i.e., whe a port is part of a linked list of ports.
* There are two such lists; 'port_list', which is used for management, * There are two such lists; 'port_list', which is used for management,
* and 'wait_list', which is used to queue ports during congestion. * and 'wait_list', which is used to queue ports during congestion.
* *
* 3: The name table (name_table.c, name_distr.c, subscription.c) * 3: The name table (name_table.c, name_distr.c, subscription.c)
* - There is one big read/write-lock (tipc_nametbl_lock) protecting the * - There is one big read/write-lock (tipc_nametbl_lock) protecting the
* overall name table structure. Nothing must be added/removed to * overall name table structure. Nothing must be added/removed to
* this structure without holding write access to it. * this structure without holding write access to it.
* - There is one local spin_lock per sub_sequence, which can be seen * - There is one local spin_lock per sub_sequence, which can be seen
* as a sub-domain to the tipc_nametbl_lock domain. It is used only * as a sub-domain to the tipc_nametbl_lock domain. It is used only
...@@ -118,7 +118,7 @@ ...@@ -118,7 +118,7 @@
DEFINE_RWLOCK(tipc_net_lock); DEFINE_RWLOCK(tipc_net_lock);
struct network tipc_net = { NULL }; struct network tipc_net = { NULL };
struct node *tipc_net_select_remote_node(u32 addr, u32 ref) struct node *tipc_net_select_remote_node(u32 addr, u32 ref)
{ {
return tipc_zone_select_remote_node(tipc_net.zones[tipc_zone(addr)], addr, ref); return tipc_zone_select_remote_node(tipc_net.zones[tipc_zone(addr)], addr, ref);
} }
...@@ -224,7 +224,7 @@ void tipc_net_route_msg(struct sk_buff *buf) ...@@ -224,7 +224,7 @@ void tipc_net_route_msg(struct sk_buff *buf)
buf_discard(buf); buf_discard(buf);
} else { } else {
msg_dbg(msg, "NET>REJ>:"); msg_dbg(msg, "NET>REJ>:");
tipc_reject_msg(buf, msg_destport(msg) ? tipc_reject_msg(buf, msg_destport(msg) ?
TIPC_ERR_NO_PORT : TIPC_ERR_NO_NAME); TIPC_ERR_NO_PORT : TIPC_ERR_NO_NAME);
} }
return; return;
...@@ -236,7 +236,7 @@ void tipc_net_route_msg(struct sk_buff *buf) ...@@ -236,7 +236,7 @@ void tipc_net_route_msg(struct sk_buff *buf)
dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg); dnode = msg_short(msg) ? tipc_own_addr : msg_destnode(msg);
if (in_scope(dnode, tipc_own_addr)) { if (in_scope(dnode, tipc_own_addr)) {
if (msg_isdata(msg)) { if (msg_isdata(msg)) {
if (msg_mcast(msg)) if (msg_mcast(msg))
tipc_port_recv_mcast(buf, NULL); tipc_port_recv_mcast(buf, NULL);
else if (msg_destport(msg)) else if (msg_destport(msg))
tipc_port_recv_msg(buf); tipc_port_recv_msg(buf);
...@@ -284,7 +284,7 @@ int tipc_net_start(void) ...@@ -284,7 +284,7 @@ int tipc_net_start(void)
(res = tipc_bclink_init())) { (res = tipc_bclink_init())) {
return res; return res;
} }
tipc_subscr_stop(); tipc_subscr_stop();
tipc_cfg_stop(); tipc_cfg_stop();
tipc_k_signal((Handler)tipc_subscr_start, 0); tipc_k_signal((Handler)tipc_subscr_start, 0);
tipc_k_signal((Handler)tipc_cfg_init, 0); tipc_k_signal((Handler)tipc_cfg_init, 0);
...@@ -298,12 +298,12 @@ void tipc_net_stop(void) ...@@ -298,12 +298,12 @@ void tipc_net_stop(void)
{ {
if (tipc_mode != TIPC_NET_MODE) if (tipc_mode != TIPC_NET_MODE)
return; return;
write_lock_bh(&tipc_net_lock); write_lock_bh(&tipc_net_lock);
tipc_bearer_stop(); tipc_bearer_stop();
tipc_mode = TIPC_NODE_MODE; tipc_mode = TIPC_NODE_MODE;
tipc_bclink_stop(); tipc_bclink_stop();
net_stop(); net_stop();
write_unlock_bh(&tipc_net_lock); write_unlock_bh(&tipc_net_lock);
info("Left network mode \n"); info("Left network mode \n");
} }
/* /*
* net/tipc/net.h: Include file for TIPC network routing code * net/tipc/net.h: Include file for TIPC network routing code
* *
* Copyright (c) 1995-2006, Ericsson AB * Copyright (c) 1995-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -43,7 +43,7 @@ struct _zone; ...@@ -43,7 +43,7 @@ struct _zone;
* struct network - TIPC network structure * struct network - TIPC network structure
* @zones: array of pointers to all zones within network * @zones: array of pointers to all zones within network
*/ */
struct network { struct network {
struct _zone **zones; struct _zone **zones;
}; };
......
/* /*
* net/tipc/netlink.c: TIPC configuration handling * net/tipc/netlink.c: TIPC configuration handling
* *
* Copyright (c) 2005-2006, Ericsson AB * Copyright (c) 2005-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -63,15 +63,15 @@ static int handle_cmd(struct sk_buff *skb, struct genl_info *info) ...@@ -63,15 +63,15 @@ static int handle_cmd(struct sk_buff *skb, struct genl_info *info)
genlmsg_unicast(rep_buf, req_nlh->nlmsg_pid); genlmsg_unicast(rep_buf, req_nlh->nlmsg_pid);
} }
return 0; return 0;
} }
static struct genl_family family = { static struct genl_family family = {
.id = GENL_ID_GENERATE, .id = GENL_ID_GENERATE,
.name = TIPC_GENL_NAME, .name = TIPC_GENL_NAME,
.version = TIPC_GENL_VERSION, .version = TIPC_GENL_VERSION,
.hdrsize = TIPC_GENL_HDRLEN, .hdrsize = TIPC_GENL_HDRLEN,
.maxattr = 0, .maxattr = 0,
}; };
static struct genl_ops ops = { static struct genl_ops ops = {
...@@ -93,7 +93,7 @@ int tipc_netlink_start(void) ...@@ -93,7 +93,7 @@ int tipc_netlink_start(void)
if (genl_register_ops(&family, &ops)) if (genl_register_ops(&family, &ops))
goto err_unregister; goto err_unregister;
return 0; return 0;
err_unregister: err_unregister:
genl_unregister_family(&family); genl_unregister_family(&family);
......
/* /*
* net/tipc/node.c: TIPC node management routines * net/tipc/node.c: TIPC node management routines
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2005-2006, Wind River Systems * Copyright (c) 2005-2006, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -58,7 +58,7 @@ struct node *tipc_node_create(u32 addr) ...@@ -58,7 +58,7 @@ struct node *tipc_node_create(u32 addr)
{ {
struct cluster *c_ptr; struct cluster *c_ptr;
struct node *n_ptr; struct node *n_ptr;
struct node **curr_node; struct node **curr_node;
n_ptr = kzalloc(sizeof(*n_ptr),GFP_ATOMIC); n_ptr = kzalloc(sizeof(*n_ptr),GFP_ATOMIC);
if (!n_ptr) { if (!n_ptr) {
...@@ -74,16 +74,16 @@ struct node *tipc_node_create(u32 addr) ...@@ -74,16 +74,16 @@ struct node *tipc_node_create(u32 addr)
kfree(n_ptr); kfree(n_ptr);
return NULL; return NULL;
} }
n_ptr->addr = addr; n_ptr->addr = addr;
spin_lock_init(&n_ptr->lock); spin_lock_init(&n_ptr->lock);
INIT_LIST_HEAD(&n_ptr->nsub); INIT_LIST_HEAD(&n_ptr->nsub);
n_ptr->owner = c_ptr; n_ptr->owner = c_ptr;
tipc_cltr_attach_node(c_ptr, n_ptr); tipc_cltr_attach_node(c_ptr, n_ptr);
n_ptr->last_router = -1; n_ptr->last_router = -1;
/* Insert node into ordered list */ /* Insert node into ordered list */
for (curr_node = &tipc_nodes; *curr_node; for (curr_node = &tipc_nodes; *curr_node;
curr_node = &(*curr_node)->next) { curr_node = &(*curr_node)->next) {
if (addr < (*curr_node)->addr) { if (addr < (*curr_node)->addr) {
n_ptr->next = *curr_node; n_ptr->next = *curr_node;
...@@ -116,7 +116,7 @@ void tipc_node_delete(struct node *n_ptr) ...@@ -116,7 +116,7 @@ void tipc_node_delete(struct node *n_ptr)
/** /**
* tipc_node_link_up - handle addition of link * tipc_node_link_up - handle addition of link
* *
* Link becomes active (alone or shared) or standby, depending on its priority. * Link becomes active (alone or shared) or standby, depending on its priority.
*/ */
...@@ -128,19 +128,19 @@ void tipc_node_link_up(struct node *n_ptr, struct link *l_ptr) ...@@ -128,19 +128,19 @@ void tipc_node_link_up(struct node *n_ptr, struct link *l_ptr)
info("Established link <%s> on network plane %c\n", info("Established link <%s> on network plane %c\n",
l_ptr->name, l_ptr->b_ptr->net_plane); l_ptr->name, l_ptr->b_ptr->net_plane);
if (!active[0]) { if (!active[0]) {
dbg(" link %x into %x/%x\n", l_ptr, &active[0], &active[1]); dbg(" link %x into %x/%x\n", l_ptr, &active[0], &active[1]);
active[0] = active[1] = l_ptr; active[0] = active[1] = l_ptr;
node_established_contact(n_ptr); node_established_contact(n_ptr);
return; return;
} }
if (l_ptr->priority < active[0]->priority) { if (l_ptr->priority < active[0]->priority) {
info("New link <%s> becomes standby\n", l_ptr->name); info("New link <%s> becomes standby\n", l_ptr->name);
return; return;
} }
tipc_link_send_duplicate(active[0], l_ptr); tipc_link_send_duplicate(active[0], l_ptr);
if (l_ptr->priority == active[0]->priority) { if (l_ptr->priority == active[0]->priority) {
active[0] = l_ptr; active[0] = l_ptr;
return; return;
} }
...@@ -160,17 +160,17 @@ static void node_select_active_links(struct node *n_ptr) ...@@ -160,17 +160,17 @@ static void node_select_active_links(struct node *n_ptr)
u32 i; u32 i;
u32 highest_prio = 0; u32 highest_prio = 0;
active[0] = active[1] = NULL; active[0] = active[1] = NULL;
for (i = 0; i < MAX_BEARERS; i++) { for (i = 0; i < MAX_BEARERS; i++) {
struct link *l_ptr = n_ptr->links[i]; struct link *l_ptr = n_ptr->links[i];
if (!l_ptr || !tipc_link_is_up(l_ptr) || if (!l_ptr || !tipc_link_is_up(l_ptr) ||
(l_ptr->priority < highest_prio)) (l_ptr->priority < highest_prio))
continue; continue;
if (l_ptr->priority > highest_prio) { if (l_ptr->priority > highest_prio) {
highest_prio = l_ptr->priority; highest_prio = l_ptr->priority;
active[0] = active[1] = l_ptr; active[0] = active[1] = l_ptr;
} else { } else {
active[1] = l_ptr; active[1] = l_ptr;
...@@ -203,15 +203,15 @@ void tipc_node_link_down(struct node *n_ptr, struct link *l_ptr) ...@@ -203,15 +203,15 @@ void tipc_node_link_down(struct node *n_ptr, struct link *l_ptr)
active[1] = active[0]; active[1] = active[0];
if (active[0] == l_ptr) if (active[0] == l_ptr)
node_select_active_links(n_ptr); node_select_active_links(n_ptr);
if (tipc_node_is_up(n_ptr)) if (tipc_node_is_up(n_ptr))
tipc_link_changeover(l_ptr); tipc_link_changeover(l_ptr);
else else
node_lost_contact(n_ptr); node_lost_contact(n_ptr);
} }
int tipc_node_has_active_links(struct node *n_ptr) int tipc_node_has_active_links(struct node *n_ptr)
{ {
return (n_ptr && return (n_ptr &&
((n_ptr->active_links[0]) || (n_ptr->active_links[1]))); ((n_ptr->active_links[0]) || (n_ptr->active_links[1])));
} }
...@@ -236,28 +236,28 @@ struct node *tipc_node_attach_link(struct link *l_ptr) ...@@ -236,28 +236,28 @@ struct node *tipc_node_attach_link(struct link *l_ptr)
if (!n_ptr) if (!n_ptr)
n_ptr = tipc_node_create(l_ptr->addr); n_ptr = tipc_node_create(l_ptr->addr);
if (n_ptr) { if (n_ptr) {
u32 bearer_id = l_ptr->b_ptr->identity; u32 bearer_id = l_ptr->b_ptr->identity;
char addr_string[16]; char addr_string[16];
if (n_ptr->link_cnt >= 2) { if (n_ptr->link_cnt >= 2) {
char addr_string[16]; char addr_string[16];
err("Attempt to create third link to %s\n", err("Attempt to create third link to %s\n",
addr_string_fill(addr_string, n_ptr->addr)); addr_string_fill(addr_string, n_ptr->addr));
return NULL; return NULL;
} }
if (!n_ptr->links[bearer_id]) { if (!n_ptr->links[bearer_id]) {
n_ptr->links[bearer_id] = l_ptr; n_ptr->links[bearer_id] = l_ptr;
tipc_net.zones[tipc_zone(l_ptr->addr)]->links++; tipc_net.zones[tipc_zone(l_ptr->addr)]->links++;
n_ptr->link_cnt++; n_ptr->link_cnt++;
return n_ptr; return n_ptr;
} }
err("Attempt to establish second link on <%s> to %s \n", err("Attempt to establish second link on <%s> to %s \n",
l_ptr->b_ptr->publ.name, l_ptr->b_ptr->publ.name,
addr_string_fill(addr_string, l_ptr->addr)); addr_string_fill(addr_string, l_ptr->addr));
} }
return NULL; return NULL;
} }
...@@ -272,17 +272,17 @@ void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr) ...@@ -272,17 +272,17 @@ void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr)
* Routing table management - five cases to handle: * Routing table management - five cases to handle:
* *
* 1: A link towards a zone/cluster external node comes up. * 1: A link towards a zone/cluster external node comes up.
* => Send a multicast message updating routing tables of all * => Send a multicast message updating routing tables of all
* system nodes within own cluster that the new destination * system nodes within own cluster that the new destination
* can be reached via this node. * can be reached via this node.
* (node.establishedContact()=>cluster.multicastNewRoute()) * (node.establishedContact()=>cluster.multicastNewRoute())
* *
* 2: A link towards a slave node comes up. * 2: A link towards a slave node comes up.
* => Send a multicast message updating routing tables of all * => Send a multicast message updating routing tables of all
* system nodes within own cluster that the new destination * system nodes within own cluster that the new destination
* can be reached via this node. * can be reached via this node.
* (node.establishedContact()=>cluster.multicastNewRoute()) * (node.establishedContact()=>cluster.multicastNewRoute())
* => Send a message to the slave node about existence * => Send a message to the slave node about existence
* of all system nodes within cluster: * of all system nodes within cluster:
* (node.establishedContact()=>cluster.sendLocalRoutes()) * (node.establishedContact()=>cluster.sendLocalRoutes())
* *
...@@ -292,13 +292,13 @@ void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr) ...@@ -292,13 +292,13 @@ void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr)
* nodes which can be reached via this node. * nodes which can be reached via this node.
* (node.establishedContact()==>network.sendExternalRoutes()) * (node.establishedContact()==>network.sendExternalRoutes())
* (node.establishedContact()==>network.sendSlaveRoutes()) * (node.establishedContact()==>network.sendSlaveRoutes())
* => Send messages to all directly connected slave nodes * => Send messages to all directly connected slave nodes
* containing information about the existence of the new node * containing information about the existence of the new node
* (node.establishedContact()=>cluster.multicastNewRoute()) * (node.establishedContact()=>cluster.multicastNewRoute())
* *
* 4: The link towards a zone/cluster external node or slave * 4: The link towards a zone/cluster external node or slave
* node goes down. * node goes down.
* => Send a multcast message updating routing tables of all * => Send a multcast message updating routing tables of all
* nodes within cluster that the new destination can not any * nodes within cluster that the new destination can not any
* longer be reached via this node. * longer be reached via this node.
* (node.lostAllLinks()=>cluster.bcastLostRoute()) * (node.lostAllLinks()=>cluster.bcastLostRoute())
...@@ -308,7 +308,7 @@ void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr) ...@@ -308,7 +308,7 @@ void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr)
* routing tables. Note: This is a completely node * routing tables. Note: This is a completely node
* local operation. * local operation.
* (node.lostAllLinks()=>network.removeAsRouter()) * (node.lostAllLinks()=>network.removeAsRouter())
* => Send messages to all directly connected slave nodes * => Send messages to all directly connected slave nodes
* containing information about loss of the node * containing information about loss of the node
* (node.establishedContact()=>cluster.multicastLostRoute()) * (node.establishedContact()=>cluster.multicastLostRoute())
* *
...@@ -319,12 +319,12 @@ static void node_established_contact(struct node *n_ptr) ...@@ -319,12 +319,12 @@ static void node_established_contact(struct node *n_ptr)
struct cluster *c_ptr; struct cluster *c_ptr;
dbg("node_established_contact:-> %x\n", n_ptr->addr); dbg("node_established_contact:-> %x\n", n_ptr->addr);
if (!tipc_node_has_active_routes(n_ptr) && in_own_cluster(n_ptr->addr)) { if (!tipc_node_has_active_routes(n_ptr) && in_own_cluster(n_ptr->addr)) {
tipc_k_signal((Handler)tipc_named_node_up, n_ptr->addr); tipc_k_signal((Handler)tipc_named_node_up, n_ptr->addr);
} }
/* Syncronize broadcast acks */ /* Syncronize broadcast acks */
n_ptr->bclink.acked = tipc_bclink_get_last_sent(); n_ptr->bclink.acked = tipc_bclink_get_last_sent();
if (is_slave(tipc_own_addr)) if (is_slave(tipc_own_addr))
return; return;
...@@ -333,11 +333,11 @@ static void node_established_contact(struct node *n_ptr) ...@@ -333,11 +333,11 @@ static void node_established_contact(struct node *n_ptr)
c_ptr = tipc_cltr_find(tipc_own_addr); c_ptr = tipc_cltr_find(tipc_own_addr);
if (!c_ptr) if (!c_ptr)
c_ptr = tipc_cltr_create(tipc_own_addr); c_ptr = tipc_cltr_create(tipc_own_addr);
if (c_ptr) if (c_ptr)
tipc_cltr_bcast_new_route(c_ptr, n_ptr->addr, 1, tipc_cltr_bcast_new_route(c_ptr, n_ptr->addr, 1,
tipc_max_nodes); tipc_max_nodes);
return; return;
} }
c_ptr = n_ptr->owner; c_ptr = n_ptr->owner;
if (is_slave(n_ptr->addr)) { if (is_slave(n_ptr->addr)) {
...@@ -367,26 +367,26 @@ static void node_lost_contact(struct node *n_ptr) ...@@ -367,26 +367,26 @@ static void node_lost_contact(struct node *n_ptr)
char addr_string[16]; char addr_string[16];
u32 i; u32 i;
/* Clean up broadcast reception remains */ /* Clean up broadcast reception remains */
n_ptr->bclink.gap_after = n_ptr->bclink.gap_to = 0; n_ptr->bclink.gap_after = n_ptr->bclink.gap_to = 0;
while (n_ptr->bclink.deferred_head) { while (n_ptr->bclink.deferred_head) {
struct sk_buff* buf = n_ptr->bclink.deferred_head; struct sk_buff* buf = n_ptr->bclink.deferred_head;
n_ptr->bclink.deferred_head = buf->next; n_ptr->bclink.deferred_head = buf->next;
buf_discard(buf); buf_discard(buf);
} }
if (n_ptr->bclink.defragm) { if (n_ptr->bclink.defragm) {
buf_discard(n_ptr->bclink.defragm); buf_discard(n_ptr->bclink.defragm);
n_ptr->bclink.defragm = NULL; n_ptr->bclink.defragm = NULL;
} }
if (in_own_cluster(n_ptr->addr) && n_ptr->bclink.supported) { if (in_own_cluster(n_ptr->addr) && n_ptr->bclink.supported) {
tipc_bclink_acknowledge(n_ptr, mod(n_ptr->bclink.acked + 10000)); tipc_bclink_acknowledge(n_ptr, mod(n_ptr->bclink.acked + 10000));
} }
/* Update routing tables */ /* Update routing tables */
if (is_slave(tipc_own_addr)) { if (is_slave(tipc_own_addr)) {
tipc_net_remove_as_router(n_ptr->addr); tipc_net_remove_as_router(n_ptr->addr);
} else { } else {
if (!in_own_cluster(n_ptr->addr)) { if (!in_own_cluster(n_ptr->addr)) {
/* Case 4 (see above) */ /* Case 4 (see above) */
c_ptr = tipc_cltr_find(tipc_own_addr); c_ptr = tipc_cltr_find(tipc_own_addr);
tipc_cltr_bcast_lost_route(c_ptr, n_ptr->addr, 1, tipc_cltr_bcast_lost_route(c_ptr, n_ptr->addr, 1,
...@@ -399,7 +399,7 @@ static void node_lost_contact(struct node *n_ptr) ...@@ -399,7 +399,7 @@ static void node_lost_contact(struct node *n_ptr)
tipc_max_nodes); tipc_max_nodes);
} else { } else {
if (n_ptr->bclink.supported) { if (n_ptr->bclink.supported) {
tipc_nmap_remove(&tipc_cltr_bcast_nodes, tipc_nmap_remove(&tipc_cltr_bcast_nodes,
n_ptr->addr); n_ptr->addr);
if (n_ptr->addr < tipc_own_addr) if (n_ptr->addr < tipc_own_addr)
tipc_own_tag--; tipc_own_tag--;
...@@ -414,13 +414,13 @@ static void node_lost_contact(struct node *n_ptr) ...@@ -414,13 +414,13 @@ static void node_lost_contact(struct node *n_ptr)
if (tipc_node_has_active_routes(n_ptr)) if (tipc_node_has_active_routes(n_ptr))
return; return;
info("Lost contact with %s\n", info("Lost contact with %s\n",
addr_string_fill(addr_string, n_ptr->addr)); addr_string_fill(addr_string, n_ptr->addr));
/* Abort link changeover */ /* Abort link changeover */
for (i = 0; i < MAX_BEARERS; i++) { for (i = 0; i < MAX_BEARERS; i++) {
struct link *l_ptr = n_ptr->links[i]; struct link *l_ptr = n_ptr->links[i];
if (!l_ptr) if (!l_ptr)
continue; continue;
l_ptr->reset_checkpoint = l_ptr->next_in_no; l_ptr->reset_checkpoint = l_ptr->next_in_no;
l_ptr->exp_msg_count = 0; l_ptr->exp_msg_count = 0;
...@@ -429,7 +429,7 @@ static void node_lost_contact(struct node *n_ptr) ...@@ -429,7 +429,7 @@ static void node_lost_contact(struct node *n_ptr)
/* Notify subscribers */ /* Notify subscribers */
list_for_each_entry_safe(ns, tns, &n_ptr->nsub, nodesub_list) { list_for_each_entry_safe(ns, tns, &n_ptr->nsub, nodesub_list) {
ns->node = NULL; ns->node = NULL;
list_del_init(&ns->nodesub_list); list_del_init(&ns->nodesub_list);
tipc_k_signal((Handler)ns->handle_node_down, tipc_k_signal((Handler)ns->handle_node_down,
(unsigned long)ns->usr_handle); (unsigned long)ns->usr_handle);
...@@ -438,7 +438,7 @@ static void node_lost_contact(struct node *n_ptr) ...@@ -438,7 +438,7 @@ static void node_lost_contact(struct node *n_ptr)
/** /**
* tipc_node_select_next_hop - find the next-hop node for a message * tipc_node_select_next_hop - find the next-hop node for a message
* *
* Called by when cluster local lookup has failed. * Called by when cluster local lookup has failed.
*/ */
...@@ -447,13 +447,13 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector) ...@@ -447,13 +447,13 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector)
struct node *n_ptr; struct node *n_ptr;
u32 router_addr; u32 router_addr;
if (!tipc_addr_domain_valid(addr)) if (!tipc_addr_domain_valid(addr))
return NULL; return NULL;
/* Look for direct link to destination processsor */ /* Look for direct link to destination processsor */
n_ptr = tipc_node_find(addr); n_ptr = tipc_node_find(addr);
if (n_ptr && tipc_node_has_active_links(n_ptr)) if (n_ptr && tipc_node_has_active_links(n_ptr))
return n_ptr; return n_ptr;
/* Cluster local system nodes *must* have direct links */ /* Cluster local system nodes *must* have direct links */
if (!is_slave(addr) && in_own_cluster(addr)) if (!is_slave(addr) && in_own_cluster(addr))
...@@ -461,10 +461,10 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector) ...@@ -461,10 +461,10 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector)
/* Look for cluster local router with direct link to node */ /* Look for cluster local router with direct link to node */
router_addr = tipc_node_select_router(n_ptr, selector); router_addr = tipc_node_select_router(n_ptr, selector);
if (router_addr) if (router_addr)
return tipc_node_select(router_addr, selector); return tipc_node_select(router_addr, selector);
/* Slave nodes can only be accessed within own cluster via a /* Slave nodes can only be accessed within own cluster via a
known router with direct link -- if no router was found,give up */ known router with direct link -- if no router was found,give up */
if (is_slave(addr)) if (is_slave(addr))
return NULL; return NULL;
...@@ -473,20 +473,20 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector) ...@@ -473,20 +473,20 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector)
addr = tipc_addr(tipc_zone(addr), tipc_cluster(addr), 0); addr = tipc_addr(tipc_zone(addr), tipc_cluster(addr), 0);
n_ptr = tipc_net_select_remote_node(addr, selector); n_ptr = tipc_net_select_remote_node(addr, selector);
if (n_ptr && tipc_node_has_active_links(n_ptr)) if (n_ptr && tipc_node_has_active_links(n_ptr))
return n_ptr; return n_ptr;
/* Last resort -- look for any router to anywhere in remote zone */ /* Last resort -- look for any router to anywhere in remote zone */
router_addr = tipc_net_select_router(addr, selector); router_addr = tipc_net_select_router(addr, selector);
if (router_addr) if (router_addr)
return tipc_node_select(router_addr, selector); return tipc_node_select(router_addr, selector);
return NULL; return NULL;
} }
/** /**
* tipc_node_select_router - select router to reach specified node * tipc_node_select_router - select router to reach specified node
* *
* Uses a deterministic and fair algorithm for selecting router node. * Uses a deterministic and fair algorithm for selecting router node.
*/ */
u32 tipc_node_select_router(struct node *n_ptr, u32 ref) u32 tipc_node_select_router(struct node *n_ptr, u32 ref)
...@@ -496,8 +496,8 @@ u32 tipc_node_select_router(struct node *n_ptr, u32 ref) ...@@ -496,8 +496,8 @@ u32 tipc_node_select_router(struct node *n_ptr, u32 ref)
u32 start; u32 start;
u32 r; u32 r;
if (!n_ptr) if (!n_ptr)
return 0; return 0;
if (n_ptr->last_router < 0) if (n_ptr->last_router < 0)
return 0; return 0;
...@@ -531,10 +531,10 @@ void tipc_node_add_router(struct node *n_ptr, u32 router) ...@@ -531,10 +531,10 @@ void tipc_node_add_router(struct node *n_ptr, u32 router)
{ {
u32 r_num = tipc_node(router); u32 r_num = tipc_node(router);
n_ptr->routers[r_num / 32] = n_ptr->routers[r_num / 32] =
((1 << (r_num % 32)) | n_ptr->routers[r_num / 32]); ((1 << (r_num % 32)) | n_ptr->routers[r_num / 32]);
n_ptr->last_router = tipc_max_nodes / 32; n_ptr->last_router = tipc_max_nodes / 32;
while ((--n_ptr->last_router >= 0) && while ((--n_ptr->last_router >= 0) &&
!n_ptr->routers[n_ptr->last_router]); !n_ptr->routers[n_ptr->last_router]);
} }
...@@ -548,7 +548,7 @@ void tipc_node_remove_router(struct node *n_ptr, u32 router) ...@@ -548,7 +548,7 @@ void tipc_node_remove_router(struct node *n_ptr, u32 router)
n_ptr->routers[r_num / 32] = n_ptr->routers[r_num / 32] =
((~(1 << (r_num % 32))) & (n_ptr->routers[r_num / 32])); ((~(1 << (r_num % 32))) & (n_ptr->routers[r_num / 32]));
n_ptr->last_router = tipc_max_nodes / 32; n_ptr->last_router = tipc_max_nodes / 32;
while ((--n_ptr->last_router >= 0) && while ((--n_ptr->last_router >= 0) &&
!n_ptr->routers[n_ptr->last_router]); !n_ptr->routers[n_ptr->last_router]);
if (!tipc_node_is_up(n_ptr)) if (!tipc_node_is_up(n_ptr))
...@@ -562,7 +562,7 @@ void node_print(struct print_buf *buf, struct node *n_ptr, char *str) ...@@ -562,7 +562,7 @@ void node_print(struct print_buf *buf, struct node *n_ptr, char *str)
tipc_printf(buf, "\n\n%s", str); tipc_printf(buf, "\n\n%s", str);
for (i = 0; i < MAX_BEARERS; i++) { for (i = 0; i < MAX_BEARERS; i++) {
if (!n_ptr->links[i]) if (!n_ptr->links[i])
continue; continue;
tipc_printf(buf, "Links[%u]: %x, ", i, n_ptr->links[i]); tipc_printf(buf, "Links[%u]: %x, ", i, n_ptr->links[i]);
} }
...@@ -590,7 +590,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) ...@@ -590,7 +590,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
u32 domain; u32 domain;
struct sk_buff *buf; struct sk_buff *buf;
struct node *n_ptr; struct node *n_ptr;
struct tipc_node_info node_info; struct tipc_node_info node_info;
u32 payload_size; u32 payload_size;
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
...@@ -601,10 +601,10 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) ...@@ -601,10 +601,10 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (network address)"); " (network address)");
if (!tipc_nodes) if (!tipc_nodes)
return tipc_cfg_reply_none(); return tipc_cfg_reply_none();
/* For now, get space for all other nodes /* For now, get space for all other nodes
(will need to modify this when slave nodes are supported */ (will need to modify this when slave nodes are supported */
payload_size = TLV_SPACE(sizeof(node_info)) * (tipc_max_nodes - 1); payload_size = TLV_SPACE(sizeof(node_info)) * (tipc_max_nodes - 1);
...@@ -620,9 +620,9 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) ...@@ -620,9 +620,9 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space)
for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) {
if (!in_scope(domain, n_ptr->addr)) if (!in_scope(domain, n_ptr->addr))
continue; continue;
node_info.addr = htonl(n_ptr->addr); node_info.addr = htonl(n_ptr->addr);
node_info.up = htonl(tipc_node_is_up(n_ptr)); node_info.up = htonl(tipc_node_is_up(n_ptr));
tipc_cfg_append_tlv(buf, TIPC_TLV_NODE_INFO, tipc_cfg_append_tlv(buf, TIPC_TLV_NODE_INFO,
&node_info, sizeof(node_info)); &node_info, sizeof(node_info));
} }
...@@ -634,7 +634,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) ...@@ -634,7 +634,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
u32 domain; u32 domain;
struct sk_buff *buf; struct sk_buff *buf;
struct node *n_ptr; struct node *n_ptr;
struct tipc_link_info link_info; struct tipc_link_info link_info;
u32 payload_size; u32 payload_size;
if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR)) if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_NET_ADDR))
...@@ -645,9 +645,9 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) ...@@ -645,9 +645,9 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
" (network address)"); " (network address)");
if (tipc_mode != TIPC_NET_MODE) if (tipc_mode != TIPC_NET_MODE)
return tipc_cfg_reply_none(); return tipc_cfg_reply_none();
/* Get space for all unicast links + multicast link */ /* Get space for all unicast links + multicast link */
payload_size = TLV_SPACE(sizeof(link_info)) * payload_size = TLV_SPACE(sizeof(link_info)) *
...@@ -661,27 +661,27 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) ...@@ -661,27 +661,27 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
/* Add TLV for broadcast link */ /* Add TLV for broadcast link */
link_info.dest = htonl(tipc_own_addr & 0xfffff00); link_info.dest = htonl(tipc_own_addr & 0xfffff00);
link_info.up = htonl(1); link_info.up = htonl(1);
sprintf(link_info.str, tipc_bclink_name); sprintf(link_info.str, tipc_bclink_name);
tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info)); tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info));
/* Add TLVs for any other links in scope */ /* Add TLVs for any other links in scope */
for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) { for (n_ptr = tipc_nodes; n_ptr; n_ptr = n_ptr->next) {
u32 i; u32 i;
if (!in_scope(domain, n_ptr->addr)) if (!in_scope(domain, n_ptr->addr))
continue; continue;
for (i = 0; i < MAX_BEARERS; i++) { for (i = 0; i < MAX_BEARERS; i++) {
if (!n_ptr->links[i]) if (!n_ptr->links[i])
continue; continue;
link_info.dest = htonl(n_ptr->addr); link_info.dest = htonl(n_ptr->addr);
link_info.up = htonl(tipc_link_is_up(n_ptr->links[i])); link_info.up = htonl(tipc_link_is_up(n_ptr->links[i]));
strcpy(link_info.str, n_ptr->links[i]->name); strcpy(link_info.str, n_ptr->links[i]->name);
tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO,
&link_info, sizeof(link_info)); &link_info, sizeof(link_info));
} }
} }
return buf; return buf;
......
/* /*
* net/tipc/node.h: Include file for TIPC node management routines * net/tipc/node.h: Include file for TIPC node management routines
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
* @deferred_tail: newest OOS b'cast message received from node * @deferred_tail: newest OOS b'cast message received from node
* @defragm: list of partially reassembled b'cast message fragments from node * @defragm: list of partially reassembled b'cast message fragments from node
*/ */
struct node { struct node {
u32 addr; u32 addr;
spinlock_t lock; spinlock_t lock;
...@@ -85,8 +85,8 @@ struct node { ...@@ -85,8 +85,8 @@ struct node {
int supported; int supported;
u32 acked; u32 acked;
u32 last_in; u32 last_in;
u32 gap_after; u32 gap_after;
u32 gap_to; u32 gap_to;
u32 nack_sync; u32 nack_sync;
struct sk_buff *deferred_head; struct sk_buff *deferred_head;
struct sk_buff *deferred_tail; struct sk_buff *deferred_tail;
......
/* /*
* net/tipc/node_subscr.c: TIPC "node down" subscription handling * net/tipc/node_subscr.c: TIPC "node down" subscription handling
* *
* Copyright (c) 1995-2006, Ericsson AB * Copyright (c) 1995-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -44,14 +44,14 @@ ...@@ -44,14 +44,14 @@
* tipc_nodesub_subscribe - create "node down" subscription for specified node * tipc_nodesub_subscribe - create "node down" subscription for specified node
*/ */
void tipc_nodesub_subscribe(struct node_subscr *node_sub, u32 addr, void tipc_nodesub_subscribe(struct node_subscr *node_sub, u32 addr,
void *usr_handle, net_ev_handler handle_down) void *usr_handle, net_ev_handler handle_down)
{ {
if (addr == tipc_own_addr) { if (addr == tipc_own_addr) {
node_sub->node = NULL; node_sub->node = NULL;
return; return;
} }
node_sub->node = tipc_node_find(addr); node_sub->node = tipc_node_find(addr);
if (!node_sub->node) { if (!node_sub->node) {
warn("Node subscription rejected, unknown node 0x%x\n", addr); warn("Node subscription rejected, unknown node 0x%x\n", addr);
......
/* /*
* net/tipc/node_subscr.h: Include file for TIPC "node down" subscription handling * net/tipc/node_subscr.h: Include file for TIPC "node down" subscription handling
* *
* Copyright (c) 1995-2006, Ericsson AB * Copyright (c) 1995-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
......
/* /*
* net/tipc/port.c: TIPC port code * net/tipc/port.c: TIPC port code
* *
* Copyright (c) 1992-2006, Ericsson AB * Copyright (c) 1992-2006, Ericsson AB
* Copyright (c) 2004-2005, Wind River Systems * Copyright (c) 2004-2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -126,8 +126,8 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain, ...@@ -126,8 +126,8 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain,
ext_targets = tipc_nametbl_mc_translate(seq->type, seq->lower, seq->upper, ext_targets = tipc_nametbl_mc_translate(seq->type, seq->lower, seq->upper,
TIPC_NODE_SCOPE, &dports); TIPC_NODE_SCOPE, &dports);
/* Send message to destinations (duplicate it only if necessary) */ /* Send message to destinations (duplicate it only if necessary) */
if (ext_targets) { if (ext_targets) {
if (dports.count != 0) { if (dports.count != 0) {
...@@ -157,7 +157,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain, ...@@ -157,7 +157,7 @@ int tipc_multicast(u32 ref, struct tipc_name_seq const *seq, u32 domain,
/** /**
* tipc_port_recv_mcast - deliver multicast message to all destination ports * tipc_port_recv_mcast - deliver multicast message to all destination ports
* *
* If there is no port list, perform a lookup to create one * If there is no port list, perform a lookup to create one
*/ */
...@@ -213,7 +213,7 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp) ...@@ -213,7 +213,7 @@ void tipc_port_recv_mcast(struct sk_buff *buf, struct port_list *dp)
/** /**
* tipc_createport_raw - create a native TIPC port * tipc_createport_raw - create a native TIPC port
* *
* Returns local port reference * Returns local port reference
*/ */
...@@ -273,7 +273,7 @@ int tipc_deleteport(u32 ref) ...@@ -273,7 +273,7 @@ int tipc_deleteport(u32 ref)
tipc_withdraw(ref, 0, NULL); tipc_withdraw(ref, 0, NULL);
p_ptr = tipc_port_lock(ref); p_ptr = tipc_port_lock(ref);
if (!p_ptr) if (!p_ptr)
return -EINVAL; return -EINVAL;
tipc_ref_discard(ref); tipc_ref_discard(ref);
...@@ -302,7 +302,7 @@ int tipc_deleteport(u32 ref) ...@@ -302,7 +302,7 @@ int tipc_deleteport(u32 ref)
/** /**
* tipc_get_port() - return port associated with 'ref' * tipc_get_port() - return port associated with 'ref'
* *
* Note: Port is not locked. * Note: Port is not locked.
*/ */
...@@ -336,7 +336,7 @@ static int port_unreliable(struct port *p_ptr) ...@@ -336,7 +336,7 @@ static int port_unreliable(struct port *p_ptr)
int tipc_portunreliable(u32 ref, unsigned int *isunreliable) int tipc_portunreliable(u32 ref, unsigned int *isunreliable)
{ {
struct port *p_ptr; struct port *p_ptr;
p_ptr = tipc_port_lock(ref); p_ptr = tipc_port_lock(ref);
if (!p_ptr) if (!p_ptr)
return -EINVAL; return -EINVAL;
...@@ -348,7 +348,7 @@ int tipc_portunreliable(u32 ref, unsigned int *isunreliable) ...@@ -348,7 +348,7 @@ int tipc_portunreliable(u32 ref, unsigned int *isunreliable)
int tipc_set_portunreliable(u32 ref, unsigned int isunreliable) int tipc_set_portunreliable(u32 ref, unsigned int isunreliable)
{ {
struct port *p_ptr; struct port *p_ptr;
p_ptr = tipc_port_lock(ref); p_ptr = tipc_port_lock(ref);
if (!p_ptr) if (!p_ptr)
return -EINVAL; return -EINVAL;
...@@ -365,7 +365,7 @@ static int port_unreturnable(struct port *p_ptr) ...@@ -365,7 +365,7 @@ static int port_unreturnable(struct port *p_ptr)
int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable) int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable)
{ {
struct port *p_ptr; struct port *p_ptr;
p_ptr = tipc_port_lock(ref); p_ptr = tipc_port_lock(ref);
if (!p_ptr) if (!p_ptr)
return -EINVAL; return -EINVAL;
...@@ -377,7 +377,7 @@ int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable) ...@@ -377,7 +377,7 @@ int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable)
int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable) int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable)
{ {
struct port *p_ptr; struct port *p_ptr;
p_ptr = tipc_port_lock(ref); p_ptr = tipc_port_lock(ref);
if (!p_ptr) if (!p_ptr)
return -EINVAL; return -EINVAL;
...@@ -386,19 +386,19 @@ int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable) ...@@ -386,19 +386,19 @@ int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable)
return TIPC_OK; return TIPC_OK;
} }
/* /*
* port_build_proto_msg(): build a port level protocol * port_build_proto_msg(): build a port level protocol
* or a connection abortion message. Called with * or a connection abortion message. Called with
* tipc_port lock on. * tipc_port lock on.
*/ */
static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode, static struct sk_buff *port_build_proto_msg(u32 destport, u32 destnode,
u32 origport, u32 orignode, u32 origport, u32 orignode,
u32 usr, u32 type, u32 err, u32 usr, u32 type, u32 err,
u32 seqno, u32 ack) u32 seqno, u32 ack)
{ {
struct sk_buff *buf; struct sk_buff *buf;
struct tipc_msg *msg; struct tipc_msg *msg;
buf = buf_acquire(LONG_H_SIZE); buf = buf_acquire(LONG_H_SIZE);
if (buf) { if (buf) {
msg = buf_msg(buf); msg = buf_msg(buf);
...@@ -461,7 +461,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err) ...@@ -461,7 +461,7 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
msg_set_orignode(rmsg, tipc_own_addr); msg_set_orignode(rmsg, tipc_own_addr);
else else
msg_set_orignode(rmsg, msg_destnode(msg)); msg_set_orignode(rmsg, msg_destnode(msg));
msg_set_size(rmsg, data_sz + hdr_sz); msg_set_size(rmsg, data_sz + hdr_sz);
msg_set_nametype(rmsg, msg_nametype(msg)); msg_set_nametype(rmsg, msg_nametype(msg));
msg_set_nameinst(rmsg, msg_nameinst(msg)); msg_set_nameinst(rmsg, msg_nameinst(msg));
memcpy(rbuf->data + hdr_sz, msg_data(msg), data_sz); memcpy(rbuf->data + hdr_sz, msg_data(msg), data_sz);
...@@ -492,7 +492,7 @@ int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, ...@@ -492,7 +492,7 @@ int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr,
struct sk_buff *buf; struct sk_buff *buf;
int res; int res;
res = msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE, res = msg_build(hdr, msg_sect, num_sect, MAX_MSG_SIZE,
!p_ptr->user_port, &buf); !p_ptr->user_port, &buf);
if (!buf) if (!buf)
return res; return res;
...@@ -523,7 +523,7 @@ static void port_timeout(unsigned long ref) ...@@ -523,7 +523,7 @@ static void port_timeout(unsigned long ref)
tipc_own_addr, tipc_own_addr,
CONN_MANAGER, CONN_MANAGER,
CONN_PROBE, CONN_PROBE,
TIPC_OK, TIPC_OK,
port_out_seqno(p_ptr), port_out_seqno(p_ptr),
0); 0);
port_incr_out_seqno(p_ptr); port_incr_out_seqno(p_ptr);
...@@ -562,7 +562,7 @@ static struct sk_buff *port_build_self_abort_msg(struct port *p_ptr, u32 err) ...@@ -562,7 +562,7 @@ static struct sk_buff *port_build_self_abort_msg(struct port *p_ptr, u32 err)
port_peernode(p_ptr), port_peernode(p_ptr),
imp, imp,
TIPC_CONN_MSG, TIPC_CONN_MSG,
err, err,
p_ptr->last_in_seqno + 1, p_ptr->last_in_seqno + 1,
0); 0);
} }
...@@ -582,7 +582,7 @@ static struct sk_buff *port_build_peer_abort_msg(struct port *p_ptr, u32 err) ...@@ -582,7 +582,7 @@ static struct sk_buff *port_build_peer_abort_msg(struct port *p_ptr, u32 err)
tipc_own_addr, tipc_own_addr,
imp, imp,
TIPC_CONN_MSG, TIPC_CONN_MSG,
err, err,
port_out_seqno(p_ptr), port_out_seqno(p_ptr),
0); 0);
} }
...@@ -613,7 +613,7 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf) ...@@ -613,7 +613,7 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
} }
} }
if (msg_type(msg) == CONN_ACK) { if (msg_type(msg) == CONN_ACK) {
int wakeup = tipc_port_congested(p_ptr) && int wakeup = tipc_port_congested(p_ptr) &&
p_ptr->publ.congested && p_ptr->publ.congested &&
p_ptr->wakeup; p_ptr->wakeup;
p_ptr->acked += msg_msgcnt(msg); p_ptr->acked += msg_msgcnt(msg);
...@@ -630,8 +630,8 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf) ...@@ -630,8 +630,8 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
} }
if (err) { if (err) {
r_buf = port_build_proto_msg(msg_origport(msg), r_buf = port_build_proto_msg(msg_origport(msg),
msg_orignode(msg), msg_orignode(msg),
msg_destport(msg), msg_destport(msg),
tipc_own_addr, tipc_own_addr,
DATA_HIGH, DATA_HIGH,
TIPC_CONN_MSG, TIPC_CONN_MSG,
...@@ -643,10 +643,10 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf) ...@@ -643,10 +643,10 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
/* All is fine */ /* All is fine */
if (msg_type(msg) == CONN_PROBE) { if (msg_type(msg) == CONN_PROBE) {
r_buf = port_build_proto_msg(msg_origport(msg), r_buf = port_build_proto_msg(msg_origport(msg),
msg_orignode(msg), msg_orignode(msg),
msg_destport(msg), msg_destport(msg),
tipc_own_addr, tipc_own_addr,
CONN_MANAGER, CONN_MANAGER,
CONN_PROBE_REPLY, CONN_PROBE_REPLY,
TIPC_OK, TIPC_OK,
...@@ -665,39 +665,39 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf) ...@@ -665,39 +665,39 @@ void tipc_port_recv_proto_msg(struct sk_buff *buf)
static void port_print(struct port *p_ptr, struct print_buf *buf, int full_id) static void port_print(struct port *p_ptr, struct print_buf *buf, int full_id)
{ {
struct publication *publ; struct publication *publ;
if (full_id) if (full_id)
tipc_printf(buf, "<%u.%u.%u:%u>:", tipc_printf(buf, "<%u.%u.%u:%u>:",
tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr), tipc_zone(tipc_own_addr), tipc_cluster(tipc_own_addr),
tipc_node(tipc_own_addr), p_ptr->publ.ref); tipc_node(tipc_own_addr), p_ptr->publ.ref);
else else
tipc_printf(buf, "%-10u:", p_ptr->publ.ref); tipc_printf(buf, "%-10u:", p_ptr->publ.ref);
if (p_ptr->publ.connected) { if (p_ptr->publ.connected) {
u32 dport = port_peerport(p_ptr); u32 dport = port_peerport(p_ptr);
u32 destnode = port_peernode(p_ptr); u32 destnode = port_peernode(p_ptr);
tipc_printf(buf, " connected to <%u.%u.%u:%u>", tipc_printf(buf, " connected to <%u.%u.%u:%u>",
tipc_zone(destnode), tipc_cluster(destnode), tipc_zone(destnode), tipc_cluster(destnode),
tipc_node(destnode), dport); tipc_node(destnode), dport);
if (p_ptr->publ.conn_type != 0) if (p_ptr->publ.conn_type != 0)
tipc_printf(buf, " via {%u,%u}", tipc_printf(buf, " via {%u,%u}",
p_ptr->publ.conn_type, p_ptr->publ.conn_type,
p_ptr->publ.conn_instance); p_ptr->publ.conn_instance);
} }
else if (p_ptr->publ.published) { else if (p_ptr->publ.published) {
tipc_printf(buf, " bound to"); tipc_printf(buf, " bound to");
list_for_each_entry(publ, &p_ptr->publications, pport_list) { list_for_each_entry(publ, &p_ptr->publications, pport_list) {
if (publ->lower == publ->upper) if (publ->lower == publ->upper)
tipc_printf(buf, " {%u,%u}", publ->type, tipc_printf(buf, " {%u,%u}", publ->type,
publ->lower); publ->lower);
else else
tipc_printf(buf, " {%u,%u,%u}", publ->type, tipc_printf(buf, " {%u,%u,%u}", publ->type,
publ->lower, publ->upper); publ->lower, publ->upper);
} }
} }
tipc_printf(buf, "\n"); tipc_printf(buf, "\n");
} }
#define MAX_PORT_QUERY 32768 #define MAX_PORT_QUERY 32768
...@@ -818,7 +818,7 @@ static void port_dispatcher_sigh(void *dummy) ...@@ -818,7 +818,7 @@ static void port_dispatcher_sigh(void *dummy)
struct sk_buff *next = buf->next; struct sk_buff *next = buf->next;
struct tipc_msg *msg = buf_msg(buf); struct tipc_msg *msg = buf_msg(buf);
u32 dref = msg_destport(msg); u32 dref = msg_destport(msg);
message_type = msg_type(msg); message_type = msg_type(msg);
if (message_type > TIPC_DIRECT_MSG) if (message_type > TIPC_DIRECT_MSG)
goto reject; /* Unsupported message type */ goto reject; /* Unsupported message type */
...@@ -838,7 +838,7 @@ static void port_dispatcher_sigh(void *dummy) ...@@ -838,7 +838,7 @@ static void port_dispatcher_sigh(void *dummy)
goto err; goto err;
switch (message_type) { switch (message_type) {
case TIPC_CONN_MSG:{ case TIPC_CONN_MSG:{
tipc_conn_msg_event cb = up_ptr->conn_msg_cb; tipc_conn_msg_event cb = up_ptr->conn_msg_cb;
u32 peer_port = port_peerport(p_ptr); u32 peer_port = port_peerport(p_ptr);
...@@ -856,9 +856,9 @@ static void port_dispatcher_sigh(void *dummy) ...@@ -856,9 +856,9 @@ static void port_dispatcher_sigh(void *dummy)
goto reject; goto reject;
if (unlikely(!cb)) if (unlikely(!cb))
goto reject; goto reject;
if (unlikely(++p_ptr->publ.conn_unacked >= if (unlikely(++p_ptr->publ.conn_unacked >=
TIPC_FLOW_CONTROL_WIN)) TIPC_FLOW_CONTROL_WIN))
tipc_acknowledge(dref, tipc_acknowledge(dref,
p_ptr->publ.conn_unacked); p_ptr->publ.conn_unacked);
skb_pull(buf, msg_hdr_sz(msg)); skb_pull(buf, msg_hdr_sz(msg));
cb(usr_handle, dref, &buf, msg_data(msg), cb(usr_handle, dref, &buf, msg_data(msg),
...@@ -874,7 +874,7 @@ static void port_dispatcher_sigh(void *dummy) ...@@ -874,7 +874,7 @@ static void port_dispatcher_sigh(void *dummy)
if (unlikely(!cb)) if (unlikely(!cb))
goto reject; goto reject;
skb_pull(buf, msg_hdr_sz(msg)); skb_pull(buf, msg_hdr_sz(msg));
cb(usr_handle, dref, &buf, msg_data(msg), cb(usr_handle, dref, &buf, msg_data(msg),
msg_data_sz(msg), msg_importance(msg), msg_data_sz(msg), msg_importance(msg),
&orig); &orig);
break; break;
...@@ -895,7 +895,7 @@ static void port_dispatcher_sigh(void *dummy) ...@@ -895,7 +895,7 @@ static void port_dispatcher_sigh(void *dummy)
dseq.upper = (message_type == TIPC_NAMED_MSG) dseq.upper = (message_type == TIPC_NAMED_MSG)
? dseq.lower : msg_nameupper(msg); ? dseq.lower : msg_nameupper(msg);
skb_pull(buf, msg_hdr_sz(msg)); skb_pull(buf, msg_hdr_sz(msg));
cb(usr_handle, dref, &buf, msg_data(msg), cb(usr_handle, dref, &buf, msg_data(msg),
msg_data_sz(msg), msg_importance(msg), msg_data_sz(msg), msg_importance(msg),
&orig, &dseq); &orig, &dseq);
break; break;
...@@ -907,9 +907,9 @@ static void port_dispatcher_sigh(void *dummy) ...@@ -907,9 +907,9 @@ static void port_dispatcher_sigh(void *dummy)
continue; continue;
err: err:
switch (message_type) { switch (message_type) {
case TIPC_CONN_MSG:{ case TIPC_CONN_MSG:{
tipc_conn_shutdown_event cb = tipc_conn_shutdown_event cb =
up_ptr->conn_err_cb; up_ptr->conn_err_cb;
u32 peer_port = port_peerport(p_ptr); u32 peer_port = port_peerport(p_ptr);
u32 peer_node = port_peernode(p_ptr); u32 peer_node = port_peernode(p_ptr);
...@@ -940,7 +940,7 @@ static void port_dispatcher_sigh(void *dummy) ...@@ -940,7 +940,7 @@ static void port_dispatcher_sigh(void *dummy)
} }
case TIPC_MCAST_MSG: case TIPC_MCAST_MSG:
case TIPC_NAMED_MSG:{ case TIPC_NAMED_MSG:{
tipc_named_msg_err_event cb = tipc_named_msg_err_event cb =
up_ptr->named_err_cb; up_ptr->named_err_cb;
spin_unlock_bh(p_ptr->publ.lock); spin_unlock_bh(p_ptr->publ.lock);
...@@ -951,7 +951,7 @@ static void port_dispatcher_sigh(void *dummy) ...@@ -951,7 +951,7 @@ static void port_dispatcher_sigh(void *dummy)
dseq.upper = (message_type == TIPC_NAMED_MSG) dseq.upper = (message_type == TIPC_NAMED_MSG)
? dseq.lower : msg_nameupper(msg); ? dseq.lower : msg_nameupper(msg);
skb_pull(buf, msg_hdr_sz(msg)); skb_pull(buf, msg_hdr_sz(msg));
cb(usr_handle, dref, &buf, msg_data(msg), cb(usr_handle, dref, &buf, msg_data(msg),
msg_data_sz(msg), msg_errcode(msg), &dseq); msg_data_sz(msg), msg_errcode(msg), &dseq);
break; break;
} }
...@@ -986,9 +986,9 @@ static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf) ...@@ -986,9 +986,9 @@ static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf)
return TIPC_OK; return TIPC_OK;
} }
/* /*
* Wake up port after congestion: Called with port locked, * Wake up port after congestion: Called with port locked,
* *
*/ */
static void port_wakeup_sh(unsigned long ref) static void port_wakeup_sh(unsigned long ref)
...@@ -1033,7 +1033,7 @@ void tipc_acknowledge(u32 ref, u32 ack) ...@@ -1033,7 +1033,7 @@ void tipc_acknowledge(u32 ref, u32 ack)
tipc_own_addr, tipc_own_addr,
CONN_MANAGER, CONN_MANAGER,
CONN_ACK, CONN_ACK,
TIPC_OK, TIPC_OK,
port_out_seqno(p_ptr), port_out_seqno(p_ptr),
ack); ack);
} }
...@@ -1046,20 +1046,20 @@ void tipc_acknowledge(u32 ref, u32 ack) ...@@ -1046,20 +1046,20 @@ void tipc_acknowledge(u32 ref, u32 ack)
* registry if non-zero user_ref. * registry if non-zero user_ref.
*/ */
int tipc_createport(u32 user_ref, int tipc_createport(u32 user_ref,
void *usr_handle, void *usr_handle,
unsigned int importance, unsigned int importance,
tipc_msg_err_event error_cb, tipc_msg_err_event error_cb,
tipc_named_msg_err_event named_error_cb, tipc_named_msg_err_event named_error_cb,
tipc_conn_shutdown_event conn_error_cb, tipc_conn_shutdown_event conn_error_cb,
tipc_msg_event msg_cb, tipc_msg_event msg_cb,
tipc_named_msg_event named_msg_cb, tipc_named_msg_event named_msg_cb,
tipc_conn_msg_event conn_msg_cb, tipc_conn_msg_event conn_msg_cb,
tipc_continue_event continue_event_cb,/* May be zero */ tipc_continue_event continue_event_cb,/* May be zero */
u32 *portref) u32 *portref)
{ {
struct user_port *up_ptr; struct user_port *up_ptr;
struct port *p_ptr; struct port *p_ptr;
u32 ref; u32 ref;
up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC); up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC);
...@@ -1088,7 +1088,7 @@ int tipc_createport(u32 user_ref, ...@@ -1088,7 +1088,7 @@ int tipc_createport(u32 user_ref,
INIT_LIST_HEAD(&up_ptr->uport_list); INIT_LIST_HEAD(&up_ptr->uport_list);
tipc_reg_add_port(up_ptr); tipc_reg_add_port(up_ptr);
*portref = p_ptr->publ.ref; *portref = p_ptr->publ.ref;
dbg(" tipc_createport: %x with ref %u\n", p_ptr, p_ptr->publ.ref); dbg(" tipc_createport: %x with ref %u\n", p_ptr, p_ptr->publ.ref);
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
return TIPC_OK; return TIPC_OK;
} }
...@@ -1103,7 +1103,7 @@ int tipc_ownidentity(u32 ref, struct tipc_portid *id) ...@@ -1103,7 +1103,7 @@ int tipc_ownidentity(u32 ref, struct tipc_portid *id)
int tipc_portimportance(u32 ref, unsigned int *importance) int tipc_portimportance(u32 ref, unsigned int *importance)
{ {
struct port *p_ptr; struct port *p_ptr;
p_ptr = tipc_port_lock(ref); p_ptr = tipc_port_lock(ref);
if (!p_ptr) if (!p_ptr)
return -EINVAL; return -EINVAL;
...@@ -1172,19 +1172,19 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) ...@@ -1172,19 +1172,19 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
struct publication *publ; struct publication *publ;
struct publication *tpubl; struct publication *tpubl;
int res = -EINVAL; int res = -EINVAL;
p_ptr = tipc_port_lock(ref); p_ptr = tipc_port_lock(ref);
if (!p_ptr) if (!p_ptr)
return -EINVAL; return -EINVAL;
if (!seq) { if (!seq) {
list_for_each_entry_safe(publ, tpubl, list_for_each_entry_safe(publ, tpubl,
&p_ptr->publications, pport_list) { &p_ptr->publications, pport_list) {
tipc_nametbl_withdraw(publ->type, publ->lower, tipc_nametbl_withdraw(publ->type, publ->lower,
publ->ref, publ->key); publ->ref, publ->key);
} }
res = TIPC_OK; res = TIPC_OK;
} else { } else {
list_for_each_entry_safe(publ, tpubl, list_for_each_entry_safe(publ, tpubl,
&p_ptr->publications, pport_list) { &p_ptr->publications, pport_list) {
if (publ->scope != scope) if (publ->scope != scope)
continue; continue;
...@@ -1194,7 +1194,7 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq) ...@@ -1194,7 +1194,7 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
continue; continue;
if (publ->upper != seq->upper) if (publ->upper != seq->upper)
break; break;
tipc_nametbl_withdraw(publ->type, publ->lower, tipc_nametbl_withdraw(publ->type, publ->lower,
publ->ref, publ->key); publ->ref, publ->key);
res = TIPC_OK; res = TIPC_OK;
break; break;
...@@ -1292,7 +1292,7 @@ int tipc_shutdown(u32 ref) ...@@ -1292,7 +1292,7 @@ int tipc_shutdown(u32 ref)
tipc_own_addr, tipc_own_addr,
imp, imp,
TIPC_CONN_MSG, TIPC_CONN_MSG,
TIPC_CONN_SHUTDOWN, TIPC_CONN_SHUTDOWN,
port_out_seqno(p_ptr), port_out_seqno(p_ptr),
0); 0);
} }
...@@ -1304,7 +1304,7 @@ int tipc_shutdown(u32 ref) ...@@ -1304,7 +1304,7 @@ int tipc_shutdown(u32 ref)
int tipc_isconnected(u32 ref, int *isconnected) int tipc_isconnected(u32 ref, int *isconnected)
{ {
struct port *p_ptr; struct port *p_ptr;
p_ptr = tipc_port_lock(ref); p_ptr = tipc_port_lock(ref);
if (!p_ptr) if (!p_ptr)
return -EINVAL; return -EINVAL;
...@@ -1317,7 +1317,7 @@ int tipc_peer(u32 ref, struct tipc_portid *peer) ...@@ -1317,7 +1317,7 @@ int tipc_peer(u32 ref, struct tipc_portid *peer)
{ {
struct port *p_ptr; struct port *p_ptr;
int res; int res;
p_ptr = tipc_port_lock(ref); p_ptr = tipc_port_lock(ref);
if (!p_ptr) if (!p_ptr)
return -EINVAL; return -EINVAL;
...@@ -1348,7 +1348,7 @@ int tipc_port_recv_sections(struct port *sender, unsigned int num_sect, ...@@ -1348,7 +1348,7 @@ int tipc_port_recv_sections(struct port *sender, unsigned int num_sect,
{ {
struct sk_buff *buf; struct sk_buff *buf;
int res; int res;
res = msg_build(&sender->publ.phdr, msg_sect, num_sect, res = msg_build(&sender->publ.phdr, msg_sect, num_sect,
MAX_MSG_SIZE, !sender->user_port, &buf); MAX_MSG_SIZE, !sender->user_port, &buf);
if (likely(buf)) if (likely(buf))
...@@ -1394,7 +1394,7 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect) ...@@ -1394,7 +1394,7 @@ int tipc_send(u32 ref, unsigned int num_sect, struct iovec const *msg_sect)
return -ELINKCONG; return -ELINKCONG;
} }
/** /**
* tipc_send_buf - send message buffer on connection * tipc_send_buf - send message buffer on connection
*/ */
...@@ -1406,7 +1406,7 @@ int tipc_send_buf(u32 ref, struct sk_buff *buf, unsigned int dsz) ...@@ -1406,7 +1406,7 @@ int tipc_send_buf(u32 ref, struct sk_buff *buf, unsigned int dsz)
u32 hsz; u32 hsz;
u32 sz; u32 sz;
u32 res; u32 res;
p_ptr = tipc_port_deref(ref); p_ptr = tipc_port_deref(ref);
if (!p_ptr || !p_ptr->publ.connected) if (!p_ptr || !p_ptr->publ.connected)
return -EINVAL; return -EINVAL;
...@@ -1447,12 +1447,12 @@ int tipc_send_buf(u32 ref, struct sk_buff *buf, unsigned int dsz) ...@@ -1447,12 +1447,12 @@ int tipc_send_buf(u32 ref, struct sk_buff *buf, unsigned int dsz)
* tipc_forward2name - forward message sections to port name * tipc_forward2name - forward message sections to port name
*/ */
int tipc_forward2name(u32 ref, int tipc_forward2name(u32 ref,
struct tipc_name const *name, struct tipc_name const *name,
u32 domain, u32 domain,
u32 num_sect, u32 num_sect,
struct iovec const *msg_sect, struct iovec const *msg_sect,
struct tipc_portid const *orig, struct tipc_portid const *orig,
unsigned int importance) unsigned int importance)
{ {
struct port *p_ptr; struct port *p_ptr;
...@@ -1483,7 +1483,7 @@ int tipc_forward2name(u32 ref, ...@@ -1483,7 +1483,7 @@ int tipc_forward2name(u32 ref,
p_ptr->sent++; p_ptr->sent++;
if (likely(destnode == tipc_own_addr)) if (likely(destnode == tipc_own_addr))
return tipc_port_recv_sections(p_ptr, num_sect, msg_sect); return tipc_port_recv_sections(p_ptr, num_sect, msg_sect);
res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect, res = tipc_link_send_sections_fast(p_ptr, msg_sect, num_sect,
destnode); destnode);
if (likely(res != -ELINKCONG)) if (likely(res != -ELINKCONG))
return res; return res;
...@@ -1493,7 +1493,7 @@ int tipc_forward2name(u32 ref, ...@@ -1493,7 +1493,7 @@ int tipc_forward2name(u32 ref,
} }
return -ELINKCONG; return -ELINKCONG;
} }
return tipc_port_reject_sections(p_ptr, msg, msg_sect, num_sect, return tipc_port_reject_sections(p_ptr, msg, msg_sect, num_sect,
TIPC_ERR_NO_NAME); TIPC_ERR_NO_NAME);
} }
...@@ -1501,10 +1501,10 @@ int tipc_forward2name(u32 ref, ...@@ -1501,10 +1501,10 @@ int tipc_forward2name(u32 ref,
* tipc_send2name - send message sections to port name * tipc_send2name - send message sections to port name
*/ */
int tipc_send2name(u32 ref, int tipc_send2name(u32 ref,
struct tipc_name const *name, struct tipc_name const *name,
unsigned int domain, unsigned int domain,
unsigned int num_sect, unsigned int num_sect,
struct iovec const *msg_sect) struct iovec const *msg_sect)
{ {
struct tipc_portid orig; struct tipc_portid orig;
...@@ -1515,7 +1515,7 @@ int tipc_send2name(u32 ref, ...@@ -1515,7 +1515,7 @@ int tipc_send2name(u32 ref,
TIPC_PORT_IMPORTANCE); TIPC_PORT_IMPORTANCE);
} }
/** /**
* tipc_forward_buf2name - forward message buffer to port name * tipc_forward_buf2name - forward message buffer to port name
*/ */
...@@ -1571,14 +1571,14 @@ int tipc_forward_buf2name(u32 ref, ...@@ -1571,14 +1571,14 @@ int tipc_forward_buf2name(u32 ref,
return tipc_reject_msg(buf, TIPC_ERR_NO_NAME); return tipc_reject_msg(buf, TIPC_ERR_NO_NAME);
} }
/** /**
* tipc_send_buf2name - send message buffer to port name * tipc_send_buf2name - send message buffer to port name
*/ */
int tipc_send_buf2name(u32 ref, int tipc_send_buf2name(u32 ref,
struct tipc_name const *dest, struct tipc_name const *dest,
u32 domain, u32 domain,
struct sk_buff *buf, struct sk_buff *buf,
unsigned int dsz) unsigned int dsz)
{ {
struct tipc_portid orig; struct tipc_portid orig;
...@@ -1589,15 +1589,15 @@ int tipc_send_buf2name(u32 ref, ...@@ -1589,15 +1589,15 @@ int tipc_send_buf2name(u32 ref,
TIPC_PORT_IMPORTANCE); TIPC_PORT_IMPORTANCE);
} }
/** /**
* tipc_forward2port - forward message sections to port identity * tipc_forward2port - forward message sections to port identity
*/ */
int tipc_forward2port(u32 ref, int tipc_forward2port(u32 ref,
struct tipc_portid const *dest, struct tipc_portid const *dest,
unsigned int num_sect, unsigned int num_sect,
struct iovec const *msg_sect, struct iovec const *msg_sect,
struct tipc_portid const *orig, struct tipc_portid const *orig,
unsigned int importance) unsigned int importance)
{ {
struct port *p_ptr; struct port *p_ptr;
...@@ -1630,24 +1630,24 @@ int tipc_forward2port(u32 ref, ...@@ -1630,24 +1630,24 @@ int tipc_forward2port(u32 ref,
return -ELINKCONG; return -ELINKCONG;
} }
/** /**
* tipc_send2port - send message sections to port identity * tipc_send2port - send message sections to port identity
*/ */
int tipc_send2port(u32 ref, int tipc_send2port(u32 ref,
struct tipc_portid const *dest, struct tipc_portid const *dest,
unsigned int num_sect, unsigned int num_sect,
struct iovec const *msg_sect) struct iovec const *msg_sect)
{ {
struct tipc_portid orig; struct tipc_portid orig;
orig.ref = ref; orig.ref = ref;
orig.node = tipc_own_addr; orig.node = tipc_own_addr;
return tipc_forward2port(ref, dest, num_sect, msg_sect, &orig, return tipc_forward2port(ref, dest, num_sect, msg_sect, &orig,
TIPC_PORT_IMPORTANCE); TIPC_PORT_IMPORTANCE);
} }
/** /**
* tipc_forward_buf2port - forward message buffer to port identity * tipc_forward_buf2port - forward message buffer to port identity
*/ */
int tipc_forward_buf2port(u32 ref, int tipc_forward_buf2port(u32 ref,
...@@ -1692,20 +1692,20 @@ int tipc_forward_buf2port(u32 ref, ...@@ -1692,20 +1692,20 @@ int tipc_forward_buf2port(u32 ref,
return -ELINKCONG; return -ELINKCONG;
} }
/** /**
* tipc_send_buf2port - send message buffer to port identity * tipc_send_buf2port - send message buffer to port identity
*/ */
int tipc_send_buf2port(u32 ref, int tipc_send_buf2port(u32 ref,
struct tipc_portid const *dest, struct tipc_portid const *dest,
struct sk_buff *buf, struct sk_buff *buf,
unsigned int dsz) unsigned int dsz)
{ {
struct tipc_portid orig; struct tipc_portid orig;
orig.ref = ref; orig.ref = ref;
orig.node = tipc_own_addr; orig.node = tipc_own_addr;
return tipc_forward_buf2port(ref, dest, buf, dsz, &orig, return tipc_forward_buf2port(ref, dest, buf, dsz, &orig,
TIPC_PORT_IMPORTANCE); TIPC_PORT_IMPORTANCE);
} }
/* /*
* net/tipc/port.h: Include file for TIPC port code * net/tipc/port.h: Include file for TIPC port code
* *
* Copyright (c) 1994-2006, Ericsson AB * Copyright (c) 1994-2006, Ericsson AB
* Copyright (c) 2004-2005, Wind River Systems * Copyright (c) 2004-2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -52,17 +52,17 @@ ...@@ -52,17 +52,17 @@
* <various callback routines> * <various callback routines>
* @uport_list: adjacent user ports in list of ports held by user * @uport_list: adjacent user ports in list of ports held by user
*/ */
struct user_port { struct user_port {
u32 user_ref; u32 user_ref;
void *usr_handle; void *usr_handle;
u32 ref; u32 ref;
tipc_msg_err_event err_cb; tipc_msg_err_event err_cb;
tipc_named_msg_err_event named_err_cb; tipc_named_msg_err_event named_err_cb;
tipc_conn_shutdown_event conn_err_cb; tipc_conn_shutdown_event conn_err_cb;
tipc_msg_event msg_cb; tipc_msg_event msg_cb;
tipc_named_msg_event named_msg_cb; tipc_named_msg_event named_msg_cb;
tipc_conn_msg_event conn_msg_cb; tipc_conn_msg_event conn_msg_cb;
tipc_continue_event continue_event_cb; tipc_continue_event continue_event_cb;
struct list_head uport_list; struct list_head uport_list;
}; };
...@@ -113,7 +113,7 @@ struct port { ...@@ -113,7 +113,7 @@ struct port {
extern spinlock_t tipc_port_list_lock; extern spinlock_t tipc_port_list_lock;
struct port_list; struct port_list;
int tipc_port_recv_sections(struct port *p_ptr, u32 num_sect, int tipc_port_recv_sections(struct port *p_ptr, u32 num_sect,
struct iovec const *msg_sect); struct iovec const *msg_sect);
int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr, int tipc_port_reject_sections(struct port *p_ptr, struct tipc_msg *hdr,
struct iovec const *msg_sect, u32 num_sect, struct iovec const *msg_sect, u32 num_sect,
...@@ -133,9 +133,9 @@ static inline struct port *tipc_port_lock(u32 ref) ...@@ -133,9 +133,9 @@ static inline struct port *tipc_port_lock(u32 ref)
return (struct port *)tipc_ref_lock(ref); return (struct port *)tipc_ref_lock(ref);
} }
/** /**
* tipc_port_unlock - unlock a port instance * tipc_port_unlock - unlock a port instance
* *
* Can use pointer instead of tipc_ref_unlock() since port is already locked. * Can use pointer instead of tipc_ref_unlock() since port is already locked.
*/ */
...@@ -164,7 +164,7 @@ static inline int tipc_port_congested(struct port *p_ptr) ...@@ -164,7 +164,7 @@ static inline int tipc_port_congested(struct port *p_ptr)
return((p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2)); return((p_ptr->sent - p_ptr->acked) >= (TIPC_FLOW_CONTROL_WIN * 2));
} }
/** /**
* tipc_port_recv_msg - receive message from lower layer and deliver to port user * tipc_port_recv_msg - receive message from lower layer and deliver to port user
*/ */
...@@ -175,7 +175,7 @@ static inline int tipc_port_recv_msg(struct sk_buff *buf) ...@@ -175,7 +175,7 @@ static inline int tipc_port_recv_msg(struct sk_buff *buf)
u32 destport = msg_destport(msg); u32 destport = msg_destport(msg);
u32 dsz = msg_data_sz(msg); u32 dsz = msg_data_sz(msg);
u32 err; u32 err;
/* forward unresolved named message */ /* forward unresolved named message */
if (unlikely(!destport)) { if (unlikely(!destport)) {
tipc_net_route_msg(buf); tipc_net_route_msg(buf);
......
/* /*
* net/tipc/ref.c: TIPC object registry code * net/tipc/ref.c: TIPC object registry code
* *
* Copyright (c) 1991-2006, Ericsson AB * Copyright (c) 1991-2006, Ericsson AB
* Copyright (c) 2004-2005, Wind River Systems * Copyright (c) 2004-2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -50,11 +50,11 @@ ...@@ -50,11 +50,11 @@
* Object reference table consists of 2**N entries. * Object reference table consists of 2**N entries.
* *
* A used entry has object ptr != 0, reference == XXXX|own index * A used entry has object ptr != 0, reference == XXXX|own index
* (XXXX changes each time entry is acquired) * (XXXX changes each time entry is acquired)
* A free entry has object ptr == 0, reference == YYYY|next free index * A free entry has object ptr == 0, reference == YYYY|next free index
* (YYYY is one more than last used XXXX) * (YYYY is one more than last used XXXX)
* *
* Free list is initially chained from entry (2**N)-1 to entry 1. * Free list is initially chained from entry (2**N)-1 to entry 1.
* Entry 0 is not used to allow index 0 to indicate the end of the free list. * Entry 0 is not used to allow index 0 to indicate the end of the free list.
* *
* Note: Any accidental reference of the form XXXX|0--0 won't match entry 0 * Note: Any accidental reference of the form XXXX|0--0 won't match entry 0
...@@ -113,9 +113,9 @@ void tipc_ref_table_stop(void) ...@@ -113,9 +113,9 @@ void tipc_ref_table_stop(void)
/** /**
* tipc_ref_acquire - create reference to an object * tipc_ref_acquire - create reference to an object
* *
* Return a unique reference value which can be translated back to the pointer * Return a unique reference value which can be translated back to the pointer
* 'object' at a later time. Also, pass back a pointer to the lock protecting * 'object' at a later time. Also, pass back a pointer to the lock protecting
* the object, but without locking it. * the object, but without locking it.
*/ */
...@@ -141,15 +141,15 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock) ...@@ -141,15 +141,15 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
index = tipc_ref_table.first_free; index = tipc_ref_table.first_free;
entry = &(tipc_ref_table.entries[index]); entry = &(tipc_ref_table.entries[index]);
index_mask = tipc_ref_table.index_mask; index_mask = tipc_ref_table.index_mask;
/* take lock in case a previous user of entry still holds it */ /* take lock in case a previous user of entry still holds it */
spin_lock_bh(&entry->lock); spin_lock_bh(&entry->lock);
next_plus_upper = entry->data.next_plus_upper; next_plus_upper = entry->data.next_plus_upper;
tipc_ref_table.first_free = next_plus_upper & index_mask; tipc_ref_table.first_free = next_plus_upper & index_mask;
reference = (next_plus_upper & ~index_mask) + index; reference = (next_plus_upper & ~index_mask) + index;
entry->data.reference = reference; entry->data.reference = reference;
entry->object = object; entry->object = object;
if (lock != 0) if (lock != 0)
*lock = &entry->lock; *lock = &entry->lock;
spin_unlock_bh(&entry->lock); spin_unlock_bh(&entry->lock);
} }
write_unlock_bh(&ref_table_lock); write_unlock_bh(&ref_table_lock);
...@@ -158,7 +158,7 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock) ...@@ -158,7 +158,7 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
/** /**
* tipc_ref_discard - invalidate references to an object * tipc_ref_discard - invalidate references to an object
* *
* Disallow future references to an object and free up the entry for re-use. * Disallow future references to an object and free up the entry for re-use.
* Note: The entry's spin_lock may still be busy after discard * Note: The entry's spin_lock may still be busy after discard
*/ */
...@@ -166,7 +166,7 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock) ...@@ -166,7 +166,7 @@ u32 tipc_ref_acquire(void *object, spinlock_t **lock)
void tipc_ref_discard(u32 ref) void tipc_ref_discard(u32 ref)
{ {
struct reference *entry; struct reference *entry;
u32 index; u32 index;
u32 index_mask; u32 index_mask;
if (!ref) { if (!ref) {
...@@ -198,7 +198,7 @@ void tipc_ref_discard(u32 ref) ...@@ -198,7 +198,7 @@ void tipc_ref_discard(u32 ref)
tipc_ref_table.first_free = index; tipc_ref_table.first_free = index;
else else
/* next_plus_upper is always XXXX|0--0 for last free entry */ /* next_plus_upper is always XXXX|0--0 for last free entry */
tipc_ref_table.entries[tipc_ref_table.last_free].data.next_plus_upper tipc_ref_table.entries[tipc_ref_table.last_free].data.next_plus_upper
|= index; |= index;
tipc_ref_table.last_free = index; tipc_ref_table.last_free = index;
......
/* /*
* net/tipc/ref.h: Include file for TIPC object registry code * net/tipc/ref.h: Include file for TIPC object registry code
* *
* Copyright (c) 1991-2006, Ericsson AB * Copyright (c) 1991-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
* @lock: spinlock controlling access to object * @lock: spinlock controlling access to object
* @data: reference value associated with object (or link to next unused entry) * @data: reference value associated with object (or link to next unused entry)
*/ */
struct reference { struct reference {
void *object; void *object;
spinlock_t lock; spinlock_t lock;
...@@ -96,7 +96,7 @@ static inline void *tipc_ref_lock(u32 ref) ...@@ -96,7 +96,7 @@ static inline void *tipc_ref_lock(u32 ref)
} }
/** /**
* tipc_ref_unlock - unlock referenced object * tipc_ref_unlock - unlock referenced object
*/ */
static inline void tipc_ref_unlock(u32 ref) static inline void tipc_ref_unlock(u32 ref)
...@@ -119,7 +119,7 @@ static inline void tipc_ref_unlock(u32 ref) ...@@ -119,7 +119,7 @@ static inline void tipc_ref_unlock(u32 ref)
static inline void *tipc_ref_deref(u32 ref) static inline void *tipc_ref_deref(u32 ref)
{ {
if (likely(tipc_ref_table.entries)) { if (likely(tipc_ref_table.entries)) {
struct reference *r = struct reference *r =
&tipc_ref_table.entries[ref & tipc_ref_table.index_mask]; &tipc_ref_table.entries[ref & tipc_ref_table.index_mask];
if (likely(r->data.reference == ref)) if (likely(r->data.reference == ref))
......
/* /*
* net/tipc/socket.c: TIPC socket API * net/tipc/socket.c: TIPC socket API
* *
* Copyright (c) 2001-2006, Ericsson AB * Copyright (c) 2001-2006, Ericsson AB
* Copyright (c) 2004-2006, Wind River Systems * Copyright (c) 2004-2006, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -82,29 +82,29 @@ static int sockets_enabled = 0; ...@@ -82,29 +82,29 @@ static int sockets_enabled = 0;
static atomic_t tipc_queue_size = ATOMIC_INIT(0); static atomic_t tipc_queue_size = ATOMIC_INIT(0);
/* /*
* sock_lock(): Lock a port/socket pair. lock_sock() can * sock_lock(): Lock a port/socket pair. lock_sock() can
* not be used here, since the same lock must protect ports * not be used here, since the same lock must protect ports
* with non-socket interfaces. * with non-socket interfaces.
* See net.c for description of locking policy. * See net.c for description of locking policy.
*/ */
static void sock_lock(struct tipc_sock* tsock) static void sock_lock(struct tipc_sock* tsock)
{ {
spin_lock_bh(tsock->p->lock); spin_lock_bh(tsock->p->lock);
} }
/* /*
* sock_unlock(): Unlock a port/socket pair * sock_unlock(): Unlock a port/socket pair
*/ */
static void sock_unlock(struct tipc_sock* tsock) static void sock_unlock(struct tipc_sock* tsock)
{ {
spin_unlock_bh(tsock->p->lock); spin_unlock_bh(tsock->p->lock);
} }
/** /**
* pollmask - determine the current set of poll() events for a socket * pollmask - determine the current set of poll() events for a socket
* @sock: socket structure * @sock: socket structure
* *
* TIPC sets the returned events as follows: * TIPC sets the returned events as follows:
* a) POLLRDNORM and POLLIN are set if the socket's receive queue is non-empty * a) POLLRDNORM and POLLIN are set if the socket's receive queue is non-empty
* or if a connection-oriented socket is does not have an active connection * or if a connection-oriented socket is does not have an active connection
...@@ -115,7 +115,7 @@ static void sock_unlock(struct tipc_sock* tsock) ...@@ -115,7 +115,7 @@ static void sock_unlock(struct tipc_sock* tsock)
* *
* IMPORTANT: The fact that a read or write operation will not block does NOT * IMPORTANT: The fact that a read or write operation will not block does NOT
* imply that the operation will succeed! * imply that the operation will succeed!
* *
* Returns pollmask value * Returns pollmask value
*/ */
...@@ -130,7 +130,7 @@ static u32 pollmask(struct socket *sock) ...@@ -130,7 +130,7 @@ static u32 pollmask(struct socket *sock)
else else
mask = 0; mask = 0;
if (sock->state == SS_DISCONNECTING) if (sock->state == SS_DISCONNECTING)
mask |= POLLHUP; mask |= POLLHUP;
else else
mask |= POLLOUT; mask |= POLLOUT;
...@@ -146,9 +146,9 @@ static u32 pollmask(struct socket *sock) ...@@ -146,9 +146,9 @@ static u32 pollmask(struct socket *sock)
static void advance_queue(struct tipc_sock *tsock) static void advance_queue(struct tipc_sock *tsock)
{ {
sock_lock(tsock); sock_lock(tsock);
buf_discard(skb_dequeue(&tsock->sk.sk_receive_queue)); buf_discard(skb_dequeue(&tsock->sk.sk_receive_queue));
sock_unlock(tsock); sock_unlock(tsock);
atomic_dec(&tipc_queue_size); atomic_dec(&tipc_queue_size);
} }
...@@ -156,7 +156,7 @@ static void advance_queue(struct tipc_sock *tsock) ...@@ -156,7 +156,7 @@ static void advance_queue(struct tipc_sock *tsock)
* tipc_create - create a TIPC socket * tipc_create - create a TIPC socket
* @sock: pre-allocated socket structure * @sock: pre-allocated socket structure
* @protocol: protocol indicator (must be 0) * @protocol: protocol indicator (must be 0)
* *
* This routine creates and attaches a 'struct sock' to the 'struct socket', * This routine creates and attaches a 'struct sock' to the 'struct socket',
* then create and attaches a TIPC port to the 'struct sock' part. * then create and attaches a TIPC port to the 'struct sock' part.
* *
...@@ -167,7 +167,7 @@ static int tipc_create(struct socket *sock, int protocol) ...@@ -167,7 +167,7 @@ static int tipc_create(struct socket *sock, int protocol)
struct tipc_sock *tsock; struct tipc_sock *tsock;
struct tipc_port *port; struct tipc_port *port;
struct sock *sk; struct sock *sk;
u32 ref; u32 ref;
if (unlikely(protocol != 0)) if (unlikely(protocol != 0))
return -EPROTONOSUPPORT; return -EPROTONOSUPPORT;
...@@ -232,7 +232,7 @@ static int tipc_create(struct socket *sock, int protocol) ...@@ -232,7 +232,7 @@ static int tipc_create(struct socket *sock, int protocol)
* For SEQPACKET and STREAM socket types, the first message is rejected * For SEQPACKET and STREAM socket types, the first message is rejected
* and any others are discarded. (If the first message on a STREAM socket * and any others are discarded. (If the first message on a STREAM socket
* is partially-read, it is discarded and the next one is rejected instead.) * is partially-read, it is discarded and the next one is rejected instead.)
* *
* NOTE: Rejected messages are not necessarily returned to the sender! They * NOTE: Rejected messages are not necessarily returned to the sender! They
* are returned or discarded according to the "destination droppable" setting * are returned or discarded according to the "destination droppable" setting
* specified for the message by the sender. * specified for the message by the sender.
...@@ -247,7 +247,7 @@ static int release(struct socket *sock) ...@@ -247,7 +247,7 @@ static int release(struct socket *sock)
int res = TIPC_OK; int res = TIPC_OK;
struct sk_buff *buf; struct sk_buff *buf;
dbg("sock_delete: %x\n",tsock); dbg("sock_delete: %x\n",tsock);
if (!tsock) if (!tsock)
return 0; return 0;
down_interruptible(&tsock->sem); down_interruptible(&tsock->sem);
...@@ -255,7 +255,7 @@ static int release(struct socket *sock) ...@@ -255,7 +255,7 @@ static int release(struct socket *sock)
up(&tsock->sem); up(&tsock->sem);
return 0; return 0;
} }
/* Reject unreceived messages, unless no longer connected */ /* Reject unreceived messages, unless no longer connected */
while (sock->state != SS_DISCONNECTING) { while (sock->state != SS_DISCONNECTING) {
...@@ -289,7 +289,7 @@ static int release(struct socket *sock) ...@@ -289,7 +289,7 @@ static int release(struct socket *sock)
sock_put(sk); sock_put(sk);
atomic_dec(&tipc_user_count); atomic_dec(&tipc_user_count);
return res; return res;
} }
...@@ -298,11 +298,11 @@ static int release(struct socket *sock) ...@@ -298,11 +298,11 @@ static int release(struct socket *sock)
* @sock: socket structure * @sock: socket structure
* @uaddr: socket address describing name(s) and desired operation * @uaddr: socket address describing name(s) and desired operation
* @uaddr_len: size of socket address data structure * @uaddr_len: size of socket address data structure
* *
* Name and name sequence binding is indicated using a positive scope value; * Name and name sequence binding is indicated using a positive scope value;
* a negative scope value unbinds the specified name. Specifying no name * 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. * (i.e. a socket address length of 0) unbinds all names from the socket.
* *
* Returns 0 on success, errno otherwise * Returns 0 on success, errno otherwise
*/ */
...@@ -314,7 +314,7 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len) ...@@ -314,7 +314,7 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len)
if (down_interruptible(&tsock->sem)) if (down_interruptible(&tsock->sem))
return -ERESTARTSYS; return -ERESTARTSYS;
if (unlikely(!uaddr_len)) { if (unlikely(!uaddr_len)) {
res = tipc_withdraw(tsock->p->ref, 0, NULL); res = tipc_withdraw(tsock->p->ref, 0, NULL);
goto exit; goto exit;
...@@ -335,8 +335,8 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len) ...@@ -335,8 +335,8 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len)
res = -EAFNOSUPPORT; res = -EAFNOSUPPORT;
goto exit; goto exit;
} }
if (addr->scope > 0) if (addr->scope > 0)
res = tipc_publish(tsock->p->ref, addr->scope, res = tipc_publish(tsock->p->ref, addr->scope,
&addr->addr.nameseq); &addr->addr.nameseq);
else else
...@@ -347,17 +347,17 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len) ...@@ -347,17 +347,17 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len)
return res; return res;
} }
/** /**
* get_name - get port ID of socket or peer socket * get_name - get port ID of socket or peer socket
* @sock: socket structure * @sock: socket structure
* @uaddr: area for returned socket address * @uaddr: area for returned socket address
* @uaddr_len: area for returned length of socket address * @uaddr_len: area for returned length of socket address
* @peer: 0 to obtain socket name, 1 to obtain peer socket name * @peer: 0 to obtain socket name, 1 to obtain peer socket name
* *
* Returns 0 on success, errno otherwise * Returns 0 on success, errno otherwise
*/ */
static int get_name(struct socket *sock, struct sockaddr *uaddr, static int get_name(struct socket *sock, struct sockaddr *uaddr,
int *uaddr_len, int peer) int *uaddr_len, int peer)
{ {
struct tipc_sock *tsock = tipc_sk(sock->sk); struct tipc_sock *tsock = tipc_sk(sock->sk);
...@@ -390,7 +390,7 @@ static int get_name(struct socket *sock, struct sockaddr *uaddr, ...@@ -390,7 +390,7 @@ static int get_name(struct socket *sock, struct sockaddr *uaddr,
* Returns the pollmask * Returns the pollmask
*/ */
static unsigned int poll(struct file *file, struct socket *sock, static unsigned int poll(struct file *file, struct socket *sock,
poll_table *wait) poll_table *wait)
{ {
poll_wait(file, sock->sk->sk_sleep, wait); poll_wait(file, sock->sk->sk_sleep, wait);
...@@ -398,14 +398,14 @@ static unsigned int poll(struct file *file, struct socket *sock, ...@@ -398,14 +398,14 @@ static unsigned int poll(struct file *file, struct socket *sock,
return pollmask(sock); return pollmask(sock);
} }
/** /**
* dest_name_check - verify user is permitted to send to specified port name * dest_name_check - verify user is permitted to send to specified port name
* @dest: destination address * @dest: destination address
* @m: descriptor for message to be sent * @m: descriptor for message to be sent
* *
* Prevents restricted configuration commands from being issued by * Prevents restricted configuration commands from being issued by
* unauthorized users. * unauthorized users.
* *
* Returns 0 if permission is granted, otherwise errno * Returns 0 if permission is granted, otherwise errno
*/ */
...@@ -413,19 +413,19 @@ static int dest_name_check(struct sockaddr_tipc *dest, struct msghdr *m) ...@@ -413,19 +413,19 @@ static int dest_name_check(struct sockaddr_tipc *dest, struct msghdr *m)
{ {
struct tipc_cfg_msg_hdr hdr; struct tipc_cfg_msg_hdr hdr;
if (likely(dest->addr.name.name.type >= TIPC_RESERVED_TYPES)) if (likely(dest->addr.name.name.type >= TIPC_RESERVED_TYPES))
return 0; return 0;
if (likely(dest->addr.name.name.type == TIPC_TOP_SRV)) if (likely(dest->addr.name.name.type == TIPC_TOP_SRV))
return 0; return 0;
if (likely(dest->addr.name.name.type != TIPC_CFG_SRV)) if (likely(dest->addr.name.name.type != TIPC_CFG_SRV))
return -EACCES; return -EACCES;
if (copy_from_user(&hdr, m->msg_iov[0].iov_base, sizeof(hdr))) if (copy_from_user(&hdr, m->msg_iov[0].iov_base, sizeof(hdr)))
return -EFAULT; return -EFAULT;
if ((ntohs(hdr.tcm_type) & 0xC000) && (!capable(CAP_NET_ADMIN))) if ((ntohs(hdr.tcm_type) & 0xC000) && (!capable(CAP_NET_ADMIN)))
return -EACCES; return -EACCES;
return 0; return 0;
} }
...@@ -435,12 +435,12 @@ static int dest_name_check(struct sockaddr_tipc *dest, struct msghdr *m) ...@@ -435,12 +435,12 @@ static int dest_name_check(struct sockaddr_tipc *dest, struct msghdr *m)
* @sock: socket structure * @sock: socket structure
* @m: message to send * @m: message to send
* @total_len: length of message * @total_len: length of message
* *
* Message must have an destination specified explicitly. * Message must have an destination specified explicitly.
* Used for SOCK_RDM and SOCK_DGRAM messages, * Used for SOCK_RDM and SOCK_DGRAM messages,
* and for 'SYN' messages on SOCK_SEQPACKET and SOCK_STREAM connections. * and for 'SYN' messages on SOCK_SEQPACKET and SOCK_STREAM connections.
* (Note: 'SYN+' is prohibited on SOCK_STREAM.) * (Note: 'SYN+' is prohibited on SOCK_STREAM.)
* *
* Returns the number of bytes sent on success, or errno otherwise * Returns the number of bytes sent on success, or errno otherwise
*/ */
...@@ -448,7 +448,7 @@ static int send_msg(struct kiocb *iocb, struct socket *sock, ...@@ -448,7 +448,7 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
struct msghdr *m, size_t total_len) struct msghdr *m, size_t total_len)
{ {
struct tipc_sock *tsock = tipc_sk(sock->sk); struct tipc_sock *tsock = tipc_sk(sock->sk);
struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name; struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name;
struct sk_buff *buf; struct sk_buff *buf;
int needs_conn; int needs_conn;
int res = -EINVAL; int res = -EINVAL;
...@@ -489,61 +489,61 @@ static int send_msg(struct kiocb *iocb, struct socket *sock, ...@@ -489,61 +489,61 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
sock->state = SS_CONNECTING; sock->state = SS_CONNECTING;
} }
do { do {
if (dest->addrtype == TIPC_ADDR_NAME) { if (dest->addrtype == TIPC_ADDR_NAME) {
if ((res = dest_name_check(dest, m))) if ((res = dest_name_check(dest, m)))
goto exit; goto exit;
res = tipc_send2name(tsock->p->ref, res = tipc_send2name(tsock->p->ref,
&dest->addr.name.name, &dest->addr.name.name,
dest->addr.name.domain, dest->addr.name.domain,
m->msg_iovlen, m->msg_iovlen,
m->msg_iov); m->msg_iov);
} }
else if (dest->addrtype == TIPC_ADDR_ID) { else if (dest->addrtype == TIPC_ADDR_ID) {
res = tipc_send2port(tsock->p->ref, res = tipc_send2port(tsock->p->ref,
&dest->addr.id, &dest->addr.id,
m->msg_iovlen, m->msg_iovlen,
m->msg_iov); m->msg_iov);
} }
else if (dest->addrtype == TIPC_ADDR_MCAST) { else if (dest->addrtype == TIPC_ADDR_MCAST) {
if (needs_conn) { if (needs_conn) {
res = -EOPNOTSUPP; res = -EOPNOTSUPP;
goto exit; goto exit;
} }
if ((res = dest_name_check(dest, m))) if ((res = dest_name_check(dest, m)))
goto exit; goto exit;
res = tipc_multicast(tsock->p->ref, res = tipc_multicast(tsock->p->ref,
&dest->addr.nameseq, &dest->addr.nameseq,
0, 0,
m->msg_iovlen, m->msg_iovlen,
m->msg_iov); m->msg_iov);
} }
if (likely(res != -ELINKCONG)) { if (likely(res != -ELINKCONG)) {
exit: exit:
up(&tsock->sem); up(&tsock->sem);
return res; return res;
} }
if (m->msg_flags & MSG_DONTWAIT) { if (m->msg_flags & MSG_DONTWAIT) {
res = -EWOULDBLOCK; res = -EWOULDBLOCK;
goto exit; goto exit;
} }
if (wait_event_interruptible(*sock->sk->sk_sleep, if (wait_event_interruptible(*sock->sk->sk_sleep,
!tsock->p->congested)) { !tsock->p->congested)) {
res = -ERESTARTSYS; res = -ERESTARTSYS;
goto exit; goto exit;
} }
} while (1); } while (1);
} }
/** /**
* send_packet - send a connection-oriented message * send_packet - send a connection-oriented message
* @iocb: (unused) * @iocb: (unused)
* @sock: socket structure * @sock: socket structure
* @m: message to send * @m: message to send
* @total_len: length of message * @total_len: length of message
* *
* Used for SOCK_SEQPACKET messages and SOCK_STREAM data. * Used for SOCK_SEQPACKET messages and SOCK_STREAM data.
* *
* Returns the number of bytes sent on success, or errno otherwise * Returns the number of bytes sent on success, or errno otherwise
*/ */
...@@ -551,7 +551,7 @@ static int send_packet(struct kiocb *iocb, struct socket *sock, ...@@ -551,7 +551,7 @@ static int send_packet(struct kiocb *iocb, struct socket *sock,
struct msghdr *m, size_t total_len) struct msghdr *m, size_t total_len)
{ {
struct tipc_sock *tsock = tipc_sk(sock->sk); struct tipc_sock *tsock = tipc_sk(sock->sk);
struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name; struct sockaddr_tipc *dest = (struct sockaddr_tipc *)m->msg_name;
int res; int res;
/* Handle implied connection establishment */ /* Handle implied connection establishment */
...@@ -561,45 +561,45 @@ static int send_packet(struct kiocb *iocb, struct socket *sock, ...@@ -561,45 +561,45 @@ static int send_packet(struct kiocb *iocb, struct socket *sock,
if (down_interruptible(&tsock->sem)) { if (down_interruptible(&tsock->sem)) {
return -ERESTARTSYS; return -ERESTARTSYS;
} }
do { do {
if (unlikely(sock->state != SS_CONNECTED)) { if (unlikely(sock->state != SS_CONNECTED)) {
if (sock->state == SS_DISCONNECTING) if (sock->state == SS_DISCONNECTING)
res = -EPIPE; res = -EPIPE;
else else
res = -ENOTCONN; res = -ENOTCONN;
goto exit; goto exit;
} }
res = tipc_send(tsock->p->ref, m->msg_iovlen, m->msg_iov); res = tipc_send(tsock->p->ref, m->msg_iovlen, m->msg_iov);
if (likely(res != -ELINKCONG)) { if (likely(res != -ELINKCONG)) {
exit: exit:
up(&tsock->sem); up(&tsock->sem);
return res; return res;
} }
if (m->msg_flags & MSG_DONTWAIT) { if (m->msg_flags & MSG_DONTWAIT) {
res = -EWOULDBLOCK; res = -EWOULDBLOCK;
goto exit; goto exit;
} }
if (wait_event_interruptible(*sock->sk->sk_sleep, if (wait_event_interruptible(*sock->sk->sk_sleep,
!tsock->p->congested)) { !tsock->p->congested)) {
res = -ERESTARTSYS; res = -ERESTARTSYS;
goto exit; goto exit;
} }
} while (1); } while (1);
} }
/** /**
* send_stream - send stream-oriented data * send_stream - send stream-oriented data
* @iocb: (unused) * @iocb: (unused)
* @sock: socket structure * @sock: socket structure
* @m: data to send * @m: data to send
* @total_len: total length of data to be sent * @total_len: total length of data to be sent
* *
* Used for SOCK_STREAM data. * Used for SOCK_STREAM data.
* *
* Returns the number of bytes sent on success (or partial success), * Returns the number of bytes sent on success (or partial success),
* or errno if no data sent * or errno if no data sent
*/ */
...@@ -616,26 +616,26 @@ static int send_stream(struct kiocb *iocb, struct socket *sock, ...@@ -616,26 +616,26 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
int bytes_to_send; int bytes_to_send;
int bytes_sent; int bytes_sent;
int res; int res;
if (likely(total_len <= TIPC_MAX_USER_MSG_SIZE)) if (likely(total_len <= TIPC_MAX_USER_MSG_SIZE))
return send_packet(iocb, sock, m, total_len); return send_packet(iocb, sock, m, total_len);
/* Can only send large data streams if already connected */ /* Can only send large data streams if already connected */
if (unlikely(sock->state != SS_CONNECTED)) { if (unlikely(sock->state != SS_CONNECTED)) {
if (sock->state == SS_DISCONNECTING) if (sock->state == SS_DISCONNECTING)
return -EPIPE; return -EPIPE;
else else
return -ENOTCONN; return -ENOTCONN;
} }
if (unlikely(m->msg_name)) if (unlikely(m->msg_name))
return -EISCONN; return -EISCONN;
/* /*
* Send each iovec entry using one or more messages * Send each iovec entry using one or more messages
* *
* Note: This algorithm is good for the most likely case * Note: This algorithm is good for the most likely case
* (i.e. one large iovec entry), but could be improved to pass sets * (i.e. one large iovec entry), but could be improved to pass sets
* of small iovec entries into send_packet(). * of small iovec entries into send_packet().
*/ */
...@@ -657,7 +657,7 @@ static int send_stream(struct kiocb *iocb, struct socket *sock, ...@@ -657,7 +657,7 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
? curr_left : TIPC_MAX_USER_MSG_SIZE; ? curr_left : TIPC_MAX_USER_MSG_SIZE;
my_iov.iov_base = curr_start; my_iov.iov_base = curr_start;
my_iov.iov_len = bytes_to_send; my_iov.iov_len = bytes_to_send;
if ((res = send_packet(iocb, sock, &my_msg, 0)) < 0) { if ((res = send_packet(iocb, sock, &my_msg, 0)) < 0) {
return bytes_sent ? bytes_sent : res; return bytes_sent ? bytes_sent : res;
} }
curr_left -= bytes_to_send; curr_left -= bytes_to_send;
...@@ -676,11 +676,11 @@ static int send_stream(struct kiocb *iocb, struct socket *sock, ...@@ -676,11 +676,11 @@ static int send_stream(struct kiocb *iocb, struct socket *sock,
* @sock: socket structure * @sock: socket structure
* @tsock: TIPC-specific socket structure * @tsock: TIPC-specific socket structure
* @msg: peer's response message * @msg: peer's response message
* *
* Returns 0 on success, errno otherwise * Returns 0 on success, errno otherwise
*/ */
static int auto_connect(struct socket *sock, struct tipc_sock *tsock, static int auto_connect(struct socket *sock, struct tipc_sock *tsock,
struct tipc_msg *msg) struct tipc_msg *msg)
{ {
struct tipc_portid peer; struct tipc_portid peer;
...@@ -702,15 +702,15 @@ static int auto_connect(struct socket *sock, struct tipc_sock *tsock, ...@@ -702,15 +702,15 @@ static int auto_connect(struct socket *sock, struct tipc_sock *tsock,
* set_orig_addr - capture sender's address for received message * set_orig_addr - capture sender's address for received message
* @m: descriptor for message info * @m: descriptor for message info
* @msg: received message header * @msg: received message header
* *
* Note: Address is not captured if not requested by receiver. * Note: Address is not captured if not requested by receiver.
*/ */
static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg) static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg)
{ {
struct sockaddr_tipc *addr = (struct sockaddr_tipc *)m->msg_name; struct sockaddr_tipc *addr = (struct sockaddr_tipc *)m->msg_name;
if (addr) { if (addr) {
addr->family = AF_TIPC; addr->family = AF_TIPC;
addr->addrtype = TIPC_ADDR_ID; addr->addrtype = TIPC_ADDR_ID;
addr->addr.id.ref = msg_origport(msg); addr->addr.id.ref = msg_origport(msg);
...@@ -722,13 +722,13 @@ static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg) ...@@ -722,13 +722,13 @@ static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg)
} }
/** /**
* anc_data_recv - optionally capture ancillary data for received message * anc_data_recv - optionally capture ancillary data for received message
* @m: descriptor for message info * @m: descriptor for message info
* @msg: received message header * @msg: received message header
* @tport: TIPC port associated with message * @tport: TIPC port associated with message
* *
* Note: Ancillary data is not captured if not requested by receiver. * Note: Ancillary data is not captured if not requested by receiver.
* *
* Returns 0 if successful, otherwise errno * Returns 0 if successful, otherwise errno
*/ */
...@@ -753,7 +753,7 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg, ...@@ -753,7 +753,7 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg,
if ((res = put_cmsg(m, SOL_TIPC, TIPC_ERRINFO, 8, anc_data))) if ((res = put_cmsg(m, SOL_TIPC, TIPC_ERRINFO, 8, anc_data)))
return res; return res;
if (anc_data[1] && if (anc_data[1] &&
(res = put_cmsg(m, SOL_TIPC, TIPC_RETDATA, anc_data[1], (res = put_cmsg(m, SOL_TIPC, TIPC_RETDATA, anc_data[1],
msg_data(msg)))) msg_data(msg))))
return res; return res;
} }
...@@ -790,13 +790,13 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg, ...@@ -790,13 +790,13 @@ static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg,
return 0; return 0;
} }
/** /**
* recv_msg - receive packet-oriented message * recv_msg - receive packet-oriented message
* @iocb: (unused) * @iocb: (unused)
* @m: descriptor for message info * @m: descriptor for message info
* @buf_len: total size of user buffer area * @buf_len: total size of user buffer area
* @flags: receive flags * @flags: receive flags
* *
* Used for SOCK_DGRAM, SOCK_RDM, and SOCK_SEQPACKET messages. * Used for SOCK_DGRAM, SOCK_RDM, and SOCK_SEQPACKET messages.
* If the complete message doesn't fit in user area, truncate it. * If the complete message doesn't fit in user area, truncate it.
* *
...@@ -827,9 +827,9 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock, ...@@ -827,9 +827,9 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
if (sock->type == SOCK_SEQPACKET) { if (sock->type == SOCK_SEQPACKET) {
if (unlikely(sock->state == SS_UNCONNECTED)) if (unlikely(sock->state == SS_UNCONNECTED))
return -ENOTCONN; return -ENOTCONN;
if (unlikely((sock->state == SS_DISCONNECTING) && if (unlikely((sock->state == SS_DISCONNECTING) &&
(skb_queue_len(&sock->sk->sk_receive_queue) == 0))) (skb_queue_len(&sock->sk->sk_receive_queue) == 0)))
return -ENOTCONN; return -ENOTCONN;
} }
/* Look for a message in receive queue; wait if necessary */ /* Look for a message in receive queue; wait if necessary */
...@@ -845,7 +845,7 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock, ...@@ -845,7 +845,7 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
} }
if ((res = wait_event_interruptible( if ((res = wait_event_interruptible(
*sock->sk->sk_sleep, *sock->sk->sk_sleep,
((q_len = skb_queue_len(&sock->sk->sk_receive_queue)) || ((q_len = skb_queue_len(&sock->sk->sk_receive_queue)) ||
(sock->state == SS_DISCONNECTING))) )) { (sock->state == SS_DISCONNECTING))) )) {
goto exit; goto exit;
...@@ -890,7 +890,7 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock, ...@@ -890,7 +890,7 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
goto exit; goto exit;
/* Capture message data (if valid) & compute return value (always) */ /* Capture message data (if valid) & compute return value (always) */
if (!err) { if (!err) {
if (unlikely(buf_len < sz)) { if (unlikely(buf_len < sz)) {
sz = buf_len; sz = buf_len;
...@@ -913,23 +913,23 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock, ...@@ -913,23 +913,23 @@ static int recv_msg(struct kiocb *iocb, struct socket *sock,
/* Consume received message (optional) */ /* Consume received message (optional) */
if (likely(!(flags & MSG_PEEK))) { if (likely(!(flags & MSG_PEEK))) {
if (unlikely(++tsock->p->conn_unacked >= TIPC_FLOW_CONTROL_WIN)) if (unlikely(++tsock->p->conn_unacked >= TIPC_FLOW_CONTROL_WIN))
tipc_acknowledge(tsock->p->ref, tsock->p->conn_unacked); tipc_acknowledge(tsock->p->ref, tsock->p->conn_unacked);
advance_queue(tsock); advance_queue(tsock);
} }
exit: exit:
up(&tsock->sem); up(&tsock->sem);
return res; return res;
} }
/** /**
* recv_stream - receive stream-oriented data * recv_stream - receive stream-oriented data
* @iocb: (unused) * @iocb: (unused)
* @m: descriptor for message info * @m: descriptor for message info
* @buf_len: total size of user buffer area * @buf_len: total size of user buffer area
* @flags: receive flags * @flags: receive flags
* *
* Used for SOCK_STREAM messages only. If not enough data is available * Used for SOCK_STREAM messages only. If not enough data is available
* will optionally wait for more; never truncates data. * will optionally wait for more; never truncates data.
* *
* Returns size of returned message data, errno otherwise * Returns size of returned message data, errno otherwise
...@@ -980,7 +980,7 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock, ...@@ -980,7 +980,7 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
} }
if ((res = wait_event_interruptible( if ((res = wait_event_interruptible(
*sock->sk->sk_sleep, *sock->sk->sk_sleep,
((q_len = skb_queue_len(&sock->sk->sk_receive_queue)) || ((q_len = skb_queue_len(&sock->sk->sk_receive_queue)) ||
(sock->state == SS_DISCONNECTING))) )) { (sock->state == SS_DISCONNECTING))) )) {
goto exit; goto exit;
...@@ -1017,7 +1017,7 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock, ...@@ -1017,7 +1017,7 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
} }
/* Capture message data (if valid) & compute return value (always) */ /* Capture message data (if valid) & compute return value (always) */
if (!err) { if (!err) {
buf_crs = (unsigned char *)(TIPC_SKB_CB(buf)->handle); buf_crs = (unsigned char *)(TIPC_SKB_CB(buf)->handle);
sz = buf->tail - buf_crs; sz = buf->tail - buf_crs;
...@@ -1050,14 +1050,14 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock, ...@@ -1050,14 +1050,14 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
/* Consume received message (optional) */ /* Consume received message (optional) */
if (likely(!(flags & MSG_PEEK))) { if (likely(!(flags & MSG_PEEK))) {
if (unlikely(++tsock->p->conn_unacked >= TIPC_FLOW_CONTROL_WIN)) if (unlikely(++tsock->p->conn_unacked >= TIPC_FLOW_CONTROL_WIN))
tipc_acknowledge(tsock->p->ref, tsock->p->conn_unacked); tipc_acknowledge(tsock->p->ref, tsock->p->conn_unacked);
advance_queue(tsock); advance_queue(tsock);
} }
/* Loop around if more data is required */ /* Loop around if more data is required */
if ((sz_copied < buf_len) /* didn't get all requested data */ if ((sz_copied < buf_len) /* didn't get all requested data */
&& (flags & MSG_WAITALL) /* ... and need to wait for more */ && (flags & MSG_WAITALL) /* ... and need to wait for more */
&& (!(flags & MSG_PEEK)) /* ... and aren't just peeking at data */ && (!(flags & MSG_PEEK)) /* ... and aren't just peeking at data */
&& (!err) /* ... and haven't reached a FIN */ && (!err) /* ... and haven't reached a FIN */
...@@ -1074,7 +1074,7 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock, ...@@ -1074,7 +1074,7 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
* @queue_size: current size of queue * @queue_size: current size of queue
* @base: nominal maximum size of queue * @base: nominal maximum size of queue
* @msg: message to be added to queue * @msg: message to be added to queue
* *
* Returns 1 if queue is currently overloaded, 0 otherwise * Returns 1 if queue is currently overloaded, 0 otherwise
*/ */
...@@ -1098,7 +1098,7 @@ static int queue_overloaded(u32 queue_size, u32 base, struct tipc_msg *msg) ...@@ -1098,7 +1098,7 @@ static int queue_overloaded(u32 queue_size, u32 base, struct tipc_msg *msg)
return (queue_size > threshold); return (queue_size > threshold);
} }
/** /**
* async_disconnect - wrapper function used to disconnect port * async_disconnect - wrapper function used to disconnect port
* @portref: TIPC port reference (passed as pointer-sized value) * @portref: TIPC port reference (passed as pointer-sized value)
*/ */
...@@ -1108,13 +1108,13 @@ static void async_disconnect(unsigned long portref) ...@@ -1108,13 +1108,13 @@ static void async_disconnect(unsigned long portref)
tipc_disconnect((u32)portref); tipc_disconnect((u32)portref);
} }
/** /**
* dispatch - handle arriving message * dispatch - handle arriving message
* @tport: TIPC port that received message * @tport: TIPC port that received message
* @buf: message * @buf: message
* *
* Called with port locked. Must not take socket lock to avoid deadlock risk. * Called with port locked. Must not take socket lock to avoid deadlock risk.
* *
* Returns TIPC error status code (TIPC_OK if message is not to be rejected) * Returns TIPC error status code (TIPC_OK if message is not to be rejected)
*/ */
...@@ -1159,13 +1159,13 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf) ...@@ -1159,13 +1159,13 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
msg_dbg(msg, "dispatch filter 4\n"); msg_dbg(msg, "dispatch filter 4\n");
return TIPC_ERR_NO_PORT; return TIPC_ERR_NO_PORT;
} }
} }
else if (sock->state == SS_LISTENING) { else if (sock->state == SS_LISTENING) {
if (msg_connected(msg) || msg_errcode(msg)) { if (msg_connected(msg) || msg_errcode(msg)) {
msg_dbg(msg, "dispatch filter 5\n"); msg_dbg(msg, "dispatch filter 5\n");
return TIPC_ERR_NO_PORT; return TIPC_ERR_NO_PORT;
} }
} }
else if (sock->state == SS_DISCONNECTING) { else if (sock->state == SS_DISCONNECTING) {
msg_dbg(msg, "dispatch filter 6\n"); msg_dbg(msg, "dispatch filter 6\n");
return TIPC_ERR_NO_PORT; return TIPC_ERR_NO_PORT;
...@@ -1180,18 +1180,18 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf) ...@@ -1180,18 +1180,18 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
/* Reject message if there isn't room to queue it */ /* Reject message if there isn't room to queue it */
if (unlikely((u32)atomic_read(&tipc_queue_size) > if (unlikely((u32)atomic_read(&tipc_queue_size) >
OVERLOAD_LIMIT_BASE)) { OVERLOAD_LIMIT_BASE)) {
if (queue_overloaded(atomic_read(&tipc_queue_size), if (queue_overloaded(atomic_read(&tipc_queue_size),
OVERLOAD_LIMIT_BASE, msg)) OVERLOAD_LIMIT_BASE, msg))
return TIPC_ERR_OVERLOAD; return TIPC_ERR_OVERLOAD;
} }
recv_q_len = skb_queue_len(&tsock->sk.sk_receive_queue); recv_q_len = skb_queue_len(&tsock->sk.sk_receive_queue);
if (unlikely(recv_q_len > (OVERLOAD_LIMIT_BASE / 2))) { if (unlikely(recv_q_len > (OVERLOAD_LIMIT_BASE / 2))) {
if (queue_overloaded(recv_q_len, if (queue_overloaded(recv_q_len,
OVERLOAD_LIMIT_BASE / 2, msg)) OVERLOAD_LIMIT_BASE / 2, msg))
return TIPC_ERR_OVERLOAD; return TIPC_ERR_OVERLOAD;
} }
/* Initiate connection termination for an incoming 'FIN' */ /* Initiate connection termination for an incoming 'FIN' */
...@@ -1213,10 +1213,10 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf) ...@@ -1213,10 +1213,10 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
return TIPC_OK; return TIPC_OK;
} }
/** /**
* wakeupdispatch - wake up port after congestion * wakeupdispatch - wake up port after congestion
* @tport: port to wakeup * @tport: port to wakeup
* *
* Called with port lock on. * Called with port lock on.
*/ */
...@@ -1238,7 +1238,7 @@ static void wakeupdispatch(struct tipc_port *tport) ...@@ -1238,7 +1238,7 @@ static void wakeupdispatch(struct tipc_port *tport)
* Returns 0 on success, errno otherwise * Returns 0 on success, errno otherwise
*/ */
static int connect(struct socket *sock, struct sockaddr *dest, int destlen, static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
int flags) int flags)
{ {
struct tipc_sock *tsock = tipc_sk(sock->sk); struct tipc_sock *tsock = tipc_sk(sock->sk);
...@@ -1260,7 +1260,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen, ...@@ -1260,7 +1260,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
if (sock->state == SS_CONNECTING) if (sock->state == SS_CONNECTING)
return -EALREADY; return -EALREADY;
if (sock->state != SS_UNCONNECTED) if (sock->state != SS_UNCONNECTED)
return -EISCONN; return -EISCONN;
/* /*
* Reject connection attempt using multicast address * Reject connection attempt using multicast address
...@@ -1270,7 +1270,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen, ...@@ -1270,7 +1270,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
*/ */
if (dst->addrtype == TIPC_ADDR_MCAST) if (dst->addrtype == TIPC_ADDR_MCAST)
return -EINVAL; return -EINVAL;
/* Send a 'SYN-' to destination */ /* Send a 'SYN-' to destination */
...@@ -1281,19 +1281,19 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen, ...@@ -1281,19 +1281,19 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
return res; return res;
} }
if (down_interruptible(&tsock->sem)) if (down_interruptible(&tsock->sem))
return -ERESTARTSYS; return -ERESTARTSYS;
/* Wait for destination's 'ACK' response */ /* Wait for destination's 'ACK' response */
res = wait_event_interruptible_timeout(*sock->sk->sk_sleep, res = wait_event_interruptible_timeout(*sock->sk->sk_sleep,
skb_queue_len(&sock->sk->sk_receive_queue), skb_queue_len(&sock->sk->sk_receive_queue),
sock->sk->sk_rcvtimeo); sock->sk->sk_rcvtimeo);
buf = skb_peek(&sock->sk->sk_receive_queue); buf = skb_peek(&sock->sk->sk_receive_queue);
if (res > 0) { if (res > 0) {
msg = buf_msg(buf); msg = buf_msg(buf);
res = auto_connect(sock, tsock, msg); res = auto_connect(sock, tsock, msg);
if (!res) { if (!res) {
if (!msg_data_sz(msg)) if (!msg_data_sz(msg))
advance_queue(tsock); advance_queue(tsock);
} }
...@@ -1301,7 +1301,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen, ...@@ -1301,7 +1301,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
if (res == 0) { if (res == 0) {
res = -ETIMEDOUT; res = -ETIMEDOUT;
} else } else
{ /* leave "res" unchanged */ } { /* leave "res" unchanged */ }
sock->state = SS_DISCONNECTING; sock->state = SS_DISCONNECTING;
} }
...@@ -1309,11 +1309,11 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen, ...@@ -1309,11 +1309,11 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
return res; return res;
} }
/** /**
* listen - allow socket to listen for incoming connections * listen - allow socket to listen for incoming connections
* @sock: socket structure * @sock: socket structure
* @len: (unused) * @len: (unused)
* *
* Returns 0 on success, errno otherwise * Returns 0 on success, errno otherwise
*/ */
...@@ -1326,15 +1326,15 @@ static int listen(struct socket *sock, int len) ...@@ -1326,15 +1326,15 @@ static int listen(struct socket *sock, int len)
if (sock->state != SS_UNCONNECTED) if (sock->state != SS_UNCONNECTED)
return -EINVAL; return -EINVAL;
sock->state = SS_LISTENING; sock->state = SS_LISTENING;
return 0; return 0;
} }
/** /**
* accept - wait for connection request * accept - wait for connection request
* @sock: listening socket * @sock: listening socket
* @newsock: new socket that is to be connected * @newsock: new socket that is to be connected
* @flags: file-related flags associated with socket * @flags: file-related flags associated with socket
* *
* Returns 0 on success, errno otherwise * Returns 0 on success, errno otherwise
*/ */
...@@ -1348,15 +1348,15 @@ static int accept(struct socket *sock, struct socket *newsock, int flags) ...@@ -1348,15 +1348,15 @@ static int accept(struct socket *sock, struct socket *newsock, int flags)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (sock->state != SS_LISTENING) if (sock->state != SS_LISTENING)
return -EINVAL; return -EINVAL;
if (unlikely((skb_queue_len(&sock->sk->sk_receive_queue) == 0) && if (unlikely((skb_queue_len(&sock->sk->sk_receive_queue) == 0) &&
(flags & O_NONBLOCK))) (flags & O_NONBLOCK)))
return -EWOULDBLOCK; return -EWOULDBLOCK;
if (down_interruptible(&tsock->sem)) if (down_interruptible(&tsock->sem))
return -ERESTARTSYS; return -ERESTARTSYS;
if (wait_event_interruptible(*sock->sk->sk_sleep, if (wait_event_interruptible(*sock->sk->sk_sleep,
skb_queue_len(&sock->sk->sk_receive_queue))) { skb_queue_len(&sock->sk->sk_receive_queue))) {
res = -ERESTARTSYS; res = -ERESTARTSYS;
goto exit; goto exit;
...@@ -1381,18 +1381,18 @@ static int accept(struct socket *sock, struct socket *newsock, int flags) ...@@ -1381,18 +1381,18 @@ static int accept(struct socket *sock, struct socket *newsock, int flags)
new_tsock->p->conn_instance = msg_nameinst(msg); new_tsock->p->conn_instance = msg_nameinst(msg);
} }
/* /*
* Respond to 'SYN-' by discarding it & returning 'ACK'-. * Respond to 'SYN-' by discarding it & returning 'ACK'-.
* Respond to 'SYN+' by queuing it on new socket. * Respond to 'SYN+' by queuing it on new socket.
*/ */
msg_dbg(msg,"<ACC<: "); msg_dbg(msg,"<ACC<: ");
if (!msg_data_sz(msg)) { if (!msg_data_sz(msg)) {
struct msghdr m = {NULL,}; struct msghdr m = {NULL,};
send_packet(NULL, newsock, &m, 0); send_packet(NULL, newsock, &m, 0);
advance_queue(tsock); advance_queue(tsock);
} else { } else {
sock_lock(tsock); sock_lock(tsock);
skb_dequeue(&sock->sk->sk_receive_queue); skb_dequeue(&sock->sk->sk_receive_queue);
sock_unlock(tsock); sock_unlock(tsock);
...@@ -1410,7 +1410,7 @@ static int accept(struct socket *sock, struct socket *newsock, int flags) ...@@ -1410,7 +1410,7 @@ static int accept(struct socket *sock, struct socket *newsock, int flags)
* @how: direction to close (unused; always treated as read + write) * @how: direction to close (unused; always treated as read + write)
* *
* Terminates connection (if necessary), then purges socket's receive queue. * Terminates connection (if necessary), then purges socket's receive queue.
* *
* Returns 0 on success, errno otherwise * Returns 0 on success, errno otherwise
*/ */
...@@ -1483,32 +1483,32 @@ static int shutdown(struct socket *sock, int how) ...@@ -1483,32 +1483,32 @@ static int shutdown(struct socket *sock, int how)
* @opt: option identifier * @opt: option identifier
* @ov: pointer to new option value * @ov: pointer to new option value
* @ol: length of option value * @ol: length of option value
* *
* For stream sockets only, accepts and ignores all IPPROTO_TCP options * For stream sockets only, accepts and ignores all IPPROTO_TCP options
* (to ease compatibility). * (to ease compatibility).
* *
* Returns 0 on success, errno otherwise * Returns 0 on success, errno otherwise
*/ */
static int setsockopt(struct socket *sock, static int setsockopt(struct socket *sock,
int lvl, int opt, char __user *ov, int ol) int lvl, int opt, char __user *ov, int ol)
{ {
struct tipc_sock *tsock = tipc_sk(sock->sk); struct tipc_sock *tsock = tipc_sk(sock->sk);
u32 value; u32 value;
int res; int res;
if ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM)) if ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM))
return 0; return 0;
if (lvl != SOL_TIPC) if (lvl != SOL_TIPC)
return -ENOPROTOOPT; return -ENOPROTOOPT;
if (ol < sizeof(value)) if (ol < sizeof(value))
return -EINVAL; return -EINVAL;
if ((res = get_user(value, (u32 __user *)ov))) if ((res = get_user(value, (u32 __user *)ov)))
return res; return res;
if (down_interruptible(&tsock->sem)) if (down_interruptible(&tsock->sem))
return -ERESTARTSYS; return -ERESTARTSYS;
switch (opt) { switch (opt) {
case TIPC_IMPORTANCE: case TIPC_IMPORTANCE:
res = tipc_set_portimportance(tsock->p->ref, value); res = tipc_set_portimportance(tsock->p->ref, value);
...@@ -1516,7 +1516,7 @@ static int setsockopt(struct socket *sock, ...@@ -1516,7 +1516,7 @@ static int setsockopt(struct socket *sock,
case TIPC_SRC_DROPPABLE: case TIPC_SRC_DROPPABLE:
if (sock->type != SOCK_STREAM) if (sock->type != SOCK_STREAM)
res = tipc_set_portunreliable(tsock->p->ref, value); res = tipc_set_portunreliable(tsock->p->ref, value);
else else
res = -ENOPROTOOPT; res = -ENOPROTOOPT;
break; break;
case TIPC_DEST_DROPPABLE: case TIPC_DEST_DROPPABLE:
...@@ -1540,29 +1540,29 @@ static int setsockopt(struct socket *sock, ...@@ -1540,29 +1540,29 @@ static int setsockopt(struct socket *sock,
* @opt: option identifier * @opt: option identifier
* @ov: receptacle for option value * @ov: receptacle for option value
* @ol: receptacle for length of option value * @ol: receptacle for length of option value
* *
* For stream sockets only, returns 0 length result for all IPPROTO_TCP options * For stream sockets only, returns 0 length result for all IPPROTO_TCP options
* (to ease compatibility). * (to ease compatibility).
* *
* Returns 0 on success, errno otherwise * Returns 0 on success, errno otherwise
*/ */
static int getsockopt(struct socket *sock, static int getsockopt(struct socket *sock,
int lvl, int opt, char __user *ov, int __user *ol) int lvl, int opt, char __user *ov, int __user *ol)
{ {
struct tipc_sock *tsock = tipc_sk(sock->sk); struct tipc_sock *tsock = tipc_sk(sock->sk);
int len; int len;
u32 value; u32 value;
int res; int res;
if ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM)) if ((lvl == IPPROTO_TCP) && (sock->type == SOCK_STREAM))
return put_user(0, ol); return put_user(0, ol);
if (lvl != SOL_TIPC) if (lvl != SOL_TIPC)
return -ENOPROTOOPT; return -ENOPROTOOPT;
if ((res = get_user(len, ol))) if ((res = get_user(len, ol)))
return res; return res;
if (down_interruptible(&tsock->sem)) if (down_interruptible(&tsock->sem))
return -ERESTARTSYS; return -ERESTARTSYS;
switch (opt) { switch (opt) {
...@@ -1595,30 +1595,30 @@ static int getsockopt(struct socket *sock, ...@@ -1595,30 +1595,30 @@ static int getsockopt(struct socket *sock,
res = put_user(sizeof(value), ol); res = put_user(sizeof(value), ol);
} }
up(&tsock->sem); up(&tsock->sem);
return res; return res;
} }
/** /**
* Placeholders for non-implemented functionality * Placeholders for non-implemented functionality
* *
* Returns error code (POSIX-compliant where defined) * Returns error code (POSIX-compliant where defined)
*/ */
static int ioctl(struct socket *s, u32 cmd, unsigned long arg) static int ioctl(struct socket *s, u32 cmd, unsigned long arg)
{ {
return -EINVAL; return -EINVAL;
} }
static int no_mmap(struct file *file, struct socket *sock, static int no_mmap(struct file *file, struct socket *sock,
struct vm_area_struct *vma) struct vm_area_struct *vma)
{ {
return -EINVAL; return -EINVAL;
} }
static ssize_t no_sendpage(struct socket *sock, struct page *page, static ssize_t no_sendpage(struct socket *sock, struct page *page,
int offset, size_t size, int flags) int offset, size_t size, int flags)
{ {
return -EINVAL; return -EINVAL;
} }
static int no_skpair(struct socket *s1, struct socket *s2) static int no_skpair(struct socket *s1, struct socket *s2)
...@@ -1647,8 +1647,8 @@ static struct proto_ops msg_ops = { ...@@ -1647,8 +1647,8 @@ static struct proto_ops msg_ops = {
.getsockopt = getsockopt, .getsockopt = getsockopt,
.sendmsg = send_msg, .sendmsg = send_msg,
.recvmsg = recv_msg, .recvmsg = recv_msg,
.mmap = no_mmap, .mmap = no_mmap,
.sendpage = no_sendpage .sendpage = no_sendpage
}; };
static struct proto_ops packet_ops = { static struct proto_ops packet_ops = {
...@@ -1668,8 +1668,8 @@ static struct proto_ops packet_ops = { ...@@ -1668,8 +1668,8 @@ static struct proto_ops packet_ops = {
.getsockopt = getsockopt, .getsockopt = getsockopt,
.sendmsg = send_packet, .sendmsg = send_packet,
.recvmsg = recv_msg, .recvmsg = recv_msg,
.mmap = no_mmap, .mmap = no_mmap,
.sendpage = no_sendpage .sendpage = no_sendpage
}; };
static struct proto_ops stream_ops = { static struct proto_ops stream_ops = {
...@@ -1689,8 +1689,8 @@ static struct proto_ops stream_ops = { ...@@ -1689,8 +1689,8 @@ static struct proto_ops stream_ops = {
.getsockopt = getsockopt, .getsockopt = getsockopt,
.sendmsg = send_stream, .sendmsg = send_stream,
.recvmsg = recv_stream, .recvmsg = recv_stream,
.mmap = no_mmap, .mmap = no_mmap,
.sendpage = no_sendpage .sendpage = no_sendpage
}; };
static struct net_proto_family tipc_family_ops = { static struct net_proto_family tipc_family_ops = {
...@@ -1707,14 +1707,14 @@ static struct proto tipc_proto = { ...@@ -1707,14 +1707,14 @@ static struct proto tipc_proto = {
/** /**
* tipc_socket_init - initialize TIPC socket interface * tipc_socket_init - initialize TIPC socket interface
* *
* Returns 0 on success, errno otherwise * Returns 0 on success, errno otherwise
*/ */
int tipc_socket_init(void) int tipc_socket_init(void)
{ {
int res; int res;
res = proto_register(&tipc_proto, 1); res = proto_register(&tipc_proto, 1);
if (res) { if (res) {
err("Failed to register TIPC protocol type\n"); err("Failed to register TIPC protocol type\n");
goto out; goto out;
......
/* /*
* net/tipc/subscr.c: TIPC subscription service * net/tipc/subscr.c: TIPC subscription service
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -49,10 +49,10 @@ ...@@ -49,10 +49,10 @@
* @port_ref: object reference to port used to communicate with subscriber * @port_ref: object reference to port used to communicate with subscriber
* @swap: indicates if subscriber uses opposite endianness in its messages * @swap: indicates if subscriber uses opposite endianness in its messages
*/ */
struct subscriber { struct subscriber {
u32 ref; u32 ref;
spinlock_t *lock; spinlock_t *lock;
struct list_head subscriber_list; struct list_head subscriber_list;
struct list_head subscription_list; struct list_head subscription_list;
u32 port_ref; u32 port_ref;
...@@ -82,7 +82,7 @@ static struct top_srv topsrv = { 0 }; ...@@ -82,7 +82,7 @@ static struct top_srv topsrv = { 0 };
* htohl - convert value to endianness used by destination * htohl - convert value to endianness used by destination
* @in: value to convert * @in: value to convert
* @swap: non-zero if endianness must be reversed * @swap: non-zero if endianness must be reversed
* *
* Returns converted value * Returns converted value
*/ */
...@@ -97,11 +97,11 @@ static u32 htohl(u32 in, int swap) ...@@ -97,11 +97,11 @@ static u32 htohl(u32 in, int swap)
* subscr_send_event - send a message containing a tipc_event to the subscriber * subscr_send_event - send a message containing a tipc_event to the subscriber
*/ */
static void subscr_send_event(struct subscription *sub, static void subscr_send_event(struct subscription *sub,
u32 found_lower, u32 found_lower,
u32 found_upper, u32 found_upper,
u32 event, u32 event,
u32 port_ref, u32 port_ref,
u32 node) u32 node)
{ {
struct iovec msg_sect; struct iovec msg_sect;
...@@ -123,8 +123,8 @@ static void subscr_send_event(struct subscription *sub, ...@@ -123,8 +123,8 @@ static void subscr_send_event(struct subscription *sub,
* Returns 1 if there is overlap, otherwise 0. * Returns 1 if there is overlap, otherwise 0.
*/ */
int tipc_subscr_overlap(struct subscription *sub, int tipc_subscr_overlap(struct subscription *sub,
u32 found_lower, u32 found_lower,
u32 found_upper) u32 found_upper)
{ {
...@@ -139,15 +139,15 @@ int tipc_subscr_overlap(struct subscription *sub, ...@@ -139,15 +139,15 @@ int tipc_subscr_overlap(struct subscription *sub,
/** /**
* tipc_subscr_report_overlap - issue event if there is subscription overlap * tipc_subscr_report_overlap - issue event if there is subscription overlap
* *
* Protected by nameseq.lock in name_table.c * Protected by nameseq.lock in name_table.c
*/ */
void tipc_subscr_report_overlap(struct subscription *sub, void tipc_subscr_report_overlap(struct subscription *sub,
u32 found_lower, u32 found_lower,
u32 found_upper, u32 found_upper,
u32 event, u32 event,
u32 port_ref, u32 port_ref,
u32 node, u32 node,
int must) int must)
{ {
...@@ -189,11 +189,11 @@ static void subscr_timeout(struct subscription *sub) ...@@ -189,11 +189,11 @@ static void subscr_timeout(struct subscription *sub)
/* Notify subscriber of timeout, then unlink subscription */ /* Notify subscriber of timeout, then unlink subscription */
subscr_send_event(sub, subscr_send_event(sub,
sub->evt.s.seq.lower, sub->evt.s.seq.lower,
sub->evt.s.seq.upper, sub->evt.s.seq.upper,
TIPC_SUBSCR_TIMEOUT, TIPC_SUBSCR_TIMEOUT,
0, 0,
0); 0);
list_del(&sub->subscription_list); list_del(&sub->subscription_list);
...@@ -221,11 +221,11 @@ static void subscr_del(struct subscription *sub) ...@@ -221,11 +221,11 @@ static void subscr_del(struct subscription *sub)
/** /**
* subscr_terminate - terminate communication with a subscriber * subscr_terminate - terminate communication with a subscriber
* *
* Called with subscriber locked. Routine must temporarily release this lock * Called with subscriber locked. Routine must temporarily release this lock
* to enable subscription timeout routine(s) to finish without deadlocking; * to enable subscription timeout routine(s) to finish without deadlocking;
* the lock is then reclaimed to allow caller to release it upon return. * the lock is then reclaimed to allow caller to release it upon return.
* (This should work even in the unlikely event some other thread creates * (This should work even in the unlikely event some other thread creates
* a new object reference in the interim that uses this lock; this routine will * a new object reference in the interim that uses this lock; this routine will
* simply wait for it to be released, then claim it.) * simply wait for it to be released, then claim it.)
*/ */
...@@ -241,7 +241,7 @@ static void subscr_terminate(struct subscriber *subscriber) ...@@ -241,7 +241,7 @@ static void subscr_terminate(struct subscriber *subscriber)
spin_unlock_bh(subscriber->lock); spin_unlock_bh(subscriber->lock);
/* Destroy any existing subscriptions for subscriber */ /* Destroy any existing subscriptions for subscriber */
list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list, list_for_each_entry_safe(sub, sub_temp, &subscriber->subscription_list,
subscription_list) { subscription_list) {
if (sub->timeout != TIPC_WAIT_FOREVER) { if (sub->timeout != TIPC_WAIT_FOREVER) {
...@@ -315,7 +315,7 @@ static void subscr_cancel(struct tipc_subscr *s, ...@@ -315,7 +315,7 @@ static void subscr_cancel(struct tipc_subscr *s,
/** /**
* subscr_subscribe - create subscription for subscriber * subscr_subscribe - create subscription for subscriber
* *
* Called with subscriber locked * Called with subscriber locked
*/ */
...@@ -431,7 +431,7 @@ static void subscr_conn_msg_event(void *usr_handle, ...@@ -431,7 +431,7 @@ static void subscr_conn_msg_event(void *usr_handle,
subscr_terminate(subscriber); subscr_terminate(subscriber);
else else
subscr_subscribe((struct tipc_subscr *)data, subscriber); subscr_subscribe((struct tipc_subscr *)data, subscriber);
spin_unlock_bh(subscriber_lock); spin_unlock_bh(subscriber_lock);
} }
...@@ -444,7 +444,7 @@ static void subscr_named_msg_event(void *usr_handle, ...@@ -444,7 +444,7 @@ static void subscr_named_msg_event(void *usr_handle,
struct sk_buff **buf, struct sk_buff **buf,
const unchar *data, const unchar *data,
u32 size, u32 size,
u32 importance, u32 importance,
struct tipc_portid const *orig, struct tipc_portid const *orig,
struct tipc_name_seq const *dest) struct tipc_name_seq const *dest)
{ {
...@@ -534,22 +534,22 @@ int tipc_subscr_start(void) ...@@ -534,22 +534,22 @@ int tipc_subscr_start(void)
return res; return res;
} }
res = tipc_createport(topsrv.user_ref, res = tipc_createport(topsrv.user_ref,
NULL, NULL,
TIPC_CRITICAL_IMPORTANCE, TIPC_CRITICAL_IMPORTANCE,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
subscr_named_msg_event, subscr_named_msg_event,
NULL, NULL,
NULL, NULL,
&topsrv.setup_port); &topsrv.setup_port);
if (res) if (res)
goto failed; goto failed;
res = tipc_nametbl_publish_rsv(topsrv.setup_port, TIPC_NODE_SCOPE, &seq); res = tipc_nametbl_publish_rsv(topsrv.setup_port, TIPC_NODE_SCOPE, &seq);
if (res) if (res)
goto failed; goto failed;
spin_unlock_bh(&topsrv.lock); spin_unlock_bh(&topsrv.lock);
...@@ -571,7 +571,7 @@ void tipc_subscr_stop(void) ...@@ -571,7 +571,7 @@ void tipc_subscr_stop(void)
if (topsrv.user_ref) { if (topsrv.user_ref) {
tipc_deleteport(topsrv.setup_port); tipc_deleteport(topsrv.setup_port);
list_for_each_entry_safe(subscriber, subscriber_temp, list_for_each_entry_safe(subscriber, subscriber_temp,
&topsrv.subscriber_list, &topsrv.subscriber_list,
subscriber_list) { subscriber_list) {
tipc_ref_lock(subscriber->ref); tipc_ref_lock(subscriber->ref);
......
/* /*
* net/tipc/subscr.h: Include file for TIPC subscription service * net/tipc/subscr.h: Include file for TIPC subscription service
* *
* Copyright (c) 2003-2006, Ericsson AB * Copyright (c) 2003-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
* @timer_ref: reference to timer governing subscription duration (may be NULL) * @timer_ref: reference to timer governing subscription duration (may be NULL)
* @owner: pointer to subscriber object associated with this subscription * @owner: pointer to subscriber object associated with this subscription
*/ */
struct subscription { struct subscription {
struct tipc_name_seq seq; struct tipc_name_seq seq;
u32 timeout; u32 timeout;
...@@ -60,15 +60,15 @@ struct subscription { ...@@ -60,15 +60,15 @@ struct subscription {
struct subscriber *owner; struct subscriber *owner;
}; };
int tipc_subscr_overlap(struct subscription * sub, int tipc_subscr_overlap(struct subscription * sub,
u32 found_lower, u32 found_lower,
u32 found_upper); u32 found_upper);
void tipc_subscr_report_overlap(struct subscription * sub, void tipc_subscr_report_overlap(struct subscription * sub,
u32 found_lower, u32 found_lower,
u32 found_upper, u32 found_upper,
u32 event, u32 event,
u32 port_ref, u32 port_ref,
u32 node, u32 node,
int must_report); int must_report);
......
/* /*
* net/tipc/user_reg.c: TIPC user registry code * net/tipc/user_reg.c: TIPC user registry code
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2004-2005, Wind River Systems * Copyright (c) 2004-2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
/* /*
* TIPC user registry keeps track of users of the tipc_port interface. * TIPC user registry keeps track of users of the tipc_port interface.
* *
* The registry utilizes an array of "TIPC user" entries; * The registry utilizes an array of "TIPC user" entries;
* a user's ID is the index of their associated array entry. * a user's ID is the index of their associated array entry.
* Array entry 0 is not used, so userid 0 is not valid; * Array entry 0 is not used, so userid 0 is not valid;
* TIPC sometimes uses this value to denote an anonymous user. * TIPC sometimes uses this value to denote an anonymous user.
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
* struct tipc_user - registered TIPC user info * struct tipc_user - registered TIPC user info
* @next: index of next free registry entry (or -1 for an allocated entry) * @next: index of next free registry entry (or -1 for an allocated entry)
* @callback: ptr to routine to call when TIPC mode changes (NULL if none) * @callback: ptr to routine to call when TIPC mode changes (NULL if none)
* @usr_handle: user-defined value passed to callback routine * @usr_handle: user-defined value passed to callback routine
* @ports: list of user ports owned by the user * @ports: list of user ports owned by the user
*/ */
...@@ -71,7 +71,7 @@ static DEFINE_SPINLOCK(reg_lock); ...@@ -71,7 +71,7 @@ static DEFINE_SPINLOCK(reg_lock);
/** /**
* reg_init - create TIPC user registry (but don't activate it) * reg_init - create TIPC user registry (but don't activate it)
* *
* If registry has been pre-initialized it is left "as is". * If registry has been pre-initialized it is left "as is".
* NOTE: This routine may be called when TIPC is inactive. * NOTE: This routine may be called when TIPC is inactive.
*/ */
...@@ -79,7 +79,7 @@ static DEFINE_SPINLOCK(reg_lock); ...@@ -79,7 +79,7 @@ static DEFINE_SPINLOCK(reg_lock);
static int reg_init(void) static int reg_init(void)
{ {
u32 i; u32 i;
spin_lock_bh(&reg_lock); spin_lock_bh(&reg_lock);
if (!users) { if (!users) {
users = kzalloc(USER_LIST_SIZE, GFP_ATOMIC); users = kzalloc(USER_LIST_SIZE, GFP_ATOMIC);
...@@ -137,7 +137,7 @@ int tipc_reg_start(void) ...@@ -137,7 +137,7 @@ int tipc_reg_start(void)
*/ */
void tipc_reg_stop(void) void tipc_reg_stop(void)
{ {
int id; int id;
if (!users) if (!users)
...@@ -174,14 +174,14 @@ int tipc_attach(u32 *userid, tipc_mode_event cb, void *usr_handle) ...@@ -174,14 +174,14 @@ int tipc_attach(u32 *userid, tipc_mode_event cb, void *usr_handle)
user_ptr = &users[next_free_user]; user_ptr = &users[next_free_user];
*userid = next_free_user; *userid = next_free_user;
next_free_user = user_ptr->next; next_free_user = user_ptr->next;
user_ptr->next = -1; user_ptr->next = -1;
spin_unlock_bh(&reg_lock); spin_unlock_bh(&reg_lock);
user_ptr->callback = cb; user_ptr->callback = cb;
user_ptr->usr_handle = usr_handle; user_ptr->usr_handle = usr_handle;
INIT_LIST_HEAD(&user_ptr->ports); INIT_LIST_HEAD(&user_ptr->ports);
atomic_inc(&tipc_user_count); atomic_inc(&tipc_user_count);
if (cb && (tipc_mode != TIPC_NOT_RUNNING)) if (cb && (tipc_mode != TIPC_NOT_RUNNING))
tipc_k_signal((Handler)reg_callback, (unsigned long)user_ptr); tipc_k_signal((Handler)reg_callback, (unsigned long)user_ptr);
return TIPC_OK; return TIPC_OK;
...@@ -207,16 +207,16 @@ void tipc_detach(u32 userid) ...@@ -207,16 +207,16 @@ void tipc_detach(u32 userid)
} }
user_ptr = &users[userid]; user_ptr = &users[userid];
user_ptr->callback = NULL; user_ptr->callback = NULL;
INIT_LIST_HEAD(&ports_temp); INIT_LIST_HEAD(&ports_temp);
list_splice(&user_ptr->ports, &ports_temp); list_splice(&user_ptr->ports, &ports_temp);
user_ptr->next = next_free_user; user_ptr->next = next_free_user;
next_free_user = userid; next_free_user = userid;
spin_unlock_bh(&reg_lock); spin_unlock_bh(&reg_lock);
atomic_dec(&tipc_user_count); atomic_dec(&tipc_user_count);
list_for_each_entry_safe(up_ptr, temp_up_ptr, &ports_temp, uport_list) { list_for_each_entry_safe(up_ptr, temp_up_ptr, &ports_temp, uport_list) {
tipc_deleteport(up_ptr->ref); tipc_deleteport(up_ptr->ref);
} }
} }
......
/* /*
* net/tipc/user_reg.h: Include file for TIPC user registry code * net/tipc/user_reg.h: Include file for TIPC user registry code
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
......
/* /*
* net/tipc/zone.c: TIPC zone management routines * net/tipc/zone.c: TIPC zone management routines
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2005, Wind River Systems * Copyright (c) 2005, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -92,7 +92,7 @@ void tipc_zone_remove_as_router(struct _zone *z_ptr, u32 router) ...@@ -92,7 +92,7 @@ void tipc_zone_remove_as_router(struct _zone *z_ptr, u32 router)
for (c_num = 1; c_num <= tipc_max_clusters; c_num++) { for (c_num = 1; c_num <= tipc_max_clusters; c_num++) {
if (z_ptr->clusters[c_num]) { if (z_ptr->clusters[c_num]) {
tipc_cltr_remove_as_router(z_ptr->clusters[c_num], tipc_cltr_remove_as_router(z_ptr->clusters[c_num],
router); router);
} }
} }
......
/* /*
* net/tipc/zone.h: Include file for TIPC zone management routines * net/tipc/zone.h: Include file for TIPC zone management routines
* *
* Copyright (c) 2000-2006, Ericsson AB * Copyright (c) 2000-2006, Ericsson AB
* Copyright (c) 2005-2006, Wind River Systems * Copyright (c) 2005-2006, Wind River Systems
* All rights reserved. * All rights reserved.
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
* @clusters: array of pointers to all clusters within zone * @clusters: array of pointers to all clusters within zone
* @links: number of (unicast) links to zone * @links: number of (unicast) links to zone
*/ */
struct _zone { struct _zone {
u32 addr; u32 addr;
struct cluster *clusters[2]; /* currently limited to just 1 cluster */ struct cluster *clusters[2]; /* currently limited to just 1 cluster */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment