Beispiel #1
0
def print_sock(nsock):
    print("\tportid    : %x" % nsock.portid)
    #     print("\tdst_portid: %x" % nsock.dst_portid)  # all 0
    sock = nsock.sk
    print("\tsock %lx" % sock.address_of_().value_())
    head = sock.sk_wq.wait.head
    print("\tsk_data_ready: %s" % lib.address_to_name(hex(sock.sk_data_ready)))
    print("")
    #     print(head)
    if 1:
        return
    for entry in list_for_each_entry('struct wait_queue_entry',
                                     head.address_of_(), 'entry'):
        print("\twait_queue_entry %lx" % entry.value_())
        print("\twait_queue_entry.flags %d" % entry.flags.value_())
        eppoll_entry = container_of(entry, "struct eppoll_entry", 'wait')
        print("\teppoll_entry %lx" % eppoll_entry)
        epitem = eppoll_entry.base
        print("\tepitem %lx" % epitem)
        event = epitem.event
        ffd = epitem.ffd
        print("\tepoll_filefd %lx" % ffd.address_of_().value_())
        if entry.flags.value_():
            print("\tfd: %d" % ffd.fd.value_())
            print("\tfile: %lx" % ffd.file)

            # 10000019
            # EPOLLIN | EPOLLERR | EPOLLHUP | EPOLLWAKEUP
            print("\tevents: %x" % event.events)
            print("\tdata: %x" % event.data)
        func = entry.func
        print("\t%s" % lib.address_to_name(hex(func)))
        print("")
Beispiel #2
0
def print_packet_type(pt):
    type = pt.type.value_()
    func = pt.func.value_()
    list_func = pt.list_func.value_()
    id_match = pt.id_match.value_()
    print("type: %4x, func: %10s, list_func: %15s, id_match: %s" % \
        (socket.ntohs(type),                    \
        lib.address_to_name(hex(func)),        \
        lib.address_to_name(hex(list_func)),        \
        lib.address_to_name(hex(id_match))))
Beispiel #3
0
def print_worker_pool(pool):
    #     print("worker_pool %lx" % pool.value_())
    workers = pool.workers.address_of_()
    for worker in list_for_each_entry('struct worker', workers, 'node'):
        desc = worker.desc.string_().decode()
        if desc == "miniflow" or pool.id.value_() >= 32:
            #         if desc == "miniflow":
            func = worker.current_func.value_()
            if func:
                func = lib.address_to_name(hex(func))
            else:
                continue
            print("worker %lx" % worker.value_())
            print("pool cpu: %d, pool id: %d" %
                  (pool.cpu.value_(), pool.id.value_()))
            print("desc: %s" % desc)
            print("worker.task.cpu: %d, worker.id: %d, current_func: %s" % \
                (worker.task.cpu.value_(), worker.id.value_(), func))
            print("")
Beispiel #4
0
    pci_name = dev.device.kobj.name.string_().decode()
    print(pci_name)
    print(dev.coredev_type)
    print("mlx5_core_dev %lx" % dev.address_of_())
    ctx_list = dev.priv.ctx_list

    if i == 0:
        print("mode: %d" % dev.priv.eswitch.mode)
        mode = dev.priv.eswitch.mode

    for ctx in list_for_each_entry('struct mlx5_device_context', ctx_list.address_of_(), 'list'):
        intf = ctx.intf
        print("intf")
        print(intf)
        continue
        name = lib.address_to_name(hex(intf))
        if name == "mlx5_ib_interface":
            print("intf %20s, state: %x, contex: %lx" % (name, ctx.state, ctx.context))
            print(ctx)
            # for legacy mode, context is the pointer of mlx5_ib_dev
            # for switchdev mode, it is mlx5_core_dev
#             if mode.value_() == prog['SRIOV_LEGACY']:
            if mode.value_() == prog['MLX5_ESWITCH_LEGACY']:
                mlx5_ib_dev = Object(prog, 'struct mlx5_ib_dev', address=ctx.context)
                print("mlx5_ib_dev.num_ports: %d" % mlx5_ib_dev.num_ports.value_())
                print("ib_dev.phys_port_cnt: %d" % mlx5_ib_dev.ib_dev.phys_port_cnt.value_())
        if name == "mlx5e_interface":
            print(intf)
    print("")

