net/vmw_vsock/af_vsock_tap.c
Source file repositories/reference/linux-study-clean/net/vmw_vsock/af_vsock_tap.c
File Facts
- System
- Linux kernel
- Corpus path
net/vmw_vsock/af_vsock_tap.c- Extension
.c- Size
- 2032 bytes
- Lines
- 111
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hnet/sock.hnet/af_vsock.hlinux/if_arp.h
Detected Declarations
function vsock_add_tapfunction vsock_remove_tapfunction list_for_each_entryfunction __vsock_deliver_tap_skbfunction __vsock_deliver_tapfunction list_for_each_entry_rcufunction vsock_deliver_tapexport vsock_add_tapexport vsock_remove_tapexport vsock_deliver_tap
Annotated Snippet
if (vt == tmp) {
list_del_rcu(&vt->list);
found = true;
goto out;
}
}
pr_warn("vsock_remove_tap: %p not found\n", vt);
out:
spin_unlock(&vsock_tap_lock);
synchronize_net();
if (found)
module_put(vt->module);
return found ? 0 : -ENODEV;
}
EXPORT_SYMBOL_GPL(vsock_remove_tap);
static int __vsock_deliver_tap_skb(struct sk_buff *skb,
struct net_device *dev)
{
int ret = 0;
struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
if (nskb) {
dev_hold(dev);
nskb->dev = dev;
ret = dev_queue_xmit(nskb);
if (unlikely(ret > 0))
ret = net_xmit_errno(ret);
dev_put(dev);
}
return ret;
}
static void __vsock_deliver_tap(struct sk_buff *skb)
{
int ret;
struct vsock_tap *tmp;
list_for_each_entry_rcu(tmp, &vsock_tap_all, list) {
ret = __vsock_deliver_tap_skb(skb, tmp->dev);
if (unlikely(ret))
break;
}
}
void vsock_deliver_tap(struct sk_buff *build_skb(void *opaque), void *opaque)
{
struct sk_buff *skb;
rcu_read_lock();
if (likely(list_empty(&vsock_tap_all)))
goto out;
skb = build_skb(opaque);
if (skb) {
__vsock_deliver_tap(skb);
consume_skb(skb);
}
out:
rcu_read_unlock();
}
EXPORT_SYMBOL_GPL(vsock_deliver_tap);
Annotation
- Immediate include surface: `linux/module.h`, `net/sock.h`, `net/af_vsock.h`, `linux/if_arp.h`.
- Detected declarations: `function vsock_add_tap`, `function vsock_remove_tap`, `function list_for_each_entry`, `function __vsock_deliver_tap_skb`, `function __vsock_deliver_tap`, `function list_for_each_entry_rcu`, `function vsock_deliver_tap`, `export vsock_add_tap`, `export vsock_remove_tap`, `export vsock_deliver_tap`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.