tools/net/ynl/tests/netdev.c
Source file repositories/reference/linux-study-clean/tools/net/ynl/tests/netdev.c
File Facts
- System
- Linux kernel
- Corpus path
tools/net/ynl/tests/netdev.c- Extension
.c- Size
- 4961 bytes
- Lines
- 232
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hstring.hynl.hnet/if.hkselftest_harness.hnetdev-user.hrt-link-user.h
Detected Declarations
function netdev_print_devicefunction veth_createfunction veth_deletefunction ynl_dump_foreach
Annotated Snippet
if (d->_present.ifindex) {
ifindex = d->ifindex;
break;
}
}
netdev_dev_get_list_free(devs);
if (!ifindex)
SKIP(return, "no device to query");
req = netdev_dev_get_req_alloc();
ASSERT_NE(NULL, req);
netdev_dev_get_req_set_ifindex(req, ifindex);
dev = netdev_dev_get(self->ys, req);
netdev_dev_get_req_free(req);
ASSERT_NE(NULL, dev) {
TH_LOG("dev_get failed: %s", self->ys->err.msg);
}
netdev_print_device(_metadata, dev, 0);
netdev_dev_get_rsp_free(dev);
}
TEST_F(netdev, ntf_check)
{
struct ynl_ntf_base_type *ntf;
int veth_ifindex;
bool received;
int ret;
ret = ynl_subscribe(self->ys, "mgmt");
ASSERT_EQ(0, ret) {
TH_LOG("subscribe failed: %s", self->ys->err.msg);
}
self->ys_link = ynl_sock_create(&ynl_rt_link_family, NULL);
ASSERT_NE(NULL, self->ys_link)
TH_LOG("failed to create rt-link socket");
veth_ifindex = veth_create(self->ys_link);
ASSERT_GT(veth_ifindex, 0)
TH_LOG("failed to create veth");
ynl_ntf_check(self->ys);
ntf = ynl_ntf_dequeue(self->ys);
received = ntf;
if (ntf) {
netdev_print_device(_metadata,
(struct netdev_dev_get_rsp *)&ntf->data,
ntf->cmd);
ynl_ntf_free(ntf);
}
/* Drain any remaining notifications */
while ((ntf = ynl_ntf_dequeue(self->ys)))
ynl_ntf_free(ntf);
veth_delete(_metadata, self->ys_link, veth_ifindex);
ASSERT_TRUE(received)
TH_LOG("no notification received");
}
TEST_HARNESS_MAIN
Annotation
- Immediate include surface: `stdio.h`, `string.h`, `ynl.h`, `net/if.h`, `kselftest_harness.h`, `netdev-user.h`, `rt-link-user.h`.
- Detected declarations: `function netdev_print_device`, `function veth_create`, `function veth_delete`, `function ynl_dump_foreach`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.