net/netfilter/ipset/ip_set_getport.c
Source file repositories/reference/linux-study-clean/net/netfilter/ipset/ip_set_getport.c
File Facts
- System
- Linux kernel
- Corpus path
net/netfilter/ipset/ip_set_getport.c- Extension
.c- Size
- 3439 bytes
- Lines
- 151
- 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/ip.hlinux/skbuff.hlinux/icmp.hlinux/icmpv6.hlinux/sctp.hlinux/netfilter_ipv6/ip6_tables.hnet/ip.hnet/ipv6.hlinux/netfilter/ipset/ip_set_getport.hlinux/export.h
Detected Declarations
function get_portfunction ip_set_get_ip4_portfunction ip_set_get_ip6_portexport ip_set_get_ip4_portexport ip_set_get_ip6_port
Annotated Snippet
switch (protocol) {
case IPPROTO_TCP:
case IPPROTO_SCTP:
case IPPROTO_UDP:
case IPPROTO_UDPLITE:
case IPPROTO_ICMP:
/* Port info not available for fragment offset > 0 */
return false;
default:
/* Other protocols doesn't have ports,
* so we can match fragments.
*/
*proto = protocol;
return true;
}
return get_port(skb, protocol, protooff, src, port, proto);
}
EXPORT_SYMBOL_GPL(ip_set_get_ip4_port);
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
bool
ip_set_get_ip6_port(const struct sk_buff *skb, bool src,
__be16 *port, u8 *proto)
{
int protoff;
u8 nexthdr;
__be16 frag_off = 0;
nexthdr = ipv6_hdr(skb)->nexthdr;
protoff = ipv6_skip_exthdr(skb,
skb_network_offset(skb) +
sizeof(struct ipv6hdr), &nexthdr,
&frag_off);
if (protoff < 0 || (frag_off & htons(~0x7)) != 0)
return false;
return get_port(skb, nexthdr, protoff, src, port, proto);
}
EXPORT_SYMBOL_GPL(ip_set_get_ip6_port);
#endif
Annotation
- Immediate include surface: `linux/ip.h`, `linux/skbuff.h`, `linux/icmp.h`, `linux/icmpv6.h`, `linux/sctp.h`, `linux/netfilter_ipv6/ip6_tables.h`, `net/ip.h`, `net/ipv6.h`.
- Detected declarations: `function get_port`, `function ip_set_get_ip4_port`, `function ip_set_get_ip6_port`, `export ip_set_get_ip4_port`, `export ip_set_get_ip6_port`.
- 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.