All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gerrit Renker <gerrit@erg.abdn.ac.uk>
To: dccp@vger.kernel.org
Subject: [PATCH 9/11]: Fill in the Data1..3 fields when option processing encounters option errors
Date: Mon, 01 Oct 2007 14:18:31 +0000	[thread overview]
Message-ID: <200710011518.31492@strip-the-willow> (raw)

[DCCP]: Fill in the Data1..3 fields when option processing encounters option errors

DCCP provides the Data 1..3 fields in the Reset header to carry information
about why the connection was reset. An earlier patch provided basic support,
this patch extends the capabilities by adding Reset information when processing
erroneous options.
This support will be made use of by the next two patches which process Change/
Confirm feature-negotiation options.

Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
---
 net/dccp/options.c |   18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

--- a/net/dccp/options.c
+++ b/net/dccp/options.c
@@ -64,7 +64,7 @@ int dccp_parse_options(struct sock *sk, 
 	unsigned char opt, len;
 	unsigned char *value;
 	u32 elapsed_time, opt_val;
-	int rc;
+	u8 rc = DCCP_RESET_CODE_OPTION_ERROR;
 	int mandatory = 0;
 
 	memset(opt_recv, 0, sizeof(*opt_recv));
@@ -81,16 +81,16 @@ int dccp_parse_options(struct sock *sk, 
 				goto out_invalid_option;
 
 			len = *opt_ptr++;
-			if (len < 3)
-				goto out_invalid_option;
 			/*
 			 * Remove the type and len fields, leaving
 			 * just the value size
 			 */
-			len	-= 2;
 			value	= opt_ptr;
+			len	-= 2;
 			opt_ptr += len;
 
+			if (len = 0)
+				goto out_invalid_option;
 			if (opt_ptr > opt_end)
 				goto out_invalid_option;
 		}
@@ -282,8 +282,14 @@ ignore_option:
 
 out_invalid_option:
 	DCCP_INC_STATS_BH(DCCP_MIB_INVALIDOPT);
-	DCCP_SKB_CB(skb)->dccpd_reset_code = DCCP_RESET_CODE_OPTION_ERROR;
-	DCCP_WARN("DCCP(%p): invalid option %d, len=%d", sk, opt, len);
+	DCCP_WARN("DCCP(%p): Option %d (len=%d) error=%u\n", sk, opt, len, rc);
+	DCCP_SKB_CB(skb)->dccpd_reset_code = rc;
+	if (rc = DCCP_RESET_CODE_OPTION_ERROR ||
+	    rc = DCCP_RESET_CODE_MANDATORY_ERROR) {
+		DCCP_SKB_CB(skb)->dccpd_reset_data[0] = opt;
+		DCCP_SKB_CB(skb)->dccpd_reset_data[1] = len > 0? value[0] : 0;
+		DCCP_SKB_CB(skb)->dccpd_reset_data[2] = len > 1? value[1] : 0;
+	}
 	return -1;
 }
 

             reply	other threads:[~2007-10-01 14:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-01 14:18 Gerrit Renker [this message]
2007-10-01 23:20 ` [PATCH 9/11]: Fill in the Data1..3 fields when option processing encounters option errors Ian McDonald

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200710011518.31492@strip-the-willow \
    --to=gerrit@erg.abdn.ac.uk \
    --cc=dccp@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.