Skip to content

Commit 7764d6e

Browse files
Jon Paul Maloydavem330
authored andcommitted
tipc: add framework for node capabilities exchange
The TIPC protocol spec has defined a 13 bit capability bitmap in the neighbor discovery header, as a means to maintain compatibility between different code and protocol generations. Until now this field has been unused. We now introduce the basic framework for exchanging capabilities between nodes at first contact. After exchange, a peer node's capabilities are stored as a 16 bit bitmap in struct tipc_node. Reviewed-by: Erik Hugne <[email protected]> Reviewed-by: Ying Xue <[email protected]> Signed-off-by: Jon Maloy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5f1764d commit 7764d6e

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

net/tipc/discover.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ static void tipc_disc_init_msg(struct net *net, struct sk_buff *buf, u32 type,
8989
MAX_H_SIZE, dest_domain);
9090
msg_set_non_seq(msg, 1);
9191
msg_set_node_sig(msg, tn->random);
92+
msg_set_node_capabilities(msg, 0);
9293
msg_set_dest_domain(msg, dest_domain);
9394
msg_set_bc_netid(msg, tn->net_id);
9495
b_ptr->media->addr2msg(msg_media_addr(msg), &b_ptr->addr);
@@ -133,6 +134,7 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *buf,
133134
u32 net_id = msg_bc_netid(msg);
134135
u32 mtyp = msg_type(msg);
135136
u32 signature = msg_node_sig(msg);
137+
u16 caps = msg_node_capabilities(msg);
136138
bool addr_match = false;
137139
bool sign_match = false;
138140
bool link_up = false;
@@ -167,6 +169,7 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *buf,
167169
if (!node)
168170
return;
169171
tipc_node_lock(node);
172+
node->capabilities = caps;
170173
link = node->links[bearer->identity];
171174

172175
/* Prepare to validate requesting node's signature and media address */

net/tipc/msg.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
510510
#define DSC_REQ_MSG 0
511511
#define DSC_RESP_MSG 1
512512

513-
514513
/*
515514
* Word 1
516515
*/
@@ -534,6 +533,16 @@ static inline void msg_set_node_sig(struct tipc_msg *m, u32 n)
534533
msg_set_bits(m, 1, 0, 0xffff, n);
535534
}
536535

536+
static inline u32 msg_node_capabilities(struct tipc_msg *m)
537+
{
538+
return msg_bits(m, 1, 15, 0x1fff);
539+
}
540+
541+
static inline void msg_set_node_capabilities(struct tipc_msg *m, u32 n)
542+
{
543+
msg_set_bits(m, 1, 15, 0x1fff, n);
544+
}
545+
537546

538547
/*
539548
* Word 2

net/tipc/node.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct tipc_node_bclink {
106106
* @list: links to adjacent nodes in sorted list of cluster's nodes
107107
* @working_links: number of working links to node (both active and standby)
108108
* @link_cnt: number of links to node
109+
* @capabilities: bitmap, indicating peer node's functional capabilities
109110
* @signature: node instance identifier
110111
* @link_id: local and remote bearer ids of changing link, if any
111112
* @publ_list: list of publications
@@ -125,7 +126,8 @@ struct tipc_node {
125126
struct tipc_node_bclink bclink;
126127
struct list_head list;
127128
int link_cnt;
128-
int working_links;
129+
u16 working_links;
130+
u16 capabilities;
129131
u32 signature;
130132
u32 link_id;
131133
struct list_head publ_list;

0 commit comments

Comments
 (0)