All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 9/11]: Fill in the Data1..3 fields when option processing encounters option errors
@ 2007-10-01 14:18 Gerrit Renker
  2007-10-01 23:20 ` Ian McDonald
  0 siblings, 1 reply; 2+ messages in thread
From: Gerrit Renker @ 2007-10-01 14:18 UTC (permalink / raw)
  To: dccp

[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;
 }
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 9/11]: Fill in the Data1..3 fields when option processing encounters option errors
  2007-10-01 14:18 [PATCH 9/11]: Fill in the Data1..3 fields when option processing encounters option errors Gerrit Renker
@ 2007-10-01 23:20 ` Ian McDonald
  0 siblings, 0 replies; 2+ messages in thread
From: Ian McDonald @ 2007-10-01 23:20 UTC (permalink / raw)
  To: dccp

On 10/2/07, Gerrit Renker <gerrit@erg.abdn.ac.uk> wrote:
> [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>

Acked-by: Ian McDonald <ian.mcdonald@jandi.co.nz>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-10-01 23:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-01 14:18 [PATCH 9/11]: Fill in the Data1..3 fields when option processing encounters option errors Gerrit Renker
2007-10-01 23:20 ` Ian McDonald

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.