net/ipv6/netfilter/nf_reject_ipv6.c
Source file repositories/reference/linux-study-clean/net/ipv6/netfilter/nf_reject_ipv6.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/netfilter/nf_reject_ipv6.c- Extension
.c- Size
- 11394 bytes
- Lines
- 452
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hnet/ipv6.hnet/ip6_route.hnet/ip6_fib.hnet/ip6_checksum.hnet/netfilter/ipv6/nf_reject.hlinux/netfilter_ipv6.hlinux/netfilter_bridge.h
Detected Declarations
function nf_reject_v6_csum_okfunction nf_reject_ip6hdr_validatefunction nf_skb_is_icmp6_unreachfunction nf_reject_ip6_tcphdr_getfunction nf_reject_ip6hdr_putfunction nf_reject_ip6_tcphdr_putfunction nf_reject6_fill_skb_dstfunction nf_send_reset6function reject6_csum_okfunction nf_send_unreach6export nf_reject_skb_v6_tcp_resetexport nf_reject_skb_v6_unreachexport nf_send_reset6export nf_send_unreach6
Annotated Snippet
if (!br_indev) {
kfree_skb(nskb);
return;
}
nskb->dev = br_indev;
nskb->protocol = htons(ETH_P_IPV6);
ip6h->payload_len = htons(sizeof(struct tcphdr));
if (dev_hard_header(nskb, nskb->dev, ntohs(nskb->protocol),
oeth->h_source, oeth->h_dest, nskb->len) < 0) {
kfree_skb(nskb);
return;
}
dev_queue_xmit(nskb);
} else
#endif
ip6_local_out(net, sk, nskb);
}
EXPORT_SYMBOL_GPL(nf_send_reset6);
static bool reject6_csum_ok(struct sk_buff *skb, int hook)
{
const struct ipv6hdr *ip6h = ipv6_hdr(skb);
int thoff;
__be16 fo;
u8 proto;
if (skb_csum_unnecessary(skb))
return true;
proto = ip6h->nexthdr;
thoff = ipv6_skip_exthdr(skb, ((u8 *)(ip6h + 1) - skb->data), &proto, &fo);
if (thoff < 0 || thoff >= skb->len || (fo & htons(~0x7)) != 0)
return false;
if (!nf_reject_verify_csum(skb, thoff, proto))
return true;
return nf_ip6_checksum(skb, hook, thoff, proto) == 0;
}
void nf_send_unreach6(struct net *net, struct sk_buff *skb_in,
unsigned char code, unsigned int hooknum)
{
if (!reject6_csum_ok(skb_in, hooknum))
return;
if (hooknum == NF_INET_LOCAL_OUT && skb_in->dev == NULL)
skb_in->dev = net->loopback_dev;
if (!skb_dst(skb_in) && nf_reject6_fill_skb_dst(skb_in) < 0)
return;
icmpv6_send(skb_in, ICMPV6_DEST_UNREACH, code, 0);
}
EXPORT_SYMBOL_GPL(nf_send_unreach6);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("IPv6 packet rejection core");
Annotation
- Immediate include surface: `linux/module.h`, `net/ipv6.h`, `net/ip6_route.h`, `net/ip6_fib.h`, `net/ip6_checksum.h`, `net/netfilter/ipv6/nf_reject.h`, `linux/netfilter_ipv6.h`, `linux/netfilter_bridge.h`.
- Detected declarations: `function nf_reject_v6_csum_ok`, `function nf_reject_ip6hdr_validate`, `function nf_skb_is_icmp6_unreach`, `function nf_reject_ip6_tcphdr_get`, `function nf_reject_ip6hdr_put`, `function nf_reject_ip6_tcphdr_put`, `function nf_reject6_fill_skb_dst`, `function nf_send_reset6`, `function reject6_csum_ok`, `function nf_send_unreach6`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.