Skip to content

Commit ff2ebbf

Browse files
Hoang Ledavem330
authored andcommitted
tipc: introduce new capability flag for cluster
As a preparation for introducing a smooth switching between replicast and broadcast method for multicast message, We have to introduce a new capability flag TIPC_MCAST_RBCTL to handle this new feature. During a cluster upgrade a node can come back with this new capabilities which also must be reflected in the cluster capabilities field. The new feature is only applicable if all node in the cluster supports this new capability. Acked-by: Jon Maloy <[email protected]> Signed-off-by: Hoang Le <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 02ec6ca commit ff2ebbf

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

net/tipc/core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "net.h"
4444
#include "socket.h"
4545
#include "bcast.h"
46+
#include "node.h"
4647

4748
#include <linux/module.h>
4849

@@ -59,6 +60,7 @@ static int __net_init tipc_init_net(struct net *net)
5960
tn->node_addr = 0;
6061
tn->trial_addr = 0;
6162
tn->addr_trial_end = 0;
63+
tn->capabilities = TIPC_NODE_CAPABILITIES;
6264
memset(tn->node_id, 0, sizeof(tn->node_id));
6365
memset(tn->node_id_string, 0, sizeof(tn->node_id_string));
6466
tn->mon_threshold = TIPC_DEF_MON_THRESHOLD;

net/tipc/core.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ struct tipc_net {
122122
/* Topology subscription server */
123123
struct tipc_topsrv *topsrv;
124124
atomic_t subscription_count;
125+
126+
/* Cluster capabilities */
127+
u16 capabilities;
125128
};
126129

127130
static inline struct tipc_net *tipc_net(struct net *net)

net/tipc/node.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,11 @@ static struct tipc_node *tipc_node_create(struct net *net, u32 addr,
383383
tipc_link_update_caps(l, capabilities);
384384
}
385385
write_unlock_bh(&n->lock);
386+
/* Calculate cluster capabilities */
387+
tn->capabilities = TIPC_NODE_CAPABILITIES;
388+
list_for_each_entry_rcu(temp_node, &tn->node_list, list) {
389+
tn->capabilities &= temp_node->capabilities;
390+
}
386391
goto exit;
387392
}
388393
n = kzalloc(sizeof(*n), GFP_ATOMIC);
@@ -433,6 +438,11 @@ static struct tipc_node *tipc_node_create(struct net *net, u32 addr,
433438
break;
434439
}
435440
list_add_tail_rcu(&n->list, &temp_node->list);
441+
/* Calculate cluster capabilities */
442+
tn->capabilities = TIPC_NODE_CAPABILITIES;
443+
list_for_each_entry_rcu(temp_node, &tn->node_list, list) {
444+
tn->capabilities &= temp_node->capabilities;
445+
}
436446
trace_tipc_node_create(n, true, " ");
437447
exit:
438448
spin_unlock_bh(&tn->node_list_lock);
@@ -589,6 +599,7 @@ static void tipc_node_clear_links(struct tipc_node *node)
589599
*/
590600
static bool tipc_node_cleanup(struct tipc_node *peer)
591601
{
602+
struct tipc_node *temp_node;
592603
struct tipc_net *tn = tipc_net(peer->net);
593604
bool deleted = false;
594605

@@ -604,6 +615,13 @@ static bool tipc_node_cleanup(struct tipc_node *peer)
604615
deleted = true;
605616
}
606617
tipc_node_write_unlock(peer);
618+
619+
/* Calculate cluster capabilities */
620+
tn->capabilities = TIPC_NODE_CAPABILITIES;
621+
list_for_each_entry_rcu(temp_node, &tn->node_list, list) {
622+
tn->capabilities &= temp_node->capabilities;
623+
}
624+
607625
spin_unlock_bh(&tn->node_list_lock);
608626
return deleted;
609627
}

net/tipc/node.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ enum {
5151
TIPC_BLOCK_FLOWCTL = (1 << 3),
5252
TIPC_BCAST_RCAST = (1 << 4),
5353
TIPC_NODE_ID128 = (1 << 5),
54-
TIPC_LINK_PROTO_SEQNO = (1 << 6)
54+
TIPC_LINK_PROTO_SEQNO = (1 << 6),
55+
TIPC_MCAST_RBCTL = (1 << 7)
5556
};
5657

5758
#define TIPC_NODE_CAPABILITIES (TIPC_SYN_BIT | \
@@ -60,7 +61,8 @@ enum {
6061
TIPC_BCAST_RCAST | \
6162
TIPC_BLOCK_FLOWCTL | \
6263
TIPC_NODE_ID128 | \
63-
TIPC_LINK_PROTO_SEQNO)
64+
TIPC_LINK_PROTO_SEQNO | \
65+
TIPC_MCAST_RBCTL)
6466
#define INVALID_BEARER_ID -1
6567

6668
void tipc_node_stop(struct net *net);

0 commit comments

Comments
 (0)