net/netfilter/nf_conntrack_ovs.c
Source file repositories/reference/linux-study-clean/net/netfilter/nf_conntrack_ovs.c
File Facts
- System
- Linux kernel
- Corpus path
net/netfilter/nf_conntrack_ovs.c- Extension
.c- Size
- 4812 bytes
- Lines
- 193
- 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
net/netfilter/nf_conntrack_helper.hnet/netfilter/nf_conntrack_seqadj.hnet/netfilter/ipv6/nf_defrag_ipv6.hnet/ipv6_frag.hnet/ip.hlinux/netfilter_ipv6.h
Detected Declarations
function nf_ct_helperfunction nf_ct_add_helperfunction nf_ct_skb_network_trimfunction nf_ct_handle_fragmentsexport nf_ct_helperexport nf_ct_add_helperexport nf_ct_skb_network_trimexport nf_ct_handle_fragments
Annotated Snippet
if (ofs < 0 || (frag_off & htons(~0x7)) != 0) {
pr_debug("proto header not found\n");
return NF_ACCEPT;
}
protoff = ofs;
proto = nexthdr;
break;
}
default:
WARN_ONCE(1, "helper invoked on non-IP family!");
return NF_DROP;
}
if (helper->tuple.dst.protonum != proto)
return NF_ACCEPT;
helper_cb = rcu_dereference(helper->help);
if (!helper_cb)
return NF_ACCEPT;
err = helper_cb(skb, protoff, ct, ctinfo);
if (err != NF_ACCEPT)
return err;
/* Adjust seqs after helper. This is needed due to some helpers (e.g.,
* FTP with NAT) adusting the TCP payload size when mangling IP
* addresses and/or port numbers in the text-based control connection.
*/
if (test_bit(IPS_SEQ_ADJUST_BIT, &ct->status) &&
!nf_ct_seq_adjust(skb, ct, ctinfo, protoff))
return NF_DROP;
return NF_ACCEPT;
}
EXPORT_SYMBOL_GPL(nf_ct_helper);
int nf_ct_add_helper(struct nf_conn *ct, const char *name, u8 family,
u8 proto, bool nat, struct nf_conntrack_helper **hp)
{
struct nf_conntrack_helper *helper;
struct nf_conn_help *help;
int ret = 0;
helper = nf_conntrack_helper_try_module_get(name, family, proto);
if (!helper)
return -EINVAL;
help = nf_ct_helper_ext_add(ct, GFP_KERNEL);
if (!help) {
nf_conntrack_helper_put(helper);
return -ENOMEM;
}
#if IS_ENABLED(CONFIG_NF_NAT)
if (nat) {
ret = nf_nat_helper_try_module_get(name, family, proto);
if (ret) {
nf_conntrack_helper_put(helper);
return ret;
}
}
#endif
rcu_assign_pointer(help->helper, helper);
*hp = helper;
return ret;
}
EXPORT_SYMBOL_GPL(nf_ct_add_helper);
/* Trim the skb to the length specified by the IP/IPv6 header,
* removing any trailing lower-layer padding. This prepares the skb
* for higher-layer processing that assumes skb->len excludes padding
* (such as nf_ip_checksum). The caller needs to pull the skb to the
* network header, and ensure ip_hdr/ipv6_hdr points to valid data.
*/
int nf_ct_skb_network_trim(struct sk_buff *skb, int family)
{
unsigned int len;
switch (family) {
case NFPROTO_IPV4:
len = skb_ip_totlen(skb);
break;
case NFPROTO_IPV6:
len = skb_ipv6_payload_len(skb);
if (ipv6_hdr(skb)->nexthdr == NEXTHDR_HOP) {
int err = nf_ip6_check_hbh_len(skb, &len);
if (err)
return err;
}
len += sizeof(struct ipv6hdr);
break;
Annotation
- Immediate include surface: `net/netfilter/nf_conntrack_helper.h`, `net/netfilter/nf_conntrack_seqadj.h`, `net/netfilter/ipv6/nf_defrag_ipv6.h`, `net/ipv6_frag.h`, `net/ip.h`, `linux/netfilter_ipv6.h`.
- Detected declarations: `function nf_ct_helper`, `function nf_ct_add_helper`, `function nf_ct_skb_network_trim`, `function nf_ct_handle_fragments`, `export nf_ct_helper`, `export nf_ct_add_helper`, `export nf_ct_skb_network_trim`, `export nf_ct_handle_fragments`.
- 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.