net/x25/x25_forward.c
Source file repositories/reference/linux-study-clean/net/x25/x25_forward.c
File Facts
- System
- Linux kernel
- Corpus path
net/x25/x25_forward.c- Extension
.c- Size
- 3438 bytes
- Lines
- 157
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/if_arp.hlinux/init.hlinux/slab.hnet/x25.h
Detected Declarations
function x25_forward_callfunction x25_forward_datafunction x25_clear_forward_by_lcifunction list_for_each_entry_safefunction x25_clear_forward_by_devfunction list_for_each_entry_safe
Annotated Snippet
if (x25_frwd->lci == lci) {
pr_warn("call request for lci which is already registered!, transmitting but not registering new pair\n");
same_lci = 1;
}
}
read_unlock_bh(&x25_forward_list_lock);
/* Save the forwarding details for future traffic */
if (!same_lci){
if ((new_frwd = kmalloc_obj(struct x25_forward, GFP_ATOMIC)) == NULL){
rc = -ENOMEM;
goto out_put_nb;
}
new_frwd->lci = lci;
new_frwd->dev1 = rt->dev;
new_frwd->dev2 = from->dev;
write_lock_bh(&x25_forward_list_lock);
list_add(&new_frwd->node, &x25_forward_list);
write_unlock_bh(&x25_forward_list_lock);
}
/* Forward the call request */
if ( (skbn = skb_clone(skb, GFP_ATOMIC)) == NULL){
goto out_put_nb;
}
x25_transmit_link(skbn, neigh_new);
rc = 1;
out_put_nb:
x25_neigh_put(neigh_new);
out_put_route:
x25_route_put(rt);
out_no_route:
return rc;
}
int x25_forward_data(int lci, struct x25_neigh *from, struct sk_buff *skb) {
struct x25_forward *frwd;
struct net_device *peer = NULL;
struct x25_neigh *nb;
struct sk_buff *skbn;
int rc = 0;
read_lock_bh(&x25_forward_list_lock);
list_for_each_entry(frwd, &x25_forward_list, node) {
if (frwd->lci == lci) {
/* The call is established, either side can send */
if (from->dev == frwd->dev1) {
peer = frwd->dev2;
} else {
peer = frwd->dev1;
}
break;
}
}
read_unlock_bh(&x25_forward_list_lock);
if ( (nb = x25_get_neigh(peer)) == NULL)
goto out;
if ( (skbn = pskb_copy(skb, GFP_ATOMIC)) == NULL){
goto output;
}
x25_transmit_link(skbn, nb);
rc = 1;
output:
x25_neigh_put(nb);
out:
return rc;
}
void x25_clear_forward_by_lci(unsigned int lci)
{
struct x25_forward *fwd, *tmp;
write_lock_bh(&x25_forward_list_lock);
list_for_each_entry_safe(fwd, tmp, &x25_forward_list, node) {
if (fwd->lci == lci) {
list_del(&fwd->node);
kfree(fwd);
}
}
Annotation
- Immediate include surface: `linux/if_arp.h`, `linux/init.h`, `linux/slab.h`, `net/x25.h`.
- Detected declarations: `function x25_forward_call`, `function x25_forward_data`, `function x25_clear_forward_by_lci`, `function list_for_each_entry_safe`, `function x25_clear_forward_by_dev`, `function list_for_each_entry_safe`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.