Print this page
10703 smatch unreachable code checking needs reworking
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>


9086                         case IPOPT_TS_PRESPEC:
9087                         case IPOPT_TS_PRESPEC_RFC791:
9088                                 /* Verify that the address matched */
9089                                 off = opt[IPOPT_OFFSET] - 1;
9090                                 bcopy((char *)opt + off, &dst, IP_ADDR_LEN);
9091                                 if (ip_type_v4(dst, ipst) != IRE_LOCAL) {
9092                                         /* Not for us */
9093                                         break;
9094                                 }
9095                                 /* FALLTHROUGH */
9096                         case IPOPT_TS_TSANDADDR:
9097                                 off = IP_ADDR_LEN + IPOPT_TS_TIMELEN;
9098                                 break;
9099                         default:
9100                                 /*
9101                                  * ip_*put_options should have already
9102                                  * dropped this packet.
9103                                  */
9104                                 cmn_err(CE_PANIC, "ip_forward_options: "
9105                                     "unknown IT - bug in ip_input_options?\n");
9106                                 return (B_TRUE);        /* Keep "lint" happy */
9107                         }
9108                         if (opt[IPOPT_OFFSET] - 1 + off > optlen) {
9109                                 /* Increase overflow counter */
9110                                 off = (opt[IPOPT_POS_OV_FLG] >> 4) + 1;
9111                                 opt[IPOPT_POS_OV_FLG] =
9112                                     (uint8_t)((opt[IPOPT_POS_OV_FLG] & 0x0F) |
9113                                     (off << 4));
9114                                 break;
9115                         }
9116                         off = opt[IPOPT_OFFSET] - 1;
9117                         switch (opt[IPOPT_POS_OV_FLG] & 0x0F) {
9118                         case IPOPT_TS_PRESPEC:
9119                         case IPOPT_TS_PRESPEC_RFC791:
9120                         case IPOPT_TS_TSANDADDR:
9121                                 /* Pick a reasonable addr on the outbound if */
9122                                 ASSERT(dst_ill != NULL);
9123                                 if (ip_select_source_v4(dst_ill, INADDR_ANY,
9124                                     dst, INADDR_ANY, ALL_ZONES, ipst, &ifaddr,
9125                                     NULL, NULL) != 0) {
9126                                         /* No source! Shouldn't happen */


9313                         case IPOPT_TS_PRESPEC:
9314                         case IPOPT_TS_PRESPEC_RFC791:
9315                                 /* Verify that the address matched */
9316                                 off = opt[IPOPT_OFFSET] - 1;
9317                                 bcopy((char *)opt + off, &dst, IP_ADDR_LEN);
9318                                 if (ip_type_v4(dst, ipst) != IRE_LOCAL) {
9319                                         /* Not for us */
9320                                         break;
9321                                 }
9322                                 /* FALLTHROUGH */
9323                         case IPOPT_TS_TSANDADDR:
9324                                 off = IP_ADDR_LEN + IPOPT_TS_TIMELEN;
9325                                 break;
9326                         default:
9327                                 /*
9328                                  * ip_*put_options should have already
9329                                  * dropped this packet.
9330                                  */
9331                                 cmn_err(CE_PANIC, "ip_input_local_options: "
9332                                     "unknown IT - bug in ip_input_options?\n");
9333                                 return (B_TRUE);        /* Keep "lint" happy */
9334                         }
9335                         if (opt[IPOPT_OFFSET] - 1 + off > optlen) {
9336                                 /* Increase overflow counter */
9337                                 off = (opt[IPOPT_POS_OV_FLG] >> 4) + 1;
9338                                 opt[IPOPT_POS_OV_FLG] =
9339                                     (uint8_t)((opt[IPOPT_POS_OV_FLG] & 0x0F) |
9340                                     (off << 4));
9341                                 break;
9342                         }
9343                         off = opt[IPOPT_OFFSET] - 1;
9344                         switch (opt[IPOPT_POS_OV_FLG] & 0x0F) {
9345                         case IPOPT_TS_PRESPEC:
9346                         case IPOPT_TS_PRESPEC_RFC791:
9347                         case IPOPT_TS_TSANDADDR:
9348                                 /* Pick a reasonable addr on the outbound if */
9349                                 if (ip_select_source_v4(ill, INADDR_ANY,
9350                                     ipha->ipha_dst, INADDR_ANY, ALL_ZONES, ipst,
9351                                     &ifaddr, NULL, NULL) != 0) {
9352                                         /* No source! Shouldn't happen */
9353                                         ifaddr = INADDR_ANY;


12001                         case IPOPT_TS_PRESPEC:
12002                         case IPOPT_TS_PRESPEC_RFC791:
12003                                 /* Verify that the address matched */
12004                                 off = opt[IPOPT_OFFSET] - 1;
12005                                 bcopy((char *)opt + off, &dst, IP_ADDR_LEN);
12006                                 if (ip_type_v4(dst, ipst) != IRE_LOCAL) {
12007                                         /* Not for us */
12008                                         break;
12009                                 }
12010                                 /* FALLTHROUGH */
12011                         case IPOPT_TS_TSANDADDR:
12012                                 off = IP_ADDR_LEN + IPOPT_TS_TIMELEN;
12013                                 break;
12014                         default:
12015                                 /*
12016                                  * ip_*put_options should have already
12017                                  * dropped this packet.
12018                                  */
12019                                 cmn_err(CE_PANIC, "ip_output_local_options: "
12020                                     "unknown IT - bug in ip_output_options?\n");
12021                                 return; /* Keep "lint" happy */
12022                         }
12023                         if (opt[IPOPT_OFFSET] - 1 + off > optlen) {
12024                                 /* Increase overflow counter */
12025                                 off = (opt[IPOPT_POS_OV_FLG] >> 4) + 1;
12026                                 opt[IPOPT_POS_OV_FLG] = (uint8_t)
12027                                     (opt[IPOPT_POS_OV_FLG] & 0x0F) |
12028                                     (off << 4);
12029                                 break;
12030                         }
12031                         off = opt[IPOPT_OFFSET] - 1;
12032                         switch (opt[IPOPT_POS_OV_FLG] & 0x0F) {
12033                         case IPOPT_TS_PRESPEC:
12034                         case IPOPT_TS_PRESPEC_RFC791:
12035                         case IPOPT_TS_TSANDADDR:
12036                                 dst = htonl(INADDR_LOOPBACK);
12037                                 bcopy(&dst, (char *)opt + off, IP_ADDR_LEN);
12038                                 opt[IPOPT_OFFSET] += IP_ADDR_LEN;
12039                                 /* FALLTHROUGH */
12040                         case IPOPT_TS_TSONLY:
12041                                 off = opt[IPOPT_OFFSET] - 1;




9086                         case IPOPT_TS_PRESPEC:
9087                         case IPOPT_TS_PRESPEC_RFC791:
9088                                 /* Verify that the address matched */
9089                                 off = opt[IPOPT_OFFSET] - 1;
9090                                 bcopy((char *)opt + off, &dst, IP_ADDR_LEN);
9091                                 if (ip_type_v4(dst, ipst) != IRE_LOCAL) {
9092                                         /* Not for us */
9093                                         break;
9094                                 }
9095                                 /* FALLTHROUGH */
9096                         case IPOPT_TS_TSANDADDR:
9097                                 off = IP_ADDR_LEN + IPOPT_TS_TIMELEN;
9098                                 break;
9099                         default:
9100                                 /*
9101                                  * ip_*put_options should have already
9102                                  * dropped this packet.
9103                                  */
9104                                 cmn_err(CE_PANIC, "ip_forward_options: "
9105                                     "unknown IT - bug in ip_input_options?\n");

9106                         }
9107                         if (opt[IPOPT_OFFSET] - 1 + off > optlen) {
9108                                 /* Increase overflow counter */
9109                                 off = (opt[IPOPT_POS_OV_FLG] >> 4) + 1;
9110                                 opt[IPOPT_POS_OV_FLG] =
9111                                     (uint8_t)((opt[IPOPT_POS_OV_FLG] & 0x0F) |
9112                                     (off << 4));
9113                                 break;
9114                         }
9115                         off = opt[IPOPT_OFFSET] - 1;
9116                         switch (opt[IPOPT_POS_OV_FLG] & 0x0F) {
9117                         case IPOPT_TS_PRESPEC:
9118                         case IPOPT_TS_PRESPEC_RFC791:
9119                         case IPOPT_TS_TSANDADDR:
9120                                 /* Pick a reasonable addr on the outbound if */
9121                                 ASSERT(dst_ill != NULL);
9122                                 if (ip_select_source_v4(dst_ill, INADDR_ANY,
9123                                     dst, INADDR_ANY, ALL_ZONES, ipst, &ifaddr,
9124                                     NULL, NULL) != 0) {
9125                                         /* No source! Shouldn't happen */


9312                         case IPOPT_TS_PRESPEC:
9313                         case IPOPT_TS_PRESPEC_RFC791:
9314                                 /* Verify that the address matched */
9315                                 off = opt[IPOPT_OFFSET] - 1;
9316                                 bcopy((char *)opt + off, &dst, IP_ADDR_LEN);
9317                                 if (ip_type_v4(dst, ipst) != IRE_LOCAL) {
9318                                         /* Not for us */
9319                                         break;
9320                                 }
9321                                 /* FALLTHROUGH */
9322                         case IPOPT_TS_TSANDADDR:
9323                                 off = IP_ADDR_LEN + IPOPT_TS_TIMELEN;
9324                                 break;
9325                         default:
9326                                 /*
9327                                  * ip_*put_options should have already
9328                                  * dropped this packet.
9329                                  */
9330                                 cmn_err(CE_PANIC, "ip_input_local_options: "
9331                                     "unknown IT - bug in ip_input_options?\n");

9332                         }
9333                         if (opt[IPOPT_OFFSET] - 1 + off > optlen) {
9334                                 /* Increase overflow counter */
9335                                 off = (opt[IPOPT_POS_OV_FLG] >> 4) + 1;
9336                                 opt[IPOPT_POS_OV_FLG] =
9337                                     (uint8_t)((opt[IPOPT_POS_OV_FLG] & 0x0F) |
9338                                     (off << 4));
9339                                 break;
9340                         }
9341                         off = opt[IPOPT_OFFSET] - 1;
9342                         switch (opt[IPOPT_POS_OV_FLG] & 0x0F) {
9343                         case IPOPT_TS_PRESPEC:
9344                         case IPOPT_TS_PRESPEC_RFC791:
9345                         case IPOPT_TS_TSANDADDR:
9346                                 /* Pick a reasonable addr on the outbound if */
9347                                 if (ip_select_source_v4(ill, INADDR_ANY,
9348                                     ipha->ipha_dst, INADDR_ANY, ALL_ZONES, ipst,
9349                                     &ifaddr, NULL, NULL) != 0) {
9350                                         /* No source! Shouldn't happen */
9351                                         ifaddr = INADDR_ANY;


11999                         case IPOPT_TS_PRESPEC:
12000                         case IPOPT_TS_PRESPEC_RFC791:
12001                                 /* Verify that the address matched */
12002                                 off = opt[IPOPT_OFFSET] - 1;
12003                                 bcopy((char *)opt + off, &dst, IP_ADDR_LEN);
12004                                 if (ip_type_v4(dst, ipst) != IRE_LOCAL) {
12005                                         /* Not for us */
12006                                         break;
12007                                 }
12008                                 /* FALLTHROUGH */
12009                         case IPOPT_TS_TSANDADDR:
12010                                 off = IP_ADDR_LEN + IPOPT_TS_TIMELEN;
12011                                 break;
12012                         default:
12013                                 /*
12014                                  * ip_*put_options should have already
12015                                  * dropped this packet.
12016                                  */
12017                                 cmn_err(CE_PANIC, "ip_output_local_options: "
12018                                     "unknown IT - bug in ip_output_options?\n");

12019                         }
12020                         if (opt[IPOPT_OFFSET] - 1 + off > optlen) {
12021                                 /* Increase overflow counter */
12022                                 off = (opt[IPOPT_POS_OV_FLG] >> 4) + 1;
12023                                 opt[IPOPT_POS_OV_FLG] = (uint8_t)
12024                                     (opt[IPOPT_POS_OV_FLG] & 0x0F) |
12025                                     (off << 4);
12026                                 break;
12027                         }
12028                         off = opt[IPOPT_OFFSET] - 1;
12029                         switch (opt[IPOPT_POS_OV_FLG] & 0x0F) {
12030                         case IPOPT_TS_PRESPEC:
12031                         case IPOPT_TS_PRESPEC_RFC791:
12032                         case IPOPT_TS_TSANDADDR:
12033                                 dst = htonl(INADDR_LOOPBACK);
12034                                 bcopy(&dst, (char *)opt + off, IP_ADDR_LEN);
12035                                 opt[IPOPT_OFFSET] += IP_ADDR_LEN;
12036                                 /* FALLTHROUGH */
12037                         case IPOPT_TS_TSONLY:
12038                                 off = opt[IPOPT_OFFSET] - 1;