Skip to content

Commit ce865a6

Browse files
Gerrit Renkerdavem330
authored andcommitted
[DCCP]: Add support for abortive release
This continues from the previous patch and adds support for actively aborting a DCCP connection, using a Reset Code 2, "Aborted" to inform the peer of an abortive release. I have tried this in various client/server settings and it works as expected. Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk> Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d83bd95 commit ce865a6

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎net/dccp/proto.c‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,12 @@ static inline int dccp_listen_start(struct sock *sk, int backlog)
276276
return inet_csk_listen_start(sk, backlog);
277277
}
278278

279+
static inline int dccp_need_reset(int state)
280+
{
281+
return state != DCCP_CLOSED && state != DCCP_LISTEN &&
282+
state != DCCP_REQUESTING;
283+
}
284+
279285
int dccp_disconnect(struct sock *sk, int flags)
280286
{
281287
struct inet_connection_sock *icsk = inet_csk(sk);
@@ -286,10 +292,15 @@ int dccp_disconnect(struct sock *sk, int flags)
286292
if (old_state != DCCP_CLOSED)
287293
dccp_set_state(sk, DCCP_CLOSED);
288294

289-
/* ABORT function of RFC793 */
295+
/*
296+
* This corresponds to the ABORT function of RFC793, sec. 3.8
297+
* TCP uses a RST segment, DCCP a Reset packet with Code 2, "Aborted".
298+
*/
290299
if (old_state == DCCP_LISTEN) {
291300
inet_csk_listen_stop(sk);
292-
/* FIXME: do the active reset thing */
301+
} else if (dccp_need_reset(old_state)) {
302+
dccp_send_reset(sk, DCCP_RESET_CODE_ABORTED);
303+
sk->sk_err = ECONNRESET;
293304
} else if (old_state == DCCP_REQUESTING)
294305
sk->sk_err = ECONNRESET;
295306

0 commit comments

Comments
 (0)