aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/socket.c
diff options
context:
space:
mode:
authorParthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>2016-11-01 09:02:44 -0400
committerDavid S. Miller <davem@davemloft.net>2016-11-01 11:53:25 -0400
commit8ea642ee9a0dbcb25aace4cfd0ed41aeee893a7f (patch)
treeaee4e9de914295b93faadd02e0c7987d4bccbe67 /net/tipc/socket.c
parent0c288c86928e50d6d8d2efa4ca23dca58d28543e (diff)
tipc: create TIPC_ESTABLISHED as a new sk_state
Until now, tipc maintains probing state for connected sockets in tsk->probing_state variable. In this commit, we express this information as socket states and this remove the variable. We set probe_unacked flag when a probe is sent out and reset it if we receive a reply. Instead of the probing state TIPC_CONN_OK, we create a new state TIPC_ESTABLISHED. There is no functional change in this commit. Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/socket.c')
-rw-r--r--net/tipc/socket.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index ce7d9be8833c..9215e2144b6a 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -47,13 +47,12 @@
47#define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */ 47#define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */
48#define CONN_PROBING_INTERVAL msecs_to_jiffies(3600000) /* [ms] => 1 h */ 48#define CONN_PROBING_INTERVAL msecs_to_jiffies(3600000) /* [ms] => 1 h */
49#define TIPC_FWD_MSG 1 49#define TIPC_FWD_MSG 1
50#define TIPC_CONN_OK 0
51#define TIPC_CONN_PROBING 1
52#define TIPC_MAX_PORT 0xffffffff 50#define TIPC_MAX_PORT 0xffffffff
53#define TIPC_MIN_PORT 1 51#define TIPC_MIN_PORT 1
54 52
55enum { 53enum {
56 TIPC_LISTEN = TCP_LISTEN, 54 TIPC_LISTEN = TCP_LISTEN,
55 TIPC_ESTABLISHED = TCP_ESTABLISHED,
57}; 56};
58 57
59/** 58/**
@@ -88,9 +87,9 @@ struct tipc_sock {
88 struct list_head sock_list; 87 struct list_head sock_list;
89 struct list_head publications; 88 struct list_head publications;
90 u32 pub_count; 89 u32 pub_count;
91 u32 probing_state;
92 uint conn_timeout; 90 uint conn_timeout;
93 atomic_t dupl_rcvcnt; 91 atomic_t dupl_rcvcnt;
92 bool probe_unacked;
94 bool link_cong; 93 bool link_cong;
95 u16 snt_unacked; 94 u16 snt_unacked;
96 u16 snd_win; 95 u16 snd_win;
@@ -356,6 +355,11 @@ static int tipc_set_sk_state(struct sock *sk, int state)
356 if (oldstate == SS_UNCONNECTED) 355 if (oldstate == SS_UNCONNECTED)
357 res = 0; 356 res = 0;
358 break; 357 break;
358 case TIPC_ESTABLISHED:
359 if (oldstate == SS_CONNECTING ||
360 oldstate == SS_UNCONNECTED)
361 res = 0;
362 break;
359 } 363 }
360 364
361 if (!res) 365 if (!res)
@@ -858,7 +862,7 @@ static void tipc_sk_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb,
858 if (!tsk_peer_msg(tsk, hdr)) 862 if (!tsk_peer_msg(tsk, hdr))
859 goto exit; 863 goto exit;
860 864
861 tsk->probing_state = TIPC_CONN_OK; 865 tsk->probe_unacked = false;
862 866
863 if (mtyp == CONN_PROBE) { 867 if (mtyp == CONN_PROBE) {
864 msg_set_type(hdr, CONN_PROBE_REPLY); 868 msg_set_type(hdr, CONN_PROBE_REPLY);
@@ -1198,8 +1202,8 @@ static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port,
1198 msg_set_lookup_scope(msg, 0); 1202 msg_set_lookup_scope(msg, 0);
1199 msg_set_hdr_sz(msg, SHORT_H_SIZE); 1203 msg_set_hdr_sz(msg, SHORT_H_SIZE);
1200 1204
1201 tsk->probing_state = TIPC_CONN_OK;
1202 sk_reset_timer(sk, &sk->sk_timer, jiffies + CONN_PROBING_INTERVAL); 1205 sk_reset_timer(sk, &sk->sk_timer, jiffies + CONN_PROBING_INTERVAL);
1206 tipc_set_sk_state(sk, TIPC_ESTABLISHED);
1203 tipc_node_add_conn(net, peer_node, tsk->portid, peer_port); 1207 tipc_node_add_conn(net, peer_node, tsk->portid, peer_port);
1204 tsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid); 1208 tsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid);
1205 tsk->peer_caps = tipc_node_get_capabilities(net, peer_node); 1209 tsk->peer_caps = tipc_node_get_capabilities(net, peer_node);
@@ -2263,7 +2267,7 @@ static void tipc_sk_timeout(unsigned long data)
2263 peer_port = tsk_peer_port(tsk); 2267 peer_port = tsk_peer_port(tsk);
2264 peer_node = tsk_peer_node(tsk); 2268 peer_node = tsk_peer_node(tsk);
2265 2269
2266 if (tsk->probing_state == TIPC_CONN_PROBING) { 2270 if (tsk->probe_unacked) {
2267 if (!sock_owned_by_user(sk)) { 2271 if (!sock_owned_by_user(sk)) {
2268 sk->sk_socket->state = SS_DISCONNECTING; 2272 sk->sk_socket->state = SS_DISCONNECTING;
2269 tipc_node_remove_conn(sock_net(sk), tsk_peer_node(tsk), 2273 tipc_node_remove_conn(sock_net(sk), tsk_peer_node(tsk),
@@ -2281,7 +2285,7 @@ static void tipc_sk_timeout(unsigned long data)
2281 skb = tipc_msg_create(CONN_MANAGER, CONN_PROBE, 2285 skb = tipc_msg_create(CONN_MANAGER, CONN_PROBE,
2282 INT_H_SIZE, 0, peer_node, own_node, 2286 INT_H_SIZE, 0, peer_node, own_node,
2283 peer_port, tsk->portid, TIPC_OK); 2287 peer_port, tsk->portid, TIPC_OK);
2284 tsk->probing_state = TIPC_CONN_PROBING; 2288 tsk->probe_unacked = true;
2285 sk_reset_timer(sk, &sk->sk_timer, jiffies + CONN_PROBING_INTERVAL); 2289 sk_reset_timer(sk, &sk->sk_timer, jiffies + CONN_PROBING_INTERVAL);
2286 bh_unlock_sock(sk); 2290 bh_unlock_sock(sk);
2287 if (skb) 2291 if (skb)