Print this page
dccp: getting kernel segfaults, back out recent added features
   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2012 David Hoeppner. All rights reserved.
  14  */
  15 
  16 #include <sys/types.h> 
  17 #include <sys/stream.h> 
  18 #include <sys/debug.h> 
  19 #include <sys/cmn_err.h>

  20 #include <inet/dccp_impl.h>
  21 #include <inet/dccp_stack.h>
  22 
  23 /*
  24  * This file contains functions to parse and process DCCP options.
  25  */
  26 
  27 
  28 /*
  29  * Parse the options in a DCCP header.
  30  */
  31 int
  32 dccp_parse_options(dccp_t *dccp, dccpha_t *dccpha)
  33 {
  34         uchar_t         *end;
  35         uchar_t         *up;
  36         uint8_t         dccp_type;
  37         uint32_t        option_value;
  38         uint8_t         option_type;
  39         uint8_t         option_length;


 110                 case DCCP_OPTION_NDP_COUNT:
 111                         cmn_err(CE_NOTE, "NDP COUNT");
 112                         if (option_length > 6)
 113                                 goto option_error;
 114                         break;
 115                 case DCCP_OPTION_ACK_VECTOR_1:
 116                         cmn_err(CE_NOTE, "ACK VECTOR 1");
 117                         break;
 118                 case DCCP_OPTION_ACK_VECTOR_2:
 119                         cmn_err(CE_NOTE, "ACK VECTOR 2");
 120                         break;
 121                 case DCCP_OPTION_DATA_DROPPED:
 122                         cmn_err(CE_NOTE, "DATA DROPPED");
 123                         break;
 124                 case DCCP_OPTION_TIMESTAMP:
 125                         cmn_err(CE_NOTE, "TIMESTAMP");
 126                         if (option_length != 4)
 127                                 goto option_error;
 128 
 129                         /* XXX read unaligned big endian */
 130                         option_value = ((uint8_t)value[0] << 31);



 131                         if (option_value) {
 132                                 cmn_err(CE_NOTE, "Zero timestamp");
 133                                 break;
 134                         }
 135 
 136                         dccp->dccp_timestamp_echo = ntohs(option_value);
 137                         dccp->dccp_timestamp = gethrtime();
 138                         break;
 139                 case DCCP_OPTION_TIMESTAMP_ECHO:
 140                         cmn_err(CE_NOTE, "TIMESTAMP ECHO");
 141                         if (option_length != 4 &&
 142                             option_length != 6 &&
 143                             option_length != 8) {
 144                                 goto option_error;
 145                         }
 146 
 147                         break;
 148                 case DCCP_OPTION_ELAPSED_TIME:
 149                         cmn_err(CE_NOTE, "ELAPSES TIME");
 150                         switch (option_length) {
 151                         case 2:
 152                                 break;
 153                         case 4:
 154                                 break;
 155                         default:
 156                                 goto option_error;
 157                         }


 245                         len++;
 246                         buf[len] = 0;
 247                         len++;
 248                 }
 249 
 250                 if (feature->df_type == DCCP_FEATURE_ECN_INCAPABLE) {
 251                         buf[len] = option_type;
 252                         len++;
 253                         buf[len] = 4;
 254                         len++;
 255                         buf[len] = feature->df_type;
 256                         len++;
 257                         buf[len] = 1;
 258                         len++;
 259                 }
 260         }
 261 
 262         if (dccp->dccp_timestamp_echo != 0) {
 263                 uint32_t        elapsed;
 264                 int             elapsed_length;

 265 
 266                 buf[len] = DCCP_OPTION_TIMESTAMP_ECHO;
 267                 len++;





 268 
 269                 elapsed = gethrtime() - dccp->dccp_timestamp;
 270 
 271                 dccp->dccp_timestamp_echo = 0;
 272         }
 273 
 274         total_len = ((len + (4 - 1)) / 4) * 4;
 275         options = kmem_zalloc(total_len, KM_SLEEP);
 276         if (options == NULL) {
 277                 cmn_err(CE_NOTE, "kmem_zalloc failed");
 278                 return (ENOMEM);
 279         }
 280         memcpy(options, buf, len);
 281 
 282         *opt = options;
 283         *opt_len = len;
 284 
 285         return (0);
 286 }
   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2012 David Hoeppner. All rights reserved.
  14  */
  15 
  16 #include <sys/types.h> 
  17 #include <sys/stream.h> 
  18 #include <sys/debug.h> 
  19 #include <sys/cmn_err.h>
  20 
  21 #include <inet/dccp_impl.h>
  22 #include <inet/dccp_stack.h>
  23 
  24 /*
  25  * This file contains functions to parse and process DCCP options.
  26  */
  27 
  28 
  29 /*
  30  * Parse the options in a DCCP header.
  31  */
  32 int
  33 dccp_parse_options(dccp_t *dccp, dccpha_t *dccpha)
  34 {
  35         uchar_t         *end;
  36         uchar_t         *up;
  37         uint8_t         dccp_type;
  38         uint32_t        option_value;
  39         uint8_t         option_type;
  40         uint8_t         option_length;


 111                 case DCCP_OPTION_NDP_COUNT:
 112                         cmn_err(CE_NOTE, "NDP COUNT");
 113                         if (option_length > 6)
 114                                 goto option_error;
 115                         break;
 116                 case DCCP_OPTION_ACK_VECTOR_1:
 117                         cmn_err(CE_NOTE, "ACK VECTOR 1");
 118                         break;
 119                 case DCCP_OPTION_ACK_VECTOR_2:
 120                         cmn_err(CE_NOTE, "ACK VECTOR 2");
 121                         break;
 122                 case DCCP_OPTION_DATA_DROPPED:
 123                         cmn_err(CE_NOTE, "DATA DROPPED");
 124                         break;
 125                 case DCCP_OPTION_TIMESTAMP:
 126                         cmn_err(CE_NOTE, "TIMESTAMP");
 127                         if (option_length != 4)
 128                                 goto option_error;
 129 
 130                         /* XXX read unaligned big endian */
 131                         option_value = ((uint8_t)value[0] << 24);
 132                         option_value += ((uint8_t)value[1] << 16);
 133                         option_value += ((uint8_t)value[2] << 8);
 134                         option_value += (uint8_t)value[3];
 135                         if (option_value) {
 136                                 cmn_err(CE_NOTE, "Zero timestamp");
 137                                 break;
 138                         }
 139 
 140                         dccp->dccp_timestamp_echo = ntohs(option_value);
 141                         dccp->dccp_timestamp = TICK_TO_MSEC(LBOLT_FASTPATH);
 142                         break;
 143                 case DCCP_OPTION_TIMESTAMP_ECHO:
 144                         cmn_err(CE_NOTE, "TIMESTAMP ECHO");
 145                         if (option_length != 4 &&
 146                             option_length != 6 &&
 147                             option_length != 8) {
 148                                 goto option_error;
 149                         }
 150 
 151                         break;
 152                 case DCCP_OPTION_ELAPSED_TIME:
 153                         cmn_err(CE_NOTE, "ELAPSES TIME");
 154                         switch (option_length) {
 155                         case 2:
 156                                 break;
 157                         case 4:
 158                                 break;
 159                         default:
 160                                 goto option_error;
 161                         }


 249                         len++;
 250                         buf[len] = 0;
 251                         len++;
 252                 }
 253 
 254                 if (feature->df_type == DCCP_FEATURE_ECN_INCAPABLE) {
 255                         buf[len] = option_type;
 256                         len++;
 257                         buf[len] = 4;
 258                         len++;
 259                         buf[len] = feature->df_type;
 260                         len++;
 261                         buf[len] = 1;
 262                         len++;
 263                 }
 264         }
 265 
 266         if (dccp->dccp_timestamp_echo != 0) {
 267                 uint32_t        elapsed;
 268                 int             elapsed_length;
 269                 clock_t         now;
 270 
 271                 buf[len] = DCCP_OPTION_TIMESTAMP_ECHO;
 272                 len++;
 273                 buf[len] = 10;
 274                 len++;
 275 
 276                 now = TICK_TO_MSEC(LBOLT_FASTPATH);
 277                 elapsed =  now - dccp->dccp_timestamp;
 278 

 279 
 280                 dccp->dccp_timestamp_echo = 0;
 281         }
 282 
 283         total_len = ((len + (4 - 1)) / 4) * 4;
 284         options = kmem_zalloc(total_len, KM_SLEEP);
 285         if (options == NULL) {
 286                 cmn_err(CE_NOTE, "kmem_zalloc failed");
 287                 return (ENOMEM);
 288         }
 289         memcpy(options, buf, len);
 290 
 291         *opt = options;
 292         *opt_len = len;
 293 
 294         return (0);
 295 }