tools/testing/selftests/bpf/prog_tests/test_dst_clear.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/test_dst_clear.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/test_dst_clear.c- Extension
.c- Size
- 1416 bytes
- Lines
- 56
- 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
sys/types.hsys/socket.hnet/if.htest_progs.hnetwork_helpers.htest_dst_clear.skel.h
Detected Declarations
function test_ns_dst_clear
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#include "test_progs.h"
#include "network_helpers.h"
#include "test_dst_clear.skel.h"
#define IPV4_IFACE_ADDR "1.0.0.1"
#define UDP_TEST_PORT 7777
void test_ns_dst_clear(void)
{
LIBBPF_OPTS(bpf_tcx_opts, tcx_opts);
struct test_dst_clear *skel;
struct sockaddr_in addr;
struct bpf_link *link;
socklen_t addrlen;
char buf[128] = {};
int sockfd, err;
skel = test_dst_clear__open_and_load();
if (!ASSERT_OK_PTR(skel, "skel open_and_load"))
return;
SYS(fail, "ip addr add %s/8 dev lo", IPV4_IFACE_ADDR);
link = bpf_program__attach_tcx(skel->progs.dst_clear,
if_nametoindex("lo"), &tcx_opts);
if (!ASSERT_OK_PTR(link, "attach_tcx"))
goto fail;
skel->links.dst_clear = link;
addrlen = sizeof(addr);
err = make_sockaddr(AF_INET, IPV4_IFACE_ADDR, UDP_TEST_PORT,
(void *)&addr, &addrlen);
if (!ASSERT_OK(err, "make_sockaddr"))
goto fail;
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (!ASSERT_NEQ(sockfd, -1, "socket"))
goto fail;
err = sendto(sockfd, buf, sizeof(buf), 0, (void *)&addr, addrlen);
close(sockfd);
if (!ASSERT_EQ(err, sizeof(buf), "send"))
goto fail;
ASSERT_TRUE(skel->bss->had_dst, "had_dst");
ASSERT_TRUE(skel->bss->dst_cleared, "dst_cleared");
fail:
test_dst_clear__destroy(skel);
}
Annotation
- Immediate include surface: `sys/types.h`, `sys/socket.h`, `net/if.h`, `test_progs.h`, `network_helpers.h`, `test_dst_clear.skel.h`.
- Detected declarations: `function test_ns_dst_clear`.
- 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.