Print this page
dccp: build fixes, mdb (vfs sonode missing)

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/mdb/common/modules/genunix/net.c
          +++ new/usr/src/cmd/mdb/common/modules/genunix/net.c
↓ open down ↓ 39 lines elided ↑ open up ↑
  40   40  #include <sys/stream.h>
  41   41  #include <sys/vfs.h>
  42   42  #include <sys/stropts.h>
  43   43  #include <sys/tpicommon.h>
  44   44  #include <sys/socket.h>
  45   45  #include <sys/socketvar.h>
  46   46  #include <sys/cred_impl.h>
  47   47  #include <inet/udp_impl.h>
  48   48  #include <inet/rawip_impl.h>
  49   49  #include <inet/mi.h>
       50 +#include <inet/dccp_impl.h>
  50   51  #include <fs/sockfs/socktpi_impl.h>
  51   52  #include <net/bridge_impl.h>
  52   53  #include <io/trill_impl.h>
  53   54  #include <sys/mac_impl.h>
  54   55  
  55   56  #define ADDR_V6_WIDTH   23
  56   57  #define ADDR_V4_WIDTH   15
  57   58  
  58   59  #define NETSTAT_ALL     0x01
  59   60  #define NETSTAT_VERBOSE 0x02
↓ open down ↓ 75 lines elided ↑ open up ↑
 135  136          netstack_t nss;
 136  137  
 137  138          if (mdb_vread(&nss, sizeof (nss), wsp->walk_addr) == -1) {
 138  139                  mdb_warn("can't read netstack at %p", wsp->walk_addr);
 139  140                  return (WALK_ERR);
 140  141          }
 141  142          kaddr = (uintptr_t)nss.netstack_modules[NS_UDP];
 142  143          return (wsp->walk_callback(kaddr, wsp->walk_layer, wsp->walk_cbdata));
 143  144  }
 144  145  
      146 +int
      147 +dccp_stacks_walk_init(mdb_walk_state_t *wsp)
      148 +{
      149 +        if (mdb_layered_walk("netstack", wsp) == -1) {
      150 +                mdb_warn("can't walk 'netstack'");
      151 +                return (WALK_ERR);
      152 +        }
      153 +        return (WALK_NEXT);
      154 +}
      155 +
      156 +int
      157 +dccp_stacks_walk_step(mdb_walk_state_t *wsp)
      158 +{
      159 +        uintptr_t kaddr;
      160 +        netstack_t nss;
      161 +
      162 +        if (mdb_vread(&nss, sizeof (nss), wsp->walk_addr) == -1) {
      163 +                mdb_warn("can't read netstack at %p", wsp->walk_addr);
      164 +                return (WALK_ERR);
      165 +        }
      166 +        kaddr = (uintptr_t)nss.netstack_modules[NS_DCCP];
      167 +        return (wsp->walk_callback(kaddr, wsp->walk_layer, wsp->walk_cbdata));
      168 +}
      169 +
 145  170  /*
 146  171   * Print an IPv4 address and port number in a compact and easy to read format
 147  172   * The arguments are in network byte order
 148  173   */
 149  174  static void
 150  175  net_ipv4addrport_pr(const in6_addr_t *nipv6addr, in_port_t nport)
 151  176  {
 152  177          uint32_t naddr = V4_PART_OF_V6((*nipv6addr));
 153  178  
 154  179          mdb_nhconvert(&nport, &nport, sizeof (nport));
↓ open down ↓ 45 lines elided ↑ open up ↑
 200  225              (IN6_IS_ADDR_UNSPECIFIED(&udp->udp_connp->conn_laddr_v6) &&
 201  226              (udp->udp_state <= TS_IDLE)));
 202  227  }
 203  228  
 204  229  static int
 205  230  net_udp_ipv6(const udp_t *udp)
 206  231  {
 207  232          return (udp->udp_connp->conn_ipversion == IPV6_VERSION);
 208  233  }
 209  234  
      235 +static int
      236 +net_dccp_active(const dccp_t *dccp)
      237 +{
      238 +        return ((dccp->dccp_state == TS_IDLE) ||
      239 +            (dccp->dccp_state == TS_DATA_XFER));
      240 +}
      241 +
      242 +static int
      243 +net_dccp_ipv4(const dccp_t *dccp)
      244 +{
      245 +        return ((dccp->dccp_connp->conn_ipversion == IPV4_VERSION) ||
      246 +            (IN6_IS_ADDR_UNSPECIFIED(&dccp->dccp_connp->conn_laddr_v6) &&
      247 +            (dccp->dccp_state <= DCCPS_LISTEN)));
      248 +}
      249 +
      250 +static int
      251 +net_dccp_ipv6(const dccp_t *dccp)
      252 +{
      253 +        return (dccp->dccp_connp->conn_ipversion == IPV6_VERSION);
      254 +}
      255 +
 210  256  int
 211  257  sonode_walk_init(mdb_walk_state_t *wsp)
 212  258  {
 213  259          if (wsp->walk_addr == NULL) {
 214  260                  GElf_Sym sym;
 215  261                  struct socklist *slp;
 216  262  
 217  263                  if (mdb_lookup_by_obj("sockfs", "socklist", &sym) == -1) {
 218  264                          mdb_warn("failed to lookup sockfs`socklist");
 219  265                          return (WALK_ERR);
↓ open down ↓ 518 lines elided ↑ open up ↑
 738  784                  net_ipv6addrport_pr(&connp->conn_laddr_v6, connp->conn_lport);
 739  785                  mdb_printf(" ");
 740  786                  net_ipv6addrport_pr(&connp->conn_faddr_v6, connp->conn_fport);
 741  787          }
 742  788          mdb_printf(" %5i", ns_to_stackid((uintptr_t)connp->conn_netstack));
 743  789          mdb_printf(" %4i\n", connp->conn_zoneid);
 744  790  
 745  791          return (WALK_NEXT);
 746  792  }
 747  793  
      794 +static void
      795 +netstat_dccp_verbose_pr(const dccp_t *dccp)
      796 +{
      797 +/* XXX:DCCP
      798 +        mdb_printf("       %5i %08x %08x %5i %08x %08x %5li %5i\n",
      799 +            tcp->tcp_swnd, tcp->tcp_snxt, tcp->tcp_suna, tcp->tcp_rwnd,
      800 +            tcp->tcp_rack, tcp->tcp_rnxt, tcp->tcp_rto, tcp->tcp_mss);
      801 +*/
      802 +}
      803 +
      804 +/*ARGSUSED*/
      805 +static int
      806 +netstat_dccp_cb(uintptr_t kaddr, const void *walk_data, void *cb_data)
      807 +{
      808 +        netstat_cb_data_t *ncb = cb_data;
      809 +        uint_t opts = ncb->opts;
      810 +        int af = ncb->af;
      811 +        uintptr_t dccp_kaddr;
      812 +        conn_t *connp = &ncb->conn;
      813 +        dccp_t dccps, *dccp;
      814 +
      815 +        if (mdb_vread(connp, sizeof (conn_t), kaddr) == -1) {
      816 +                mdb_warn("failed to read conn_t at %p", kaddr);
      817 +                return (WALK_ERR);
      818 +        }
      819 +
      820 +        dccp_kaddr = (uintptr_t)connp->conn_dccp;
      821 +        if (mdb_vread(&dccps, sizeof (dccp_t), dccp_kaddr) == -1) {
      822 +                mdb_warn("failed to read tcp_t at %p", dccp_kaddr);
      823 +                return (WALK_ERR);
      824 +        }
      825 +
      826 +        dccp = &dccps;
      827 +        connp->conn_dccp = dccp;
      828 +        dccp->dccp_connp = connp;
      829 +
      830 +        if (!((opts & NETSTAT_ALL) || net_dccp_active(dccp)) ||
      831 +            (af == AF_INET && !net_dccp_ipv4(dccp)) ||
      832 +            (af == AF_INET6 && !net_dccp_ipv6(dccp))) {
      833 +                return (WALK_NEXT);
      834 +        }
      835 +
      836 +        mdb_printf("%0?p %2i ", dccp_kaddr, dccp->dccp_state);
      837 +        if (af == AF_INET) {
      838 +                net_ipv4addrport_pr(&connp->conn_laddr_v6, connp->conn_lport);
      839 +                mdb_printf(" ");
      840 +                net_ipv4addrport_pr(&connp->conn_faddr_v6, connp->conn_fport);
      841 +        } else if (af == AF_INET6) {
      842 +                net_ipv6addrport_pr(&connp->conn_laddr_v6, connp->conn_lport);
      843 +                mdb_printf(" ");
      844 +                net_ipv6addrport_pr(&connp->conn_faddr_v6, connp->conn_fport);
      845 +        }
      846 +        mdb_printf(" %5i", ns_to_stackid((uintptr_t)connp->conn_netstack));
      847 +        mdb_printf(" %4i\n", connp->conn_zoneid);
      848 +        if (opts & NETSTAT_VERBOSE)
      849 +                netstat_dccp_verbose_pr(dccp);
      850 +
      851 +        return (WALK_NEXT);
      852 +}
      853 +
 748  854  /*
 749  855   * print the address of a unix domain socket
 750  856   *
 751  857   * so is the address of a AF_UNIX struct sonode in mdb's address space
 752  858   * soa is the address of the struct soaddr to print
 753  859   *
 754  860   * returns 0 on success, -1 otherwise
 755  861   */
 756  862  static int
 757  863  netstat_unix_name_pr(const struct sotpi_sonode *st, const struct soaddr *soa)
↓ open down ↓ 451 lines elided ↑ open up ↑
1209 1315                  if (status != DCMD_OK)
1210 1316                          goto out;
1211 1317          }
1212 1318  
1213 1319          if ((optP == NULL) || (strcmp("icmp", optP) == 0)) {
1214 1320                  status = netstat_print_common("rawip_conn_cache", IPPROTO_ICMP,
1215 1321                      netstat_icmp_cb, cbdata);
1216 1322                  if (status != DCMD_OK)
1217 1323                          goto out;
1218 1324          }
     1325 +
     1326 +        if ((optP == NULL) || (strcmp("dccp", optP) == 0)) {
     1327 +                status = netstat_print_common("dccp_conn_cache", IPPROTO_DCCP,
     1328 +                    netstat_dccp_cb, cbdata);
     1329 +                if (status != DCMD_OK)
     1330 +                        goto out;
     1331 +        }
1219 1332  out:
1220 1333          mdb_free(cbdata, sizeof (netstat_cb_data_t));
1221 1334          return (status);
1222 1335  }
1223 1336  
1224 1337  /*
1225 1338   * "::dladm show-bridge" support
1226 1339   */
1227 1340  typedef struct {
1228 1341          uint_t opt_l;
↓ open down ↓ 414 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX