Skip to content

Commit 60020e1

Browse files
Jon Paul Maloydavem330
authored andcommitted
tipc: propagate peer node capabilities to socket layer
During neighbor discovery, nodes advertise their capabilities as a bit map in a dedicated 16-bit field in the discovery message header. This bit map has so far only be stored in the node structure on the peer nodes, but we now see the need to keep a copy even in the socket structure. This commit adds this functionality. 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>
1 parent 7c8bcfb commit 60020e1

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

‎net/tipc/node.c‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* net/tipc/node.c: TIPC node management routines
33
*
4-
* Copyright (c) 2000-2006, 2012-2015, Ericsson AB
4+
* Copyright (c) 2000-2006, 2012-2016, Ericsson AB
55
* Copyright (c) 2005-2006, 2010-2014, Wind River Systems
66
* All rights reserved.
77
*
@@ -191,6 +191,20 @@ int tipc_node_get_mtu(struct net *net, u32 addr, u32 sel)
191191
tipc_node_put(n);
192192
return mtu;
193193
}
194+
195+
u16 tipc_node_get_capabilities(struct net *net, u32 addr)
196+
{
197+
struct tipc_node *n;
198+
u16 caps;
199+
200+
n = tipc_node_find(net, addr);
201+
if (unlikely(!n))
202+
return TIPC_NODE_CAPABILITIES;
203+
caps = n->capabilities;
204+
tipc_node_put(n);
205+
return caps;
206+
}
207+
194208
/*
195209
* A trivial power-of-two bitmask technique is used for speed, since this
196210
* operation is done for every incoming TIPC packet. The number of hash table
@@ -304,8 +318,11 @@ struct tipc_node *tipc_node_create(struct net *net, u32 addr, u16 capabilities)
304318

305319
spin_lock_bh(&tn->node_list_lock);
306320
n = tipc_node_find(net, addr);
307-
if (n)
321+
if (n) {
322+
/* Same node may come back with new capabilities */
323+
n->capabilities = capabilities;
308324
goto exit;
325+
}
309326
n = kzalloc(sizeof(*n), GFP_ATOMIC);
310327
if (!n) {
311328
pr_warn("Node creation failed, no memory\n");

‎net/tipc/node.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void tipc_node_broadcast(struct net *net, struct sk_buff *skb);
7070
int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port);
7171
void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port);
7272
int tipc_node_get_mtu(struct net *net, u32 addr, u32 sel);
73+
u16 tipc_node_get_capabilities(struct net *net, u32 addr);
7374
int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb);
7475
int tipc_nl_node_dump_link(struct sk_buff *skb, struct netlink_callback *cb);
7576
int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info);

‎net/tipc/socket.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ struct tipc_sock {
9898
bool link_cong;
9999
uint sent_unacked;
100100
uint rcv_unacked;
101+
u16 peer_caps;
101102
struct sockaddr_tipc remote;
102103
struct rhash_head node;
103104
struct rcu_head rcu;
@@ -1118,6 +1119,7 @@ static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port,
11181119
sk_reset_timer(sk, &sk->sk_timer, jiffies + tsk->probing_intv);
11191120
tipc_node_add_conn(net, peer_node, tsk->portid, peer_port);
11201121
tsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid);
1122+
tsk->peer_caps = tipc_node_get_capabilities(net, peer_node);
11211123
}
11221124

11231125
/**

0 commit comments

Comments
 (0)