net/core/dev_addr_lists_test.c
Source file repositories/reference/linux-study-clean/net/core/dev_addr_lists_test.c
File Facts
- System
- Linux kernel
- Corpus path
net/core/dev_addr_lists_test.c- Extension
.c- Size
- 18449 bytes
- Lines
- 631
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
kunit/test.hlinux/etherdevice.hlinux/math64.hlinux/netdevice.hlinux/rtnetlink.h
Detected Declarations
struct dev_addr_test_privfunction dev_addr_test_syncfunction dev_addr_test_unsyncfunction dev_addr_test_resetfunction dev_addr_test_initfunction dev_addr_test_exitfunction dev_addr_test_basicfunction dev_addr_test_sync_onefunction dev_addr_test_add_delfunction dev_addr_test_del_mainfunction dev_addr_test_add_setfunction dev_addr_test_add_exclfunction dev_addr_test_snapshot_syncfunction dev_addr_test_snapshot_remove_during_syncfunction entryfunction dev_addr_test_snapshot_add_and_removefunction dev_addr_test_snapshot_benchmark
Annotated Snippet
static const struct net_device_ops dummy_netdev_ops = {
};
#define ADDR_A 1
#define ADDR_B 2
#define ADDR_C 3
struct dev_addr_test_priv {
u32 addr_seen;
u32 addr_synced;
u32 addr_unsynced;
};
static int dev_addr_test_sync(struct net_device *netdev, const unsigned char *a)
{
struct dev_addr_test_priv *datp = netdev_priv(netdev);
if (a[0] < 31 && !memchr_inv(a, a[0], ETH_ALEN)) {
datp->addr_seen |= 1 << a[0];
datp->addr_synced |= 1 << a[0];
}
return 0;
}
static int dev_addr_test_unsync(struct net_device *netdev,
const unsigned char *a)
{
struct dev_addr_test_priv *datp = netdev_priv(netdev);
if (a[0] < 31 && !memchr_inv(a, a[0], ETH_ALEN)) {
datp->addr_seen &= ~(1 << a[0]);
datp->addr_unsynced |= 1 << a[0];
}
return 0;
}
static void dev_addr_test_reset(struct net_device *netdev)
{
struct dev_addr_test_priv *datp = netdev_priv(netdev);
datp->addr_seen = 0;
datp->addr_synced = 0;
datp->addr_unsynced = 0;
}
static int dev_addr_test_init(struct kunit *test)
{
struct dev_addr_test_priv *datp;
struct net_device *netdev;
int err;
netdev = alloc_etherdev(sizeof(*datp));
KUNIT_ASSERT_TRUE(test, !!netdev);
test->priv = netdev;
netdev->netdev_ops = &dummy_netdev_ops;
err = register_netdev(netdev);
if (err) {
free_netdev(netdev);
KUNIT_FAIL(test, "Can't register netdev %d", err);
}
return 0;
}
static void dev_addr_test_exit(struct kunit *test)
{
struct net_device *netdev = test->priv;
unregister_netdev(netdev);
free_netdev(netdev);
}
static void dev_addr_test_basic(struct kunit *test)
{
struct net_device *netdev = test->priv;
u8 addr[ETH_ALEN];
rtnl_lock();
KUNIT_EXPECT_TRUE(test, !!netdev->dev_addr);
memset(addr, 2, sizeof(addr));
eth_hw_addr_set(netdev, addr);
KUNIT_EXPECT_MEMEQ(test, netdev->dev_addr, addr, sizeof(addr));
memset(addr, 3, sizeof(addr));
dev_addr_set(netdev, addr);
KUNIT_EXPECT_MEMEQ(test, netdev->dev_addr, addr, sizeof(addr));
rtnl_unlock();
Annotation
- Immediate include surface: `kunit/test.h`, `linux/etherdevice.h`, `linux/math64.h`, `linux/netdevice.h`, `linux/rtnetlink.h`.
- Detected declarations: `struct dev_addr_test_priv`, `function dev_addr_test_sync`, `function dev_addr_test_unsync`, `function dev_addr_test_reset`, `function dev_addr_test_init`, `function dev_addr_test_exit`, `function dev_addr_test_basic`, `function dev_addr_test_sync_one`, `function dev_addr_test_add_del`, `function dev_addr_test_del_main`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern 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.