Beispiel #5
0
# 3: NF_INET_LOCAL_OUT
#   1: ipv4_conntrack_defrag
#   2: selinux_ip_output
#   3: ipv4_conntrack_local
#   4: iptable_mangle_hook
#   5: nf_nat_ipv4_local_fn
#   6: ipt_do_table
# 4: NF_INET_POST_ROUTING
#   1: iptable_mangle_hook
#   2: nf_nat_ipv4_out
#   3: selinux_ip_postroute
#   4: ipv4_confirm

enum = {}
enum[0] = "NF_INET_PRE_ROUTING"
enum[1] = "NF_INET_LOCAL_IN"
enum[2] = "NF_INET_FORWARD"
enum[3] = "NF_INET_LOCAL_OUT"
enum[4] = "NF_INET_POST_ROUTING"

ipv4 = nf.hooks_ipv4

for i in range(5):
    print("%d: %s" % (i, enum[i]))
    entry = ipv4[i]
    num = entry.num_hook_entries
    for i in range(num):
        hook = entry.hooks[i].hook
        print("  %d: %s, %x" %
              (i + 1, lib.address_to_name(hex(hook)), entry.hooks[i].priv))
Beispiel #6
0
#!/usr/local/bin/drgn -k

from drgn.helpers.linux import *
from drgn import Object
import time
import sys
import os

sys.path.append("..")
import lib

gen = prog['init_net'].gen
id = prog['tcf_action_net_id']
print("tcf_action_net_id: %d" % id)
ptr = gen.ptr[id]
tcf_action_net = Object(prog, 'struct tcf_action_net', address=ptr.value_())
print("tcf_action_net %lx" % tcf_action_net.address_of_())

for cb in list_for_each_entry('struct tcf_action_egdev_cb', tcf_action_net.egdev_list.address_of_(), 'list'):
    print(cb)
    func = cb.cb.value_()
    func = lib.address_to_name(hex(func))
    print(func)
    priv = cb.cb_priv
    priv = Object(prog, 'struct mlx5e_priv', address=priv.value_())
    print(priv.netdev.name.string_().decode())
Beispiel #7
0
import os

libpath = os.path.dirname(os.path.realpath("__file__"))
sys.path.append(libpath)
import lib

nfs = prog['net_families']
# print(nfs)

NPROTO = 45

for i in range(NPROTO):
    nf = nfs[i]
    if nf.value_():
        print("family: %2d, create: %20s" %
              (nf.family.value_(), lib.address_to_name(hex(nf.create))))

inetsw = prog['inetsw']

SOCK_PACKET = prog['SOCK_PACKET']
SOCK_MAX = SOCK_PACKET.value_() + 1
print("")

for i in range(SOCK_MAX):
    head = inetsw[i]
    for a in list_for_each_entry('struct inet_protosw', head.address_of_(),
                                 'list'):
        print("type: %d, protocol: %3d, prot: %15s, ops: %20s" %
              (a.type.value_(), a.protocol.value_(),
               lib.address_to_name(hex(a.prot)), lib.address_to_name(hex(
                   a.ops))))
Beispiel #8
0
#   1: ipv4_conntrack_defrag
#   2: ipv4_conntrack_in
# 1: NF_INET_LOCAL_IN
#   1: ipv4_confirm
# 2: NF_INET_FORWARD
#   1: selinux_ipv4_forward
# 3: NF_INET_LOCAL_OUT
#   1: ipv4_conntrack_defrag
#   2: selinux_ipv4_output
#   3: ipv4_conntrack_local
# 4: NF_INET_POST_ROUTING
#   1: selinux_ipv4_postroute
#   2: ipv4_confirm

enum = {}
enum[0] = "NT_INET_PRE_ROUTING"
enum[1] = "NF_INET_LOCAL_IN"
enum[2] = "NF_INET_FORWARD"
enum[3] = "NF_INET_LOCAL_OUT"
enum[4] = "NF_INET_POST_ROUTING"

ipv4 = nf.hooks_ipv4

for i in range(5):
    print("%d: %s" % (i, enum[i]))
    entry = ipv4[i]
    num = entry.num_hook_entries
    for i in range(num):
        hook = entry.hooks[i].hook
        print("  %d: %s" % (i + 1, lib.address_to_name(hex(hook))))