Print this page
XXXX adding PID information to netstat output

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/udp/udp_stats.c
          +++ new/usr/src/uts/common/inet/udp/udp_stats.c
↓ open down ↓ 45 lines elided ↑ open up ↑
  46   46  /*
  47   47   * return SNMP stuff in buffer in mpdata. We don't hold any lock and report
  48   48   * information that can be changing beneath us.
  49   49   */
  50   50  mblk_t *
  51   51  udp_snmp_get(queue_t *q, mblk_t *mpctl, boolean_t legacy_req)
  52   52  {
  53   53          mblk_t                  *mpdata;
  54   54          mblk_t                  *mp_conn_ctl;
  55   55          mblk_t                  *mp_attr_ctl;
       56 +        mblk_t                  *mp_pidnode_ctl;
  56   57          mblk_t                  *mp6_conn_ctl;
  57   58          mblk_t                  *mp6_attr_ctl;
       59 +        mblk_t                  *mp6_pidnode_ctl;
  58   60          mblk_t                  *mp_conn_tail;
  59   61          mblk_t                  *mp_attr_tail;
       62 +        mblk_t                  *mp_pidnode_tail;
  60   63          mblk_t                  *mp6_conn_tail;
  61   64          mblk_t                  *mp6_attr_tail;
       65 +        mblk_t                  *mp6_pidnode_tail;
  62   66          struct opthdr           *optp;
  63   67          mib2_udpEntry_t         ude;
  64   68          mib2_udp6Entry_t        ude6;
  65   69          mib2_transportMLPEntry_t mlp;
  66   70          int                     state;
  67   71          zoneid_t                zoneid;
  68   72          int                     i;
  69   73          connf_t                 *connfp;
  70   74          conn_t                  *connp = Q_TO_CONN(q);
  71   75          int                     v4_conn_idx;
  72   76          int                     v6_conn_idx;
  73   77          boolean_t               needattr;
  74   78          udp_t                   *udp;
  75   79          ip_stack_t              *ipst = connp->conn_netstack->netstack_ip;
  76   80          udp_stack_t             *us = connp->conn_netstack->netstack_udp;
  77   81          mblk_t                  *mp2ctl;
  78   82          mib2_udp_t              udp_mib;
  79   83          size_t                  udp_mib_size, ude_size, ude6_size;
  80   84  
  81      -
  82   85          /*
  83   86           * make a copy of the original message
  84   87           */
  85   88          mp2ctl = copymsg(mpctl);
  86   89  
  87   90          mp_conn_ctl = mp_attr_ctl = mp6_conn_ctl = NULL;
  88   91          if (mpctl == NULL ||
  89   92              (mpdata = mpctl->b_cont) == NULL ||
  90   93              (mp_conn_ctl = copymsg(mpctl)) == NULL ||
  91   94              (mp_attr_ctl = copymsg(mpctl)) == NULL ||
       95 +            (mp_pidnode_ctl = copymsg(mpctl)) == NULL ||
  92   96              (mp6_conn_ctl = copymsg(mpctl)) == NULL ||
  93      -            (mp6_attr_ctl = copymsg(mpctl)) == NULL) {
       97 +            (mp6_attr_ctl = copymsg(mpctl)) == NULL ||
       98 +            (mp6_pidnode_ctl = copymsg(mpctl)) == NULL) {
  94   99                  freemsg(mp_conn_ctl);
  95  100                  freemsg(mp_attr_ctl);
      101 +                freemsg(mp_pidnode_ctl);
  96  102                  freemsg(mp6_conn_ctl);
      103 +                freemsg(mp6_attr_ctl);
      104 +                freemsg(mp6_pidnode_ctl);
  97  105                  freemsg(mpctl);
  98  106                  freemsg(mp2ctl);
  99  107                  return (0);
 100  108          }
 101  109  
 102  110          zoneid = connp->conn_zoneid;
 103  111  
 104  112          if (legacy_req) {
 105  113                  udp_mib_size = LEGACY_MIB_SIZE(&udp_mib, mib2_udp_t);
 106  114                  ude_size = LEGACY_MIB_SIZE(&ude, mib2_udpEntry_t);
↓ open down ↓ 21 lines elided ↑ open up ↑
 128  136          SYNC32_MIB(&udp_mib, udpOutDatagrams, udpHCOutDatagrams);
 129  137  
 130  138          optp = (struct opthdr *)&mpctl->b_rptr[sizeof (struct T_optmgmt_ack)];
 131  139          optp->level = MIB2_UDP;
 132  140          optp->name = 0;
 133  141          (void) snmp_append_data(mpdata, (char *)&udp_mib, udp_mib_size);
 134  142          optp->len = msgdsize(mpdata);
 135  143          qreply(q, mpctl);
 136  144  
 137  145          mp_conn_tail = mp_attr_tail = mp6_conn_tail = mp6_attr_tail = NULL;
      146 +        mp_pidnode_tail = mp6_pidnode_tail = NULL;
 138  147          v4_conn_idx = v6_conn_idx = 0;
 139  148  
 140  149          for (i = 0; i < CONN_G_HASH_SIZE; i++) {
 141  150                  connfp = &ipst->ips_ipcl_globalhash_fanout[i];
 142  151                  connp = NULL;
 143  152  
 144  153                  while ((connp = ipcl_get_next_conn(connfp, connp,
 145  154                      IPCL_UDPCONN))) {
 146  155                          udp = connp->conn_udp;
 147  156                          if (zoneid != connp->conn_zoneid)
↓ open down ↓ 94 lines elided ↑ open up ↑
 242  251                                   */
 243  252                                  ude.udpInstance = (uint32_t)(uintptr_t)udp;
 244  253                                  ude.udpCreationProcess =
 245  254                                      (connp->conn_cpid < 0) ?
 246  255                                      MIB2_UNKNOWN_PROCESS :
 247  256                                      connp->conn_cpid;
 248  257                                  ude.udpCreationTime = connp->conn_open_time;
 249  258  
 250  259                                  (void) snmp_append_data2(mp_conn_ctl->b_cont,
 251  260                                      &mp_conn_tail, (char *)&ude, ude_size);
      261 +
      262 +                                (void) snmp_append_data2(mp_pidnode_ctl->b_cont,
      263 +                                    &mp_pidnode_tail, (char *)&ude, ude_size);
      264 +
      265 +                                (void) snmp_append_mblk2(mp_pidnode_ctl->b_cont,
      266 +                                    &mp_pidnode_tail, conn_get_pid_mblk(connp));
      267 +
 252  268                                  mlp.tme_connidx = v4_conn_idx++;
 253  269                                  if (needattr)
 254  270                                          (void) snmp_append_data2(
 255  271                                              mp_attr_ctl->b_cont, &mp_attr_tail,
 256  272                                              (char *)&mlp, sizeof (mlp));
 257  273                          }
 258  274                          if (connp->conn_ipversion == IPV6_VERSION) {
 259  275                                  ude6.udp6EntryInfo.ue_state  = state;
 260  276                                  ude6.udp6LocalAddress = connp->conn_laddr_v6;
 261  277                                  ude6.udp6LocalPort = ntohs(connp->conn_lport);
↓ open down ↓ 23 lines elided ↑ open up ↑
 285  301                                   */
 286  302                                  ude6.udp6Instance = (uint32_t)(uintptr_t)udp;
 287  303                                  ude6.udp6CreationProcess =
 288  304                                      (connp->conn_cpid < 0) ?
 289  305                                      MIB2_UNKNOWN_PROCESS :
 290  306                                      connp->conn_cpid;
 291  307                                  ude6.udp6CreationTime = connp->conn_open_time;
 292  308  
 293  309                                  (void) snmp_append_data2(mp6_conn_ctl->b_cont,
 294  310                                      &mp6_conn_tail, (char *)&ude6, ude6_size);
      311 +
      312 +                                (void) snmp_append_data2(
      313 +                                    mp6_pidnode_ctl->b_cont, &mp6_pidnode_tail,
      314 +                                    (char *)&ude6, ude6_size);
      315 +
      316 +                                (void) snmp_append_mblk2(
      317 +                                    mp6_pidnode_ctl->b_cont, &mp6_pidnode_tail,
      318 +                                    conn_get_pid_mblk(connp));
      319 +
 295  320                                  mlp.tme_connidx = v6_conn_idx++;
 296  321                                  if (needattr)
 297  322                                          (void) snmp_append_data2(
 298  323                                              mp6_attr_ctl->b_cont,
 299  324                                              &mp6_attr_tail, (char *)&mlp,
 300  325                                              sizeof (mlp));
 301  326                          }
 302  327                  }
 303  328          }
 304  329  
↓ open down ↓ 9 lines elided ↑ open up ↑
 314  339          optp = (struct opthdr *)&mp_attr_ctl->b_rptr[
 315  340              sizeof (struct T_optmgmt_ack)];
 316  341          optp->level = MIB2_UDP;
 317  342          optp->name = EXPER_XPORT_MLP;
 318  343          optp->len = msgdsize(mp_attr_ctl->b_cont);
 319  344          if (optp->len == 0)
 320  345                  freemsg(mp_attr_ctl);
 321  346          else
 322  347                  qreply(q, mp_attr_ctl);
 323  348  
      349 +        /* table of EXPER_XPORT_PROC_INFO ipv4 */
      350 +        optp = (struct opthdr *)&mp_pidnode_ctl->b_rptr[
      351 +            sizeof (struct T_optmgmt_ack)];
      352 +        optp->level = MIB2_UDP;
      353 +        optp->name = EXPER_XPORT_PROC_INFO;
      354 +        optp->len = msgdsize(mp_pidnode_ctl->b_cont);
      355 +        if (optp->len == 0)
      356 +                freemsg(mp_pidnode_ctl);
      357 +        else
      358 +                qreply(q, mp_pidnode_ctl);
      359 +
 324  360          /* IPv6 UDP endpoints */
 325  361          optp = (struct opthdr *)&mp6_conn_ctl->b_rptr[
 326  362              sizeof (struct T_optmgmt_ack)];
 327  363          optp->level = MIB2_UDP6;
 328  364          optp->name = MIB2_UDP6_ENTRY;
 329  365          optp->len = msgdsize(mp6_conn_ctl->b_cont);
 330  366          qreply(q, mp6_conn_ctl);
 331  367  
 332  368          /* table of MLP attributes... */
 333  369          optp = (struct opthdr *)&mp6_attr_ctl->b_rptr[
 334  370              sizeof (struct T_optmgmt_ack)];
 335  371          optp->level = MIB2_UDP6;
 336  372          optp->name = EXPER_XPORT_MLP;
 337  373          optp->len = msgdsize(mp6_attr_ctl->b_cont);
 338  374          if (optp->len == 0)
 339  375                  freemsg(mp6_attr_ctl);
 340  376          else
 341  377                  qreply(q, mp6_attr_ctl);
      378 +
      379 +        /* table of EXPER_XPORT_PROC_INFO ipv6 */
      380 +        optp = (struct opthdr *)&mp6_pidnode_ctl->b_rptr[
      381 +            sizeof (struct T_optmgmt_ack)];
      382 +        optp->level = MIB2_UDP6;
      383 +        optp->name = EXPER_XPORT_PROC_INFO;
      384 +        optp->len = msgdsize(mp6_pidnode_ctl->b_cont);
      385 +        if (optp->len == 0)
      386 +                freemsg(mp6_pidnode_ctl);
      387 +        else
      388 +                qreply(q, mp6_pidnode_ctl);
 342  389  
 343  390          return (mp2ctl);
 344  391  }
 345  392  
 346  393  /*
 347  394   * Return 0 if invalid set request, 1 otherwise, including non-udp requests.
 348  395   * NOTE: Per MIB-II, UDP has no writable data.
 349  396   * TODO:  If this ever actually tries to set anything, it needs to be
 350  397   * to do the appropriate locking.
 351  398   */
↓ open down ↓ 238 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX