out_string += "\n\t(struct ifnet *)" + hex(ifnet)
if iface.if_snd.ifcq_len :
out_string += "\n\t" + str(iface.if_snd.ifcq_len)
- if dlifnet.dl_if_inpstorage.rcvq_pkts.qlen :
- out_string += "\n\t" + str(dlifnet.dl_if_inpstorage.rcvq_pkts.qlen)
+ if dlifnet.dl_if_inpstorage.dlth_pkts.qlen :
+ out_string += "\n\t" + str(dlifnet.dl_if_inpstorage.dlth_pkts.qlen)
print out_string
def GetIfConfiguration(ifname):
if show_all :
out_string += GetIfaddrs(iface)
out_string += "\n"
- print out_string
+ print out_string
# Macro: showifnets
@lldb_command('showifnets')
out_string += "unp_addr: " + GetSocketAddrAsStringUnix(pcb.unp_addr)
return out_string
+def GetVsockSocketAsString(sock) :
+ out_string = ""
+ pcb = Cast(sock.so_pcb, 'vsockpcb *')
+ if (pcb == 0):
+ out_string += "vsockpcb: (null) "
+ else:
+ out_string += "vsockpcb: " + hex(pcb) + " "
+ out_string += str(pcb.local_address) + " "
+ out_string += str(pcb.remote_address)
+ return out_string
+
def GetSocket(socket) :
""" Show the contents of a socket
"""
out_string += GetIPv4SocketAsString(so)
if (domain.dom_family == 30):
out_string += GetIPv6SocketAsString(so)
+ if (domain.dom_family == 40):
+ out_string += GetVsockSocketAsString(so)
out_string += " s=" + str(int(so.so_snd.sb_cc)) + " r=" + str(int(so.so_rcv.sb_cc)) + " usecnt=" + str(int(so.so_usecount)) + "] "
else:
out_string += "(null)"
out_string += GetIPv4SocketAsString(so)
if (domain.dom_family == 30):
out_string += GetIPv6SocketAsString(so)
+ if (domain.dom_family == 40):
+ out_string += GetVsockSocketAsString(so)
print out_string
else:
print "Unknown value passed as argument."
proc_lastfile = unsigned(proc_filedesc.fd_lastfile)
if proc_filedesc.fd_nfiles != 0:
while count <= proc_lastfile:
- if (unsigned(proc_ofiles[count]) != 0 and proc_ofiles[count].f_fglob != 0):
- fg = proc_ofiles[count].f_fglob
+ if (unsigned(proc_ofiles[count]) != 0 and proc_ofiles[count].fp_glob != 0):
+ fg = proc_ofiles[count].fp_glob
if (int(fg.fg_ops.fo_type) == 2):
if (proc_filedesc.fd_ofileflags[count] & 4):
out_string += "U: "
out_string += "\n\t"
so = pcb.inp_socket
if (so != 0):
- out_string += "so=" + str(so) + " s=" + str(int(so.so_snd.sb_cc)) + " r=" + str(int(so.so_rcv.sb_cc)) + " usecnt=" + str(int(so.so_usecount)) + ", "
+ out_string += "so=" + str(so) + " s=" + str(int(so.so_snd.sb_cc)) + " r=" + str(int(so.so_rcv.sb_cc))
+ if proto == IPPROTO_TCP :
+ tcpcb = cast(pcb.inp_ppcb, 'tcpcb *')
+ out_string += " reass=" + str(int(tcpcb.t_reassqlen))
+
+ out_string += " usecnt=" + str(int(so.so_usecount)) + ", "
if (pcb.inp_state == 0 or pcb.inp_state == INPCB_STATE_INUSE):
out_string += "inuse"
CalcMbufInList(mpkt, rcv_record_cnt, rcv_buf, rcv_mbuf_cnt, rcv_mbuf_cluster_cnt)
def GetPcbInfo(pcbi, proto):
- tcp_reassqlen = 0
+ tcp_reassqlen = [0]
+ tcp_reassq_bytes = 0
+ mbuf_reassq_cnt = [0]
+ mbuf_reassq_bytes = [0] * (Mbuf_Type.MT_LAST + 1)
+ mbuf_reassq_cluster = [0]
out_string = ""
snd_mbuf_cnt = [0]
snd_mbuf_cluster_cnt = [0]
CalcMbufInSB(so, snd_cc, snd_buf, rcv_cc, rcv_buf, snd_record_cnt, rcv_record_cnt, snd_mbuf_cnt, rcv_mbuf_cnt, snd_mbuf_cluster_cnt, rcv_mbuf_cluster_cnt)
if proto == IPPROTO_TCP and pcb.inp_ppcb:
tcpcb = cast(pcb.inp_ppcb, 'tcpcb *')
- tcp_reassqlen += tcpcb.t_reassqlen
+ reass_entry = cast(tcpcb.t_segq.lh_first, 'tseg_qent *')
+ curr_reass = 0
+ while reass_entry != 0:
+ CalcMbufInList(reass_entry.tqe_m, tcp_reassqlen, mbuf_reassq_bytes, mbuf_reassq_cnt, mbuf_reassq_cluster)
+ tcp_reassq_bytes += reass_entry.tqe_len
+ curr_reass += reass_entry.tqe_len
+
+ reass_entry = reass_entry.tqe_q.le_next
pcb = cast(pcb.inp_hash.le_next, 'inpcb *')
i += 1
out_string += "total snd_buf bytes of type " + Mbuf_Type.reverse_mapping[x] + " : " + str(int(snd_buf[x])) + " total recv_buf bytes of type " + Mbuf_Type.reverse_mapping[x] + " : " + str(int(rcv_buf[x])) + "\n"
out_string += "port hash base is " + hex(pcbi.ipi_porthashbase) + "\n"
if proto == IPPROTO_TCP:
- out_string += "TCP reassembly queue length: " + str(tcp_reassqlen) + "\n"
+ out_string += "TCP reassembly queue length: " + str(tcp_reassqlen[0]) + " TCP-payload bytes: " + str(tcp_reassq_bytes) + "\n"
+
+ for x in range(Mbuf_Type.MT_LAST):
+ if mbuf_reassq_bytes[x] != 0:
+ out_string += "total reassq bytes of type " + Mbuf_Type.reverse_mapping[x] + " : " + str(mbuf_reassq_bytes[x]) + "\n"
i = 0
hashbase = pcbi.ipi_porthashbase
p |= ((port & 0x000000ff) << 8)
return str(p)
+
+# Macro: mbuf_list_usage_summary
+@lldb_command('mbuf_list_usage_summary')
+def ShowMbufListUsageSummary(cmd_args=None):
+ """ Print mbuf list usage summary
+ """
+ out_string = ""
+ pkt_cnt = [0]
+ buf_byte_cnt = [0] * (Mbuf_Type.MT_LAST + 1)
+ mbuf_cnt = [0]
+ mbuf_cluster_cnt = [0]
+
+ mpkt = kern.GetValueFromAddress(cmd_args[0], 'struct mbuf *')
+ CalcMbufInList(mpkt, pkt_cnt, buf_byte_cnt, mbuf_cnt, mbuf_cluster_cnt)
+
+ out_string += "Total packet count is " + str(int(pkt_cnt[0])) + "\n"
+ for x in range(Mbuf_Type.MT_LAST):
+ if (buf_byte_cnt[x] != 0):
+ out_string += "Total buf bytes of type " + Mbuf_Type.reverse_mapping[x] + " : " + str(int(buf_byte_cnt[x])) + "\n"
+ out_string += "Total mbuf count " + str(int(mbuf_cnt[0])) + "\n"
+ out_string += "Total mbuf cluster count " + str(int(mbuf_cluster_cnt[0])) + "\n"
+ print out_string
+
# Macro: show_kern_event_pcbinfo
def GetKernEventPcbInfo(kev_pcb_head):
out_string = ""