mirror of
https://github.com/JakeHillion/drgn.git
synced 2024-12-23 09:43:06 +00:00
557b8152cc
Add a helper to get the network device ("struct net_device *") given an interface name. As an example: >>> netdev = netdev_get_by_name(prog["init_net"], "lo") >>> netdev.ifindex.value_() 1 Or pass a "Program" as the first argument, and let the helper find in the initial network namespace (i.e. "init_net"): >>> netdev = netdev_get_by_index(prog, "dummy0") >>> netdev.ifindex.value_() 2 Also add a test for this new helper to tests/helpers/linux/test_net.py. This helper simply does a linear search over the name hash table of the network namespace, since implementing hashing in drgn is non-trivial. It is obviously slower than net/core/dev.c:netdev_name_node_lookup() in the kernel, but still useful. Linux kernel commit ff92741270bf ("net: introduce name_node struct to be used in hashlist") introduced struct netdev_name_node for name lookups. Start by assuming that the kernel has this commit, and fall back to the old path if that fails. Signed-off-by: Peilin Ye <peilin.ye@bytedance.com> |
||
---|---|---|
.. | ||
helpers | ||
__init__.py | ||
assembler.py | ||
dwarf.py | ||
dwarfwriter.py | ||
elf.py | ||
elfwriter.py | ||
libdrgn.py | ||
test_docs.py | ||
test_dwarf.py | ||
test_language_c.py | ||
test_lexer.py | ||
test_object.py | ||
test_path.py | ||
test_platform.py | ||
test_program.py | ||
test_python.py | ||
test_serialize.py | ||
test_type.py | ||
test_util.py |