diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2007-11-25 01:14:15 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 23:55:02 +0100 |
commit | ce865a61c810c971b47f57c729ec6e9b2d522d94 (patch) | |
tree | 95e3013184679deb4699d416f2431910b9dd5c68 /net/dccp/proto.c | |
parent | [DCCP]: Check for unread data on close (diff) | |
download | linux-ce865a61c810c971b47f57c729ec6e9b2d522d94.tar.xz linux-ce865a61c810c971b47f57c729ec6e9b2d522d94.zip |
[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>
Diffstat (limited to 'net/dccp/proto.c')
-rw-r--r-- | net/dccp/proto.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 5f47b458ed8f..73006b747678 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -276,6 +276,12 @@ static inline int dccp_listen_start(struct sock *sk, int backlog) return inet_csk_listen_start(sk, backlog); } +static inline int dccp_need_reset(int state) +{ + return state != DCCP_CLOSED && state != DCCP_LISTEN && + state != DCCP_REQUESTING; +} + int dccp_disconnect(struct sock *sk, int flags) { struct inet_connection_sock *icsk = inet_csk(sk); @@ -286,10 +292,15 @@ int dccp_disconnect(struct sock *sk, int flags) if (old_state != DCCP_CLOSED) dccp_set_state(sk, DCCP_CLOSED); - /* ABORT function of RFC793 */ + /* + * This corresponds to the ABORT function of RFC793, sec. 3.8 + * TCP uses a RST segment, DCCP a Reset packet with Code 2, "Aborted". + */ if (old_state == DCCP_LISTEN) { inet_csk_listen_stop(sk); - /* FIXME: do the active reset thing */ + } else if (dccp_need_reset(old_state)) { + dccp_send_reset(sk, DCCP_RESET_CODE_ABORTED); + sk->sk_err = ECONNRESET; } else if (old_state == DCCP_REQUESTING) sk->sk_err = ECONNRESET; |