Print this page
6394 ::mac_flow -s segfaults
Reviewed by: Jason King <jason.brian.king@gmail.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/mdb/common/modules/mac/mac.c
          +++ new/usr/src/cmd/mdb/common/modules/mac/mac.c
↓ open down ↓ 320 lines elided ↑ open up ↑
 321  321                  txaddr = addr + OFFSETOF(flow_entry_t, fe_tx_srs);
 322  322                  (void) mdb_vread(&tx_srs, sizeof (uintptr_t), txaddr);
 323  323                  mdb_printf("%?p %-32s %?p\n",
 324  324                      addr, fe.fe_flow_name, fe.fe_tx_srs);
 325  325                  break;
 326  326          }
 327  327          case MAC_FLOW_STATS: {
 328  328                  uint64_t                totibytes = 0;
 329  329                  uint64_t                totobytes = 0;
 330  330                  mac_soft_ring_set_t     *mac_srs;
 331      -                mac_rx_stats_t          *mac_rx_stat;
 332      -                mac_tx_stats_t          *mac_tx_stat;
      331 +                mac_rx_stats_t          mac_rx_stat;
      332 +                mac_tx_stats_t          mac_tx_stat;
 333  333                  int                     i;
 334  334  
      335 +                /*
      336 +                 * Sum bytes for all Rx SRS.
      337 +                 */
 335  338                  for (i = 0; i < fe.fe_rx_srs_cnt; i++) {
 336  339                          mac_srs = (mac_soft_ring_set_t *)(fe.fe_rx_srs[i]);
 337      -                        mac_rx_stat = &mac_srs->srs_rx.sr_stat;
 338      -                        totibytes += mac_rx_stat->mrs_intrbytes +
 339      -                            mac_rx_stat->mrs_pollbytes +
 340      -                            mac_rx_stat->mrs_lclbytes;
      340 +                        if (mdb_vread(&mac_rx_stat, sizeof (mac_rx_stats_t),
      341 +                            (uintptr_t)&mac_srs->srs_rx.sr_stat) == -1) {
      342 +                                mdb_warn("failed to read mac_rx_stats_t at %p",
      343 +                                    &mac_srs->srs_rx.sr_stat);
      344 +                                return (DCMD_ERR);
      345 +                        }
      346 +
      347 +                        totibytes += mac_rx_stat.mrs_intrbytes +
      348 +                            mac_rx_stat.mrs_pollbytes +
      349 +                            mac_rx_stat.mrs_lclbytes;
 341  350                  }
      351 +
      352 +                /*
      353 +                 * Sum bytes for Tx SRS.
      354 +                 */
 342  355                  mac_srs = (mac_soft_ring_set_t *)(fe.fe_tx_srs);
 343  356                  if (mac_srs != NULL) {
 344      -                        mac_tx_stat = &mac_srs->srs_tx.st_stat;
 345      -                        totobytes = mac_tx_stat->mts_obytes;
      357 +                        if (mdb_vread(&mac_tx_stat, sizeof (mac_tx_stats_t),
      358 +                            (uintptr_t)&mac_srs->srs_tx.st_stat) == -1) {
      359 +                                mdb_warn("failed to read max_tx_stats_t at %p",
      360 +                                    &mac_srs->srs_tx.st_stat);
      361 +                                return (DCMD_ERR);
      362 +                        }
      363 +
      364 +                        totobytes = mac_tx_stat.mts_obytes;
 346  365                  }
      366 +
 347  367                  mdb_printf("%?p %-32s %16llu %16llu\n",
 348  368                      addr, fe.fe_flow_name, totibytes, totobytes);
 349  369  
 350  370                  break;
 351  371          }
 352  372          }
 353  373          return (DCMD_OK);
 354  374  }
 355  375  
 356  376  /*
↓ open down ↓ 893 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX