aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2016-05-02 11:58:46 -0400
committerDavid S. Miller <davem@davemloft.net>2016-05-03 15:51:15 -0400
commit60020e1857042387cdcd4cd6680a9e5496213379 (patch)
treeb0cff474233a2bd0f37734942f23afd3213486ad /net
parent7c8bcfb1255fe9d929c227d67bdcd84430fd200b (diff)
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>
Diffstat (limited to 'net')
-rw-r--r--net/tipc/node.c21
-rw-r--r--net/tipc/node.h1
-rw-r--r--net/tipc/socket.c2
3 files changed, 22 insertions, 2 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c
index c29915688230..29cc85319327 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * net/tipc/node.c: TIPC node management routines 2 * net/tipc/node.c: TIPC node management routines
3 * 3 *
4 * Copyright (c) 2000-2006, 2012-2015, Ericsson AB 4 * Copyright (c) 2000-2006, 2012-2016, Ericsson AB
5 * Copyright (c) 2005-2006, 2010-2014, Wind River Systems 5 * Copyright (c) 2005-2006, 2010-2014, Wind River Systems
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
@@ -191,6 +191,20 @@ int tipc_node_get_mtu(struct net *net, u32 addr, u32 sel)
191 tipc_node_put(n); 191 tipc_node_put(n);
192 return mtu; 192 return mtu;
193} 193}
194
195u16 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
194/* 208/*
195 * A trivial power-of-two bitmask technique is used for speed, since this 209 * A trivial power-of-two bitmask technique is used for speed, since this
196 * operation is done for every incoming TIPC packet. The number of hash table 210 * 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)
304 318
305 spin_lock_bh(&tn->node_list_lock); 319 spin_lock_bh(&tn->node_list_lock);
306 n = tipc_node_find(net, addr); 320 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;
308 goto exit; 324 goto exit;
325 }
309 n = kzalloc(sizeof(*n), GFP_ATOMIC); 326 n = kzalloc(sizeof(*n), GFP_ATOMIC);
310 if (!n) { 327 if (!n) {
311 pr_warn("Node creation failed, no memory\n"); 328 pr_warn("Node creation failed, no memory\n");
diff --git a/net/tipc/node.h b/net/tipc/node.h
index f39d9d06e8bb..18237684ffc4 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -70,6 +70,7 @@ void tipc_node_broadcast(struct net *net, struct sk_buff *skb);
70int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port); 70int tipc_node_add_conn(struct net *net, u32 dnode, u32 port, u32 peer_port);
71void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port); 71void tipc_node_remove_conn(struct net *net, u32 dnode, u32 port);
72int tipc_node_get_mtu(struct net *net, u32 addr, u32 sel); 72int tipc_node_get_mtu(struct net *net, u32 addr, u32 sel);
73u16 tipc_node_get_capabilities(struct net *net, u32 addr);
73int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb); 74int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb);
74int tipc_nl_node_dump_link(struct sk_buff *skb, struct netlink_callback *cb); 75int tipc_nl_node_dump_link(struct sk_buff *skb, struct netlink_callback *cb);
75int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info); 76int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info);
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index d37a9401e182..94bd28639855 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -98,6 +98,7 @@ struct tipc_sock {
98 bool link_cong; 98 bool link_cong;
99 uint sent_unacked; 99 uint sent_unacked;
100 uint rcv_unacked; 100 uint rcv_unacked;
101 u16 peer_caps;
101 struct sockaddr_tipc remote; 102 struct sockaddr_tipc remote;
102 struct rhash_head node; 103 struct rhash_head node;
103 struct rcu_head rcu; 104 struct rcu_head rcu;
@@ -1118,6 +1119,7 @@ static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port,
1118 sk_reset_timer(sk, &sk->sk_timer, jiffies + tsk->probing_intv); 1119 sk_reset_timer(sk, &sk->sk_timer, jiffies + tsk->probing_intv);
1119 tipc_node_add_conn(net, peer_node, tsk->portid, peer_port); 1120 tipc_node_add_conn(net, peer_node, tsk->portid, peer_port);
1120 tsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid); 1121 tsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid);
1122 tsk->peer_caps = tipc_node_get_capabilities(net, peer_node);
1121} 1123}
1122 1124
1123/** 1125/**