Skip to content

Commit 8ea642e

Browse files
Parthasarathy Bhuvaragandavem330
authored andcommitted
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0c288c8 commit 8ea642e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

net/tipc/socket.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,12 @@
4747
#define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */
4848
#define CONN_PROBING_INTERVAL msecs_to_jiffies(3600000) /* [ms] => 1 h */
4949
#define TIPC_FWD_MSG 1
50-
#define TIPC_CONN_OK 0
51-
#define TIPC_CONN_PROBING 1
5250
#define TIPC_MAX_PORT 0xffffffff
5351
#define TIPC_MIN_PORT 1
5452

5553
enum {
5654
TIPC_LISTEN = TCP_LISTEN,
55+
TIPC_ESTABLISHED = TCP_ESTABLISHED,
5756
};
5857

5958
/**
@@ -88,9 +87,9 @@ struct tipc_sock {
8887
struct list_head sock_list;
8988
struct list_head publications;
9089
u32 pub_count;
91-
u32 probing_state;
9290
uint conn_timeout;
9391
atomic_t dupl_rcvcnt;
92+
bool probe_unacked;
9493
bool link_cong;
9594
u16 snt_unacked;
9695
u16 snd_win;
@@ -356,6 +355,11 @@ static int tipc_set_sk_state(struct sock *sk, int state)
356355
if (oldstate == SS_UNCONNECTED)
357356
res = 0;
358357
break;
358+
case TIPC_ESTABLISHED:
359+
if (oldstate == SS_CONNECTING ||
360+
oldstate == SS_UNCONNECTED)
361+
res = 0;
362+
break;
359363
}
360364

361365
if (!res)
@@ -858,7 +862,7 @@ static void tipc_sk_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb,
858862
if (!tsk_peer_msg(tsk, hdr))
859863
goto exit;
860864

861-
tsk->probing_state = TIPC_CONN_OK;
865+
tsk->probe_unacked = false;
862866

863867
if (mtyp == CONN_PROBE) {
864868
msg_set_type(hdr, CONN_PROBE_REPLY);
@@ -1198,8 +1202,8 @@ static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port,
11981202
msg_set_lookup_scope(msg, 0);
11991203
msg_set_hdr_sz(msg, SHORT_H_SIZE);
12001204

1201-
tsk->probing_state = TIPC_CONN_OK;
12021205
sk_reset_timer(sk, &sk->sk_timer, jiffies + CONN_PROBING_INTERVAL);
1206+
tipc_set_sk_state(sk, TIPC_ESTABLISHED);
12031207
tipc_node_add_conn(net, peer_node, tsk->portid, peer_port);
12041208
tsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid);
12051209
tsk->peer_caps = tipc_node_get_capabilities(net, peer_node);
@@ -2263,7 +2267,7 @@ static void tipc_sk_timeout(unsigned long data)
22632267
peer_port = tsk_peer_port(tsk);
22642268
peer_node = tsk_peer_node(tsk);
22652269

2266-
if (tsk->probing_state == TIPC_CONN_PROBING) {
2270+
if (tsk->probe_unacked) {
22672271
if (!sock_owned_by_user(sk)) {
22682272
sk->sk_socket->state = SS_DISCONNECTING;
22692273
tipc_node_remove_conn(sock_net(sk), tsk_peer_node(tsk),
@@ -2281,7 +2285,7 @@ static void tipc_sk_timeout(unsigned long data)
22812285
skb = tipc_msg_create(CONN_MANAGER, CONN_PROBE,
22822286
INT_H_SIZE, 0, peer_node, own_node,
22832287
peer_port, tsk->portid, TIPC_OK);
2284-
tsk->probing_state = TIPC_CONN_PROBING;
2288+
tsk->probe_unacked = true;
22852289
sk_reset_timer(sk, &sk->sk_timer, jiffies + CONN_PROBING_INTERVAL);
22862290
bh_unlock_sock(sk);
22872291
if (skb)

0 commit comments

Comments
 (0)