net/netlabel/netlabel_calipso.c
Source file repositories/reference/linux-study-clean/net/netlabel/netlabel_calipso.c
File Facts
- System
- Linux kernel
- Corpus path
net/netlabel/netlabel_calipso.c- Extension
.c- Size
- 19648 bytes
- Lines
- 736
- 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.
- 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/types.hlinux/socket.hlinux/string.hlinux/skbuff.hlinux/audit.hlinux/slab.hnet/sock.hnet/netlink.hnet/genetlink.hnet/netlabel.hnet/calipso.hlinux/atomic.hnetlabel_user.hnetlabel_calipso.hnetlabel_mgmt.hnetlabel_domainhash.h
Detected Declarations
struct netlbl_calipso_doiwalk_argstruct netlbl_domhsh_walk_argfunction netlbl_calipso_ops_registerfunction netlbl_calipso_add_passfunction netlbl_calipso_addfunction netlbl_calipso_listfunction calipso_doi_walkfunction netlbl_calipso_listallfunction netlbl_calipso_remove_cbfunction netlbl_calipso_removefunction netlbl_calipso_genl_initfunction typefunction calipso_doi_freefunction calipso_doi_removefunction calipso_doi_putdeffunction calipso_doi_getdeffunction calipso_doi_walkfunction calipso_sock_getattrfunction calipso_sock_setattrfunction calipso_sock_delattrfunction calipso_req_setattrfunction calipso_req_delattrfunction calipso_getattrfunction calipso_skbuff_setattrfunction calipso_skbuff_delattrfunction calipso_cache_invalidatefunction calipso_cache_addexport netlbl_calipso_ops_register
Annotated Snippet
struct netlbl_calipso_doiwalk_arg {
struct netlink_callback *nl_cb;
struct sk_buff *skb;
u32 seq;
};
/* Argument struct for netlbl_domhsh_walk() */
struct netlbl_domhsh_walk_arg {
struct netlbl_audit *audit_info;
u32 doi;
};
/* NetLabel Generic NETLINK CALIPSO family */
static struct genl_family netlbl_calipso_gnl_family;
/* NetLabel Netlink attribute policy */
static const struct nla_policy calipso_genl_policy[NLBL_CALIPSO_A_MAX + 1] = {
[NLBL_CALIPSO_A_DOI] = { .type = NLA_U32 },
[NLBL_CALIPSO_A_MTYPE] = { .type = NLA_U32 },
};
static const struct netlbl_calipso_ops *calipso_ops;
/**
* netlbl_calipso_ops_register - Register the CALIPSO operations
* @ops: ops to register
*
* Description:
* Register the CALIPSO packet engine operations.
*
*/
const struct netlbl_calipso_ops *
netlbl_calipso_ops_register(const struct netlbl_calipso_ops *ops)
{
return xchg(&calipso_ops, ops);
}
EXPORT_SYMBOL(netlbl_calipso_ops_register);
static const struct netlbl_calipso_ops *netlbl_calipso_ops_get(void)
{
return READ_ONCE(calipso_ops);
}
/* NetLabel Command Handlers
*/
/**
* netlbl_calipso_add_pass - Adds a CALIPSO pass DOI definition
* @info: the Generic NETLINK info block
* @audit_info: NetLabel audit information
*
* Description:
* Create a new CALIPSO_MAP_PASS DOI definition based on the given ADD message
* and add it to the CALIPSO engine. Return zero on success and non-zero on
* error.
*
*/
static int netlbl_calipso_add_pass(struct genl_info *info,
struct netlbl_audit *audit_info)
{
int ret_val;
struct calipso_doi *doi_def = NULL;
doi_def = kmalloc_obj(*doi_def);
if (!doi_def)
return -ENOMEM;
doi_def->type = CALIPSO_MAP_PASS;
doi_def->doi = nla_get_u32(info->attrs[NLBL_CALIPSO_A_DOI]);
ret_val = calipso_doi_add(doi_def, audit_info);
if (ret_val != 0)
calipso_doi_free(doi_def);
return ret_val;
}
/**
* netlbl_calipso_add - Handle an ADD message
* @skb: the NETLINK buffer
* @info: the Generic NETLINK info block
*
* Description:
* Create a new DOI definition based on the given ADD message and add it to the
* CALIPSO engine. Returns zero on success, negative values on failure.
*
*/
static int netlbl_calipso_add(struct sk_buff *skb, struct genl_info *info)
{
int ret_val = -EINVAL;
struct netlbl_audit audit_info;
const struct netlbl_calipso_ops *ops = netlbl_calipso_ops_get();
Annotation
- Immediate include surface: `linux/types.h`, `linux/socket.h`, `linux/string.h`, `linux/skbuff.h`, `linux/audit.h`, `linux/slab.h`, `net/sock.h`, `net/netlink.h`.
- Detected declarations: `struct netlbl_calipso_doiwalk_arg`, `struct netlbl_domhsh_walk_arg`, `function netlbl_calipso_ops_register`, `function netlbl_calipso_add_pass`, `function netlbl_calipso_add`, `function netlbl_calipso_list`, `function calipso_doi_walk`, `function netlbl_calipso_listall`, `function netlbl_calipso_remove_cb`, `function netlbl_calipso_remove`.
- 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.