2006-01-02 19:04:38 +01:00
|
|
|
/*
|
|
|
|
* net/tipc/node.c: TIPC node management routines
|
2007-02-09 15:25:21 +01:00
|
|
|
*
|
2016-05-02 17:58:46 +02:00
|
|
|
* Copyright (c) 2000-2006, 2012-2016, Ericsson AB
|
2014-03-27 05:54:36 +01:00
|
|
|
* Copyright (c) 2005-2006, 2010-2014, Wind River Systems
|
2006-01-02 19:04:38 +01:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2006-01-11 13:30:43 +01:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
2006-01-02 19:04:38 +01:00
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
2006-01-11 13:30:43 +01:00
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the names of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
2006-01-02 19:04:38 +01:00
|
|
|
*
|
2006-01-11 13:30:43 +01:00
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
|
|
|
* Software Foundation.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
2006-01-02 19:04:38 +01:00
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "core.h"
|
2015-02-09 09:50:18 +01:00
|
|
|
#include "link.h"
|
2006-01-02 19:04:38 +01:00
|
|
|
#include "node.h"
|
|
|
|
#include "name_distr.h"
|
2014-08-23 00:09:07 +02:00
|
|
|
#include "socket.h"
|
2015-05-14 16:46:13 +02:00
|
|
|
#include "bcast.h"
|
tipc: add neighbor monitoring framework
TIPC based clusters are by default set up with full-mesh link
connectivity between all nodes. Those links are expected to provide
a short failure detection time, by default set to 1500 ms. Because
of this, the background load for neighbor monitoring in an N-node
cluster increases with a factor N on each node, while the overall
monitoring traffic through the network infrastructure increases at
a ~(N * (N - 1)) rate. Experience has shown that such clusters don't
scale well beyond ~100 nodes unless we significantly increase failure
discovery tolerance.
This commit introduces a framework and an algorithm that drastically
reduces this background load, while basically maintaining the original
failure detection times across the whole cluster. Using this algorithm,
background load will now grow at a rate of ~(2 * sqrt(N)) per node, and
at ~(2 * N * sqrt(N)) in traffic overhead. As an example, each node will
now have to actively monitor 38 neighbors in a 400-node cluster, instead
of as before 399.
This "Overlapping Ring Supervision Algorithm" is completely distributed
and employs no centralized or coordinated state. It goes as follows:
- Each node makes up a linearly ascending, circular list of all its N
known neighbors, based on their TIPC node identity. This algorithm
must be the same on all nodes.
- The node then selects the next M = sqrt(N) - 1 nodes downstream from
itself in the list, and chooses to actively monitor those. This is
called its "local monitoring domain".
- It creates a domain record describing the monitoring domain, and
piggy-backs this in the data area of all neighbor monitoring messages
(LINK_PROTOCOL/STATE) leaving that node. This means that all nodes in
the cluster eventually (default within 400 ms) will learn about
its monitoring domain.
- Whenever a node discovers a change in its local domain, e.g., a node
has been added or has gone down, it creates and sends out a new
version of its node record to inform all neighbors about the change.
- A node receiving a domain record from anybody outside its local domain
matches this against its own list (which may not look the same), and
chooses to not actively monitor those members of the received domain
record that are also present in its own list. Instead, it relies on
indications from the direct monitoring nodes if an indirectly
monitored node has gone up or down. If a node is indicated lost, the
receiving node temporarily activates its own direct monitoring towards
that node in order to confirm, or not, that it is actually gone.
- Since each node is actively monitoring sqrt(N) downstream neighbors,
each node is also actively monitored by the same number of upstream
neighbors. This means that all non-direct monitoring nodes normally
will receive sqrt(N) indications that a node is gone.
- A major drawback with ring monitoring is how it handles failures that
cause massive network partitionings. If both a lost node and all its
direct monitoring neighbors are inside the lost partition, the nodes in
the remaining partition will never receive indications about the loss.
To overcome this, each node also chooses to actively monitor some
nodes outside its local domain. Those nodes are called remote domain
"heads", and are selected in such a way that no node in the cluster
will be more than two direct monitoring hops away. Because of this,
each node, apart from monitoring the member of its local domain, will
also typically monitor sqrt(N) remote head nodes.
- As an optimization, local list status, domain status and domain
records are marked with a generation number. This saves senders from
unnecessarily conveying unaltered domain records, and receivers from
performing unneeded re-adaptations of their node monitoring list, such
as re-assigning domain heads.
- As a measure of caution we have added the possibility to disable the
new algorithm through configuration. We do this by keeping a threshold
value for the cluster size; a cluster that grows beyond this value
will switch from full-mesh to ring monitoring, and vice versa when
it shrinks below the value. This means that if the threshold is set to
a value larger than any anticipated cluster size (default size is 32)
the new algorithm is effectively disabled. A patch set for altering the
threshold value and for listing the table contents will follow shortly.
- This change is fully backwards compatible.
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-14 02:46:22 +02:00
|
|
|
#include "monitor.h"
|
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle
we have been using for message sending and timeout handling:
We move the function tipc_rcv() to node.c, hence handling the initial
packet reception at the link aggregation level. The function grabs
the node lock, selects the receiving link, and accesses it via a new
call tipc_link_rcv(). This function appends buffers to the input
queue for delivery upwards, but it may also append outgoing packets
to the xmit queue, just as we do during regular message sending. The
latter will happen when buffers are forwarded from the link backlog,
or when retransmission is requested.
Upon return of this function, and after having released the node lock,
tipc_rcv() delivers/tranmsits the contents of those queues, but it may
also perform actions such as link activation or reset, as indicated by
the return flags from the link.
This reduces the number of cpu cycles spent inside the node spinlock,
and reduces contention on that lock.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-16 22:54:31 +02:00
|
|
|
#include "discover.h"
|
2016-03-04 17:04:42 +01:00
|
|
|
#include "netlink.h"
|
2015-10-15 20:52:46 +02:00
|
|
|
|
2015-11-19 20:30:45 +01:00
|
|
|
#define INVALID_NODE_SIG 0x10000
|
|
|
|
|
|
|
|
/* Flags used to take different actions according to flag type
|
|
|
|
* TIPC_NOTIFY_NODE_DOWN: notify node is down
|
|
|
|
* TIPC_NOTIFY_NODE_UP: notify node is up
|
|
|
|
* TIPC_DISTRIBUTE_NAME: publish or withdraw link state name type
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
TIPC_NOTIFY_NODE_DOWN = (1 << 3),
|
|
|
|
TIPC_NOTIFY_NODE_UP = (1 << 4),
|
|
|
|
TIPC_NOTIFY_LINK_UP = (1 << 6),
|
|
|
|
TIPC_NOTIFY_LINK_DOWN = (1 << 7)
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tipc_link_entry {
|
|
|
|
struct tipc_link *link;
|
|
|
|
spinlock_t lock; /* per link */
|
|
|
|
u32 mtu;
|
|
|
|
struct sk_buff_head inputq;
|
|
|
|
struct tipc_media_addr maddr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct tipc_bclink_entry {
|
|
|
|
struct tipc_link *link;
|
|
|
|
struct sk_buff_head inputq1;
|
|
|
|
struct sk_buff_head arrvq;
|
|
|
|
struct sk_buff_head inputq2;
|
|
|
|
struct sk_buff_head namedq;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct tipc_node - TIPC node structure
|
|
|
|
* @addr: network address of node
|
|
|
|
* @ref: reference counter to node object
|
|
|
|
* @lock: rwlock governing access to structure
|
|
|
|
* @net: the applicable net namespace
|
|
|
|
* @hash: links to adjacent nodes in unsorted hash chain
|
|
|
|
* @inputq: pointer to input queue containing messages for msg event
|
|
|
|
* @namedq: pointer to name table input queue with name table messages
|
|
|
|
* @active_links: bearer ids of active links, used as index into links[] array
|
|
|
|
* @links: array containing references to all links to node
|
|
|
|
* @action_flags: bit mask of different types of node actions
|
|
|
|
* @state: connectivity state vs peer node
|
|
|
|
* @sync_point: sequence number where synch/failover is finished
|
|
|
|
* @list: links to adjacent nodes in sorted list of cluster's nodes
|
|
|
|
* @working_links: number of working links to node (both active and standby)
|
|
|
|
* @link_cnt: number of links to node
|
|
|
|
* @capabilities: bitmap, indicating peer node's functional capabilities
|
|
|
|
* @signature: node instance identifier
|
|
|
|
* @link_id: local and remote bearer ids of changing link, if any
|
|
|
|
* @publ_list: list of publications
|
|
|
|
* @rcu: rcu struct for tipc_node
|
|
|
|
*/
|
|
|
|
struct tipc_node {
|
|
|
|
u32 addr;
|
|
|
|
struct kref kref;
|
|
|
|
rwlock_t lock;
|
|
|
|
struct net *net;
|
|
|
|
struct hlist_node hash;
|
|
|
|
int active_links[2];
|
|
|
|
struct tipc_link_entry links[MAX_BEARERS];
|
|
|
|
struct tipc_bclink_entry bc_entry;
|
|
|
|
int action_flags;
|
|
|
|
struct list_head list;
|
|
|
|
int state;
|
|
|
|
u16 sync_point;
|
|
|
|
int link_cnt;
|
|
|
|
u16 working_links;
|
|
|
|
u16 capabilities;
|
|
|
|
u32 signature;
|
|
|
|
u32 link_id;
|
|
|
|
struct list_head publ_list;
|
|
|
|
struct list_head conn_sks;
|
|
|
|
unsigned long keepalive_intv;
|
|
|
|
struct timer_list timer;
|
|
|
|
struct rcu_head rcu;
|
|
|
|
};
|
|
|
|
|
2015-07-31 00:24:19 +02:00
|
|
|
/* Node FSM states and events:
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
SELF_DOWN_PEER_DOWN = 0xdd,
|
|
|
|
SELF_UP_PEER_UP = 0xaa,
|
|
|
|
SELF_DOWN_PEER_LEAVING = 0xd1,
|
|
|
|
SELF_UP_PEER_COMING = 0xac,
|
|
|
|
SELF_COMING_PEER_UP = 0xca,
|
|
|
|
SELF_LEAVING_PEER_DOWN = 0x1d,
|
|
|
|
NODE_FAILINGOVER = 0xf0,
|
|
|
|
NODE_SYNCHING = 0xcc
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
SELF_ESTABL_CONTACT_EVT = 0xece,
|
|
|
|
SELF_LOST_CONTACT_EVT = 0x1ce,
|
|
|
|
PEER_ESTABL_CONTACT_EVT = 0x9ece,
|
|
|
|
PEER_LOST_CONTACT_EVT = 0x91ce,
|
|
|
|
NODE_FAILOVER_BEGIN_EVT = 0xfbe,
|
|
|
|
NODE_FAILOVER_END_EVT = 0xfee,
|
|
|
|
NODE_SYNCH_BEGIN_EVT = 0xcbe,
|
|
|
|
NODE_SYNCH_END_EVT = 0xcee
|
|
|
|
};
|
|
|
|
|
2015-07-31 00:24:23 +02:00
|
|
|
static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id,
|
|
|
|
struct sk_buff_head *xmitq,
|
|
|
|
struct tipc_media_addr **maddr);
|
|
|
|
static void tipc_node_link_down(struct tipc_node *n, int bearer_id,
|
|
|
|
bool delete);
|
|
|
|
static void node_lost_contact(struct tipc_node *n, struct sk_buff_head *inputq);
|
2015-03-26 11:10:24 +01:00
|
|
|
static void tipc_node_delete(struct tipc_node *node);
|
2015-07-16 22:54:29 +02:00
|
|
|
static void tipc_node_timeout(unsigned long data);
|
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle
we have been using for message sending and timeout handling:
We move the function tipc_rcv() to node.c, hence handling the initial
packet reception at the link aggregation level. The function grabs
the node lock, selects the receiving link, and accesses it via a new
call tipc_link_rcv(). This function appends buffers to the input
queue for delivery upwards, but it may also append outgoing packets
to the xmit queue, just as we do during regular message sending. The
latter will happen when buffers are forwarded from the link backlog,
or when retransmission is requested.
Upon return of this function, and after having released the node lock,
tipc_rcv() delivers/tranmsits the contents of those queues, but it may
also perform actions such as link activation or reset, as indicated by
the return flags from the link.
This reduces the number of cpu cycles spent inside the node spinlock,
and reduces contention on that lock.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-16 22:54:31 +02:00
|
|
|
static void tipc_node_fsm_evt(struct tipc_node *n, int evt);
|
2015-11-19 20:30:45 +01:00
|
|
|
static struct tipc_node *tipc_node_find(struct net *net, u32 addr);
|
|
|
|
static void tipc_node_put(struct tipc_node *node);
|
|
|
|
static bool tipc_node_is_up(struct tipc_node *n);
|
2006-01-02 19:04:38 +01:00
|
|
|
|
tipc: use message to abort connections when losing contact to node
In the current implementation, each 'struct tipc_node' instance keeps
a linked list of those ports/sockets that are connected to the node
represented by that struct. The purpose of this is to let the node
object know which sockets to alert when it loses contact with its peer
node, i.e., which sockets need to have their connections aborted.
This entails an unwanted direct reference from the node structure
back to the port/socket structure, and a need to grab port_lock
when we have to make an upcall to the port. We want to get rid of
this unecessary BH entry point into the socket, and also eliminate
its use of port_lock.
In this commit, we instead let the node struct keep list of "connected
socket" structs, which each represents a connected socket, but is
allocated independently by the node at the moment of connection. If
the node loses contact with its peer node, the list is traversed, and
a "connection abort" message is created for each entry in the list. The
message is sent to it respective connected socket using the ordinary
data path, and the receiving socket aborts its connections upon reception
of the message.
This enables us to get rid of the direct reference from 'struct node' to
´struct port', and another unwanted BH access point to the latter.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-08-23 00:09:08 +02:00
|
|
|
struct tipc_sock_conn {
|
|
|
|
u32 port;
|
|
|
|
u32 peer_port;
|
|
|
|
u32 peer_node;
|
|
|
|
struct list_head list;
|
|
|
|
};
|
|
|
|
|
2015-11-19 20:30:45 +01:00
|
|
|
static struct tipc_link *node_active_link(struct tipc_node *n, int sel)
|
|
|
|
{
|
|
|
|
int bearer_id = n->active_links[sel & 1];
|
|
|
|
|
|
|
|
if (unlikely(bearer_id == INVALID_BEARER_ID))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return n->links[bearer_id].link;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tipc_node_get_mtu(struct net *net, u32 addr, u32 sel)
|
|
|
|
{
|
|
|
|
struct tipc_node *n;
|
|
|
|
int bearer_id;
|
|
|
|
unsigned int mtu = MAX_MSG_SIZE;
|
|
|
|
|
|
|
|
n = tipc_node_find(net, addr);
|
|
|
|
if (unlikely(!n))
|
|
|
|
return mtu;
|
|
|
|
|
|
|
|
bearer_id = n->active_links[sel & 1];
|
|
|
|
if (likely(bearer_id != INVALID_BEARER_ID))
|
|
|
|
mtu = n->links[bearer_id].mtu;
|
|
|
|
tipc_node_put(n);
|
|
|
|
return mtu;
|
|
|
|
}
|
2016-05-02 17:58:46 +02:00
|
|
|
|
|
|
|
u16 tipc_node_get_capabilities(struct net *net, u32 addr)
|
|
|
|
{
|
|
|
|
struct tipc_node *n;
|
|
|
|
u16 caps;
|
|
|
|
|
|
|
|
n = tipc_node_find(net, addr);
|
|
|
|
if (unlikely(!n))
|
|
|
|
return TIPC_NODE_CAPABILITIES;
|
|
|
|
caps = n->capabilities;
|
|
|
|
tipc_node_put(n);
|
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
2015-03-26 11:10:24 +01:00
|
|
|
static void tipc_node_kref_release(struct kref *kref)
|
|
|
|
{
|
2016-02-24 17:10:48 +01:00
|
|
|
struct tipc_node *n = container_of(kref, struct tipc_node, kref);
|
2015-03-26 11:10:24 +01:00
|
|
|
|
2016-02-24 17:10:48 +01:00
|
|
|
kfree(n->bc_entry.link);
|
|
|
|
kfree_rcu(n, rcu);
|
2015-03-26 11:10:24 +01:00
|
|
|
}
|
|
|
|
|
2015-11-19 20:30:45 +01:00
|
|
|
static void tipc_node_put(struct tipc_node *node)
|
2015-03-26 11:10:24 +01:00
|
|
|
{
|
|
|
|
kref_put(&node->kref, tipc_node_kref_release);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tipc_node_get(struct tipc_node *node)
|
|
|
|
{
|
|
|
|
kref_get(&node->kref);
|
|
|
|
}
|
|
|
|
|
2011-10-27 21:03:24 +02:00
|
|
|
/*
|
2011-02-26 00:42:52 +01:00
|
|
|
* tipc_node_find - locate specified node object, if it exists
|
|
|
|
*/
|
2015-11-19 20:30:45 +01:00
|
|
|
static struct tipc_node *tipc_node_find(struct net *net, u32 addr)
|
2011-02-26 00:42:52 +01:00
|
|
|
{
|
2016-02-24 17:00:19 +01:00
|
|
|
struct tipc_net *tn = tipc_net(net);
|
2011-02-26 00:42:52 +01:00
|
|
|
struct tipc_node *node;
|
2016-02-24 17:00:19 +01:00
|
|
|
unsigned int thash = tipc_hashfn(addr);
|
2011-02-26 00:42:52 +01:00
|
|
|
|
2015-01-09 08:27:10 +01:00
|
|
|
if (unlikely(!in_own_cluster_exact(net, addr)))
|
2011-02-26 00:42:52 +01:00
|
|
|
return NULL;
|
|
|
|
|
2014-03-27 05:54:37 +01:00
|
|
|
rcu_read_lock();
|
2016-02-24 17:00:19 +01:00
|
|
|
hlist_for_each_entry_rcu(node, &tn->node_htable[thash], hash) {
|
|
|
|
if (node->addr != addr)
|
|
|
|
continue;
|
|
|
|
if (!kref_get_unless_zero(&node->kref))
|
|
|
|
node = NULL;
|
|
|
|
break;
|
2011-02-26 00:42:52 +01:00
|
|
|
}
|
2014-03-27 05:54:37 +01:00
|
|
|
rcu_read_unlock();
|
2016-02-24 17:00:19 +01:00
|
|
|
return node;
|
2011-02-26 00:42:52 +01:00
|
|
|
}
|
|
|
|
|
2015-11-19 20:30:45 +01:00
|
|
|
static void tipc_node_read_lock(struct tipc_node *n)
|
2015-11-19 20:30:44 +01:00
|
|
|
{
|
|
|
|
read_lock_bh(&n->lock);
|
|
|
|
}
|
|
|
|
|
2015-11-19 20:30:45 +01:00
|
|
|
static void tipc_node_read_unlock(struct tipc_node *n)
|
2015-11-19 20:30:44 +01:00
|
|
|
{
|
|
|
|
read_unlock_bh(&n->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tipc_node_write_lock(struct tipc_node *n)
|
|
|
|
{
|
|
|
|
write_lock_bh(&n->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tipc_node_write_unlock(struct tipc_node *n)
|
|
|
|
{
|
|
|
|
struct net *net = n->net;
|
|
|
|
u32 addr = 0;
|
|
|
|
u32 flags = n->action_flags;
|
|
|
|
u32 link_id = 0;
|
tipc: add neighbor monitoring framework
TIPC based clusters are by default set up with full-mesh link
connectivity between all nodes. Those links are expected to provide
a short failure detection time, by default set to 1500 ms. Because
of this, the background load for neighbor monitoring in an N-node
cluster increases with a factor N on each node, while the overall
monitoring traffic through the network infrastructure increases at
a ~(N * (N - 1)) rate. Experience has shown that such clusters don't
scale well beyond ~100 nodes unless we significantly increase failure
discovery tolerance.
This commit introduces a framework and an algorithm that drastically
reduces this background load, while basically maintaining the original
failure detection times across the whole cluster. Using this algorithm,
background load will now grow at a rate of ~(2 * sqrt(N)) per node, and
at ~(2 * N * sqrt(N)) in traffic overhead. As an example, each node will
now have to actively monitor 38 neighbors in a 400-node cluster, instead
of as before 399.
This "Overlapping Ring Supervision Algorithm" is completely distributed
and employs no centralized or coordinated state. It goes as follows:
- Each node makes up a linearly ascending, circular list of all its N
known neighbors, based on their TIPC node identity. This algorithm
must be the same on all nodes.
- The node then selects the next M = sqrt(N) - 1 nodes downstream from
itself in the list, and chooses to actively monitor those. This is
called its "local monitoring domain".
- It creates a domain record describing the monitoring domain, and
piggy-backs this in the data area of all neighbor monitoring messages
(LINK_PROTOCOL/STATE) leaving that node. This means that all nodes in
the cluster eventually (default within 400 ms) will learn about
its monitoring domain.
- Whenever a node discovers a change in its local domain, e.g., a node
has been added or has gone down, it creates and sends out a new
version of its node record to inform all neighbors about the change.
- A node receiving a domain record from anybody outside its local domain
matches this against its own list (which may not look the same), and
chooses to not actively monitor those members of the received domain
record that are also present in its own list. Instead, it relies on
indications from the direct monitoring nodes if an indirectly
monitored node has gone up or down. If a node is indicated lost, the
receiving node temporarily activates its own direct monitoring towards
that node in order to confirm, or not, that it is actually gone.
- Since each node is actively monitoring sqrt(N) downstream neighbors,
each node is also actively monitored by the same number of upstream
neighbors. This means that all non-direct monitoring nodes normally
will receive sqrt(N) indications that a node is gone.
- A major drawback with ring monitoring is how it handles failures that
cause massive network partitionings. If both a lost node and all its
direct monitoring neighbors are inside the lost partition, the nodes in
the remaining partition will never receive indications about the loss.
To overcome this, each node also chooses to actively monitor some
nodes outside its local domain. Those nodes are called remote domain
"heads", and are selected in such a way that no node in the cluster
will be more than two direct monitoring hops away. Because of this,
each node, apart from monitoring the member of its local domain, will
also typically monitor sqrt(N) remote head nodes.
- As an optimization, local list status, domain status and domain
records are marked with a generation number. This saves senders from
unnecessarily conveying unaltered domain records, and receivers from
performing unneeded re-adaptations of their node monitoring list, such
as re-assigning domain heads.
- As a measure of caution we have added the possibility to disable the
new algorithm through configuration. We do this by keeping a threshold
value for the cluster size; a cluster that grows beyond this value
will switch from full-mesh to ring monitoring, and vice versa when
it shrinks below the value. This means that if the threshold is set to
a value larger than any anticipated cluster size (default size is 32)
the new algorithm is effectively disabled. A patch set for altering the
threshold value and for listing the table contents will follow shortly.
- This change is fully backwards compatible.
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-14 02:46:22 +02:00
|
|
|
u32 bearer_id;
|
2015-11-19 20:30:44 +01:00
|
|
|
struct list_head *publ_list;
|
|
|
|
|
|
|
|
if (likely(!flags)) {
|
|
|
|
write_unlock_bh(&n->lock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = n->addr;
|
|
|
|
link_id = n->link_id;
|
tipc: add neighbor monitoring framework
TIPC based clusters are by default set up with full-mesh link
connectivity between all nodes. Those links are expected to provide
a short failure detection time, by default set to 1500 ms. Because
of this, the background load for neighbor monitoring in an N-node
cluster increases with a factor N on each node, while the overall
monitoring traffic through the network infrastructure increases at
a ~(N * (N - 1)) rate. Experience has shown that such clusters don't
scale well beyond ~100 nodes unless we significantly increase failure
discovery tolerance.
This commit introduces a framework and an algorithm that drastically
reduces this background load, while basically maintaining the original
failure detection times across the whole cluster. Using this algorithm,
background load will now grow at a rate of ~(2 * sqrt(N)) per node, and
at ~(2 * N * sqrt(N)) in traffic overhead. As an example, each node will
now have to actively monitor 38 neighbors in a 400-node cluster, instead
of as before 399.
This "Overlapping Ring Supervision Algorithm" is completely distributed
and employs no centralized or coordinated state. It goes as follows:
- Each node makes up a linearly ascending, circular list of all its N
known neighbors, based on their TIPC node identity. This algorithm
must be the same on all nodes.
- The node then selects the next M = sqrt(N) - 1 nodes downstream from
itself in the list, and chooses to actively monitor those. This is
called its "local monitoring domain".
- It creates a domain record describing the monitoring domain, and
piggy-backs this in the data area of all neighbor monitoring messages
(LINK_PROTOCOL/STATE) leaving that node. This means that all nodes in
the cluster eventually (default within 400 ms) will learn about
its monitoring domain.
- Whenever a node discovers a change in its local domain, e.g., a node
has been added or has gone down, it creates and sends out a new
version of its node record to inform all neighbors about the change.
- A node receiving a domain record from anybody outside its local domain
matches this against its own list (which may not look the same), and
chooses to not actively monitor those members of the received domain
record that are also present in its own list. Instead, it relies on
indications from the direct monitoring nodes if an indirectly
monitored node has gone up or down. If a node is indicated lost, the
receiving node temporarily activates its own direct monitoring towards
that node in order to confirm, or not, that it is actually gone.
- Since each node is actively monitoring sqrt(N) downstream neighbors,
each node is also actively monitored by the same number of upstream
neighbors. This means that all non-direct monitoring nodes normally
will receive sqrt(N) indications that a node is gone.
- A major drawback with ring monitoring is how it handles failures that
cause massive network partitionings. If both a lost node and all its
direct monitoring neighbors are inside the lost partition, the nodes in
the remaining partition will never receive indications about the loss.
To overcome this, each node also chooses to actively monitor some
nodes outside its local domain. Those nodes are called remote domain
"heads", and are selected in such a way that no node in the cluster
will be more than two direct monitoring hops away. Because of this,
each node, apart from monitoring the member of its local domain, will
also typically monitor sqrt(N) remote head nodes.
- As an optimization, local list status, domain status and domain
records are marked with a generation number. This saves senders from
unnecessarily conveying unaltered domain records, and receivers from
performing unneeded re-adaptations of their node monitoring list, such
as re-assigning domain heads.
- As a measure of caution we have added the possibility to disable the
new algorithm through configuration. We do this by keeping a threshold
value for the cluster size; a cluster that grows beyond this value
will switch from full-mesh to ring monitoring, and vice versa when
it shrinks below the value. This means that if the threshold is set to
a value larger than any anticipated cluster size (default size is 32)
the new algorithm is effectively disabled. A patch set for altering the
threshold value and for listing the table contents will follow shortly.
- This change is fully backwards compatible.
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-14 02:46:22 +02:00
|
|
|
bearer_id = link_id & 0xffff;
|
2015-11-19 20:30:44 +01:00
|
|
|
publ_list = &n->publ_list;
|
|
|
|
|
|
|
|
n->action_flags &= ~(TIPC_NOTIFY_NODE_DOWN | TIPC_NOTIFY_NODE_UP |
|
|
|
|
TIPC_NOTIFY_LINK_DOWN | TIPC_NOTIFY_LINK_UP);
|
|
|
|
|
|
|
|
write_unlock_bh(&n->lock);
|
|
|
|
|
|
|
|
if (flags & TIPC_NOTIFY_NODE_DOWN)
|
|
|
|
tipc_publ_notify(net, publ_list, addr);
|
|
|
|
|
|
|
|
if (flags & TIPC_NOTIFY_NODE_UP)
|
|
|
|
tipc_named_node_up(net, addr);
|
|
|
|
|
tipc: add neighbor monitoring framework
TIPC based clusters are by default set up with full-mesh link
connectivity between all nodes. Those links are expected to provide
a short failure detection time, by default set to 1500 ms. Because
of this, the background load for neighbor monitoring in an N-node
cluster increases with a factor N on each node, while the overall
monitoring traffic through the network infrastructure increases at
a ~(N * (N - 1)) rate. Experience has shown that such clusters don't
scale well beyond ~100 nodes unless we significantly increase failure
discovery tolerance.
This commit introduces a framework and an algorithm that drastically
reduces this background load, while basically maintaining the original
failure detection times across the whole cluster. Using this algorithm,
background load will now grow at a rate of ~(2 * sqrt(N)) per node, and
at ~(2 * N * sqrt(N)) in traffic overhead. As an example, each node will
now have to actively monitor 38 neighbors in a 400-node cluster, instead
of as before 399.
This "Overlapping Ring Supervision Algorithm" is completely distributed
and employs no centralized or coordinated state. It goes as follows:
- Each node makes up a linearly ascending, circular list of all its N
known neighbors, based on their TIPC node identity. This algorithm
must be the same on all nodes.
- The node then selects the next M = sqrt(N) - 1 nodes downstream from
itself in the list, and chooses to actively monitor those. This is
called its "local monitoring domain".
- It creates a domain record describing the monitoring domain, and
piggy-backs this in the data area of all neighbor monitoring messages
(LINK_PROTOCOL/STATE) leaving that node. This means that all nodes in
the cluster eventually (default within 400 ms) will learn about
its monitoring domain.
- Whenever a node discovers a change in its local domain, e.g., a node
has been added or has gone down, it creates and sends out a new
version of its node record to inform all neighbors about the change.
- A node receiving a domain record from anybody outside its local domain
matches this against its own list (which may not look the same), and
chooses to not actively monitor those members of the received domain
record that are also present in its own list. Instead, it relies on
indications from the direct monitoring nodes if an indirectly
monitored node has gone up or down. If a node is indicated lost, the
receiving node temporarily activates its own direct monitoring towards
that node in order to confirm, or not, that it is actually gone.
- Since each node is actively monitoring sqrt(N) downstream neighbors,
each node is also actively monitored by the same number of upstream
neighbors. This means that all non-direct monitoring nodes normally
will receive sqrt(N) indications that a node is gone.
- A major drawback with ring monitoring is how it handles failures that
cause massive network partitionings. If both a lost node and all its
direct monitoring neighbors are inside the lost partition, the nodes in
the remaining partition will never receive indications about the loss.
To overcome this, each node also chooses to actively monitor some
nodes outside its local domain. Those nodes are called remote domain
"heads", and are selected in such a way that no node in the cluster
will be more than two direct monitoring hops away. Because of this,
each node, apart from monitoring the member of its local domain, will
also typically monitor sqrt(N) remote head nodes.
- As an optimization, local list status, domain status and domain
records are marked with a generation number. This saves senders from
unnecessarily conveying unaltered domain records, and receivers from
performing unneeded re-adaptations of their node monitoring list, such
as re-assigning domain heads.
- As a measure of caution we have added the possibility to disable the
new algorithm through configuration. We do this by keeping a threshold
value for the cluster size; a cluster that grows beyond this value
will switch from full-mesh to ring monitoring, and vice versa when
it shrinks below the value. This means that if the threshold is set to
a value larger than any anticipated cluster size (default size is 32)
the new algorithm is effectively disabled. A patch set for altering the
threshold value and for listing the table contents will follow shortly.
- This change is fully backwards compatible.
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-14 02:46:22 +02:00
|
|
|
if (flags & TIPC_NOTIFY_LINK_UP) {
|
|
|
|
tipc_mon_peer_up(net, addr, bearer_id);
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_nametbl_publish(net, TIPC_LINK_STATE, addr, addr,
|
|
|
|
TIPC_NODE_SCOPE, link_id, addr);
|
tipc: add neighbor monitoring framework
TIPC based clusters are by default set up with full-mesh link
connectivity between all nodes. Those links are expected to provide
a short failure detection time, by default set to 1500 ms. Because
of this, the background load for neighbor monitoring in an N-node
cluster increases with a factor N on each node, while the overall
monitoring traffic through the network infrastructure increases at
a ~(N * (N - 1)) rate. Experience has shown that such clusters don't
scale well beyond ~100 nodes unless we significantly increase failure
discovery tolerance.
This commit introduces a framework and an algorithm that drastically
reduces this background load, while basically maintaining the original
failure detection times across the whole cluster. Using this algorithm,
background load will now grow at a rate of ~(2 * sqrt(N)) per node, and
at ~(2 * N * sqrt(N)) in traffic overhead. As an example, each node will
now have to actively monitor 38 neighbors in a 400-node cluster, instead
of as before 399.
This "Overlapping Ring Supervision Algorithm" is completely distributed
and employs no centralized or coordinated state. It goes as follows:
- Each node makes up a linearly ascending, circular list of all its N
known neighbors, based on their TIPC node identity. This algorithm
must be the same on all nodes.
- The node then selects the next M = sqrt(N) - 1 nodes downstream from
itself in the list, and chooses to actively monitor those. This is
called its "local monitoring domain".
- It creates a domain record describing the monitoring domain, and
piggy-backs this in the data area of all neighbor monitoring messages
(LINK_PROTOCOL/STATE) leaving that node. This means that all nodes in
the cluster eventually (default within 400 ms) will learn about
its monitoring domain.
- Whenever a node discovers a change in its local domain, e.g., a node
has been added or has gone down, it creates and sends out a new
version of its node record to inform all neighbors about the change.
- A node receiving a domain record from anybody outside its local domain
matches this against its own list (which may not look the same), and
chooses to not actively monitor those members of the received domain
record that are also present in its own list. Instead, it relies on
indications from the direct monitoring nodes if an indirectly
monitored node has gone up or down. If a node is indicated lost, the
receiving node temporarily activates its own direct monitoring towards
that node in order to confirm, or not, that it is actually gone.
- Since each node is actively monitoring sqrt(N) downstream neighbors,
each node is also actively monitored by the same number of upstream
neighbors. This means that all non-direct monitoring nodes normally
will receive sqrt(N) indications that a node is gone.
- A major drawback with ring monitoring is how it handles failures that
cause massive network partitionings. If both a lost node and all its
direct monitoring neighbors are inside the lost partition, the nodes in
the remaining partition will never receive indications about the loss.
To overcome this, each node also chooses to actively monitor some
nodes outside its local domain. Those nodes are called remote domain
"heads", and are selected in such a way that no node in the cluster
will be more than two direct monitoring hops away. Because of this,
each node, apart from monitoring the member of its local domain, will
also typically monitor sqrt(N) remote head nodes.
- As an optimization, local list status, domain status and domain
records are marked with a generation number. This saves senders from
unnecessarily conveying unaltered domain records, and receivers from
performing unneeded re-adaptations of their node monitoring list, such
as re-assigning domain heads.
- As a measure of caution we have added the possibility to disable the
new algorithm through configuration. We do this by keeping a threshold
value for the cluster size; a cluster that grows beyond this value
will switch from full-mesh to ring monitoring, and vice versa when
it shrinks below the value. This means that if the threshold is set to
a value larger than any anticipated cluster size (default size is 32)
the new algorithm is effectively disabled. A patch set for altering the
threshold value and for listing the table contents will follow shortly.
- This change is fully backwards compatible.
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-14 02:46:22 +02:00
|
|
|
}
|
|
|
|
if (flags & TIPC_NOTIFY_LINK_DOWN) {
|
|
|
|
tipc_mon_peer_down(net, addr, bearer_id);
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_nametbl_withdraw(net, TIPC_LINK_STATE, addr,
|
|
|
|
link_id, addr);
|
tipc: add neighbor monitoring framework
TIPC based clusters are by default set up with full-mesh link
connectivity between all nodes. Those links are expected to provide
a short failure detection time, by default set to 1500 ms. Because
of this, the background load for neighbor monitoring in an N-node
cluster increases with a factor N on each node, while the overall
monitoring traffic through the network infrastructure increases at
a ~(N * (N - 1)) rate. Experience has shown that such clusters don't
scale well beyond ~100 nodes unless we significantly increase failure
discovery tolerance.
This commit introduces a framework and an algorithm that drastically
reduces this background load, while basically maintaining the original
failure detection times across the whole cluster. Using this algorithm,
background load will now grow at a rate of ~(2 * sqrt(N)) per node, and
at ~(2 * N * sqrt(N)) in traffic overhead. As an example, each node will
now have to actively monitor 38 neighbors in a 400-node cluster, instead
of as before 399.
This "Overlapping Ring Supervision Algorithm" is completely distributed
and employs no centralized or coordinated state. It goes as follows:
- Each node makes up a linearly ascending, circular list of all its N
known neighbors, based on their TIPC node identity. This algorithm
must be the same on all nodes.
- The node then selects the next M = sqrt(N) - 1 nodes downstream from
itself in the list, and chooses to actively monitor those. This is
called its "local monitoring domain".
- It creates a domain record describing the monitoring domain, and
piggy-backs this in the data area of all neighbor monitoring messages
(LINK_PROTOCOL/STATE) leaving that node. This means that all nodes in
the cluster eventually (default within 400 ms) will learn about
its monitoring domain.
- Whenever a node discovers a change in its local domain, e.g., a node
has been added or has gone down, it creates and sends out a new
version of its node record to inform all neighbors about the change.
- A node receiving a domain record from anybody outside its local domain
matches this against its own list (which may not look the same), and
chooses to not actively monitor those members of the received domain
record that are also present in its own list. Instead, it relies on
indications from the direct monitoring nodes if an indirectly
monitored node has gone up or down. If a node is indicated lost, the
receiving node temporarily activates its own direct monitoring towards
that node in order to confirm, or not, that it is actually gone.
- Since each node is actively monitoring sqrt(N) downstream neighbors,
each node is also actively monitored by the same number of upstream
neighbors. This means that all non-direct monitoring nodes normally
will receive sqrt(N) indications that a node is gone.
- A major drawback with ring monitoring is how it handles failures that
cause massive network partitionings. If both a lost node and all its
direct monitoring neighbors are inside the lost partition, the nodes in
the remaining partition will never receive indications about the loss.
To overcome this, each node also chooses to actively monitor some
nodes outside its local domain. Those nodes are called remote domain
"heads", and are selected in such a way that no node in the cluster
will be more than two direct monitoring hops away. Because of this,
each node, apart from monitoring the member of its local domain, will
also typically monitor sqrt(N) remote head nodes.
- As an optimization, local list status, domain status and domain
records are marked with a generation number. This saves senders from
unnecessarily conveying unaltered domain records, and receivers from
performing unneeded re-adaptations of their node monitoring list, such
as re-assigning domain heads.
- As a measure of caution we have added the possibility to disable the
new algorithm through configuration. We do this by keeping a threshold
value for the cluster size; a cluster that grows beyond this value
will switch from full-mesh to ring monitoring, and vice versa when
it shrinks below the value. This means that if the threshold is set to
a value larger than any anticipated cluster size (default size is 32)
the new algorithm is effectively disabled. A patch set for altering the
threshold value and for listing the table contents will follow shortly.
- This change is fully backwards compatible.
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-14 02:46:22 +02:00
|
|
|
}
|
2015-11-19 20:30:44 +01:00
|
|
|
}
|
|
|
|
|
2015-07-31 00:24:22 +02:00
|
|
|
struct tipc_node *tipc_node_create(struct net *net, u32 addr, u16 capabilities)
|
2006-01-02 19:04:38 +01:00
|
|
|
{
|
2015-01-09 08:27:05 +01:00
|
|
|
struct tipc_net *tn = net_generic(net, tipc_net_id);
|
2015-11-19 20:30:47 +01:00
|
|
|
struct tipc_node *n, *temp_node;
|
2015-11-19 20:30:44 +01:00
|
|
|
int i;
|
2006-01-02 19:04:38 +01:00
|
|
|
|
2015-01-09 08:27:05 +01:00
|
|
|
spin_lock_bh(&tn->node_list_lock);
|
2015-11-19 20:30:47 +01:00
|
|
|
n = tipc_node_find(net, addr);
|
2016-05-02 17:58:46 +02:00
|
|
|
if (n) {
|
|
|
|
/* Same node may come back with new capabilities */
|
|
|
|
n->capabilities = capabilities;
|
2015-02-03 14:59:19 +01:00
|
|
|
goto exit;
|
2016-05-02 17:58:46 +02:00
|
|
|
}
|
2015-11-19 20:30:47 +01:00
|
|
|
n = kzalloc(sizeof(*n), GFP_ATOMIC);
|
|
|
|
if (!n) {
|
2012-06-29 06:16:37 +02:00
|
|
|
pr_warn("Node creation failed, no memory\n");
|
2015-02-03 14:59:19 +01:00
|
|
|
goto exit;
|
2006-06-26 08:52:17 +02:00
|
|
|
}
|
2015-11-19 20:30:47 +01:00
|
|
|
n->addr = addr;
|
|
|
|
n->net = net;
|
|
|
|
n->capabilities = capabilities;
|
|
|
|
kref_init(&n->kref);
|
|
|
|
rwlock_init(&n->lock);
|
|
|
|
INIT_HLIST_NODE(&n->hash);
|
|
|
|
INIT_LIST_HEAD(&n->list);
|
|
|
|
INIT_LIST_HEAD(&n->publ_list);
|
|
|
|
INIT_LIST_HEAD(&n->conn_sks);
|
|
|
|
skb_queue_head_init(&n->bc_entry.namedq);
|
|
|
|
skb_queue_head_init(&n->bc_entry.inputq1);
|
|
|
|
__skb_queue_head_init(&n->bc_entry.arrvq);
|
|
|
|
skb_queue_head_init(&n->bc_entry.inputq2);
|
2015-11-19 20:30:44 +01:00
|
|
|
for (i = 0; i < MAX_BEARERS; i++)
|
2015-11-19 20:30:47 +01:00
|
|
|
spin_lock_init(&n->links[i].lock);
|
|
|
|
n->state = SELF_DOWN_PEER_LEAVING;
|
|
|
|
n->signature = INVALID_NODE_SIG;
|
|
|
|
n->active_links[0] = INVALID_BEARER_ID;
|
|
|
|
n->active_links[1] = INVALID_BEARER_ID;
|
|
|
|
if (!tipc_link_bc_create(net, tipc_own_addr(net), n->addr,
|
2015-11-19 20:30:46 +01:00
|
|
|
U16_MAX,
|
|
|
|
tipc_link_window(tipc_bc_sndlink(net)),
|
2015-11-19 20:30:47 +01:00
|
|
|
n->capabilities,
|
|
|
|
&n->bc_entry.inputq1,
|
|
|
|
&n->bc_entry.namedq,
|
2015-10-22 14:51:41 +02:00
|
|
|
tipc_bc_sndlink(net),
|
2015-11-19 20:30:47 +01:00
|
|
|
&n->bc_entry.link)) {
|
2015-10-22 14:51:41 +02:00
|
|
|
pr_warn("Broadcast rcv link creation failed, no memory\n");
|
2015-11-19 20:30:47 +01:00
|
|
|
kfree(n);
|
|
|
|
n = NULL;
|
2015-10-22 14:51:41 +02:00
|
|
|
goto exit;
|
|
|
|
}
|
2015-11-19 20:30:47 +01:00
|
|
|
tipc_node_get(n);
|
|
|
|
setup_timer(&n->timer, tipc_node_timeout, (unsigned long)n);
|
|
|
|
n->keepalive_intv = U32_MAX;
|
2016-02-10 22:14:57 +01:00
|
|
|
hlist_add_head_rcu(&n->hash, &tn->node_htable[tipc_hashfn(addr)]);
|
|
|
|
list_for_each_entry_rcu(temp_node, &tn->node_list, list) {
|
|
|
|
if (n->addr < temp_node->addr)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
list_add_tail_rcu(&n->list, &temp_node->list);
|
2015-02-03 14:59:19 +01:00
|
|
|
exit:
|
2015-01-09 08:27:05 +01:00
|
|
|
spin_unlock_bh(&tn->node_list_lock);
|
2015-11-19 20:30:47 +01:00
|
|
|
return n;
|
2006-01-02 19:04:38 +01:00
|
|
|
}
|
|
|
|
|
2015-07-16 22:54:29 +02:00
|
|
|
static void tipc_node_calculate_timer(struct tipc_node *n, struct tipc_link *l)
|
|
|
|
{
|
2015-11-19 20:30:46 +01:00
|
|
|
unsigned long tol = tipc_link_tolerance(l);
|
2015-07-16 22:54:29 +02:00
|
|
|
unsigned long intv = ((tol / 4) > 500) ? 500 : tol / 4;
|
|
|
|
|
|
|
|
/* Link with lowest tolerance determines timer interval */
|
2016-06-08 18:00:05 +02:00
|
|
|
if (intv < n->keepalive_intv)
|
|
|
|
n->keepalive_intv = intv;
|
2015-07-16 22:54:29 +02:00
|
|
|
|
2016-06-08 18:00:05 +02:00
|
|
|
/* Ensure link's abort limit corresponds to current tolerance */
|
|
|
|
tipc_link_set_abort_limit(l, tol / n->keepalive_intv);
|
2015-07-16 22:54:29 +02:00
|
|
|
}
|
|
|
|
|
2015-03-26 11:10:24 +01:00
|
|
|
static void tipc_node_delete(struct tipc_node *node)
|
2006-01-02 19:04:38 +01:00
|
|
|
{
|
2015-03-26 11:10:24 +01:00
|
|
|
list_del_rcu(&node->list);
|
|
|
|
hlist_del_rcu(&node->hash);
|
2016-02-24 17:10:48 +01:00
|
|
|
tipc_node_put(node);
|
|
|
|
|
|
|
|
del_timer_sync(&node->timer);
|
|
|
|
tipc_node_put(node);
|
2006-01-02 19:04:38 +01:00
|
|
|
}
|
|
|
|
|
2015-01-09 08:27:05 +01:00
|
|
|
void tipc_node_stop(struct net *net)
|
2014-03-27 05:54:36 +01:00
|
|
|
{
|
2016-02-24 17:10:48 +01:00
|
|
|
struct tipc_net *tn = tipc_net(net);
|
2014-03-27 05:54:36 +01:00
|
|
|
struct tipc_node *node, *t_node;
|
|
|
|
|
2015-01-09 08:27:05 +01:00
|
|
|
spin_lock_bh(&tn->node_list_lock);
|
2016-02-24 17:10:48 +01:00
|
|
|
list_for_each_entry_safe(node, t_node, &tn->node_list, list)
|
|
|
|
tipc_node_delete(node);
|
2015-01-09 08:27:05 +01:00
|
|
|
spin_unlock_bh(&tn->node_list_lock);
|
2014-03-27 05:54:36 +01:00
|
|
|
}
|
|
|
|
|
2015-11-19 20:30:42 +01:00
|
|
|
void tipc_node_subscribe(struct net *net, struct list_head *subscr, u32 addr)
|
|
|
|
{
|
|
|
|
struct tipc_node *n;
|
|
|
|
|
|
|
|
if (in_own_node(net, addr))
|
|
|
|
return;
|
|
|
|
|
|
|
|
n = tipc_node_find(net, addr);
|
|
|
|
if (!n) {
|
|
|
|
pr_warn("Node subscribe rejected, unknown node 0x%x\n", addr);
|
|
|
|
return;
|
|
|
|
}
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_write_lock(n);
|
2015-11-19 20:30:42 +01:00
|
|
|
list_add_tail(subscr, &n->publ_list);
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_write_unlock(n);
|
2015-11-19 20:30:42 +01:00
|
|
|
tipc_node_put(n);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tipc_node_unsubscribe(struct net *net, struct list_head *subscr, u32 addr)
|
|
|
|
{
|
|
|
|
struct tipc_node *n;
|
|
|
|
|
|
|
|
if (in_own_node(net, addr))
|
|
|
|
return;
|
|
|
|
|
|
|
|
n = tipc_node_find(net, addr);
|
|
|
|
if (!n) {
|
|
|
|
pr_warn("Node unsubscribe rejected, unknown node 0x%x\n", addr);
|
|
|
|
return;
|
|
|
|
}
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_write_lock(n);
|
2015-11-19 20:30:42 +01:00
|
|
|
list_del_init(subscr);
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_write_unlock(n);
|
2015-11-19 20:30:42 +01:00
|
|
|
tipc_node_put(n);
|
|
|
|
}
|
|
|
|
|
2015-01-09 08:27:05 +01:00
|
|
|
int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port)
|
tipc: use message to abort connections when losing contact to node
In the current implementation, each 'struct tipc_node' instance keeps
a linked list of those ports/sockets that are connected to the node
represented by that struct. The purpose of this is to let the node
object know which sockets to alert when it loses contact with its peer
node, i.e., which sockets need to have their connections aborted.
This entails an unwanted direct reference from the node structure
back to the port/socket structure, and a need to grab port_lock
when we have to make an upcall to the port. We want to get rid of
this unecessary BH entry point into the socket, and also eliminate
its use of port_lock.
In this commit, we instead let the node struct keep list of "connected
socket" structs, which each represents a connected socket, but is
allocated independently by the node at the moment of connection. If
the node loses contact with its peer node, the list is traversed, and
a "connection abort" message is created for each entry in the list. The
message is sent to it respective connected socket using the ordinary
data path, and the receiving socket aborts its connections upon reception
of the message.
This enables us to get rid of the direct reference from 'struct node' to
´struct port', and another unwanted BH access point to the latter.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-08-23 00:09:08 +02:00
|
|
|
{
|
|
|
|
struct tipc_node *node;
|
|
|
|
struct tipc_sock_conn *conn;
|
2015-03-26 11:10:24 +01:00
|
|
|
int err = 0;
|
tipc: use message to abort connections when losing contact to node
In the current implementation, each 'struct tipc_node' instance keeps
a linked list of those ports/sockets that are connected to the node
represented by that struct. The purpose of this is to let the node
object know which sockets to alert when it loses contact with its peer
node, i.e., which sockets need to have their connections aborted.
This entails an unwanted direct reference from the node structure
back to the port/socket structure, and a need to grab port_lock
when we have to make an upcall to the port. We want to get rid of
this unecessary BH entry point into the socket, and also eliminate
its use of port_lock.
In this commit, we instead let the node struct keep list of "connected
socket" structs, which each represents a connected socket, but is
allocated independently by the node at the moment of connection. If
the node loses contact with its peer node, the list is traversed, and
a "connection abort" message is created for each entry in the list. The
message is sent to it respective connected socket using the ordinary
data path, and the receiving socket aborts its connections upon reception
of the message.
This enables us to get rid of the direct reference from 'struct node' to
´struct port', and another unwanted BH access point to the latter.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-08-23 00:09:08 +02:00
|
|
|
|
2015-01-09 08:27:10 +01:00
|
|
|
if (in_own_node(net, dnode))
|
tipc: use message to abort connections when losing contact to node
In the current implementation, each 'struct tipc_node' instance keeps
a linked list of those ports/sockets that are connected to the node
represented by that struct. The purpose of this is to let the node
object know which sockets to alert when it loses contact with its peer
node, i.e., which sockets need to have their connections aborted.
This entails an unwanted direct reference from the node structure
back to the port/socket structure, and a need to grab port_lock
when we have to make an upcall to the port. We want to get rid of
this unecessary BH entry point into the socket, and also eliminate
its use of port_lock.
In this commit, we instead let the node struct keep list of "connected
socket" structs, which each represents a connected socket, but is
allocated independently by the node at the moment of connection. If
the node loses contact with its peer node, the list is traversed, and
a "connection abort" message is created for each entry in the list. The
message is sent to it respective connected socket using the ordinary
data path, and the receiving socket aborts its connections upon reception
of the message.
This enables us to get rid of the direct reference from 'struct node' to
´struct port', and another unwanted BH access point to the latter.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-08-23 00:09:08 +02:00
|
|
|
return 0;
|
|
|
|
|
2015-01-09 08:27:05 +01:00
|
|
|
node = tipc_node_find(net, dnode);
|
tipc: use message to abort connections when losing contact to node
In the current implementation, each 'struct tipc_node' instance keeps
a linked list of those ports/sockets that are connected to the node
represented by that struct. The purpose of this is to let the node
object know which sockets to alert when it loses contact with its peer
node, i.e., which sockets need to have their connections aborted.
This entails an unwanted direct reference from the node structure
back to the port/socket structure, and a need to grab port_lock
when we have to make an upcall to the port. We want to get rid of
this unecessary BH entry point into the socket, and also eliminate
its use of port_lock.
In this commit, we instead let the node struct keep list of "connected
socket" structs, which each represents a connected socket, but is
allocated independently by the node at the moment of connection. If
the node loses contact with its peer node, the list is traversed, and
a "connection abort" message is created for each entry in the list. The
message is sent to it respective connected socket using the ordinary
data path, and the receiving socket aborts its connections upon reception
of the message.
This enables us to get rid of the direct reference from 'struct node' to
´struct port', and another unwanted BH access point to the latter.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-08-23 00:09:08 +02:00
|
|
|
if (!node) {
|
|
|
|
pr_warn("Connecting sock to node 0x%x failed\n", dnode);
|
|
|
|
return -EHOSTUNREACH;
|
|
|
|
}
|
|
|
|
conn = kmalloc(sizeof(*conn), GFP_ATOMIC);
|
2015-03-26 11:10:24 +01:00
|
|
|
if (!conn) {
|
|
|
|
err = -EHOSTUNREACH;
|
|
|
|
goto exit;
|
|
|
|
}
|
tipc: use message to abort connections when losing contact to node
In the current implementation, each 'struct tipc_node' instance keeps
a linked list of those ports/sockets that are connected to the node
represented by that struct. The purpose of this is to let the node
object know which sockets to alert when it loses contact with its peer
node, i.e., which sockets need to have their connections aborted.
This entails an unwanted direct reference from the node structure
back to the port/socket structure, and a need to grab port_lock
when we have to make an upcall to the port. We want to get rid of
this unecessary BH entry point into the socket, and also eliminate
its use of port_lock.
In this commit, we instead let the node struct keep list of "connected
socket" structs, which each represents a connected socket, but is
allocated independently by the node at the moment of connection. If
the node loses contact with its peer node, the list is traversed, and
a "connection abort" message is created for each entry in the list. The
message is sent to it respective connected socket using the ordinary
data path, and the receiving socket aborts its connections upon reception
of the message.
This enables us to get rid of the direct reference from 'struct node' to
´struct port', and another unwanted BH access point to the latter.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-08-23 00:09:08 +02:00
|
|
|
conn->peer_node = dnode;
|
|
|
|
conn->port = port;
|
|
|
|
conn->peer_port = peer_port;
|
|
|
|
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_write_lock(node);
|
tipc: use message to abort connections when losing contact to node
In the current implementation, each 'struct tipc_node' instance keeps
a linked list of those ports/sockets that are connected to the node
represented by that struct. The purpose of this is to let the node
object know which sockets to alert when it loses contact with its peer
node, i.e., which sockets need to have their connections aborted.
This entails an unwanted direct reference from the node structure
back to the port/socket structure, and a need to grab port_lock
when we have to make an upcall to the port. We want to get rid of
this unecessary BH entry point into the socket, and also eliminate
its use of port_lock.
In this commit, we instead let the node struct keep list of "connected
socket" structs, which each represents a connected socket, but is
allocated independently by the node at the moment of connection. If
the node loses contact with its peer node, the list is traversed, and
a "connection abort" message is created for each entry in the list. The
message is sent to it respective connected socket using the ordinary
data path, and the receiving socket aborts its connections upon reception
of the message.
This enables us to get rid of the direct reference from 'struct node' to
´struct port', and another unwanted BH access point to the latter.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-08-23 00:09:08 +02:00
|
|
|
list_add_tail(&conn->list, &node->conn_sks);
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_write_unlock(node);
|
2015-03-26 11:10:24 +01:00
|
|
|
exit:
|
|
|
|
tipc_node_put(node);
|
|
|
|
return err;
|
tipc: use message to abort connections when losing contact to node
In the current implementation, each 'struct tipc_node' instance keeps
a linked list of those ports/sockets that are connected to the node
represented by that struct. The purpose of this is to let the node
object know which sockets to alert when it loses contact with its peer
node, i.e., which sockets need to have their connections aborted.
This entails an unwanted direct reference from the node structure
back to the port/socket structure, and a need to grab port_lock
when we have to make an upcall to the port. We want to get rid of
this unecessary BH entry point into the socket, and also eliminate
its use of port_lock.
In this commit, we instead let the node struct keep list of "connected
socket" structs, which each represents a connected socket, but is
allocated independently by the node at the moment of connection. If
the node loses contact with its peer node, the list is traversed, and
a "connection abort" message is created for each entry in the list. The
message is sent to it respective connected socket using the ordinary
data path, and the receiving socket aborts its connections upon reception
of the message.
This enables us to get rid of the direct reference from 'struct node' to
´struct port', and another unwanted BH access point to the latter.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-08-23 00:09:08 +02:00
|
|
|
}
|
|
|
|
|
2015-01-09 08:27:05 +01:00
|
|
|
void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port)
|
tipc: use message to abort connections when losing contact to node
In the current implementation, each 'struct tipc_node' instance keeps
a linked list of those ports/sockets that are connected to the node
represented by that struct. The purpose of this is to let the node
object know which sockets to alert when it loses contact with its peer
node, i.e., which sockets need to have their connections aborted.
This entails an unwanted direct reference from the node structure
back to the port/socket structure, and a need to grab port_lock
when we have to make an upcall to the port. We want to get rid of
this unecessary BH entry point into the socket, and also eliminate
its use of port_lock.
In this commit, we instead let the node struct keep list of "connected
socket" structs, which each represents a connected socket, but is
allocated independently by the node at the moment of connection. If
the node loses contact with its peer node, the list is traversed, and
a "connection abort" message is created for each entry in the list. The
message is sent to it respective connected socket using the ordinary
data path, and the receiving socket aborts its connections upon reception
of the message.
This enables us to get rid of the direct reference from 'struct node' to
´struct port', and another unwanted BH access point to the latter.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-08-23 00:09:08 +02:00
|
|
|
{
|
|
|
|
struct tipc_node *node;
|
|
|
|
struct tipc_sock_conn *conn, *safe;
|
|
|
|
|
2015-01-09 08:27:10 +01:00
|
|
|
if (in_own_node(net, dnode))
|
tipc: use message to abort connections when losing contact to node
In the current implementation, each 'struct tipc_node' instance keeps
a linked list of those ports/sockets that are connected to the node
represented by that struct. The purpose of this is to let the node
object know which sockets to alert when it loses contact with its peer
node, i.e., which sockets need to have their connections aborted.
This entails an unwanted direct reference from the node structure
back to the port/socket structure, and a need to grab port_lock
when we have to make an upcall to the port. We want to get rid of
this unecessary BH entry point into the socket, and also eliminate
its use of port_lock.
In this commit, we instead let the node struct keep list of "connected
socket" structs, which each represents a connected socket, but is
allocated independently by the node at the moment of connection. If
the node loses contact with its peer node, the list is traversed, and
a "connection abort" message is created for each entry in the list. The
message is sent to it respective connected socket using the ordinary
data path, and the receiving socket aborts its connections upon reception
of the message.
This enables us to get rid of the direct reference from 'struct node' to
´struct port', and another unwanted BH access point to the latter.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-08-23 00:09:08 +02:00
|
|
|
return;
|
|
|
|
|
2015-01-09 08:27:05 +01:00
|
|
|
node = tipc_node_find(net, dnode);
|
tipc: use message to abort connections when losing contact to node
In the current implementation, each 'struct tipc_node' instance keeps
a linked list of those ports/sockets that are connected to the node
represented by that struct. The purpose of this is to let the node
object know which sockets to alert when it loses contact with its peer
node, i.e., which sockets need to have their connections aborted.
This entails an unwanted direct reference from the node structure
back to the port/socket structure, and a need to grab port_lock
when we have to make an upcall to the port. We want to get rid of
this unecessary BH entry point into the socket, and also eliminate
its use of port_lock.
In this commit, we instead let the node struct keep list of "connected
socket" structs, which each represents a connected socket, but is
allocated independently by the node at the moment of connection. If
the node loses contact with its peer node, the list is traversed, and
a "connection abort" message is created for each entry in the list. The
message is sent to it respective connected socket using the ordinary
data path, and the receiving socket aborts its connections upon reception
of the message.
This enables us to get rid of the direct reference from 'struct node' to
´struct port', and another unwanted BH access point to the latter.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-08-23 00:09:08 +02:00
|
|
|
if (!node)
|
|
|
|
return;
|
|
|
|
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_write_lock(node);
|
tipc: use message to abort connections when losing contact to node
In the current implementation, each 'struct tipc_node' instance keeps
a linked list of those ports/sockets that are connected to the node
represented by that struct. The purpose of this is to let the node
object know which sockets to alert when it loses contact with its peer
node, i.e., which sockets need to have their connections aborted.
This entails an unwanted direct reference from the node structure
back to the port/socket structure, and a need to grab port_lock
when we have to make an upcall to the port. We want to get rid of
this unecessary BH entry point into the socket, and also eliminate
its use of port_lock.
In this commit, we instead let the node struct keep list of "connected
socket" structs, which each represents a connected socket, but is
allocated independently by the node at the moment of connection. If
the node loses contact with its peer node, the list is traversed, and
a "connection abort" message is created for each entry in the list. The
message is sent to it respective connected socket using the ordinary
data path, and the receiving socket aborts its connections upon reception
of the message.
This enables us to get rid of the direct reference from 'struct node' to
´struct port', and another unwanted BH access point to the latter.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-08-23 00:09:08 +02:00
|
|
|
list_for_each_entry_safe(conn, safe, &node->conn_sks, list) {
|
|
|
|
if (port != conn->port)
|
|
|
|
continue;
|
|
|
|
list_del(&conn->list);
|
|
|
|
kfree(conn);
|
|
|
|
}
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_write_unlock(node);
|
2015-03-26 11:10:24 +01:00
|
|
|
tipc_node_put(node);
|
tipc: use message to abort connections when losing contact to node
In the current implementation, each 'struct tipc_node' instance keeps
a linked list of those ports/sockets that are connected to the node
represented by that struct. The purpose of this is to let the node
object know which sockets to alert when it loses contact with its peer
node, i.e., which sockets need to have their connections aborted.
This entails an unwanted direct reference from the node structure
back to the port/socket structure, and a need to grab port_lock
when we have to make an upcall to the port. We want to get rid of
this unecessary BH entry point into the socket, and also eliminate
its use of port_lock.
In this commit, we instead let the node struct keep list of "connected
socket" structs, which each represents a connected socket, but is
allocated independently by the node at the moment of connection. If
the node loses contact with its peer node, the list is traversed, and
a "connection abort" message is created for each entry in the list. The
message is sent to it respective connected socket using the ordinary
data path, and the receiving socket aborts its connections upon reception
of the message.
This enables us to get rid of the direct reference from 'struct node' to
´struct port', and another unwanted BH access point to the latter.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-08-23 00:09:08 +02:00
|
|
|
}
|
|
|
|
|
2015-07-16 22:54:29 +02:00
|
|
|
/* tipc_node_timeout - handle expiration of node timer
|
|
|
|
*/
|
|
|
|
static void tipc_node_timeout(unsigned long data)
|
|
|
|
{
|
|
|
|
struct tipc_node *n = (struct tipc_node *)data;
|
2015-07-31 00:24:23 +02:00
|
|
|
struct tipc_link_entry *le;
|
2015-07-16 22:54:29 +02:00
|
|
|
struct sk_buff_head xmitq;
|
|
|
|
int bearer_id;
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
__skb_queue_head_init(&xmitq);
|
|
|
|
|
|
|
|
for (bearer_id = 0; bearer_id < MAX_BEARERS; bearer_id++) {
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_read_lock(n);
|
2015-07-31 00:24:23 +02:00
|
|
|
le = &n->links[bearer_id];
|
2015-11-19 20:30:43 +01:00
|
|
|
spin_lock_bh(&le->lock);
|
2015-07-31 00:24:23 +02:00
|
|
|
if (le->link) {
|
2015-07-16 22:54:29 +02:00
|
|
|
/* Link tolerance may change asynchronously: */
|
2015-07-31 00:24:23 +02:00
|
|
|
tipc_node_calculate_timer(n, le->link);
|
|
|
|
rc = tipc_link_timeout(le->link, &xmitq);
|
2015-07-16 22:54:29 +02:00
|
|
|
}
|
2015-11-19 20:30:43 +01:00
|
|
|
spin_unlock_bh(&le->lock);
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_read_unlock(n);
|
2015-07-31 00:24:23 +02:00
|
|
|
tipc_bearer_xmit(n->net, bearer_id, &xmitq, &le->maddr);
|
|
|
|
if (rc & TIPC_LINK_DOWN_EVT)
|
|
|
|
tipc_node_link_down(n, bearer_id, false);
|
2015-07-16 22:54:29 +02:00
|
|
|
}
|
2016-06-08 18:00:05 +02:00
|
|
|
mod_timer(&n->timer, jiffies + msecs_to_jiffies(n->keepalive_intv));
|
2015-07-16 22:54:29 +02:00
|
|
|
}
|
|
|
|
|
2006-01-02 19:04:38 +01:00
|
|
|
/**
|
2015-07-31 00:24:23 +02:00
|
|
|
* __tipc_node_link_up - handle addition of link
|
|
|
|
* Node lock must be held by caller
|
2006-01-02 19:04:38 +01:00
|
|
|
* Link becomes active (alone or shared) or standby, depending on its priority.
|
|
|
|
*/
|
2015-07-31 00:24:23 +02:00
|
|
|
static void __tipc_node_link_up(struct tipc_node *n, int bearer_id,
|
|
|
|
struct sk_buff_head *xmitq)
|
2006-01-02 19:04:38 +01:00
|
|
|
{
|
2015-07-16 22:54:22 +02:00
|
|
|
int *slot0 = &n->active_links[0];
|
|
|
|
int *slot1 = &n->active_links[1];
|
2015-07-31 00:24:19 +02:00
|
|
|
struct tipc_link *ol = node_active_link(n, 0);
|
|
|
|
struct tipc_link *nl = n->links[bearer_id].link;
|
2015-07-16 22:54:19 +02:00
|
|
|
|
2016-05-12 01:15:45 +02:00
|
|
|
if (!nl || tipc_link_is_up(nl))
|
tipc: delay ESTABLISH state event when link is established
Link establishing, just like link teardown, is a non-atomic action, in
the sense that discovering that conditions are right to establish a link,
and the actual adding of the link to one of the node's send slots is done
in two different lock contexts. The link FSM is designed to help bridging
the gap between the two contexts in a safe manner.
We have now discovered a weakness in the implementaton of this FSM.
Because we directly let the link go from state LINK_ESTABLISHING to
state LINK_ESTABLISHED already in the first lock context, we are unable
to distinguish between a fully established link, i.e., a link that has
been added to its slot, and a link that has not yet reached the second
lock context. It may hence happen that a manual intervention, e.g., when
disabling an interface, causes the function tipc_node_link_down() to try
removing the link from the node slots, decrementing its active link
counter etc, although the link was never added there in the first place.
We solve this by delaying the actual state change until we reach the
second lock context, inside the function tipc_node_link_up(). This
makes it possible for potentail callers of __tipc_node_link_down() to
know if they should proceed or not, and the problem is solved.
Unforunately, the situation described above also has a second problem.
Since there by necessity is a tipc_node_link_up() call pending once
the node lock has been released, we must defuse that call by setting
the link back from LINK_ESTABLISHING to LINK_RESET state. This forces
us to make a slight modification to the link FSM, which will now look
as follows.
+------------------------------------+
|RESET_EVT |
| |
| +--------------+
| +-----------------| SYNCHING |-----------------+
| |FAILURE_EVT +--------------+ PEER_RESET_EVT|
| | A | |
| | | | |
| | | | |
| | |SYNCH_ |SYNCH_ |
| | |BEGIN_EVT |END_EVT |
| | | | |
| V | V V
| +-------------+ +--------------+ +------------+
| | RESETTING |<---------| ESTABLISHED |--------->| PEER_RESET |
| +-------------+ FAILURE_ +--------------+ PEER_ +------------+
| | EVT | A RESET_EVT |
| | | | |
| | +----------------+ | |
| RESET_EVT| |RESET_EVT | |
| | | | |
| | | |ESTABLISH_EVT |
| | | +-------------+ | |
| | | | RESET_EVT | | |
| | | | | | |
| V V V | | |
| +-------------+ +--------------+ RESET_EVT|
+--->| RESET |--------->| ESTABLISHING |<----------------+
+-------------+ PEER_ +--------------+
| A RESET_EVT |
| | |
| | |
|FAILOVER_ |FAILOVER_ |FAILOVER_
|BEGIN_EVT |END_EVT |BEGIN_EVT
| | |
V | |
+-------------+ |
| FAILINGOVER |<----------------+
+-------------+
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-15 20:52:44 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
tipc_link_fsm_evt(nl, LINK_ESTABLISH_EVT);
|
|
|
|
if (!tipc_link_is_up(nl))
|
2015-07-31 00:24:23 +02:00
|
|
|
return;
|
|
|
|
|
2015-07-16 22:54:19 +02:00
|
|
|
n->working_links++;
|
|
|
|
n->action_flags |= TIPC_NOTIFY_LINK_UP;
|
2015-11-19 20:30:46 +01:00
|
|
|
n->link_id = tipc_link_id(nl);
|
2015-07-31 00:24:19 +02:00
|
|
|
|
|
|
|
/* Leave room for tunnel header when returning 'mtu' to users: */
|
2015-11-19 20:30:46 +01:00
|
|
|
n->links[bearer_id].mtu = tipc_link_mtu(nl) - INT_H_SIZE;
|
2014-10-20 08:44:25 +02:00
|
|
|
|
2015-07-31 00:24:15 +02:00
|
|
|
tipc_bearer_add_dest(n->net, bearer_id, n->addr);
|
tipc: simplify bearer level broadcast
Until now, we have been keeping track of the exact set of broadcast
destinations though the help structure tipc_node_map. This leads us to
have to maintain a whole infrastructure for supporting this, including
a pseudo-bearer and a number of functions to manipulate both the bearers
and the node map correctly. Apart from the complexity, this approach is
also limiting, as struct tipc_node_map only can support cluster local
broadcast if we want to avoid it becoming excessively large. We want to
eliminate this limitation, in order to enable introduction of scoped
multicast in the future.
A closer analysis reveals that it is unnecessary maintaining this "full
set" overview; it is sufficient to keep a counter per bearer, indicating
how many nodes can be reached via this bearer at the moment. The protocol
is now robust enough to handle transitional discrepancies between the
nominal number of reachable destinations, as expected by the broadcast
protocol itself, and the number which is actually reachable at the
moment. The initial broadcast synchronization, in conjunction with the
retransmission mechanism, ensures that all packets will eventually be
acknowledged by the correct set of destinations.
This commit introduces these changes.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-22 14:51:42 +02:00
|
|
|
tipc_bcast_inc_bearer_dst_cnt(n->net, bearer_id);
|
2015-07-31 00:24:15 +02:00
|
|
|
|
2015-01-22 17:10:31 +01:00
|
|
|
pr_debug("Established link <%s> on network plane %c\n",
|
2015-11-19 20:30:46 +01:00
|
|
|
tipc_link_name(nl), tipc_link_plane(nl));
|
2007-02-09 15:25:21 +01:00
|
|
|
|
2016-04-15 19:33:07 +02:00
|
|
|
/* Ensure that a STATE message goes first */
|
|
|
|
tipc_link_build_state_msg(nl, xmitq);
|
|
|
|
|
2015-07-31 00:24:19 +02:00
|
|
|
/* First link? => give it both slots */
|
|
|
|
if (!ol) {
|
2015-07-16 22:54:22 +02:00
|
|
|
*slot0 = bearer_id;
|
|
|
|
*slot1 = bearer_id;
|
2015-10-22 14:51:41 +02:00
|
|
|
tipc_node_fsm_evt(n, SELF_ESTABL_CONTACT_EVT);
|
|
|
|
n->action_flags |= TIPC_NOTIFY_NODE_UP;
|
2016-04-29 02:16:08 +02:00
|
|
|
tipc_link_set_active(nl, true);
|
tipc: simplify bearer level broadcast
Until now, we have been keeping track of the exact set of broadcast
destinations though the help structure tipc_node_map. This leads us to
have to maintain a whole infrastructure for supporting this, including
a pseudo-bearer and a number of functions to manipulate both the bearers
and the node map correctly. Apart from the complexity, this approach is
also limiting, as struct tipc_node_map only can support cluster local
broadcast if we want to avoid it becoming excessively large. We want to
eliminate this limitation, in order to enable introduction of scoped
multicast in the future.
A closer analysis reveals that it is unnecessary maintaining this "full
set" overview; it is sufficient to keep a counter per bearer, indicating
how many nodes can be reached via this bearer at the moment. The protocol
is now robust enough to handle transitional discrepancies between the
nominal number of reachable destinations, as expected by the broadcast
protocol itself, and the number which is actually reachable at the
moment. The initial broadcast synchronization, in conjunction with the
retransmission mechanism, ensures that all packets will eventually be
acknowledged by the correct set of destinations.
This commit introduces these changes.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-22 14:51:42 +02:00
|
|
|
tipc_bcast_add_peer(n->net, nl, xmitq);
|
2015-07-16 22:54:19 +02:00
|
|
|
return;
|
2006-01-02 19:04:38 +01:00
|
|
|
}
|
2015-07-16 22:54:22 +02:00
|
|
|
|
2015-07-31 00:24:19 +02:00
|
|
|
/* Second link => redistribute slots */
|
2015-11-19 20:30:46 +01:00
|
|
|
if (tipc_link_prio(nl) > tipc_link_prio(ol)) {
|
|
|
|
pr_debug("Old link <%s> becomes standby\n", tipc_link_name(ol));
|
2015-07-16 22:54:22 +02:00
|
|
|
*slot0 = bearer_id;
|
2015-07-31 00:24:19 +02:00
|
|
|
*slot1 = bearer_id;
|
2015-10-22 14:51:46 +02:00
|
|
|
tipc_link_set_active(nl, true);
|
|
|
|
tipc_link_set_active(ol, false);
|
2015-11-19 20:30:46 +01:00
|
|
|
} else if (tipc_link_prio(nl) == tipc_link_prio(ol)) {
|
2015-10-22 14:51:46 +02:00
|
|
|
tipc_link_set_active(nl, true);
|
2015-10-22 14:51:47 +02:00
|
|
|
*slot1 = bearer_id;
|
2015-07-31 00:24:19 +02:00
|
|
|
} else {
|
2015-11-19 20:30:46 +01:00
|
|
|
pr_debug("New link <%s> is standby\n", tipc_link_name(nl));
|
2006-01-02 19:04:38 +01:00
|
|
|
}
|
|
|
|
|
2015-07-31 00:24:19 +02:00
|
|
|
/* Prepare synchronization with first link */
|
|
|
|
tipc_link_tnl_prepare(ol, nl, SYNCH_MSG, xmitq);
|
2006-01-02 19:04:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-07-31 00:24:23 +02:00
|
|
|
* tipc_node_link_up - handle addition of link
|
|
|
|
*
|
|
|
|
* Link becomes active (alone or shared) or standby, depending on its priority.
|
2006-01-02 19:04:38 +01:00
|
|
|
*/
|
2015-07-31 00:24:23 +02:00
|
|
|
static void tipc_node_link_up(struct tipc_node *n, int bearer_id,
|
|
|
|
struct sk_buff_head *xmitq)
|
2006-01-02 19:04:38 +01:00
|
|
|
{
|
2016-04-15 19:33:06 +02:00
|
|
|
struct tipc_media_addr *maddr;
|
|
|
|
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_write_lock(n);
|
2015-07-31 00:24:23 +02:00
|
|
|
__tipc_node_link_up(n, bearer_id, xmitq);
|
2016-04-15 19:33:06 +02:00
|
|
|
maddr = &n->links[bearer_id].maddr;
|
|
|
|
tipc_bearer_xmit(n->net, bearer_id, xmitq, maddr);
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_write_unlock(n);
|
2015-07-31 00:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* __tipc_node_link_down - handle loss of link
|
|
|
|
*/
|
|
|
|
static void __tipc_node_link_down(struct tipc_node *n, int *bearer_id,
|
|
|
|
struct sk_buff_head *xmitq,
|
|
|
|
struct tipc_media_addr **maddr)
|
|
|
|
{
|
|
|
|
struct tipc_link_entry *le = &n->links[*bearer_id];
|
2015-07-16 22:54:22 +02:00
|
|
|
int *slot0 = &n->active_links[0];
|
|
|
|
int *slot1 = &n->active_links[1];
|
2015-11-19 20:30:46 +01:00
|
|
|
int i, highest = 0, prio;
|
2015-07-31 00:24:19 +02:00
|
|
|
struct tipc_link *l, *_l, *tnl;
|
2006-01-02 19:04:38 +01:00
|
|
|
|
2015-07-31 00:24:23 +02:00
|
|
|
l = n->links[*bearer_id].link;
|
2015-07-31 00:24:21 +02:00
|
|
|
if (!l || tipc_link_is_reset(l))
|
2015-07-31 00:24:17 +02:00
|
|
|
return;
|
|
|
|
|
2015-07-16 22:54:19 +02:00
|
|
|
n->working_links--;
|
|
|
|
n->action_flags |= TIPC_NOTIFY_LINK_DOWN;
|
2015-11-19 20:30:46 +01:00
|
|
|
n->link_id = tipc_link_id(l);
|
2006-06-26 08:52:50 +02:00
|
|
|
|
2015-07-31 00:24:23 +02:00
|
|
|
tipc_bearer_remove_dest(n->net, *bearer_id, n->addr);
|
2015-07-31 00:24:17 +02:00
|
|
|
|
2015-01-22 17:10:31 +01:00
|
|
|
pr_debug("Lost link <%s> on network plane %c\n",
|
2015-11-19 20:30:46 +01:00
|
|
|
tipc_link_name(l), tipc_link_plane(l));
|
2014-06-26 03:41:33 +02:00
|
|
|
|
2015-07-16 22:54:22 +02:00
|
|
|
/* Select new active link if any available */
|
|
|
|
*slot0 = INVALID_BEARER_ID;
|
|
|
|
*slot1 = INVALID_BEARER_ID;
|
|
|
|
for (i = 0; i < MAX_BEARERS; i++) {
|
|
|
|
_l = n->links[i].link;
|
|
|
|
if (!_l || !tipc_link_is_up(_l))
|
|
|
|
continue;
|
2015-07-31 00:24:17 +02:00
|
|
|
if (_l == l)
|
|
|
|
continue;
|
2015-11-19 20:30:46 +01:00
|
|
|
prio = tipc_link_prio(_l);
|
|
|
|
if (prio < highest)
|
2015-07-16 22:54:22 +02:00
|
|
|
continue;
|
2015-11-19 20:30:46 +01:00
|
|
|
if (prio > highest) {
|
|
|
|
highest = prio;
|
2015-07-16 22:54:22 +02:00
|
|
|
*slot0 = i;
|
|
|
|
*slot1 = i;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
*slot1 = i;
|
|
|
|
}
|
2015-07-31 00:24:17 +02:00
|
|
|
|
2015-07-31 00:24:19 +02:00
|
|
|
if (!tipc_node_is_up(n)) {
|
2015-10-15 20:52:46 +02:00
|
|
|
if (tipc_link_peer_is_down(l))
|
|
|
|
tipc_node_fsm_evt(n, PEER_LOST_CONTACT_EVT);
|
|
|
|
tipc_node_fsm_evt(n, SELF_LOST_CONTACT_EVT);
|
|
|
|
tipc_link_fsm_evt(l, LINK_RESET_EVT);
|
2015-07-31 00:24:19 +02:00
|
|
|
tipc_link_reset(l);
|
2015-10-15 20:52:45 +02:00
|
|
|
tipc_link_build_reset_msg(l, xmitq);
|
|
|
|
*maddr = &n->links[*bearer_id].maddr;
|
2015-07-31 00:24:23 +02:00
|
|
|
node_lost_contact(n, &le->inputq);
|
tipc: simplify bearer level broadcast
Until now, we have been keeping track of the exact set of broadcast
destinations though the help structure tipc_node_map. This leads us to
have to maintain a whole infrastructure for supporting this, including
a pseudo-bearer and a number of functions to manipulate both the bearers
and the node map correctly. Apart from the complexity, this approach is
also limiting, as struct tipc_node_map only can support cluster local
broadcast if we want to avoid it becoming excessively large. We want to
eliminate this limitation, in order to enable introduction of scoped
multicast in the future.
A closer analysis reveals that it is unnecessary maintaining this "full
set" overview; it is sufficient to keep a counter per bearer, indicating
how many nodes can be reached via this bearer at the moment. The protocol
is now robust enough to handle transitional discrepancies between the
nominal number of reachable destinations, as expected by the broadcast
protocol itself, and the number which is actually reachable at the
moment. The initial broadcast synchronization, in conjunction with the
retransmission mechanism, ensures that all packets will eventually be
acknowledged by the correct set of destinations.
This commit introduces these changes.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-22 14:51:42 +02:00
|
|
|
tipc_bcast_dec_bearer_dst_cnt(n->net, *bearer_id);
|
2015-07-31 00:24:19 +02:00
|
|
|
return;
|
|
|
|
}
|
tipc: simplify bearer level broadcast
Until now, we have been keeping track of the exact set of broadcast
destinations though the help structure tipc_node_map. This leads us to
have to maintain a whole infrastructure for supporting this, including
a pseudo-bearer and a number of functions to manipulate both the bearers
and the node map correctly. Apart from the complexity, this approach is
also limiting, as struct tipc_node_map only can support cluster local
broadcast if we want to avoid it becoming excessively large. We want to
eliminate this limitation, in order to enable introduction of scoped
multicast in the future.
A closer analysis reveals that it is unnecessary maintaining this "full
set" overview; it is sufficient to keep a counter per bearer, indicating
how many nodes can be reached via this bearer at the moment. The protocol
is now robust enough to handle transitional discrepancies between the
nominal number of reachable destinations, as expected by the broadcast
protocol itself, and the number which is actually reachable at the
moment. The initial broadcast synchronization, in conjunction with the
retransmission mechanism, ensures that all packets will eventually be
acknowledged by the correct set of destinations.
This commit introduces these changes.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-22 14:51:42 +02:00
|
|
|
tipc_bcast_dec_bearer_dst_cnt(n->net, *bearer_id);
|
2015-07-31 00:24:17 +02:00
|
|
|
|
2015-07-31 00:24:19 +02:00
|
|
|
/* There is still a working link => initiate failover */
|
2015-11-19 20:30:46 +01:00
|
|
|
*bearer_id = n->active_links[0];
|
|
|
|
tnl = n->links[*bearer_id].link;
|
2015-08-20 08:12:55 +02:00
|
|
|
tipc_link_fsm_evt(tnl, LINK_SYNCH_END_EVT);
|
|
|
|
tipc_node_fsm_evt(n, NODE_SYNCH_END_EVT);
|
2015-11-19 20:30:46 +01:00
|
|
|
n->sync_point = tipc_link_rcv_nxt(tnl) + (U16_MAX / 2 - 1);
|
2015-07-31 00:24:23 +02:00
|
|
|
tipc_link_tnl_prepare(l, tnl, FAILOVER_MSG, xmitq);
|
2015-07-31 00:24:17 +02:00
|
|
|
tipc_link_reset(l);
|
2015-10-15 20:52:46 +02:00
|
|
|
tipc_link_fsm_evt(l, LINK_RESET_EVT);
|
2015-07-31 00:24:21 +02:00
|
|
|
tipc_link_fsm_evt(l, LINK_FAILOVER_BEGIN_EVT);
|
2015-07-31 00:24:23 +02:00
|
|
|
tipc_node_fsm_evt(n, NODE_FAILOVER_BEGIN_EVT);
|
2015-11-19 20:30:46 +01:00
|
|
|
*maddr = &n->links[*bearer_id].maddr;
|
2015-07-31 00:24:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void tipc_node_link_down(struct tipc_node *n, int bearer_id, bool delete)
|
|
|
|
{
|
|
|
|
struct tipc_link_entry *le = &n->links[bearer_id];
|
tipc: delay ESTABLISH state event when link is established
Link establishing, just like link teardown, is a non-atomic action, in
the sense that discovering that conditions are right to establish a link,
and the actual adding of the link to one of the node's send slots is done
in two different lock contexts. The link FSM is designed to help bridging
the gap between the two contexts in a safe manner.
We have now discovered a weakness in the implementaton of this FSM.
Because we directly let the link go from state LINK_ESTABLISHING to
state LINK_ESTABLISHED already in the first lock context, we are unable
to distinguish between a fully established link, i.e., a link that has
been added to its slot, and a link that has not yet reached the second
lock context. It may hence happen that a manual intervention, e.g., when
disabling an interface, causes the function tipc_node_link_down() to try
removing the link from the node slots, decrementing its active link
counter etc, although the link was never added there in the first place.
We solve this by delaying the actual state change until we reach the
second lock context, inside the function tipc_node_link_up(). This
makes it possible for potentail callers of __tipc_node_link_down() to
know if they should proceed or not, and the problem is solved.
Unforunately, the situation described above also has a second problem.
Since there by necessity is a tipc_node_link_up() call pending once
the node lock has been released, we must defuse that call by setting
the link back from LINK_ESTABLISHING to LINK_RESET state. This forces
us to make a slight modification to the link FSM, which will now look
as follows.
+------------------------------------+
|RESET_EVT |
| |
| +--------------+
| +-----------------| SYNCHING |-----------------+
| |FAILURE_EVT +--------------+ PEER_RESET_EVT|
| | A | |
| | | | |
| | | | |
| | |SYNCH_ |SYNCH_ |
| | |BEGIN_EVT |END_EVT |
| | | | |
| V | V V
| +-------------+ +--------------+ +------------+
| | RESETTING |<---------| ESTABLISHED |--------->| PEER_RESET |
| +-------------+ FAILURE_ +--------------+ PEER_ +------------+
| | EVT | A RESET_EVT |
| | | | |
| | +----------------+ | |
| RESET_EVT| |RESET_EVT | |
| | | | |
| | | |ESTABLISH_EVT |
| | | +-------------+ | |
| | | | RESET_EVT | | |
| | | | | | |
| V V V | | |
| +-------------+ +--------------+ RESET_EVT|
+--->| RESET |--------->| ESTABLISHING |<----------------+
+-------------+ PEER_ +--------------+
| A RESET_EVT |
| | |
| | |
|FAILOVER_ |FAILOVER_ |FAILOVER_
|BEGIN_EVT |END_EVT |BEGIN_EVT
| | |
V | |
+-------------+ |
| FAILINGOVER |<----------------+
+-------------+
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-15 20:52:44 +02:00
|
|
|
struct tipc_link *l = le->link;
|
2015-07-31 00:24:23 +02:00
|
|
|
struct tipc_media_addr *maddr;
|
|
|
|
struct sk_buff_head xmitq;
|
tipc: add neighbor monitoring framework
TIPC based clusters are by default set up with full-mesh link
connectivity between all nodes. Those links are expected to provide
a short failure detection time, by default set to 1500 ms. Because
of this, the background load for neighbor monitoring in an N-node
cluster increases with a factor N on each node, while the overall
monitoring traffic through the network infrastructure increases at
a ~(N * (N - 1)) rate. Experience has shown that such clusters don't
scale well beyond ~100 nodes unless we significantly increase failure
discovery tolerance.
This commit introduces a framework and an algorithm that drastically
reduces this background load, while basically maintaining the original
failure detection times across the whole cluster. Using this algorithm,
background load will now grow at a rate of ~(2 * sqrt(N)) per node, and
at ~(2 * N * sqrt(N)) in traffic overhead. As an example, each node will
now have to actively monitor 38 neighbors in a 400-node cluster, instead
of as before 399.
This "Overlapping Ring Supervision Algorithm" is completely distributed
and employs no centralized or coordinated state. It goes as follows:
- Each node makes up a linearly ascending, circular list of all its N
known neighbors, based on their TIPC node identity. This algorithm
must be the same on all nodes.
- The node then selects the next M = sqrt(N) - 1 nodes downstream from
itself in the list, and chooses to actively monitor those. This is
called its "local monitoring domain".
- It creates a domain record describing the monitoring domain, and
piggy-backs this in the data area of all neighbor monitoring messages
(LINK_PROTOCOL/STATE) leaving that node. This means that all nodes in
the cluster eventually (default within 400 ms) will learn about
its monitoring domain.
- Whenever a node discovers a change in its local domain, e.g., a node
has been added or has gone down, it creates and sends out a new
version of its node record to inform all neighbors about the change.
- A node receiving a domain record from anybody outside its local domain
matches this against its own list (which may not look the same), and
chooses to not actively monitor those members of the received domain
record that are also present in its own list. Instead, it relies on
indications from the direct monitoring nodes if an indirectly
monitored node has gone up or down. If a node is indicated lost, the
receiving node temporarily activates its own direct monitoring towards
that node in order to confirm, or not, that it is actually gone.
- Since each node is actively monitoring sqrt(N) downstream neighbors,
each node is also actively monitored by the same number of upstream
neighbors. This means that all non-direct monitoring nodes normally
will receive sqrt(N) indications that a node is gone.
- A major drawback with ring monitoring is how it handles failures that
cause massive network partitionings. If both a lost node and all its
direct monitoring neighbors are inside the lost partition, the nodes in
the remaining partition will never receive indications about the loss.
To overcome this, each node also chooses to actively monitor some
nodes outside its local domain. Those nodes are called remote domain
"heads", and are selected in such a way that no node in the cluster
will be more than two direct monitoring hops away. Because of this,
each node, apart from monitoring the member of its local domain, will
also typically monitor sqrt(N) remote head nodes.
- As an optimization, local list status, domain status and domain
records are marked with a generation number. This saves senders from
unnecessarily conveying unaltered domain records, and receivers from
performing unneeded re-adaptations of their node monitoring list, such
as re-assigning domain heads.
- As a measure of caution we have added the possibility to disable the
new algorithm through configuration. We do this by keeping a threshold
value for the cluster size; a cluster that grows beyond this value
will switch from full-mesh to ring monitoring, and vice versa when
it shrinks below the value. This means that if the threshold is set to
a value larger than any anticipated cluster size (default size is 32)
the new algorithm is effectively disabled. A patch set for altering the
threshold value and for listing the table contents will follow shortly.
- This change is fully backwards compatible.
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-14 02:46:22 +02:00
|
|
|
int old_bearer_id = bearer_id;
|
2015-07-31 00:24:23 +02:00
|
|
|
|
tipc: delay ESTABLISH state event when link is established
Link establishing, just like link teardown, is a non-atomic action, in
the sense that discovering that conditions are right to establish a link,
and the actual adding of the link to one of the node's send slots is done
in two different lock contexts. The link FSM is designed to help bridging
the gap between the two contexts in a safe manner.
We have now discovered a weakness in the implementaton of this FSM.
Because we directly let the link go from state LINK_ESTABLISHING to
state LINK_ESTABLISHED already in the first lock context, we are unable
to distinguish between a fully established link, i.e., a link that has
been added to its slot, and a link that has not yet reached the second
lock context. It may hence happen that a manual intervention, e.g., when
disabling an interface, causes the function tipc_node_link_down() to try
removing the link from the node slots, decrementing its active link
counter etc, although the link was never added there in the first place.
We solve this by delaying the actual state change until we reach the
second lock context, inside the function tipc_node_link_up(). This
makes it possible for potentail callers of __tipc_node_link_down() to
know if they should proceed or not, and the problem is solved.
Unforunately, the situation described above also has a second problem.
Since there by necessity is a tipc_node_link_up() call pending once
the node lock has been released, we must defuse that call by setting
the link back from LINK_ESTABLISHING to LINK_RESET state. This forces
us to make a slight modification to the link FSM, which will now look
as follows.
+------------------------------------+
|RESET_EVT |
| |
| +--------------+
| +-----------------| SYNCHING |-----------------+
| |FAILURE_EVT +--------------+ PEER_RESET_EVT|
| | A | |
| | | | |
| | | | |
| | |SYNCH_ |SYNCH_ |
| | |BEGIN_EVT |END_EVT |
| | | | |
| V | V V
| +-------------+ +--------------+ +------------+
| | RESETTING |<---------| ESTABLISHED |--------->| PEER_RESET |
| +-------------+ FAILURE_ +--------------+ PEER_ +------------+
| | EVT | A RESET_EVT |
| | | | |
| | +----------------+ | |
| RESET_EVT| |RESET_EVT | |
| | | | |
| | | |ESTABLISH_EVT |
| | | +-------------+ | |
| | | | RESET_EVT | | |
| | | | | | |
| V V V | | |
| +-------------+ +--------------+ RESET_EVT|
+--->| RESET |--------->| ESTABLISHING |<----------------+
+-------------+ PEER_ +--------------+
| A RESET_EVT |
| | |
| | |
|FAILOVER_ |FAILOVER_ |FAILOVER_
|BEGIN_EVT |END_EVT |BEGIN_EVT
| | |
V | |
+-------------+ |
| FAILINGOVER |<----------------+
+-------------+
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-15 20:52:44 +02:00
|
|
|
if (!l)
|
|
|
|
return;
|
|
|
|
|
2015-07-31 00:24:23 +02:00
|
|
|
__skb_queue_head_init(&xmitq);
|
|
|
|
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_write_lock(n);
|
tipc: delay ESTABLISH state event when link is established
Link establishing, just like link teardown, is a non-atomic action, in
the sense that discovering that conditions are right to establish a link,
and the actual adding of the link to one of the node's send slots is done
in two different lock contexts. The link FSM is designed to help bridging
the gap between the two contexts in a safe manner.
We have now discovered a weakness in the implementaton of this FSM.
Because we directly let the link go from state LINK_ESTABLISHING to
state LINK_ESTABLISHED already in the first lock context, we are unable
to distinguish between a fully established link, i.e., a link that has
been added to its slot, and a link that has not yet reached the second
lock context. It may hence happen that a manual intervention, e.g., when
disabling an interface, causes the function tipc_node_link_down() to try
removing the link from the node slots, decrementing its active link
counter etc, although the link was never added there in the first place.
We solve this by delaying the actual state change until we reach the
second lock context, inside the function tipc_node_link_up(). This
makes it possible for potentail callers of __tipc_node_link_down() to
know if they should proceed or not, and the problem is solved.
Unforunately, the situation described above also has a second problem.
Since there by necessity is a tipc_node_link_up() call pending once
the node lock has been released, we must defuse that call by setting
the link back from LINK_ESTABLISHING to LINK_RESET state. This forces
us to make a slight modification to the link FSM, which will now look
as follows.
+------------------------------------+
|RESET_EVT |
| |
| +--------------+
| +-----------------| SYNCHING |-----------------+
| |FAILURE_EVT +--------------+ PEER_RESET_EVT|
| | A | |
| | | | |
| | | | |
| | |SYNCH_ |SYNCH_ |
| | |BEGIN_EVT |END_EVT |
| | | | |
| V | V V
| +-------------+ +--------------+ +------------+
| | RESETTING |<---------| ESTABLISHED |--------->| PEER_RESET |
| +-------------+ FAILURE_ +--------------+ PEER_ +------------+
| | EVT | A RESET_EVT |
| | | | |
| | +----------------+ | |
| RESET_EVT| |RESET_EVT | |
| | | | |
| | | |ESTABLISH_EVT |
| | | +-------------+ | |
| | | | RESET_EVT | | |
| | | | | | |
| V V V | | |
| +-------------+ +--------------+ RESET_EVT|
+--->| RESET |--------->| ESTABLISHING |<----------------+
+-------------+ PEER_ +--------------+
| A RESET_EVT |
| | |
| | |
|FAILOVER_ |FAILOVER_ |FAILOVER_
|BEGIN_EVT |END_EVT |BEGIN_EVT
| | |
V | |
+-------------+ |
| FAILINGOVER |<----------------+
+-------------+
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-15 20:52:44 +02:00
|
|
|
if (!tipc_link_is_establishing(l)) {
|
|
|
|
__tipc_node_link_down(n, &bearer_id, &xmitq, &maddr);
|
|
|
|
if (delete) {
|
|
|
|
kfree(l);
|
|
|
|
le->link = NULL;
|
|
|
|
n->link_cnt--;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Defuse pending tipc_node_link_up() */
|
|
|
|
tipc_link_fsm_evt(l, LINK_RESET_EVT);
|
2015-07-31 00:24:23 +02:00
|
|
|
}
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_write_unlock(n);
|
tipc: add neighbor monitoring framework
TIPC based clusters are by default set up with full-mesh link
connectivity between all nodes. Those links are expected to provide
a short failure detection time, by default set to 1500 ms. Because
of this, the background load for neighbor monitoring in an N-node
cluster increases with a factor N on each node, while the overall
monitoring traffic through the network infrastructure increases at
a ~(N * (N - 1)) rate. Experience has shown that such clusters don't
scale well beyond ~100 nodes unless we significantly increase failure
discovery tolerance.
This commit introduces a framework and an algorithm that drastically
reduces this background load, while basically maintaining the original
failure detection times across the whole cluster. Using this algorithm,
background load will now grow at a rate of ~(2 * sqrt(N)) per node, and
at ~(2 * N * sqrt(N)) in traffic overhead. As an example, each node will
now have to actively monitor 38 neighbors in a 400-node cluster, instead
of as before 399.
This "Overlapping Ring Supervision Algorithm" is completely distributed
and employs no centralized or coordinated state. It goes as follows:
- Each node makes up a linearly ascending, circular list of all its N
known neighbors, based on their TIPC node identity. This algorithm
must be the same on all nodes.
- The node then selects the next M = sqrt(N) - 1 nodes downstream from
itself in the list, and chooses to actively monitor those. This is
called its "local monitoring domain".
- It creates a domain record describing the monitoring domain, and
piggy-backs this in the data area of all neighbor monitoring messages
(LINK_PROTOCOL/STATE) leaving that node. This means that all nodes in
the cluster eventually (default within 400 ms) will learn about
its monitoring domain.
- Whenever a node discovers a change in its local domain, e.g., a node
has been added or has gone down, it creates and sends out a new
version of its node record to inform all neighbors about the change.
- A node receiving a domain record from anybody outside its local domain
matches this against its own list (which may not look the same), and
chooses to not actively monitor those members of the received domain
record that are also present in its own list. Instead, it relies on
indications from the direct monitoring nodes if an indirectly
monitored node has gone up or down. If a node is indicated lost, the
receiving node temporarily activates its own direct monitoring towards
that node in order to confirm, or not, that it is actually gone.
- Since each node is actively monitoring sqrt(N) downstream neighbors,
each node is also actively monitored by the same number of upstream
neighbors. This means that all non-direct monitoring nodes normally
will receive sqrt(N) indications that a node is gone.
- A major drawback with ring monitoring is how it handles failures that
cause massive network partitionings. If both a lost node and all its
direct monitoring neighbors are inside the lost partition, the nodes in
the remaining partition will never receive indications about the loss.
To overcome this, each node also chooses to actively monitor some
nodes outside its local domain. Those nodes are called remote domain
"heads", and are selected in such a way that no node in the cluster
will be more than two direct monitoring hops away. Because of this,
each node, apart from monitoring the member of its local domain, will
also typically monitor sqrt(N) remote head nodes.
- As an optimization, local list status, domain status and domain
records are marked with a generation number. This saves senders from
unnecessarily conveying unaltered domain records, and receivers from
performing unneeded re-adaptations of their node monitoring list, such
as re-assigning domain heads.
- As a measure of caution we have added the possibility to disable the
new algorithm through configuration. We do this by keeping a threshold
value for the cluster size; a cluster that grows beyond this value
will switch from full-mesh to ring monitoring, and vice versa when
it shrinks below the value. This means that if the threshold is set to
a value larger than any anticipated cluster size (default size is 32)
the new algorithm is effectively disabled. A patch set for altering the
threshold value and for listing the table contents will follow shortly.
- This change is fully backwards compatible.
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-14 02:46:22 +02:00
|
|
|
if (delete)
|
|
|
|
tipc_mon_remove_peer(n->net, n->addr, old_bearer_id);
|
2015-07-31 00:24:23 +02:00
|
|
|
tipc_bearer_xmit(n->net, bearer_id, &xmitq, maddr);
|
|
|
|
tipc_sk_rcv(n->net, &le->inputq);
|
2006-01-02 19:04:38 +01:00
|
|
|
}
|
|
|
|
|
2015-11-19 20:30:45 +01:00
|
|
|
static bool tipc_node_is_up(struct tipc_node *n)
|
2006-01-02 19:04:38 +01:00
|
|
|
{
|
2015-07-16 22:54:22 +02:00
|
|
|
return n->active_links[0] != INVALID_BEARER_ID;
|
2006-01-02 19:04:38 +01:00
|
|
|
}
|
|
|
|
|
2015-07-31 00:24:22 +02:00
|
|
|
void tipc_node_check_dest(struct net *net, u32 onode,
|
|
|
|
struct tipc_bearer *b,
|
|
|
|
u16 capabilities, u32 signature,
|
|
|
|
struct tipc_media_addr *maddr,
|
|
|
|
bool *respond, bool *dupl_addr)
|
2015-07-16 22:54:20 +02:00
|
|
|
{
|
2015-07-31 00:24:22 +02:00
|
|
|
struct tipc_node *n;
|
|
|
|
struct tipc_link *l;
|
2015-07-31 00:24:26 +02:00
|
|
|
struct tipc_link_entry *le;
|
2015-07-31 00:24:22 +02:00
|
|
|
bool addr_match = false;
|
|
|
|
bool sign_match = false;
|
|
|
|
bool link_up = false;
|
|
|
|
bool accept_addr = false;
|
2015-07-31 00:24:23 +02:00
|
|
|
bool reset = true;
|
2015-10-22 14:51:36 +02:00
|
|
|
char *if_name;
|
2016-06-08 18:00:05 +02:00
|
|
|
unsigned long intv;
|
2015-07-31 00:24:26 +02:00
|
|
|
|
2015-07-31 00:24:22 +02:00
|
|
|
*dupl_addr = false;
|
|
|
|
*respond = false;
|
|
|
|
|
|
|
|
n = tipc_node_create(net, onode, capabilities);
|
|
|
|
if (!n)
|
|
|
|
return;
|
2015-07-16 22:54:20 +02:00
|
|
|
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_write_lock(n);
|
2015-07-31 00:24:22 +02:00
|
|
|
|
2015-07-31 00:24:26 +02:00
|
|
|
le = &n->links[b->identity];
|
2015-07-31 00:24:22 +02:00
|
|
|
|
|
|
|
/* Prepare to validate requesting node's signature and media address */
|
2015-07-31 00:24:26 +02:00
|
|
|
l = le->link;
|
2015-07-31 00:24:22 +02:00
|
|
|
link_up = l && tipc_link_is_up(l);
|
2015-07-31 00:24:26 +02:00
|
|
|
addr_match = l && !memcmp(&le->maddr, maddr, sizeof(*maddr));
|
2015-07-31 00:24:22 +02:00
|
|
|
sign_match = (signature == n->signature);
|
|
|
|
|
|
|
|
/* These three flags give us eight permutations: */
|
|
|
|
|
|
|
|
if (sign_match && addr_match && link_up) {
|
|
|
|
/* All is fine. Do nothing. */
|
2015-07-31 00:24:23 +02:00
|
|
|
reset = false;
|
2015-07-31 00:24:22 +02:00
|
|
|
} else if (sign_match && addr_match && !link_up) {
|
|
|
|
/* Respond. The link will come up in due time */
|
|
|
|
*respond = true;
|
|
|
|
} else if (sign_match && !addr_match && link_up) {
|
|
|
|
/* Peer has changed i/f address without rebooting.
|
|
|
|
* If so, the link will reset soon, and the next
|
|
|
|
* discovery will be accepted. So we can ignore it.
|
|
|
|
* It may also be an cloned or malicious peer having
|
|
|
|
* chosen the same node address and signature as an
|
|
|
|
* existing one.
|
|
|
|
* Ignore requests until the link goes down, if ever.
|
|
|
|
*/
|
|
|
|
*dupl_addr = true;
|
|
|
|
} else if (sign_match && !addr_match && !link_up) {
|
|
|
|
/* Peer link has changed i/f address without rebooting.
|
|
|
|
* It may also be a cloned or malicious peer; we can't
|
|
|
|
* distinguish between the two.
|
|
|
|
* The signature is correct, so we must accept.
|
|
|
|
*/
|
|
|
|
accept_addr = true;
|
|
|
|
*respond = true;
|
|
|
|
} else if (!sign_match && addr_match && link_up) {
|
|
|
|
/* Peer node rebooted. Two possibilities:
|
|
|
|
* - Delayed re-discovery; this link endpoint has already
|
|
|
|
* reset and re-established contact with the peer, before
|
|
|
|
* receiving a discovery message from that node.
|
|
|
|
* (The peer happened to receive one from this node first).
|
|
|
|
* - The peer came back so fast that our side has not
|
|
|
|
* discovered it yet. Probing from this side will soon
|
|
|
|
* reset the link, since there can be no working link
|
|
|
|
* endpoint at the peer end, and the link will re-establish.
|
|
|
|
* Accept the signature, since it comes from a known peer.
|
|
|
|
*/
|
|
|
|
n->signature = signature;
|
|
|
|
} else if (!sign_match && addr_match && !link_up) {
|
|
|
|
/* The peer node has rebooted.
|
|
|
|
* Accept signature, since it is a known peer.
|
|
|
|
*/
|
|
|
|
n->signature = signature;
|
|
|
|
*respond = true;
|
|
|
|
} else if (!sign_match && !addr_match && link_up) {
|
|
|
|
/* Peer rebooted with new address, or a new/duplicate peer.
|
|
|
|
* Ignore until the link goes down, if ever.
|
|
|
|
*/
|
|
|
|
*dupl_addr = true;
|
|
|
|
} else if (!sign_match && !addr_match && !link_up) {
|
|
|
|
/* Peer rebooted with new address, or it is a new peer.
|
|
|
|
* Accept signature and address.
|
|
|
|
*/
|
|
|
|
n->signature = signature;
|
|
|
|
accept_addr = true;
|
|
|
|
*respond = true;
|
|
|
|
}
|
2015-07-16 22:54:20 +02:00
|
|
|
|
2015-07-31 00:24:22 +02:00
|
|
|
if (!accept_addr)
|
|
|
|
goto exit;
|
2015-07-16 22:54:20 +02:00
|
|
|
|
2015-07-31 00:24:22 +02:00
|
|
|
/* Now create new link if not already existing */
|
2015-07-16 22:54:29 +02:00
|
|
|
if (!l) {
|
2015-07-31 00:24:26 +02:00
|
|
|
if (n->link_cnt == 2) {
|
|
|
|
pr_warn("Cannot establish 3rd link to %x\n", n->addr);
|
|
|
|
goto exit;
|
|
|
|
}
|
2015-10-22 14:51:36 +02:00
|
|
|
if_name = strchr(b->name, ':') + 1;
|
2015-10-22 14:51:46 +02:00
|
|
|
if (!tipc_link_create(net, if_name, b->identity, b->tolerance,
|
2015-10-22 14:51:36 +02:00
|
|
|
b->net_plane, b->mtu, b->priority,
|
|
|
|
b->window, mod(tipc_net(net)->random),
|
2015-10-22 14:51:40 +02:00
|
|
|
tipc_own_addr(net), onode,
|
2015-10-22 14:51:48 +02:00
|
|
|
n->capabilities,
|
2015-10-22 14:51:41 +02:00
|
|
|
tipc_bc_sndlink(n->net), n->bc_entry.link,
|
|
|
|
&le->inputq,
|
|
|
|
&n->bc_entry.namedq, &l)) {
|
2015-07-31 00:24:22 +02:00
|
|
|
*respond = false;
|
|
|
|
goto exit;
|
|
|
|
}
|
2015-07-31 00:24:26 +02:00
|
|
|
tipc_link_reset(l);
|
2015-10-15 20:52:46 +02:00
|
|
|
tipc_link_fsm_evt(l, LINK_RESET_EVT);
|
tipc: eliminate risk of premature link setup during failover
When a link goes down, and there is still a working link towards its
destination node, a failover is initiated, and the failed link is not
allowed to re-establish until that procedure is finished. To ensure
this, the concerned link endpoints are set to state LINK_FAILINGOVER,
and the node endpoints to NODE_FAILINGOVER during the failover period.
However, if the link reset is due to a disabled bearer, the corres-
ponding link endpoint is deleted, and only the node endpoint knows
about the ongoing failover. Now, if the disabled bearer is re-enabled
during the failover period, the discovery mechanism may create a new
link endpoint that is ready to be established, despite that this is not
permitted. This situation may cause both the ongoing failover and any
subsequent link synchronization to fail.
In this commit, we ensure that a newly created link goes directly to
state LINK_FAILINGOVER if the corresponding node state is
NODE_FAILINGOVER. This eliminates the problem described above.
Furthermore, we tighten the criteria for which packets are allowed
to end a failover state in the function tipc_node_check_state().
By checking that the receiving link is up and running, instead of just
checking that it is not in failover mode, we eliminate the risk that
protocol packets from the re-created link may cause the failover to
be prematurely terminated.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-08-20 08:12:54 +02:00
|
|
|
if (n->state == NODE_FAILINGOVER)
|
|
|
|
tipc_link_fsm_evt(l, LINK_FAILOVER_BEGIN_EVT);
|
2015-07-31 00:24:26 +02:00
|
|
|
le->link = l;
|
|
|
|
n->link_cnt++;
|
2015-07-16 22:54:29 +02:00
|
|
|
tipc_node_calculate_timer(n, l);
|
2016-06-08 18:00:05 +02:00
|
|
|
if (n->link_cnt == 1) {
|
|
|
|
intv = jiffies + msecs_to_jiffies(n->keepalive_intv);
|
|
|
|
if (!mod_timer(&n->timer, intv))
|
2015-07-16 22:54:29 +02:00
|
|
|
tipc_node_get(n);
|
2016-06-08 18:00:05 +02:00
|
|
|
}
|
2015-07-16 22:54:29 +02:00
|
|
|
}
|
2015-07-31 00:24:26 +02:00
|
|
|
memcpy(&le->maddr, maddr, sizeof(*maddr));
|
2015-07-31 00:24:22 +02:00
|
|
|
exit:
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_write_unlock(n);
|
2016-03-03 14:20:41 +01:00
|
|
|
if (reset && l && !tipc_link_is_reset(l))
|
2015-07-31 00:24:23 +02:00
|
|
|
tipc_node_link_down(n, b->identity, false);
|
2015-07-31 00:24:22 +02:00
|
|
|
tipc_node_put(n);
|
2015-07-16 22:54:20 +02:00
|
|
|
}
|
|
|
|
|
2015-07-31 00:24:16 +02:00
|
|
|
void tipc_node_delete_links(struct net *net, int bearer_id)
|
|
|
|
{
|
|
|
|
struct tipc_net *tn = net_generic(net, tipc_net_id);
|
|
|
|
struct tipc_node *n;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
list_for_each_entry_rcu(n, &tn->node_list, list) {
|
2015-07-31 00:24:23 +02:00
|
|
|
tipc_node_link_down(n, bearer_id, true);
|
2015-07-31 00:24:16 +02:00
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tipc_node_reset_links(struct tipc_node *n)
|
|
|
|
{
|
|
|
|
char addr_string[16];
|
2015-07-31 00:24:23 +02:00
|
|
|
int i;
|
2015-07-31 00:24:16 +02:00
|
|
|
|
|
|
|
pr_warn("Resetting all links to %s\n",
|
|
|
|
tipc_addr_string_fill(addr_string, n->addr));
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_BEARERS; i++) {
|
2015-07-31 00:24:23 +02:00
|
|
|
tipc_node_link_down(n, i, false);
|
2015-07-31 00:24:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-16 22:54:30 +02:00
|
|
|
/* tipc_node_fsm_evt - node finite state machine
|
|
|
|
* Determines when contact is allowed with peer node
|
|
|
|
*/
|
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle
we have been using for message sending and timeout handling:
We move the function tipc_rcv() to node.c, hence handling the initial
packet reception at the link aggregation level. The function grabs
the node lock, selects the receiving link, and accesses it via a new
call tipc_link_rcv(). This function appends buffers to the input
queue for delivery upwards, but it may also append outgoing packets
to the xmit queue, just as we do during regular message sending. The
latter will happen when buffers are forwarded from the link backlog,
or when retransmission is requested.
Upon return of this function, and after having released the node lock,
tipc_rcv() delivers/tranmsits the contents of those queues, but it may
also perform actions such as link activation or reset, as indicated by
the return flags from the link.
This reduces the number of cpu cycles spent inside the node spinlock,
and reduces contention on that lock.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-16 22:54:31 +02:00
|
|
|
static void tipc_node_fsm_evt(struct tipc_node *n, int evt)
|
2015-07-16 22:54:30 +02:00
|
|
|
{
|
|
|
|
int state = n->state;
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
case SELF_DOWN_PEER_DOWN:
|
|
|
|
switch (evt) {
|
|
|
|
case SELF_ESTABL_CONTACT_EVT:
|
|
|
|
state = SELF_UP_PEER_COMING;
|
|
|
|
break;
|
|
|
|
case PEER_ESTABL_CONTACT_EVT:
|
|
|
|
state = SELF_COMING_PEER_UP;
|
|
|
|
break;
|
|
|
|
case SELF_LOST_CONTACT_EVT:
|
|
|
|
case PEER_LOST_CONTACT_EVT:
|
|
|
|
break;
|
2015-07-31 00:24:18 +02:00
|
|
|
case NODE_SYNCH_END_EVT:
|
|
|
|
case NODE_SYNCH_BEGIN_EVT:
|
|
|
|
case NODE_FAILOVER_BEGIN_EVT:
|
|
|
|
case NODE_FAILOVER_END_EVT:
|
2015-07-16 22:54:30 +02:00
|
|
|
default:
|
2015-07-31 00:24:18 +02:00
|
|
|
goto illegal_evt;
|
2015-07-16 22:54:30 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SELF_UP_PEER_UP:
|
|
|
|
switch (evt) {
|
|
|
|
case SELF_LOST_CONTACT_EVT:
|
|
|
|
state = SELF_DOWN_PEER_LEAVING;
|
|
|
|
break;
|
|
|
|
case PEER_LOST_CONTACT_EVT:
|
|
|
|
state = SELF_LEAVING_PEER_DOWN;
|
|
|
|
break;
|
2015-07-31 00:24:18 +02:00
|
|
|
case NODE_SYNCH_BEGIN_EVT:
|
|
|
|
state = NODE_SYNCHING;
|
|
|
|
break;
|
|
|
|
case NODE_FAILOVER_BEGIN_EVT:
|
|
|
|
state = NODE_FAILINGOVER;
|
|
|
|
break;
|
2015-07-16 22:54:30 +02:00
|
|
|
case SELF_ESTABL_CONTACT_EVT:
|
|
|
|
case PEER_ESTABL_CONTACT_EVT:
|
2015-07-31 00:24:18 +02:00
|
|
|
case NODE_SYNCH_END_EVT:
|
|
|
|
case NODE_FAILOVER_END_EVT:
|
2015-07-16 22:54:30 +02:00
|
|
|
break;
|
|
|
|
default:
|
2015-07-31 00:24:18 +02:00
|
|
|
goto illegal_evt;
|
2015-07-16 22:54:30 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SELF_DOWN_PEER_LEAVING:
|
|
|
|
switch (evt) {
|
|
|
|
case PEER_LOST_CONTACT_EVT:
|
|
|
|
state = SELF_DOWN_PEER_DOWN;
|
|
|
|
break;
|
|
|
|
case SELF_ESTABL_CONTACT_EVT:
|
|
|
|
case PEER_ESTABL_CONTACT_EVT:
|
|
|
|
case SELF_LOST_CONTACT_EVT:
|
|
|
|
break;
|
2015-07-31 00:24:18 +02:00
|
|
|
case NODE_SYNCH_END_EVT:
|
|
|
|
case NODE_SYNCH_BEGIN_EVT:
|
|
|
|
case NODE_FAILOVER_BEGIN_EVT:
|
|
|
|
case NODE_FAILOVER_END_EVT:
|
2015-07-16 22:54:30 +02:00
|
|
|
default:
|
2015-07-31 00:24:18 +02:00
|
|
|
goto illegal_evt;
|
2015-07-16 22:54:30 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SELF_UP_PEER_COMING:
|
|
|
|
switch (evt) {
|
|
|
|
case PEER_ESTABL_CONTACT_EVT:
|
|
|
|
state = SELF_UP_PEER_UP;
|
|
|
|
break;
|
|
|
|
case SELF_LOST_CONTACT_EVT:
|
tipc: correct error in node fsm
commit 88e8ac7000dc ("tipc: reduce transmission rate of reset messages
when link is down") revealed a flaw in the node FSM, as defined in
the log of commit 66996b6c47ed ("tipc: extend node FSM").
We see the following scenario:
1: Node B receives a RESET message from node A before its link endpoint
is fully up, i.e., the node FSM is in state SELF_UP_PEER_COMING. This
event will not change the node FSM state, but the (distinct) link FSM
will move to state RESETTING.
2: As an effect of the previous event, the local endpoint on B will
declare node A lost, and post the event SELF_DOWN to the its node
FSM. This moves the FSM state to SELF_DOWN_PEER_LEAVING, meaning
that no messages will be accepted from A until it receives another
RESET message that confirms that A's endpoint has been reset. This
is wasteful, since we know this as a fact already from the first
received RESET, but worse is that the link instance's FSM has not
wasted this information, but instead moved on to state ESTABLISHING,
meaning that it repeatedly sends out ACTIVATE messages to the reset
peer A.
3: Node A will receive one of the ACTIVATE messages, move its link FSM
to state ESTABLISHED, and start repeatedly sending out STATE messages
to node B.
4: Node B will consistently drop these messages, since it can only accept
accept a RESET according to its node FSM.
5: After four lost STATE messages node A will reset its link and start
repeatedly sending out RESET messages to B.
6: Because of the reduced send rate for RESET messages, it is very
likely that A will receive an ACTIVATE (which is sent out at a much
higher frequency) before it gets the chance to send a RESET, and A
may hence quickly move back to state ESTABLISHED and continue sending
out STATE messages, which will again be dropped by B.
7: GOTO 5.
8: After having repeated the cycle 5-7 a number of times, node A will
by chance get in between with sending a RESET, and the situation is
resolved.
Unfortunately, we have seen that it may take a substantial amount of
time before this vicious loop is broken, sometimes in the order of
minutes.
We correct this by making a small correction to the node FSM: When a
node in state SELF_UP_PEER_COMING receives a SELF_DOWN event, it now
moves directly back to state SELF_DOWN_PEER_DOWN, instead of as now
SELF_DOWN_PEER_LEAVING. This is logically consistent, since we don't
need to wait for RESET confirmation from of an endpoint that we alread
know has been reset. It also means that node B in the scenario above
will not be dropping incoming STATE messages, and the link can come up
immediately.
Finally, a symmetry comparison reveals that the FSM has a similar
error when receiving the event PEER_DOWN in state PEER_UP_SELF_COMING.
Instead of moving to PERR_DOWN_SELF_LEAVING, it should move directly
to SELF_DOWN_PEER_DOWN. Although we have never seen any negative effect
of this logical error, we choose fix this one, too.
The node FSM looks as follows after those changes:
+----------------------------------------+
| PEER_DOWN_EVT|
| |
+------------------------+----------------+ |
|SELF_DOWN_EVT | | |
| | | |
| +-----------+ +-----------+ |
| |NODE_ | |NODE_ | |
| +----------|FAILINGOVER|<---------|SYNCHING |-----------+ |
| |SELF_ +-----------+ FAILOVER_+-----------+ PEER_ | |
| |DOWN_EVT | A BEGIN_EVT A | DOWN_EVT| |
| | | | | | | |
| | | | | | | |
| | |FAILOVER_ |FAILOVER_ |SYNCH_ |SYNCH_ | |
| | |END_EVT |BEGIN_EVT |BEGIN_EVT|END_EVT | |
| | | | | | | |
| | | | | | | |
| | | +--------------+ | | |
| | +-------->| SELF_UP_ |<-------+ | |
| | +-----------------| PEER_UP |----------------+ | |
| | |SELF_DOWN_EVT +--------------+ PEER_DOWN_EVT| | |
| | | A A | | |
| | | | | | | |
| | | PEER_UP_EVT| |SELF_UP_EVT | | |
| | | | | | | |
V V V | | V V V
+------------+ +-----------+ +-----------+ +------------+
|SELF_DOWN_ | |SELF_UP_ | |PEER_UP_ | |PEER_DOWN |
|PEER_LEAVING| |PEER_COMING| |SELF_COMING| |SELF_LEAVING|
+------------+ +-----------+ +-----------+ +------------+
| | A A | |
| | | | | |
| SELF_ | |SELF_ |PEER_ |PEER_ |
| DOWN_EVT| |UP_EVT |UP_EVT |DOWN_EVT |
| | | | | |
| | | | | |
| | +--------------+ | |
|PEER_DOWN_EVT +--->| SELF_DOWN_ |<---+ SELF_DOWN_EVT|
+------------------->| PEER_DOWN |<--------------------+
+--------------+
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-08 18:00:04 +02:00
|
|
|
state = SELF_DOWN_PEER_DOWN;
|
2015-07-16 22:54:30 +02:00
|
|
|
break;
|
|
|
|
case SELF_ESTABL_CONTACT_EVT:
|
|
|
|
case PEER_LOST_CONTACT_EVT:
|
2015-07-31 00:24:18 +02:00
|
|
|
case NODE_SYNCH_END_EVT:
|
|
|
|
case NODE_FAILOVER_BEGIN_EVT:
|
tipc: delay ESTABLISH state event when link is established
Link establishing, just like link teardown, is a non-atomic action, in
the sense that discovering that conditions are right to establish a link,
and the actual adding of the link to one of the node's send slots is done
in two different lock contexts. The link FSM is designed to help bridging
the gap between the two contexts in a safe manner.
We have now discovered a weakness in the implementaton of this FSM.
Because we directly let the link go from state LINK_ESTABLISHING to
state LINK_ESTABLISHED already in the first lock context, we are unable
to distinguish between a fully established link, i.e., a link that has
been added to its slot, and a link that has not yet reached the second
lock context. It may hence happen that a manual intervention, e.g., when
disabling an interface, causes the function tipc_node_link_down() to try
removing the link from the node slots, decrementing its active link
counter etc, although the link was never added there in the first place.
We solve this by delaying the actual state change until we reach the
second lock context, inside the function tipc_node_link_up(). This
makes it possible for potentail callers of __tipc_node_link_down() to
know if they should proceed or not, and the problem is solved.
Unforunately, the situation described above also has a second problem.
Since there by necessity is a tipc_node_link_up() call pending once
the node lock has been released, we must defuse that call by setting
the link back from LINK_ESTABLISHING to LINK_RESET state. This forces
us to make a slight modification to the link FSM, which will now look
as follows.
+------------------------------------+
|RESET_EVT |
| |
| +--------------+
| +-----------------| SYNCHING |-----------------+
| |FAILURE_EVT +--------------+ PEER_RESET_EVT|
| | A | |
| | | | |
| | | | |
| | |SYNCH_ |SYNCH_ |
| | |BEGIN_EVT |END_EVT |
| | | | |
| V | V V
| +-------------+ +--------------+ +------------+
| | RESETTING |<---------| ESTABLISHED |--------->| PEER_RESET |
| +-------------+ FAILURE_ +--------------+ PEER_ +------------+
| | EVT | A RESET_EVT |
| | | | |
| | +----------------+ | |
| RESET_EVT| |RESET_EVT | |
| | | | |
| | | |ESTABLISH_EVT |
| | | +-------------+ | |
| | | | RESET_EVT | | |
| | | | | | |
| V V V | | |
| +-------------+ +--------------+ RESET_EVT|
+--->| RESET |--------->| ESTABLISHING |<----------------+
+-------------+ PEER_ +--------------+
| A RESET_EVT |
| | |
| | |
|FAILOVER_ |FAILOVER_ |FAILOVER_
|BEGIN_EVT |END_EVT |BEGIN_EVT
| | |
V | |
+-------------+ |
| FAILINGOVER |<----------------+
+-------------+
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-15 20:52:44 +02:00
|
|
|
break;
|
|
|
|
case NODE_SYNCH_BEGIN_EVT:
|
2015-07-31 00:24:18 +02:00
|
|
|
case NODE_FAILOVER_END_EVT:
|
2015-07-16 22:54:30 +02:00
|
|
|
default:
|
2015-07-31 00:24:18 +02:00
|
|
|
goto illegal_evt;
|
2015-07-16 22:54:30 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SELF_COMING_PEER_UP:
|
|
|
|
switch (evt) {
|
|
|
|
case SELF_ESTABL_CONTACT_EVT:
|
|
|
|
state = SELF_UP_PEER_UP;
|
|
|
|
break;
|
|
|
|
case PEER_LOST_CONTACT_EVT:
|
tipc: correct error in node fsm
commit 88e8ac7000dc ("tipc: reduce transmission rate of reset messages
when link is down") revealed a flaw in the node FSM, as defined in
the log of commit 66996b6c47ed ("tipc: extend node FSM").
We see the following scenario:
1: Node B receives a RESET message from node A before its link endpoint
is fully up, i.e., the node FSM is in state SELF_UP_PEER_COMING. This
event will not change the node FSM state, but the (distinct) link FSM
will move to state RESETTING.
2: As an effect of the previous event, the local endpoint on B will
declare node A lost, and post the event SELF_DOWN to the its node
FSM. This moves the FSM state to SELF_DOWN_PEER_LEAVING, meaning
that no messages will be accepted from A until it receives another
RESET message that confirms that A's endpoint has been reset. This
is wasteful, since we know this as a fact already from the first
received RESET, but worse is that the link instance's FSM has not
wasted this information, but instead moved on to state ESTABLISHING,
meaning that it repeatedly sends out ACTIVATE messages to the reset
peer A.
3: Node A will receive one of the ACTIVATE messages, move its link FSM
to state ESTABLISHED, and start repeatedly sending out STATE messages
to node B.
4: Node B will consistently drop these messages, since it can only accept
accept a RESET according to its node FSM.
5: After four lost STATE messages node A will reset its link and start
repeatedly sending out RESET messages to B.
6: Because of the reduced send rate for RESET messages, it is very
likely that A will receive an ACTIVATE (which is sent out at a much
higher frequency) before it gets the chance to send a RESET, and A
may hence quickly move back to state ESTABLISHED and continue sending
out STATE messages, which will again be dropped by B.
7: GOTO 5.
8: After having repeated the cycle 5-7 a number of times, node A will
by chance get in between with sending a RESET, and the situation is
resolved.
Unfortunately, we have seen that it may take a substantial amount of
time before this vicious loop is broken, sometimes in the order of
minutes.
We correct this by making a small correction to the node FSM: When a
node in state SELF_UP_PEER_COMING receives a SELF_DOWN event, it now
moves directly back to state SELF_DOWN_PEER_DOWN, instead of as now
SELF_DOWN_PEER_LEAVING. This is logically consistent, since we don't
need to wait for RESET confirmation from of an endpoint that we alread
know has been reset. It also means that node B in the scenario above
will not be dropping incoming STATE messages, and the link can come up
immediately.
Finally, a symmetry comparison reveals that the FSM has a similar
error when receiving the event PEER_DOWN in state PEER_UP_SELF_COMING.
Instead of moving to PERR_DOWN_SELF_LEAVING, it should move directly
to SELF_DOWN_PEER_DOWN. Although we have never seen any negative effect
of this logical error, we choose fix this one, too.
The node FSM looks as follows after those changes:
+----------------------------------------+
| PEER_DOWN_EVT|
| |
+------------------------+----------------+ |
|SELF_DOWN_EVT | | |
| | | |
| +-----------+ +-----------+ |
| |NODE_ | |NODE_ | |
| +----------|FAILINGOVER|<---------|SYNCHING |-----------+ |
| |SELF_ +-----------+ FAILOVER_+-----------+ PEER_ | |
| |DOWN_EVT | A BEGIN_EVT A | DOWN_EVT| |
| | | | | | | |
| | | | | | | |
| | |FAILOVER_ |FAILOVER_ |SYNCH_ |SYNCH_ | |
| | |END_EVT |BEGIN_EVT |BEGIN_EVT|END_EVT | |
| | | | | | | |
| | | | | | | |
| | | +--------------+ | | |
| | +-------->| SELF_UP_ |<-------+ | |
| | +-----------------| PEER_UP |----------------+ | |
| | |SELF_DOWN_EVT +--------------+ PEER_DOWN_EVT| | |
| | | A A | | |
| | | | | | | |
| | | PEER_UP_EVT| |SELF_UP_EVT | | |
| | | | | | | |
V V V | | V V V
+------------+ +-----------+ +-----------+ +------------+
|SELF_DOWN_ | |SELF_UP_ | |PEER_UP_ | |PEER_DOWN |
|PEER_LEAVING| |PEER_COMING| |SELF_COMING| |SELF_LEAVING|
+------------+ +-----------+ +-----------+ +------------+
| | A A | |
| | | | | |
| SELF_ | |SELF_ |PEER_ |PEER_ |
| DOWN_EVT| |UP_EVT |UP_EVT |DOWN_EVT |
| | | | | |
| | | | | |
| | +--------------+ | |
|PEER_DOWN_EVT +--->| SELF_DOWN_ |<---+ SELF_DOWN_EVT|
+------------------->| PEER_DOWN |<--------------------+
+--------------+
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-06-08 18:00:04 +02:00
|
|
|
state = SELF_DOWN_PEER_DOWN;
|
2015-07-16 22:54:30 +02:00
|
|
|
break;
|
|
|
|
case SELF_LOST_CONTACT_EVT:
|
|
|
|
case PEER_ESTABL_CONTACT_EVT:
|
|
|
|
break;
|
2015-07-31 00:24:18 +02:00
|
|
|
case NODE_SYNCH_END_EVT:
|
|
|
|
case NODE_SYNCH_BEGIN_EVT:
|
|
|
|
case NODE_FAILOVER_BEGIN_EVT:
|
|
|
|
case NODE_FAILOVER_END_EVT:
|
2015-07-16 22:54:30 +02:00
|
|
|
default:
|
2015-07-31 00:24:18 +02:00
|
|
|
goto illegal_evt;
|
2015-07-16 22:54:30 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SELF_LEAVING_PEER_DOWN:
|
|
|
|
switch (evt) {
|
|
|
|
case SELF_LOST_CONTACT_EVT:
|
|
|
|
state = SELF_DOWN_PEER_DOWN;
|
|
|
|
break;
|
|
|
|
case SELF_ESTABL_CONTACT_EVT:
|
|
|
|
case PEER_ESTABL_CONTACT_EVT:
|
|
|
|
case PEER_LOST_CONTACT_EVT:
|
|
|
|
break;
|
2015-07-31 00:24:18 +02:00
|
|
|
case NODE_SYNCH_END_EVT:
|
|
|
|
case NODE_SYNCH_BEGIN_EVT:
|
|
|
|
case NODE_FAILOVER_BEGIN_EVT:
|
|
|
|
case NODE_FAILOVER_END_EVT:
|
|
|
|
default:
|
|
|
|
goto illegal_evt;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NODE_FAILINGOVER:
|
|
|
|
switch (evt) {
|
|
|
|
case SELF_LOST_CONTACT_EVT:
|
|
|
|
state = SELF_DOWN_PEER_LEAVING;
|
|
|
|
break;
|
|
|
|
case PEER_LOST_CONTACT_EVT:
|
|
|
|
state = SELF_LEAVING_PEER_DOWN;
|
|
|
|
break;
|
|
|
|
case NODE_FAILOVER_END_EVT:
|
|
|
|
state = SELF_UP_PEER_UP;
|
|
|
|
break;
|
|
|
|
case NODE_FAILOVER_BEGIN_EVT:
|
|
|
|
case SELF_ESTABL_CONTACT_EVT:
|
|
|
|
case PEER_ESTABL_CONTACT_EVT:
|
|
|
|
break;
|
|
|
|
case NODE_SYNCH_BEGIN_EVT:
|
|
|
|
case NODE_SYNCH_END_EVT:
|
2015-07-16 22:54:30 +02:00
|
|
|
default:
|
2015-07-31 00:24:18 +02:00
|
|
|
goto illegal_evt;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NODE_SYNCHING:
|
|
|
|
switch (evt) {
|
|
|
|
case SELF_LOST_CONTACT_EVT:
|
|
|
|
state = SELF_DOWN_PEER_LEAVING;
|
|
|
|
break;
|
|
|
|
case PEER_LOST_CONTACT_EVT:
|
|
|
|
state = SELF_LEAVING_PEER_DOWN;
|
|
|
|
break;
|
|
|
|
case NODE_SYNCH_END_EVT:
|
|
|
|
state = SELF_UP_PEER_UP;
|
|
|
|
break;
|
|
|
|
case NODE_FAILOVER_BEGIN_EVT:
|
|
|
|
state = NODE_FAILINGOVER;
|
|
|
|
break;
|
|
|
|
case NODE_SYNCH_BEGIN_EVT:
|
|
|
|
case SELF_ESTABL_CONTACT_EVT:
|
|
|
|
case PEER_ESTABL_CONTACT_EVT:
|
|
|
|
break;
|
|
|
|
case NODE_FAILOVER_END_EVT:
|
|
|
|
default:
|
|
|
|
goto illegal_evt;
|
2015-07-16 22:54:30 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pr_err("Unknown node fsm state %x\n", state);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
n->state = state;
|
2015-07-31 00:24:18 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
illegal_evt:
|
|
|
|
pr_err("Illegal node fsm evt %x in state %x\n", evt, state);
|
2015-07-16 22:54:30 +02:00
|
|
|
}
|
|
|
|
|
2015-10-22 14:51:41 +02:00
|
|
|
static void node_lost_contact(struct tipc_node *n,
|
2015-07-31 00:24:23 +02:00
|
|
|
struct sk_buff_head *inputq)
|
2006-01-02 19:04:38 +01:00
|
|
|
{
|
|
|
|
char addr_string[16];
|
2015-02-05 14:36:42 +01:00
|
|
|
struct tipc_sock_conn *conn, *safe;
|
2015-07-31 00:24:23 +02:00
|
|
|
struct tipc_link *l;
|
2015-10-22 14:51:41 +02:00
|
|
|
struct list_head *conns = &n->conn_sks;
|
2015-02-05 14:36:42 +01:00
|
|
|
struct sk_buff *skb;
|
|
|
|
uint i;
|
2006-01-02 19:04:38 +01:00
|
|
|
|
2015-01-22 17:10:31 +01:00
|
|
|
pr_debug("Lost contact with %s\n",
|
2015-10-22 14:51:41 +02:00
|
|
|
tipc_addr_string_fill(addr_string, n->addr));
|
2011-04-07 17:58:08 +02:00
|
|
|
|
2015-10-22 14:51:41 +02:00
|
|
|
/* Clean up broadcast state */
|
tipc: simplify bearer level broadcast
Until now, we have been keeping track of the exact set of broadcast
destinations though the help structure tipc_node_map. This leads us to
have to maintain a whole infrastructure for supporting this, including
a pseudo-bearer and a number of functions to manipulate both the bearers
and the node map correctly. Apart from the complexity, this approach is
also limiting, as struct tipc_node_map only can support cluster local
broadcast if we want to avoid it becoming excessively large. We want to
eliminate this limitation, in order to enable introduction of scoped
multicast in the future.
A closer analysis reveals that it is unnecessary maintaining this "full
set" overview; it is sufficient to keep a counter per bearer, indicating
how many nodes can be reached via this bearer at the moment. The protocol
is now robust enough to handle transitional discrepancies between the
nominal number of reachable destinations, as expected by the broadcast
protocol itself, and the number which is actually reachable at the
moment. The initial broadcast synchronization, in conjunction with the
retransmission mechanism, ensures that all packets will eventually be
acknowledged by the correct set of destinations.
This commit introduces these changes.
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-22 14:51:42 +02:00
|
|
|
tipc_bcast_remove_peer(n->net, n->bc_entry.link);
|
2006-01-02 19:04:38 +01:00
|
|
|
|
tipc: eliminate delayed link deletion at link failover
When a bearer is disabled manually, all its links have to be reset
and deleted. However, if there is a remaining, parallel link ready
to take over a deleted link's traffic, we currently delay the delete
of the removed link until the failover procedure is finished. This
is because the remaining link needs to access state from the reset
link, such as the last received packet number, and any partially
reassembled buffer, in order to perform a successful failover.
In this commit, we do instead move the state data over to the new
link, so that it can fulfill the procedure autonomously, without
accessing any data on the old link. This means that we can now
proceed and delete all pertaining links immediately when a bearer
is disabled. This saves us from some unnecessary complexity in such
situations.
We also choose to change the confusing definitions CHANGEOVER_PROTOCOL,
ORIGINAL_MSG and DUPLICATE_MSG to the more descriptive TUNNEL_PROTOCOL,
FAILOVER_MSG and SYNCH_MSG respectively.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-04-02 15:33:01 +02:00
|
|
|
/* Abort any ongoing link failover */
|
2006-01-02 19:04:38 +01:00
|
|
|
for (i = 0; i < MAX_BEARERS; i++) {
|
2015-10-22 14:51:41 +02:00
|
|
|
l = n->links[i].link;
|
2015-07-31 00:24:23 +02:00
|
|
|
if (l)
|
|
|
|
tipc_link_fsm_evt(l, LINK_FAILOVER_END_EVT);
|
2006-01-02 19:04:38 +01:00
|
|
|
}
|
2015-07-31 00:24:23 +02:00
|
|
|
|
2015-02-05 14:36:42 +01:00
|
|
|
/* Notify publications from this node */
|
2015-10-22 14:51:41 +02:00
|
|
|
n->action_flags |= TIPC_NOTIFY_NODE_DOWN;
|
2015-02-05 14:36:42 +01:00
|
|
|
|
|
|
|
/* Notify sockets connected to node */
|
|
|
|
list_for_each_entry_safe(conn, safe, conns, list) {
|
|
|
|
skb = tipc_msg_create(TIPC_CRITICAL_IMPORTANCE, TIPC_CONN_MSG,
|
2015-10-22 14:51:41 +02:00
|
|
|
SHORT_H_SIZE, 0, tipc_own_addr(n->net),
|
2015-02-05 14:36:42 +01:00
|
|
|
conn->peer_node, conn->port,
|
|
|
|
conn->peer_port, TIPC_ERR_NO_NODE);
|
2015-07-31 00:24:24 +02:00
|
|
|
if (likely(skb))
|
2015-07-31 00:24:23 +02:00
|
|
|
skb_queue_tail(inputq, skb);
|
2015-02-05 14:36:42 +01:00
|
|
|
list_del(&conn->list);
|
|
|
|
kfree(conn);
|
|
|
|
}
|
2006-01-02 19:04:38 +01:00
|
|
|
}
|
|
|
|
|
2014-04-24 16:26:47 +02:00
|
|
|
/**
|
|
|
|
* tipc_node_get_linkname - get the name of a link
|
|
|
|
*
|
|
|
|
* @bearer_id: id of the bearer
|
|
|
|
* @node: peer node address
|
|
|
|
* @linkname: link name output buffer
|
|
|
|
*
|
|
|
|
* Returns 0 on success
|
|
|
|
*/
|
2015-01-09 08:27:05 +01:00
|
|
|
int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 addr,
|
|
|
|
char *linkname, size_t len)
|
2014-04-24 16:26:47 +02:00
|
|
|
{
|
|
|
|
struct tipc_link *link;
|
2015-03-26 11:10:24 +01:00
|
|
|
int err = -EINVAL;
|
2015-01-09 08:27:05 +01:00
|
|
|
struct tipc_node *node = tipc_node_find(net, addr);
|
2014-04-24 16:26:47 +02:00
|
|
|
|
2015-03-26 11:10:24 +01:00
|
|
|
if (!node)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (bearer_id >= MAX_BEARERS)
|
|
|
|
goto exit;
|
|
|
|
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_read_lock(node);
|
2015-07-16 22:54:19 +02:00
|
|
|
link = node->links[bearer_id].link;
|
2014-04-24 16:26:47 +02:00
|
|
|
if (link) {
|
2015-11-19 20:30:46 +01:00
|
|
|
strncpy(linkname, tipc_link_name(link), len);
|
2015-03-26 11:10:24 +01:00
|
|
|
err = 0;
|
2014-04-24 16:26:47 +02:00
|
|
|
}
|
2015-03-26 11:10:24 +01:00
|
|
|
exit:
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_read_unlock(node);
|
2015-03-26 11:10:24 +01:00
|
|
|
tipc_node_put(node);
|
|
|
|
return err;
|
2014-04-24 16:26:47 +02:00
|
|
|
}
|
2014-05-05 02:56:12 +02:00
|
|
|
|
2014-11-20 10:29:17 +01:00
|
|
|
/* Caller should hold node lock for the passed node */
|
2014-11-24 11:10:29 +01:00
|
|
|
static int __tipc_nl_add_node(struct tipc_nl_msg *msg, struct tipc_node *node)
|
2014-11-20 10:29:17 +01:00
|
|
|
{
|
|
|
|
void *hdr;
|
|
|
|
struct nlattr *attrs;
|
|
|
|
|
2015-02-09 09:50:03 +01:00
|
|
|
hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
|
2014-11-20 10:29:17 +01:00
|
|
|
NLM_F_MULTI, TIPC_NL_NODE_GET);
|
|
|
|
if (!hdr)
|
|
|
|
return -EMSGSIZE;
|
|
|
|
|
|
|
|
attrs = nla_nest_start(msg->skb, TIPC_NLA_NODE);
|
|
|
|
if (!attrs)
|
|
|
|
goto msg_full;
|
|
|
|
|
|
|
|
if (nla_put_u32(msg->skb, TIPC_NLA_NODE_ADDR, node->addr))
|
|
|
|
goto attr_msg_full;
|
|
|
|
if (tipc_node_is_up(node))
|
|
|
|
if (nla_put_flag(msg->skb, TIPC_NLA_NODE_UP))
|
|
|
|
goto attr_msg_full;
|
|
|
|
|
|
|
|
nla_nest_end(msg->skb, attrs);
|
|
|
|
genlmsg_end(msg->skb, hdr);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
attr_msg_full:
|
|
|
|
nla_nest_cancel(msg->skb, attrs);
|
|
|
|
msg_full:
|
|
|
|
genlmsg_cancel(msg->skb, hdr);
|
|
|
|
|
|
|
|
return -EMSGSIZE;
|
|
|
|
}
|
|
|
|
|
2015-07-16 22:54:24 +02:00
|
|
|
/**
|
|
|
|
* tipc_node_xmit() is the general link level function for message sending
|
|
|
|
* @net: the applicable net namespace
|
|
|
|
* @list: chain of buffers containing message
|
|
|
|
* @dnode: address of destination node
|
|
|
|
* @selector: a number used for deterministic link selection
|
|
|
|
* Consumes the buffer chain, except when returning -ELINKCONG
|
2016-02-11 10:43:15 +01:00
|
|
|
* Returns 0 if success, otherwise: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE,-ENOBUF
|
2015-07-16 22:54:24 +02:00
|
|
|
*/
|
|
|
|
int tipc_node_xmit(struct net *net, struct sk_buff_head *list,
|
|
|
|
u32 dnode, int selector)
|
|
|
|
{
|
2015-11-19 20:30:44 +01:00
|
|
|
struct tipc_link_entry *le = NULL;
|
2015-07-16 22:54:24 +02:00
|
|
|
struct tipc_node *n;
|
|
|
|
struct sk_buff_head xmitq;
|
2016-02-11 10:43:15 +01:00
|
|
|
int bearer_id;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (in_own_node(net, dnode)) {
|
|
|
|
tipc_sk_rcv(net, list);
|
|
|
|
return 0;
|
|
|
|
}
|
2015-07-16 22:54:24 +02:00
|
|
|
|
|
|
|
n = tipc_node_find(net, dnode);
|
2016-02-11 10:43:15 +01:00
|
|
|
if (unlikely(!n)) {
|
|
|
|
skb_queue_purge(list);
|
|
|
|
return -EHOSTUNREACH;
|
|
|
|
}
|
|
|
|
|
|
|
|
tipc_node_read_lock(n);
|
|
|
|
bearer_id = n->active_links[selector & 1];
|
|
|
|
if (unlikely(bearer_id == INVALID_BEARER_ID)) {
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_read_unlock(n);
|
2015-07-16 22:54:24 +02:00
|
|
|
tipc_node_put(n);
|
2016-02-11 10:43:15 +01:00
|
|
|
skb_queue_purge(list);
|
|
|
|
return -EHOSTUNREACH;
|
2015-07-16 22:54:24 +02:00
|
|
|
}
|
2015-11-19 20:30:44 +01:00
|
|
|
|
2016-02-11 10:43:15 +01:00
|
|
|
__skb_queue_head_init(&xmitq);
|
|
|
|
le = &n->links[bearer_id];
|
|
|
|
spin_lock_bh(&le->lock);
|
|
|
|
rc = tipc_link_xmit(le->link, list, &xmitq);
|
|
|
|
spin_unlock_bh(&le->lock);
|
|
|
|
tipc_node_read_unlock(n);
|
|
|
|
|
|
|
|
if (likely(rc == 0))
|
|
|
|
tipc_bearer_xmit(net, bearer_id, &xmitq, &le->maddr);
|
|
|
|
else if (rc == -ENOBUFS)
|
|
|
|
tipc_node_link_down(n, bearer_id, false);
|
|
|
|
|
|
|
|
tipc_node_put(n);
|
|
|
|
|
2015-12-02 21:19:37 +01:00
|
|
|
return rc;
|
2015-07-16 22:54:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* tipc_node_xmit_skb(): send single buffer to destination
|
|
|
|
* Buffers sent via this functon are generally TIPC_SYSTEM_IMPORTANCE
|
|
|
|
* messages, which will not be rejected
|
|
|
|
* The only exception is datagram messages rerouted after secondary
|
|
|
|
* lookup, which are rare and safe to dispose of anyway.
|
|
|
|
* TODO: Return real return value, and let callers use
|
|
|
|
* tipc_wait_for_sendpkt() where applicable
|
|
|
|
*/
|
|
|
|
int tipc_node_xmit_skb(struct net *net, struct sk_buff *skb, u32 dnode,
|
|
|
|
u32 selector)
|
|
|
|
{
|
|
|
|
struct sk_buff_head head;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
skb_queue_head_init(&head);
|
|
|
|
__skb_queue_tail(&head, skb);
|
|
|
|
rc = tipc_node_xmit(net, &head, dnode, selector);
|
|
|
|
if (rc == -ELINKCONG)
|
|
|
|
kfree_skb(skb);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-11-19 20:30:42 +01:00
|
|
|
void tipc_node_broadcast(struct net *net, struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct sk_buff *txskb;
|
|
|
|
struct tipc_node *n;
|
|
|
|
u32 dst;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
list_for_each_entry_rcu(n, tipc_nodes(net), list) {
|
|
|
|
dst = n->addr;
|
|
|
|
if (in_own_node(net, dst))
|
|
|
|
continue;
|
|
|
|
if (!tipc_node_is_up(n))
|
|
|
|
continue;
|
|
|
|
txskb = pskb_copy(skb, GFP_ATOMIC);
|
|
|
|
if (!txskb)
|
|
|
|
break;
|
|
|
|
msg_set_destnode(buf_msg(txskb), dst);
|
|
|
|
tipc_node_xmit_skb(net, txskb, dst, 0);
|
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
kfree_skb(skb);
|
|
|
|
}
|
|
|
|
|
2015-10-22 14:51:41 +02:00
|
|
|
/**
|
|
|
|
* tipc_node_bc_rcv - process TIPC broadcast packet arriving from off-node
|
|
|
|
* @net: the applicable net namespace
|
|
|
|
* @skb: TIPC packet
|
|
|
|
* @bearer_id: id of bearer message arrived on
|
|
|
|
*
|
|
|
|
* Invoked with no locks held.
|
|
|
|
*/
|
2015-10-24 16:56:01 +02:00
|
|
|
static void tipc_node_bc_rcv(struct net *net, struct sk_buff *skb, int bearer_id)
|
2015-10-22 14:51:41 +02:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
struct sk_buff_head xmitq;
|
|
|
|
struct tipc_bclink_entry *be;
|
|
|
|
struct tipc_link_entry *le;
|
|
|
|
struct tipc_msg *hdr = buf_msg(skb);
|
|
|
|
int usr = msg_user(hdr);
|
|
|
|
u32 dnode = msg_destnode(hdr);
|
|
|
|
struct tipc_node *n;
|
|
|
|
|
|
|
|
__skb_queue_head_init(&xmitq);
|
|
|
|
|
|
|
|
/* If NACK for other node, let rcv link for that node peek into it */
|
|
|
|
if ((usr == BCAST_PROTOCOL) && (dnode != tipc_own_addr(net)))
|
|
|
|
n = tipc_node_find(net, dnode);
|
|
|
|
else
|
|
|
|
n = tipc_node_find(net, msg_prevnode(hdr));
|
|
|
|
if (!n) {
|
|
|
|
kfree_skb(skb);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
be = &n->bc_entry;
|
|
|
|
le = &n->links[bearer_id];
|
|
|
|
|
|
|
|
rc = tipc_bcast_rcv(net, be->link, skb);
|
|
|
|
|
|
|
|
/* Broadcast ACKs are sent on a unicast link */
|
|
|
|
if (rc & TIPC_LINK_SND_BC_ACK) {
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_read_lock(n);
|
2016-04-15 19:33:07 +02:00
|
|
|
tipc_link_build_state_msg(le->link, &xmitq);
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_read_unlock(n);
|
2015-10-22 14:51:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!skb_queue_empty(&xmitq))
|
|
|
|
tipc_bearer_xmit(net, bearer_id, &xmitq, &le->maddr);
|
|
|
|
|
|
|
|
/* Deliver. 'arrvq' is under inputq2's lock protection */
|
|
|
|
if (!skb_queue_empty(&be->inputq1)) {
|
|
|
|
spin_lock_bh(&be->inputq2.lock);
|
|
|
|
spin_lock_bh(&be->inputq1.lock);
|
|
|
|
skb_queue_splice_tail_init(&be->inputq1, &be->arrvq);
|
|
|
|
spin_unlock_bh(&be->inputq1.lock);
|
|
|
|
spin_unlock_bh(&be->inputq2.lock);
|
|
|
|
tipc_sk_mcast_rcv(net, &be->arrvq, &be->inputq2);
|
|
|
|
}
|
2016-07-11 22:08:37 +02:00
|
|
|
|
|
|
|
if (rc & TIPC_LINK_DOWN_EVT) {
|
|
|
|
/* Reception reassembly failure => reset all links to peer */
|
|
|
|
if (!tipc_link_is_up(be->link))
|
|
|
|
tipc_node_reset_links(n);
|
|
|
|
|
|
|
|
/* Retransmission failure => reset all links to all peers */
|
|
|
|
if (!tipc_link_is_up(tipc_bc_sndlink(net)))
|
|
|
|
tipc_bearer_reset_all(net);
|
|
|
|
}
|
|
|
|
|
2015-10-22 14:51:41 +02:00
|
|
|
tipc_node_put(n);
|
|
|
|
}
|
|
|
|
|
2015-07-31 00:24:19 +02:00
|
|
|
/**
|
|
|
|
* tipc_node_check_state - check and if necessary update node state
|
|
|
|
* @skb: TIPC packet
|
|
|
|
* @bearer_id: identity of bearer delivering the packet
|
|
|
|
* Returns true if state is ok, otherwise consumes buffer and returns false
|
2015-07-31 00:24:16 +02:00
|
|
|
*/
|
2015-07-31 00:24:19 +02:00
|
|
|
static bool tipc_node_check_state(struct tipc_node *n, struct sk_buff *skb,
|
2015-07-31 00:24:21 +02:00
|
|
|
int bearer_id, struct sk_buff_head *xmitq)
|
2015-07-31 00:24:16 +02:00
|
|
|
{
|
|
|
|
struct tipc_msg *hdr = buf_msg(skb);
|
2015-07-31 00:24:19 +02:00
|
|
|
int usr = msg_user(hdr);
|
|
|
|
int mtyp = msg_type(hdr);
|
2015-07-31 00:24:16 +02:00
|
|
|
u16 oseqno = msg_seqno(hdr);
|
2015-07-31 00:24:19 +02:00
|
|
|
u16 iseqno = msg_seqno(msg_get_wrapped(hdr));
|
|
|
|
u16 exp_pkts = msg_msgcnt(hdr);
|
2015-11-19 20:30:46 +01:00
|
|
|
u16 rcv_nxt, syncpt, dlv_nxt, inputq_len;
|
2015-07-31 00:24:19 +02:00
|
|
|
int state = n->state;
|
tipc: fix stale link problem during synchronization
Recent changes to the link synchronization means that we can now just
drop packets arriving on the synchronizing link before the synch point
is reached. This has lead to significant simplifications to the
implementation, but also turns out to have a flip side that we need
to consider.
Under unlucky circumstances, the two endpoints may end up
repeatedly dropping each other's packets, while immediately
asking for retransmission of the same packets, just to drop
them once more. This pattern will eventually be broken when
the synch point is reached on the other link, but before that,
the endpoints may have arrived at the retransmission limit
(stale counter) that indicates that the link should be broken.
We see this happen at rare occasions.
The fix for this is to not ask for retransmissions when a link is in
state LINK_SYNCHING. The fact that the link has reached this state
means that it has already received the first SYNCH packet, and that it
knows the synch point. Hence, it doesn't need any more packets until the
other link has reached the synch point, whereafter it can go ahead and
ask for the missing packets.
However, because of the reduced traffic on the synching link that
follows this change, it may now take longer to discover that the
synch point has been reached. We compensate for this by letting all
packets, on any of the links, trig a check for synchronization
termination. This is possible because the packets themselves don't
contain any information that is needed for discovering this condition.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-08-20 08:12:56 +02:00
|
|
|
struct tipc_link *l, *tnl, *pl = NULL;
|
2015-07-31 00:24:23 +02:00
|
|
|
struct tipc_media_addr *maddr;
|
2015-11-19 20:30:46 +01:00
|
|
|
int pb_id;
|
2015-07-31 00:24:16 +02:00
|
|
|
|
2015-07-31 00:24:19 +02:00
|
|
|
l = n->links[bearer_id].link;
|
|
|
|
if (!l)
|
|
|
|
return false;
|
2015-11-19 20:30:46 +01:00
|
|
|
rcv_nxt = tipc_link_rcv_nxt(l);
|
2015-07-31 00:24:16 +02:00
|
|
|
|
|
|
|
|
2015-07-31 00:24:19 +02:00
|
|
|
if (likely((state == SELF_UP_PEER_UP) && (usr != TUNNEL_PROTOCOL)))
|
|
|
|
return true;
|
2015-07-31 00:24:16 +02:00
|
|
|
|
2015-07-31 00:24:19 +02:00
|
|
|
/* Find parallel link, if any */
|
2015-11-19 20:30:46 +01:00
|
|
|
for (pb_id = 0; pb_id < MAX_BEARERS; pb_id++) {
|
|
|
|
if ((pb_id != bearer_id) && n->links[pb_id].link) {
|
|
|
|
pl = n->links[pb_id].link;
|
2015-07-31 00:24:19 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-07-31 00:24:16 +02:00
|
|
|
|
2015-11-19 20:30:44 +01:00
|
|
|
/* Check and update node accesibility if applicable */
|
2015-07-31 00:24:19 +02:00
|
|
|
if (state == SELF_UP_PEER_COMING) {
|
|
|
|
if (!tipc_link_is_up(l))
|
|
|
|
return true;
|
|
|
|
if (!msg_peer_link_is_up(hdr))
|
|
|
|
return true;
|
|
|
|
tipc_node_fsm_evt(n, PEER_ESTABL_CONTACT_EVT);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state == SELF_DOWN_PEER_LEAVING) {
|
|
|
|
if (msg_peer_node_is_up(hdr))
|
|
|
|
return false;
|
|
|
|
tipc_node_fsm_evt(n, PEER_LOST_CONTACT_EVT);
|
2015-11-19 20:30:41 +01:00
|
|
|
return true;
|
2015-07-31 00:24:19 +02:00
|
|
|
}
|
|
|
|
|
2015-11-19 20:30:44 +01:00
|
|
|
if (state == SELF_LEAVING_PEER_DOWN)
|
|
|
|
return false;
|
|
|
|
|
2015-07-31 00:24:19 +02:00
|
|
|
/* Ignore duplicate packets */
|
tipc: eliminate risk of stalled link synchronization
In commit 6e498158a827 ("tipc: move link synch and failover to link aggregation level")
we introduced a new mechanism for performing link failover and
synchronization. We have now detected a bug in this mechanism.
During link synchronization we use the arrival of any packet on
the tunnel link to trig a check for whether it has reached the
synchronization point or not. This has turned out to be too
permissive, since it may cause an arriving non-last SYNCH packet to
end the synch state, just to see the next SYNCH packet initiate a
new synch state with a new, higher synch point. This is not fatal,
but should be avoided, because it may significantly extend the
synchronization period, while at the same time we are not allowed
to send NACKs if packets are lost. In the worst case, a low-traffic
user may see its traffic stall until a LINK_PROTOCOL state message
trigs the link to leave synchronization state.
At the same time, LINK_PROTOCOL packets which happen to have a (non-
valid) sequence number lower than the tunnel link's rcv_nxt value will
be consistently dropped, and will never be able to resolve the situation
described above.
We fix this by exempting LINK_PROTOCOL packets from the sequence number
check, as they should be. We also reduce (but don't completely
eliminate) the risk of entering multiple synchronization states by only
allowing the (logically) first SYNCH packet to initiate a synchronization
state. This works independently of actual packet arrival order.
Fixes: commit 6e498158a827 ("tipc: move link synch and failover to link aggregation level")
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-13 18:41:51 +02:00
|
|
|
if ((usr != LINK_PROTOCOL) && less(oseqno, rcv_nxt))
|
2015-07-31 00:24:19 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
/* Initiate or update failover mode if applicable */
|
|
|
|
if ((usr == TUNNEL_PROTOCOL) && (mtyp == FAILOVER_MSG)) {
|
|
|
|
syncpt = oseqno + exp_pkts - 1;
|
2015-07-31 00:24:23 +02:00
|
|
|
if (pl && tipc_link_is_up(pl)) {
|
|
|
|
__tipc_node_link_down(n, &pb_id, xmitq, &maddr);
|
2015-11-19 20:30:46 +01:00
|
|
|
tipc_skb_queue_splice_tail_init(tipc_link_inputq(pl),
|
|
|
|
tipc_link_inputq(l));
|
2015-07-31 00:24:23 +02:00
|
|
|
}
|
2015-07-31 00:24:19 +02:00
|
|
|
/* If pkts arrive out of order, use lowest calculated syncpt */
|
|
|
|
if (less(syncpt, n->sync_point))
|
|
|
|
n->sync_point = syncpt;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Open parallel link when tunnel link reaches synch point */
|
tipc: eliminate risk of premature link setup during failover
When a link goes down, and there is still a working link towards its
destination node, a failover is initiated, and the failed link is not
allowed to re-establish until that procedure is finished. To ensure
this, the concerned link endpoints are set to state LINK_FAILINGOVER,
and the node endpoints to NODE_FAILINGOVER during the failover period.
However, if the link reset is due to a disabled bearer, the corres-
ponding link endpoint is deleted, and only the node endpoint knows
about the ongoing failover. Now, if the disabled bearer is re-enabled
during the failover period, the discovery mechanism may create a new
link endpoint that is ready to be established, despite that this is not
permitted. This situation may cause both the ongoing failover and any
subsequent link synchronization to fail.
In this commit, we ensure that a newly created link goes directly to
state LINK_FAILINGOVER if the corresponding node state is
NODE_FAILINGOVER. This eliminates the problem described above.
Furthermore, we tighten the criteria for which packets are allowed
to end a failover state in the function tipc_node_check_state().
By checking that the receiving link is up and running, instead of just
checking that it is not in failover mode, we eliminate the risk that
protocol packets from the re-created link may cause the failover to
be prematurely terminated.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-08-20 08:12:54 +02:00
|
|
|
if ((n->state == NODE_FAILINGOVER) && tipc_link_is_up(l)) {
|
2015-07-31 00:24:21 +02:00
|
|
|
if (!more(rcv_nxt, n->sync_point))
|
|
|
|
return true;
|
2015-07-31 00:24:19 +02:00
|
|
|
tipc_node_fsm_evt(n, NODE_FAILOVER_END_EVT);
|
|
|
|
if (pl)
|
2015-07-31 00:24:21 +02:00
|
|
|
tipc_link_fsm_evt(pl, LINK_FAILOVER_END_EVT);
|
2015-07-31 00:24:19 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-08-20 08:12:55 +02:00
|
|
|
/* No synching needed if only one link */
|
|
|
|
if (!pl || !tipc_link_is_up(pl))
|
|
|
|
return true;
|
|
|
|
|
tipc: eliminate risk of stalled link synchronization
In commit 6e498158a827 ("tipc: move link synch and failover to link aggregation level")
we introduced a new mechanism for performing link failover and
synchronization. We have now detected a bug in this mechanism.
During link synchronization we use the arrival of any packet on
the tunnel link to trig a check for whether it has reached the
synchronization point or not. This has turned out to be too
permissive, since it may cause an arriving non-last SYNCH packet to
end the synch state, just to see the next SYNCH packet initiate a
new synch state with a new, higher synch point. This is not fatal,
but should be avoided, because it may significantly extend the
synchronization period, while at the same time we are not allowed
to send NACKs if packets are lost. In the worst case, a low-traffic
user may see its traffic stall until a LINK_PROTOCOL state message
trigs the link to leave synchronization state.
At the same time, LINK_PROTOCOL packets which happen to have a (non-
valid) sequence number lower than the tunnel link's rcv_nxt value will
be consistently dropped, and will never be able to resolve the situation
described above.
We fix this by exempting LINK_PROTOCOL packets from the sequence number
check, as they should be. We also reduce (but don't completely
eliminate) the risk of entering multiple synchronization states by only
allowing the (logically) first SYNCH packet to initiate a synchronization
state. This works independently of actual packet arrival order.
Fixes: commit 6e498158a827 ("tipc: move link synch and failover to link aggregation level")
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-10-13 18:41:51 +02:00
|
|
|
/* Initiate synch mode if applicable */
|
|
|
|
if ((usr == TUNNEL_PROTOCOL) && (mtyp == SYNCH_MSG) && (oseqno == 1)) {
|
2015-07-31 00:24:19 +02:00
|
|
|
syncpt = iseqno + exp_pkts - 1;
|
2015-07-31 00:24:21 +02:00
|
|
|
if (!tipc_link_is_up(l)) {
|
|
|
|
tipc_link_fsm_evt(l, LINK_ESTABLISH_EVT);
|
2015-07-31 00:24:23 +02:00
|
|
|
__tipc_node_link_up(n, bearer_id, xmitq);
|
2015-07-31 00:24:21 +02:00
|
|
|
}
|
2015-07-31 00:24:19 +02:00
|
|
|
if (n->state == SELF_UP_PEER_UP) {
|
|
|
|
n->sync_point = syncpt;
|
2015-07-31 00:24:21 +02:00
|
|
|
tipc_link_fsm_evt(l, LINK_SYNCH_BEGIN_EVT);
|
2015-07-31 00:24:19 +02:00
|
|
|
tipc_node_fsm_evt(n, NODE_SYNCH_BEGIN_EVT);
|
|
|
|
}
|
2015-07-31 00:24:16 +02:00
|
|
|
}
|
2015-07-31 00:24:19 +02:00
|
|
|
|
|
|
|
/* Open tunnel link when parallel link reaches synch point */
|
2015-11-19 20:30:41 +01:00
|
|
|
if (n->state == NODE_SYNCHING) {
|
tipc: fix stale link problem during synchronization
Recent changes to the link synchronization means that we can now just
drop packets arriving on the synchronizing link before the synch point
is reached. This has lead to significant simplifications to the
implementation, but also turns out to have a flip side that we need
to consider.
Under unlucky circumstances, the two endpoints may end up
repeatedly dropping each other's packets, while immediately
asking for retransmission of the same packets, just to drop
them once more. This pattern will eventually be broken when
the synch point is reached on the other link, but before that,
the endpoints may have arrived at the retransmission limit
(stale counter) that indicates that the link should be broken.
We see this happen at rare occasions.
The fix for this is to not ask for retransmissions when a link is in
state LINK_SYNCHING. The fact that the link has reached this state
means that it has already received the first SYNCH packet, and that it
knows the synch point. Hence, it doesn't need any more packets until the
other link has reached the synch point, whereafter it can go ahead and
ask for the missing packets.
However, because of the reduced traffic on the synching link that
follows this change, it may now take longer to discover that the
synch point has been reached. We compensate for this by letting all
packets, on any of the links, trig a check for synchronization
termination. This is possible because the packets themselves don't
contain any information that is needed for discovering this condition.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-08-20 08:12:56 +02:00
|
|
|
if (tipc_link_is_synching(l)) {
|
|
|
|
tnl = l;
|
|
|
|
} else {
|
|
|
|
tnl = pl;
|
|
|
|
pl = l;
|
|
|
|
}
|
2015-11-19 20:30:46 +01:00
|
|
|
inputq_len = skb_queue_len(tipc_link_inputq(pl));
|
|
|
|
dlv_nxt = tipc_link_rcv_nxt(pl) - inputq_len;
|
2015-08-20 08:12:55 +02:00
|
|
|
if (more(dlv_nxt, n->sync_point)) {
|
tipc: fix stale link problem during synchronization
Recent changes to the link synchronization means that we can now just
drop packets arriving on the synchronizing link before the synch point
is reached. This has lead to significant simplifications to the
implementation, but also turns out to have a flip side that we need
to consider.
Under unlucky circumstances, the two endpoints may end up
repeatedly dropping each other's packets, while immediately
asking for retransmission of the same packets, just to drop
them once more. This pattern will eventually be broken when
the synch point is reached on the other link, but before that,
the endpoints may have arrived at the retransmission limit
(stale counter) that indicates that the link should be broken.
We see this happen at rare occasions.
The fix for this is to not ask for retransmissions when a link is in
state LINK_SYNCHING. The fact that the link has reached this state
means that it has already received the first SYNCH packet, and that it
knows the synch point. Hence, it doesn't need any more packets until the
other link has reached the synch point, whereafter it can go ahead and
ask for the missing packets.
However, because of the reduced traffic on the synching link that
follows this change, it may now take longer to discover that the
synch point has been reached. We compensate for this by letting all
packets, on any of the links, trig a check for synchronization
termination. This is possible because the packets themselves don't
contain any information that is needed for discovering this condition.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-08-20 08:12:56 +02:00
|
|
|
tipc_link_fsm_evt(tnl, LINK_SYNCH_END_EVT);
|
2015-07-31 00:24:19 +02:00
|
|
|
tipc_node_fsm_evt(n, NODE_SYNCH_END_EVT);
|
|
|
|
return true;
|
|
|
|
}
|
tipc: fix stale link problem during synchronization
Recent changes to the link synchronization means that we can now just
drop packets arriving on the synchronizing link before the synch point
is reached. This has lead to significant simplifications to the
implementation, but also turns out to have a flip side that we need
to consider.
Under unlucky circumstances, the two endpoints may end up
repeatedly dropping each other's packets, while immediately
asking for retransmission of the same packets, just to drop
them once more. This pattern will eventually be broken when
the synch point is reached on the other link, but before that,
the endpoints may have arrived at the retransmission limit
(stale counter) that indicates that the link should be broken.
We see this happen at rare occasions.
The fix for this is to not ask for retransmissions when a link is in
state LINK_SYNCHING. The fact that the link has reached this state
means that it has already received the first SYNCH packet, and that it
knows the synch point. Hence, it doesn't need any more packets until the
other link has reached the synch point, whereafter it can go ahead and
ask for the missing packets.
However, because of the reduced traffic on the synching link that
follows this change, it may now take longer to discover that the
synch point has been reached. We compensate for this by letting all
packets, on any of the links, trig a check for synchronization
termination. This is possible because the packets themselves don't
contain any information that is needed for discovering this condition.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-08-20 08:12:56 +02:00
|
|
|
if (l == pl)
|
|
|
|
return true;
|
2015-07-31 00:24:19 +02:00
|
|
|
if ((usr == TUNNEL_PROTOCOL) && (mtyp == SYNCH_MSG))
|
|
|
|
return true;
|
|
|
|
if (usr == LINK_PROTOCOL)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2015-07-31 00:24:16 +02:00
|
|
|
}
|
|
|
|
|
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle
we have been using for message sending and timeout handling:
We move the function tipc_rcv() to node.c, hence handling the initial
packet reception at the link aggregation level. The function grabs
the node lock, selects the receiving link, and accesses it via a new
call tipc_link_rcv(). This function appends buffers to the input
queue for delivery upwards, but it may also append outgoing packets
to the xmit queue, just as we do during regular message sending. The
latter will happen when buffers are forwarded from the link backlog,
or when retransmission is requested.
Upon return of this function, and after having released the node lock,
tipc_rcv() delivers/tranmsits the contents of those queues, but it may
also perform actions such as link activation or reset, as indicated by
the return flags from the link.
This reduces the number of cpu cycles spent inside the node spinlock,
and reduces contention on that lock.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-16 22:54:31 +02:00
|
|
|
/**
|
|
|
|
* tipc_rcv - process TIPC packets/messages arriving from off-node
|
|
|
|
* @net: the applicable net namespace
|
|
|
|
* @skb: TIPC packet
|
|
|
|
* @bearer: pointer to bearer message arrived on
|
|
|
|
*
|
|
|
|
* Invoked with no locks held. Bearer pointer must point to a valid bearer
|
|
|
|
* structure (i.e. cannot be NULL), but bearer can be inactive.
|
|
|
|
*/
|
|
|
|
void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b)
|
|
|
|
{
|
|
|
|
struct sk_buff_head xmitq;
|
|
|
|
struct tipc_node *n;
|
2015-07-31 00:24:19 +02:00
|
|
|
struct tipc_msg *hdr = buf_msg(skb);
|
|
|
|
int usr = msg_user(hdr);
|
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle
we have been using for message sending and timeout handling:
We move the function tipc_rcv() to node.c, hence handling the initial
packet reception at the link aggregation level. The function grabs
the node lock, selects the receiving link, and accesses it via a new
call tipc_link_rcv(). This function appends buffers to the input
queue for delivery upwards, but it may also append outgoing packets
to the xmit queue, just as we do during regular message sending. The
latter will happen when buffers are forwarded from the link backlog,
or when retransmission is requested.
Upon return of this function, and after having released the node lock,
tipc_rcv() delivers/tranmsits the contents of those queues, but it may
also perform actions such as link activation or reset, as indicated by
the return flags from the link.
This reduces the number of cpu cycles spent inside the node spinlock,
and reduces contention on that lock.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-16 22:54:31 +02:00
|
|
|
int bearer_id = b->identity;
|
2015-07-31 00:24:19 +02:00
|
|
|
struct tipc_link_entry *le;
|
2015-10-22 14:51:41 +02:00
|
|
|
u16 bc_ack = msg_bcast_ack(hdr);
|
2016-04-29 16:40:24 +02:00
|
|
|
u32 self = tipc_own_addr(net);
|
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle
we have been using for message sending and timeout handling:
We move the function tipc_rcv() to node.c, hence handling the initial
packet reception at the link aggregation level. The function grabs
the node lock, selects the receiving link, and accesses it via a new
call tipc_link_rcv(). This function appends buffers to the input
queue for delivery upwards, but it may also append outgoing packets
to the xmit queue, just as we do during regular message sending. The
latter will happen when buffers are forwarded from the link backlog,
or when retransmission is requested.
Upon return of this function, and after having released the node lock,
tipc_rcv() delivers/tranmsits the contents of those queues, but it may
also perform actions such as link activation or reset, as indicated by
the return flags from the link.
This reduces the number of cpu cycles spent inside the node spinlock,
and reduces contention on that lock.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-16 22:54:31 +02:00
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
__skb_queue_head_init(&xmitq);
|
|
|
|
|
|
|
|
/* Ensure message is well-formed */
|
|
|
|
if (unlikely(!tipc_msg_validate(skb)))
|
|
|
|
goto discard;
|
|
|
|
|
2015-10-22 14:51:41 +02:00
|
|
|
/* Handle arrival of discovery or broadcast packet */
|
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle
we have been using for message sending and timeout handling:
We move the function tipc_rcv() to node.c, hence handling the initial
packet reception at the link aggregation level. The function grabs
the node lock, selects the receiving link, and accesses it via a new
call tipc_link_rcv(). This function appends buffers to the input
queue for delivery upwards, but it may also append outgoing packets
to the xmit queue, just as we do during regular message sending. The
latter will happen when buffers are forwarded from the link backlog,
or when retransmission is requested.
Upon return of this function, and after having released the node lock,
tipc_rcv() delivers/tranmsits the contents of those queues, but it may
also perform actions such as link activation or reset, as indicated by
the return flags from the link.
This reduces the number of cpu cycles spent inside the node spinlock,
and reduces contention on that lock.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-16 22:54:31 +02:00
|
|
|
if (unlikely(msg_non_seq(hdr))) {
|
2015-10-22 14:51:41 +02:00
|
|
|
if (unlikely(usr == LINK_CONFIG))
|
|
|
|
return tipc_disc_rcv(net, skb, b);
|
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle
we have been using for message sending and timeout handling:
We move the function tipc_rcv() to node.c, hence handling the initial
packet reception at the link aggregation level. The function grabs
the node lock, selects the receiving link, and accesses it via a new
call tipc_link_rcv(). This function appends buffers to the input
queue for delivery upwards, but it may also append outgoing packets
to the xmit queue, just as we do during regular message sending. The
latter will happen when buffers are forwarded from the link backlog,
or when retransmission is requested.
Upon return of this function, and after having released the node lock,
tipc_rcv() delivers/tranmsits the contents of those queues, but it may
also perform actions such as link activation or reset, as indicated by
the return flags from the link.
This reduces the number of cpu cycles spent inside the node spinlock,
and reduces contention on that lock.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-16 22:54:31 +02:00
|
|
|
else
|
2015-10-22 14:51:41 +02:00
|
|
|
return tipc_node_bc_rcv(net, skb, bearer_id);
|
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle
we have been using for message sending and timeout handling:
We move the function tipc_rcv() to node.c, hence handling the initial
packet reception at the link aggregation level. The function grabs
the node lock, selects the receiving link, and accesses it via a new
call tipc_link_rcv(). This function appends buffers to the input
queue for delivery upwards, but it may also append outgoing packets
to the xmit queue, just as we do during regular message sending. The
latter will happen when buffers are forwarded from the link backlog,
or when retransmission is requested.
Upon return of this function, and after having released the node lock,
tipc_rcv() delivers/tranmsits the contents of those queues, but it may
also perform actions such as link activation or reset, as indicated by
the return flags from the link.
This reduces the number of cpu cycles spent inside the node spinlock,
and reduces contention on that lock.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-16 22:54:31 +02:00
|
|
|
}
|
|
|
|
|
2016-04-29 16:40:24 +02:00
|
|
|
/* Discard unicast link messages destined for another node */
|
|
|
|
if (unlikely(!msg_short(hdr) && (msg_destnode(hdr) != self)))
|
|
|
|
goto discard;
|
|
|
|
|
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle
we have been using for message sending and timeout handling:
We move the function tipc_rcv() to node.c, hence handling the initial
packet reception at the link aggregation level. The function grabs
the node lock, selects the receiving link, and accesses it via a new
call tipc_link_rcv(). This function appends buffers to the input
queue for delivery upwards, but it may also append outgoing packets
to the xmit queue, just as we do during regular message sending. The
latter will happen when buffers are forwarded from the link backlog,
or when retransmission is requested.
Upon return of this function, and after having released the node lock,
tipc_rcv() delivers/tranmsits the contents of those queues, but it may
also perform actions such as link activation or reset, as indicated by
the return flags from the link.
This reduces the number of cpu cycles spent inside the node spinlock,
and reduces contention on that lock.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-16 22:54:31 +02:00
|
|
|
/* Locate neighboring node that sent packet */
|
|
|
|
n = tipc_node_find(net, msg_prevnode(hdr));
|
|
|
|
if (unlikely(!n))
|
|
|
|
goto discard;
|
2015-07-31 00:24:19 +02:00
|
|
|
le = &n->links[bearer_id];
|
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle
we have been using for message sending and timeout handling:
We move the function tipc_rcv() to node.c, hence handling the initial
packet reception at the link aggregation level. The function grabs
the node lock, selects the receiving link, and accesses it via a new
call tipc_link_rcv(). This function appends buffers to the input
queue for delivery upwards, but it may also append outgoing packets
to the xmit queue, just as we do during regular message sending. The
latter will happen when buffers are forwarded from the link backlog,
or when retransmission is requested.
Upon return of this function, and after having released the node lock,
tipc_rcv() delivers/tranmsits the contents of those queues, but it may
also perform actions such as link activation or reset, as indicated by
the return flags from the link.
This reduces the number of cpu cycles spent inside the node spinlock,
and reduces contention on that lock.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-16 22:54:31 +02:00
|
|
|
|
2015-10-22 14:51:41 +02:00
|
|
|
/* Ensure broadcast reception is in synch with peer's send state */
|
|
|
|
if (unlikely(usr == LINK_PROTOCOL))
|
|
|
|
tipc_bcast_sync_rcv(net, n->bc_entry.link, hdr);
|
2015-11-19 20:30:46 +01:00
|
|
|
else if (unlikely(tipc_link_acked(n->bc_entry.link) != bc_ack))
|
2015-10-22 14:51:41 +02:00
|
|
|
tipc_bcast_ack_rcv(net, n->bc_entry.link, bc_ack);
|
|
|
|
|
2015-11-19 20:30:44 +01:00
|
|
|
/* Receive packet directly if conditions permit */
|
|
|
|
tipc_node_read_lock(n);
|
|
|
|
if (likely((n->state == SELF_UP_PEER_UP) && (usr != TUNNEL_PROTOCOL))) {
|
2015-11-19 20:30:43 +01:00
|
|
|
spin_lock_bh(&le->lock);
|
2015-11-19 20:30:44 +01:00
|
|
|
if (le->link) {
|
|
|
|
rc = tipc_link_rcv(le->link, skb, &xmitq);
|
|
|
|
skb = NULL;
|
|
|
|
}
|
2015-11-19 20:30:43 +01:00
|
|
|
spin_unlock_bh(&le->lock);
|
2015-07-31 00:24:19 +02:00
|
|
|
}
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_read_unlock(n);
|
|
|
|
|
|
|
|
/* Check/update node state before receiving */
|
|
|
|
if (unlikely(skb)) {
|
|
|
|
tipc_node_write_lock(n);
|
|
|
|
if (tipc_node_check_state(n, skb, bearer_id, &xmitq)) {
|
|
|
|
if (le->link) {
|
|
|
|
rc = tipc_link_rcv(le->link, skb, &xmitq);
|
|
|
|
skb = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tipc_node_write_unlock(n);
|
|
|
|
}
|
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle
we have been using for message sending and timeout handling:
We move the function tipc_rcv() to node.c, hence handling the initial
packet reception at the link aggregation level. The function grabs
the node lock, selects the receiving link, and accesses it via a new
call tipc_link_rcv(). This function appends buffers to the input
queue for delivery upwards, but it may also append outgoing packets
to the xmit queue, just as we do during regular message sending. The
latter will happen when buffers are forwarded from the link backlog,
or when retransmission is requested.
Upon return of this function, and after having released the node lock,
tipc_rcv() delivers/tranmsits the contents of those queues, but it may
also perform actions such as link activation or reset, as indicated by
the return flags from the link.
This reduces the number of cpu cycles spent inside the node spinlock,
and reduces contention on that lock.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-16 22:54:31 +02:00
|
|
|
|
|
|
|
if (unlikely(rc & TIPC_LINK_UP_EVT))
|
2015-07-31 00:24:19 +02:00
|
|
|
tipc_node_link_up(n, bearer_id, &xmitq);
|
|
|
|
|
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle
we have been using for message sending and timeout handling:
We move the function tipc_rcv() to node.c, hence handling the initial
packet reception at the link aggregation level. The function grabs
the node lock, selects the receiving link, and accesses it via a new
call tipc_link_rcv(). This function appends buffers to the input
queue for delivery upwards, but it may also append outgoing packets
to the xmit queue, just as we do during regular message sending. The
latter will happen when buffers are forwarded from the link backlog,
or when retransmission is requested.
Upon return of this function, and after having released the node lock,
tipc_rcv() delivers/tranmsits the contents of those queues, but it may
also perform actions such as link activation or reset, as indicated by
the return flags from the link.
This reduces the number of cpu cycles spent inside the node spinlock,
and reduces contention on that lock.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-16 22:54:31 +02:00
|
|
|
if (unlikely(rc & TIPC_LINK_DOWN_EVT))
|
2015-07-31 00:24:23 +02:00
|
|
|
tipc_node_link_down(n, bearer_id, false);
|
2015-07-31 00:24:19 +02:00
|
|
|
|
2015-10-22 14:51:41 +02:00
|
|
|
if (unlikely(!skb_queue_empty(&n->bc_entry.namedq)))
|
|
|
|
tipc_named_rcv(net, &n->bc_entry.namedq);
|
2015-07-31 00:24:24 +02:00
|
|
|
|
2015-07-31 00:24:19 +02:00
|
|
|
if (!skb_queue_empty(&le->inputq))
|
|
|
|
tipc_sk_rcv(net, &le->inputq);
|
|
|
|
|
|
|
|
if (!skb_queue_empty(&xmitq))
|
|
|
|
tipc_bearer_xmit(net, bearer_id, &xmitq, &le->maddr);
|
|
|
|
|
tipc: reduce locking scope during packet reception
We convert packet/message reception according to the same principle
we have been using for message sending and timeout handling:
We move the function tipc_rcv() to node.c, hence handling the initial
packet reception at the link aggregation level. The function grabs
the node lock, selects the receiving link, and accesses it via a new
call tipc_link_rcv(). This function appends buffers to the input
queue for delivery upwards, but it may also append outgoing packets
to the xmit queue, just as we do during regular message sending. The
latter will happen when buffers are forwarded from the link backlog,
or when retransmission is requested.
Upon return of this function, and after having released the node lock,
tipc_rcv() delivers/tranmsits the contents of those queues, but it may
also perform actions such as link activation or reset, as indicated by
the return flags from the link.
This reduces the number of cpu cycles spent inside the node spinlock,
and reduces contention on that lock.
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-16 22:54:31 +02:00
|
|
|
tipc_node_put(n);
|
|
|
|
discard:
|
|
|
|
kfree_skb(skb);
|
|
|
|
}
|
|
|
|
|
2014-11-20 10:29:17 +01:00
|
|
|
int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb)
|
|
|
|
{
|
|
|
|
int err;
|
2015-01-09 08:27:05 +01:00
|
|
|
struct net *net = sock_net(skb->sk);
|
|
|
|
struct tipc_net *tn = net_generic(net, tipc_net_id);
|
2014-11-20 10:29:17 +01:00
|
|
|
int done = cb->args[0];
|
|
|
|
int last_addr = cb->args[1];
|
|
|
|
struct tipc_node *node;
|
|
|
|
struct tipc_nl_msg msg;
|
|
|
|
|
|
|
|
if (done)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
msg.skb = skb;
|
|
|
|
msg.portid = NETLINK_CB(cb->skb).portid;
|
|
|
|
msg.seq = cb->nlh->nlmsg_seq;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
2015-03-26 11:10:24 +01:00
|
|
|
if (last_addr) {
|
|
|
|
node = tipc_node_find(net, last_addr);
|
|
|
|
if (!node) {
|
|
|
|
rcu_read_unlock();
|
|
|
|
/* We never set seq or call nl_dump_check_consistent()
|
|
|
|
* this means that setting prev_seq here will cause the
|
|
|
|
* consistence check to fail in the netlink callback
|
|
|
|
* handler. Resulting in the NLMSG_DONE message having
|
|
|
|
* the NLM_F_DUMP_INTR flag set if the node state
|
|
|
|
* changed while we released the lock.
|
|
|
|
*/
|
|
|
|
cb->prev_seq = 1;
|
|
|
|
return -EPIPE;
|
|
|
|
}
|
|
|
|
tipc_node_put(node);
|
2014-11-20 10:29:17 +01:00
|
|
|
}
|
|
|
|
|
2015-01-09 08:27:05 +01:00
|
|
|
list_for_each_entry_rcu(node, &tn->node_list, list) {
|
2014-11-20 10:29:17 +01:00
|
|
|
if (last_addr) {
|
|
|
|
if (node->addr == last_addr)
|
|
|
|
last_addr = 0;
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_read_lock(node);
|
2014-11-20 10:29:17 +01:00
|
|
|
err = __tipc_nl_add_node(&msg, node);
|
|
|
|
if (err) {
|
|
|
|
last_addr = node->addr;
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_read_unlock(node);
|
2014-11-20 10:29:17 +01:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2015-11-19 20:30:44 +01:00
|
|
|
tipc_node_read_unlock(node);
|
2014-11-20 10:29:17 +01:00
|
|
|
}
|
|
|
|
done = 1;
|
|
|
|
out:
|
|
|
|
cb->args[0] = done;
|
|
|
|
cb->args[1] = last_addr;
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
return skb->len;
|
|
|
|
}
|
2015-11-19 20:30:45 +01:00
|
|
|
|
2015-11-19 20:30:46 +01:00
|
|
|
/* tipc_node_find_by_name - locate owner node of link by link's name
|
2015-11-19 20:30:45 +01:00
|
|
|
* @net: the applicable net namespace
|
|
|
|
* @name: pointer to link name string
|
|
|
|
* @bearer_id: pointer to index in 'node->links' array where the link was found.
|
|
|
|
*
|
|
|
|
* Returns pointer to node owning the link, or 0 if no matching link is found.
|
|
|
|
*/
|
2015-11-19 20:30:46 +01:00
|
|
|
static struct tipc_node *tipc_node_find_by_name(struct net *net,
|
|
|
|
const char *link_name,
|
|
|
|
unsigned int *bearer_id)
|
2015-11-19 20:30:45 +01:00
|
|
|
{
|
|
|
|
struct tipc_net *tn = net_generic(net, tipc_net_id);
|
2015-11-19 20:30:46 +01:00
|
|
|
struct tipc_link *l;
|
|
|
|
struct tipc_node *n;
|
2015-11-19 20:30:45 +01:00
|
|
|
struct tipc_node *found_node = NULL;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
*bearer_id = 0;
|
|
|
|
rcu_read_lock();
|
2015-11-19 20:30:46 +01:00
|
|
|
list_for_each_entry_rcu(n, &tn->node_list, list) {
|
|
|
|
tipc_node_read_lock(n);
|
2015-11-19 20:30:45 +01:00
|
|
|
for (i = 0; i < MAX_BEARERS; i++) {
|
2015-11-19 20:30:46 +01:00
|
|
|
l = n->links[i].link;
|
|
|
|
if (l && !strcmp(tipc_link_name(l), link_name)) {
|
2015-11-19 20:30:45 +01:00
|
|
|
*bearer_id = i;
|
2015-11-19 20:30:46 +01:00
|
|
|
found_node = n;
|
2015-11-19 20:30:45 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-11-19 20:30:46 +01:00
|
|
|
tipc_node_read_unlock(n);
|
2015-11-19 20:30:45 +01:00
|
|
|
if (found_node)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
return found_node;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tipc_nl_node_set_link(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
int res = 0;
|
|
|
|
int bearer_id;
|
|
|
|
char *name;
|
|
|
|
struct tipc_link *link;
|
|
|
|
struct tipc_node *node;
|
2016-02-01 08:19:56 +01:00
|
|
|
struct sk_buff_head xmitq;
|
2015-11-19 20:30:45 +01:00
|
|
|
struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1];
|
|
|
|
struct net *net = sock_net(skb->sk);
|
|
|
|
|
2016-02-01 08:19:56 +01:00
|
|
|
__skb_queue_head_init(&xmitq);
|
|
|
|
|
2015-11-19 20:30:45 +01:00
|
|
|
if (!info->attrs[TIPC_NLA_LINK])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
err = nla_parse_nested(attrs, TIPC_NLA_LINK_MAX,
|
|
|
|
info->attrs[TIPC_NLA_LINK],
|
|
|
|
tipc_nl_link_policy);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (!attrs[TIPC_NLA_LINK_NAME])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
name = nla_data(attrs[TIPC_NLA_LINK_NAME]);
|
|
|
|
|
|
|
|
if (strcmp(name, tipc_bclink_name) == 0)
|
|
|
|
return tipc_nl_bc_link_set(net, attrs);
|
|
|
|
|
2015-11-19 20:30:46 +01:00
|
|
|
node = tipc_node_find_by_name(net, name, &bearer_id);
|
2015-11-19 20:30:45 +01:00
|
|
|
if (!node)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
tipc_node_read_lock(node);
|
|
|
|
|
|
|
|
link = node->links[bearer_id].link;
|
|
|
|
if (!link) {
|
|
|
|
res = -EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attrs[TIPC_NLA_LINK_PROP]) {
|
|
|
|
struct nlattr *props[TIPC_NLA_PROP_MAX + 1];
|
|
|
|
|
|
|
|
err = tipc_nl_parse_link_prop(attrs[TIPC_NLA_LINK_PROP],
|
|
|
|
props);
|
|
|
|
if (err) {
|
|
|
|
res = err;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (props[TIPC_NLA_PROP_TOL]) {
|
|
|
|
u32 tol;
|
|
|
|
|
|
|
|
tol = nla_get_u32(props[TIPC_NLA_PROP_TOL]);
|
2016-02-01 08:19:56 +01:00
|
|
|
tipc_link_set_tolerance(link, tol, &xmitq);
|
2015-11-19 20:30:45 +01:00
|
|
|
}
|
|
|
|
if (props[TIPC_NLA_PROP_PRIO]) {
|
|
|
|
u32 prio;
|
|
|
|
|
|
|
|
prio = nla_get_u32(props[TIPC_NLA_PROP_PRIO]);
|
2016-02-01 08:19:56 +01:00
|
|
|
tipc_link_set_prio(link, prio, &xmitq);
|
2015-11-19 20:30:45 +01:00
|
|
|
}
|
|
|
|
if (props[TIPC_NLA_PROP_WIN]) {
|
|
|
|
u32 win;
|
|
|
|
|
|
|
|
win = nla_get_u32(props[TIPC_NLA_PROP_WIN]);
|
|
|
|
tipc_link_set_queue_limits(link, win);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
tipc_node_read_unlock(node);
|
2016-02-01 08:19:56 +01:00
|
|
|
tipc_bearer_xmit(net, bearer_id, &xmitq, &node->links[bearer_id].maddr);
|
2015-11-19 20:30:45 +01:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tipc_nl_node_get_link(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct net *net = genl_info_net(info);
|
|
|
|
struct tipc_nl_msg msg;
|
|
|
|
char *name;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
msg.portid = info->snd_portid;
|
|
|
|
msg.seq = info->snd_seq;
|
|
|
|
|
|
|
|
if (!info->attrs[TIPC_NLA_LINK_NAME])
|
|
|
|
return -EINVAL;
|
|
|
|
name = nla_data(info->attrs[TIPC_NLA_LINK_NAME]);
|
|
|
|
|
|
|
|
msg.skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
|
|
|
|
if (!msg.skb)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
if (strcmp(name, tipc_bclink_name) == 0) {
|
|
|
|
err = tipc_nl_add_bc_link(net, &msg);
|
|
|
|
if (err) {
|
|
|
|
nlmsg_free(msg.skb);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int bearer_id;
|
|
|
|
struct tipc_node *node;
|
|
|
|
struct tipc_link *link;
|
|
|
|
|
2015-11-19 20:30:46 +01:00
|
|
|
node = tipc_node_find_by_name(net, name, &bearer_id);
|
2015-11-19 20:30:45 +01:00
|
|
|
if (!node)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
tipc_node_read_lock(node);
|
|
|
|
link = node->links[bearer_id].link;
|
|
|
|
if (!link) {
|
|
|
|
tipc_node_read_unlock(node);
|
|
|
|
nlmsg_free(msg.skb);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
err = __tipc_nl_add_link(net, &msg, link, 0);
|
|
|
|
tipc_node_read_unlock(node);
|
|
|
|
if (err) {
|
|
|
|
nlmsg_free(msg.skb);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return genlmsg_reply(msg.skb, info);
|
|
|
|
}
|
|
|
|
|
|
|
|
int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
char *link_name;
|
|
|
|
unsigned int bearer_id;
|
|
|
|
struct tipc_link *link;
|
|
|
|
struct tipc_node *node;
|
|
|
|
struct nlattr *attrs[TIPC_NLA_LINK_MAX + 1];
|
|
|
|
struct net *net = sock_net(skb->sk);
|
|
|
|
struct tipc_link_entry *le;
|
|
|
|
|
|
|
|
if (!info->attrs[TIPC_NLA_LINK])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
err = nla_parse_nested(attrs, TIPC_NLA_LINK_MAX,
|
|
|
|
info->attrs[TIPC_NLA_LINK],
|
|
|
|
tipc_nl_link_policy);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (!attrs[TIPC_NLA_LINK_NAME])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
link_name = nla_data(attrs[TIPC_NLA_LINK_NAME]);
|
|
|
|
|
|
|
|
if (strcmp(link_name, tipc_bclink_name) == 0) {
|
|
|
|
err = tipc_bclink_reset_stats(net);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-11-19 20:30:46 +01:00
|
|
|
node = tipc_node_find_by_name(net, link_name, &bearer_id);
|
2015-11-19 20:30:45 +01:00
|
|
|
if (!node)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
le = &node->links[bearer_id];
|
|
|
|
tipc_node_read_lock(node);
|
|
|
|
spin_lock_bh(&le->lock);
|
|
|
|
link = node->links[bearer_id].link;
|
|
|
|
if (!link) {
|
|
|
|
spin_unlock_bh(&le->lock);
|
|
|
|
tipc_node_read_unlock(node);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2015-11-19 20:30:46 +01:00
|
|
|
tipc_link_reset_stats(link);
|
2015-11-19 20:30:45 +01:00
|
|
|
spin_unlock_bh(&le->lock);
|
|
|
|
tipc_node_read_unlock(node);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Caller should hold node lock */
|
|
|
|
static int __tipc_nl_add_node_links(struct net *net, struct tipc_nl_msg *msg,
|
|
|
|
struct tipc_node *node, u32 *prev_link)
|
|
|
|
{
|
|
|
|
u32 i;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
for (i = *prev_link; i < MAX_BEARERS; i++) {
|
|
|
|
*prev_link = i;
|
|
|
|
|
|
|
|
if (!node->links[i].link)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
err = __tipc_nl_add_link(net, msg,
|
|
|
|
node->links[i].link, NLM_F_MULTI);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
*prev_link = 0;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-11-19 20:30:46 +01:00
|
|
|
int tipc_nl_node_dump_link(struct sk_buff *skb, struct netlink_callback *cb)
|
2015-11-19 20:30:45 +01:00
|
|
|
{
|
|
|
|
struct net *net = sock_net(skb->sk);
|
|
|
|
struct tipc_net *tn = net_generic(net, tipc_net_id);
|
|
|
|
struct tipc_node *node;
|
|
|
|
struct tipc_nl_msg msg;
|
|
|
|
u32 prev_node = cb->args[0];
|
|
|
|
u32 prev_link = cb->args[1];
|
|
|
|
int done = cb->args[2];
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (done)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
msg.skb = skb;
|
|
|
|
msg.portid = NETLINK_CB(cb->skb).portid;
|
|
|
|
msg.seq = cb->nlh->nlmsg_seq;
|
|
|
|
|
|
|
|
rcu_read_lock();
|
|
|
|
if (prev_node) {
|
|
|
|
node = tipc_node_find(net, prev_node);
|
|
|
|
if (!node) {
|
|
|
|
/* We never set seq or call nl_dump_check_consistent()
|
|
|
|
* this means that setting prev_seq here will cause the
|
|
|
|
* consistence check to fail in the netlink callback
|
|
|
|
* handler. Resulting in the last NLMSG_DONE message
|
|
|
|
* having the NLM_F_DUMP_INTR flag set.
|
|
|
|
*/
|
|
|
|
cb->prev_seq = 1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
tipc_node_put(node);
|
|
|
|
|
|
|
|
list_for_each_entry_continue_rcu(node, &tn->node_list,
|
|
|
|
list) {
|
|
|
|
tipc_node_read_lock(node);
|
|
|
|
err = __tipc_nl_add_node_links(net, &msg, node,
|
|
|
|
&prev_link);
|
|
|
|
tipc_node_read_unlock(node);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
prev_node = node->addr;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
err = tipc_nl_add_bc_link(net, &msg);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
list_for_each_entry_rcu(node, &tn->node_list, list) {
|
|
|
|
tipc_node_read_lock(node);
|
|
|
|
err = __tipc_nl_add_node_links(net, &msg, node,
|
|
|
|
&prev_link);
|
|
|
|
tipc_node_read_unlock(node);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
prev_node = node->addr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
done = 1;
|
|
|
|
out:
|
|
|
|
rcu_read_unlock();
|
|
|
|
|
|
|
|
cb->args[0] = prev_node;
|
|
|
|
cb->args[1] = prev_link;
|
|
|
|
cb->args[2] = done;
|
|
|
|
|
|
|
|
return skb->len;
|
|
|
|
}
|
2016-07-26 08:47:19 +02:00
|
|
|
|
|
|
|
int tipc_nl_node_set_monitor(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct nlattr *attrs[TIPC_NLA_MON_MAX + 1];
|
|
|
|
struct net *net = sock_net(skb->sk);
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!info->attrs[TIPC_NLA_MON])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
err = nla_parse_nested(attrs, TIPC_NLA_MON_MAX,
|
|
|
|
info->attrs[TIPC_NLA_MON],
|
|
|
|
tipc_nl_monitor_policy);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (attrs[TIPC_NLA_MON_ACTIVATION_THRESHOLD]) {
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
val = nla_get_u32(attrs[TIPC_NLA_MON_ACTIVATION_THRESHOLD]);
|
|
|
|
err = tipc_nl_monitor_set_threshold(net, val);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-07-26 08:47:20 +02:00
|
|
|
|
|
|
|
static int __tipc_nl_add_monitor_prop(struct net *net, struct tipc_nl_msg *msg)
|
|
|
|
{
|
|
|
|
struct nlattr *attrs;
|
|
|
|
void *hdr;
|
|
|
|
u32 val;
|
|
|
|
|
|
|
|
hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
|
|
|
|
0, TIPC_NL_MON_GET);
|
|
|
|
if (!hdr)
|
|
|
|
return -EMSGSIZE;
|
|
|
|
|
|
|
|
attrs = nla_nest_start(msg->skb, TIPC_NLA_MON);
|
|
|
|
if (!attrs)
|
|
|
|
goto msg_full;
|
|
|
|
|
|
|
|
val = tipc_nl_monitor_get_threshold(net);
|
|
|
|
|
|
|
|
if (nla_put_u32(msg->skb, TIPC_NLA_MON_ACTIVATION_THRESHOLD, val))
|
|
|
|
goto attr_msg_full;
|
|
|
|
|
|
|
|
nla_nest_end(msg->skb, attrs);
|
|
|
|
genlmsg_end(msg->skb, hdr);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
attr_msg_full:
|
|
|
|
nla_nest_cancel(msg->skb, attrs);
|
|
|
|
msg_full:
|
|
|
|
genlmsg_cancel(msg->skb, hdr);
|
|
|
|
|
|
|
|
return -EMSGSIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tipc_nl_node_get_monitor(struct sk_buff *skb, struct genl_info *info)
|
|
|
|
{
|
|
|
|
struct net *net = sock_net(skb->sk);
|
|
|
|
struct tipc_nl_msg msg;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
msg.skb = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
|
|
|
|
msg.portid = info->snd_portid;
|
|
|
|
msg.seq = info->snd_seq;
|
|
|
|
|
|
|
|
err = __tipc_nl_add_monitor_prop(net, &msg);
|
|
|
|
if (err) {
|
|
|
|
nlmsg_free(msg.skb);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
return genlmsg_reply(msg.skb, info);
|
|
|
|
}
|
2016-07-26 08:47:22 +02:00
|
|
|
|
|
|
|
int tipc_nl_node_dump_monitor(struct sk_buff *skb, struct netlink_callback *cb)
|
|
|
|
{
|
|
|
|
struct net *net = sock_net(skb->sk);
|
|
|
|
u32 prev_bearer = cb->args[0];
|
|
|
|
struct tipc_nl_msg msg;
|
|
|
|
int err;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (prev_bearer == MAX_BEARERS)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
msg.skb = skb;
|
|
|
|
msg.portid = NETLINK_CB(cb->skb).portid;
|
|
|
|
msg.seq = cb->nlh->nlmsg_seq;
|
|
|
|
|
|
|
|
rtnl_lock();
|
|
|
|
for (i = prev_bearer; i < MAX_BEARERS; i++) {
|
|
|
|
prev_bearer = i;
|
|
|
|
err = __tipc_nl_add_monitor(net, &msg, prev_bearer);
|
|
|
|
if (err)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
rtnl_unlock();
|
|
|
|
cb->args[0] = prev_bearer;
|
|
|
|
|
|
|
|
return skb->len;
|
|
|
|
}
|
|
|
|
|
|
|
|
int tipc_nl_node_dump_monitor_peer(struct sk_buff *skb,
|
|
|
|
struct netlink_callback *cb)
|
|
|
|
{
|
|
|
|
struct net *net = sock_net(skb->sk);
|
|
|
|
u32 prev_node = cb->args[1];
|
|
|
|
u32 bearer_id = cb->args[2];
|
|
|
|
int done = cb->args[0];
|
|
|
|
struct tipc_nl_msg msg;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!prev_node) {
|
|
|
|
struct nlattr **attrs;
|
|
|
|
struct nlattr *mon[TIPC_NLA_MON_MAX + 1];
|
|
|
|
|
|
|
|
err = tipc_nlmsg_parse(cb->nlh, &attrs);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (!attrs[TIPC_NLA_MON])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
err = nla_parse_nested(mon, TIPC_NLA_MON_MAX,
|
|
|
|
attrs[TIPC_NLA_MON],
|
|
|
|
tipc_nl_monitor_policy);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (!mon[TIPC_NLA_MON_REF])
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
bearer_id = nla_get_u32(mon[TIPC_NLA_MON_REF]);
|
|
|
|
|
|
|
|
if (bearer_id >= MAX_BEARERS)
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (done)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
msg.skb = skb;
|
|
|
|
msg.portid = NETLINK_CB(cb->skb).portid;
|
|
|
|
msg.seq = cb->nlh->nlmsg_seq;
|
|
|
|
|
|
|
|
rtnl_lock();
|
|
|
|
err = tipc_nl_add_monitor_peer(net, &msg, bearer_id, &prev_node);
|
|
|
|
if (!err)
|
|
|
|
done = 1;
|
|
|
|
|
|
|
|
rtnl_unlock();
|
|
|
|
cb->args[0] = done;
|
|
|
|
cb->args[1] = prev_node;
|
|
|
|
cb->args[2] = bearer_id;
|
|
|
|
|
|
|
|
return skb->len;
|
|
|
|
}
|