tools/net/ynl/lib/ynl.c
Source file repositories/reference/linux-study-clean/tools/net/ynl/lib/ynl.c
File Facts
- System
- Linux kernel
- Corpus path
tools/net/ynl/lib/ynl.c- Extension
.c- Size
- 24358 bytes
- Lines
- 1069
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
errno.hpoll.hstring.hstdlib.hstdio.hunistd.hlinux/types.hlinux/genetlink.hsys/socket.hynl.h
Detected Declarations
function ynl_err_walk_is_selfunction ynl_err_walk_sel_policyfunction ynl_err_walk_report_onefunction ynl_err_walkfunction ynl_attr_for_each_payloadfunction ynl_ext_ack_checkfunction ynl_attr_for_eachfunction ynl_cb_errorfunction ynl_cb_donefunction __ynl_attr_validatefunction ynl_submsg_failedfunction ynl_err_resetfunction ynl_msg_endfunction ynl_gemsg_startfunction ynl_gemsg_start_reqfunction ynl_gemsg_start_dumpfunction ynl_cb_nullfunction __ynl_sock_read_msgsfunction ynl_sock_read_msgsfunction ynl_recv_ackfunction ynl_get_family_info_mcastfunction ynl_attr_for_each_nestedfunction ynl_get_family_info_cbfunction ynl_attr_for_eachfunction ynl_sock_read_familyfunction ynl_sock_createfunction ynl_sock_destroyfunction ynl_ntf_freefunction ynl_subscribefunction ynl_socket_get_fdfunction ynl_ntf_parsefunction ynl_ntf_trampolinefunction ynl_ntf_checkfunction ynl_error_unknown_notificationfunction ynl_error_parsefunction ynl_check_alienfunction ynl_req_trampolinefunction ynl_execfunction ynl_dump_trampolinefunction ynl_exec_dump
Annotated Snippet
if (_yse) { \
snprintf(_yse->msg, sizeof(_yse->msg) - 1, _msg); \
_yse->msg[sizeof(_yse->msg) - 1] = 0; \
} \
})
#define __yerr_code(yse, _code...) \
({ \
struct ynl_error *_yse = (yse); \
\
if (_yse) { \
_yse->code = _code; \
} \
})
#define __yerr(yse, _code, _msg...) \
({ \
__yerr_msg(yse, _msg); \
__yerr_code(yse, _code); \
})
#define __perr(yse, _msg) __yerr(yse, errno, _msg)
#define yerr_msg(_ys, _msg...) __yerr_msg(&(_ys)->err, _msg)
#define yerr(_ys, _code, _msg...) __yerr(&(_ys)->err, _code, _msg)
#define perr(_ys, _msg) __yerr(&(_ys)->err, errno, _msg)
/* -- Netlink boiler plate */
static bool
ynl_err_walk_is_sel(const struct ynl_policy_nest *policy,
const struct nlattr *attr)
{
unsigned int type = ynl_attr_type(attr);
return policy && type <= policy->max_attr &&
policy->table[type].is_selector;
}
static const struct ynl_policy_nest *
ynl_err_walk_sel_policy(const struct ynl_policy_attr *policy_attr,
const struct nlattr *selector)
{
const struct ynl_policy_nest *policy = policy_attr->nest;
const char *sel;
unsigned int i;
if (!policy_attr->is_submsg)
return policy;
sel = ynl_attr_get_str(selector);
for (i = 0; i <= policy->max_attr; i++) {
if (!strcmp(sel, policy->table[i].name))
return policy->table[i].nest;
}
return NULL;
}
static int
ynl_err_walk_report_one(const struct ynl_policy_nest *policy,
const struct nlattr *selector, unsigned int type,
char *str, int str_sz, int *n)
{
if (!policy) {
if (*n < str_sz)
*n += snprintf(str, str_sz, "!policy");
return 1;
}
if (type > policy->max_attr) {
if (*n < str_sz)
*n += snprintf(str, str_sz, "!oob");
return 1;
}
if (!policy->table[type].name) {
if (*n < str_sz)
*n += snprintf(str, str_sz, "!name");
return 1;
}
if (*n < str_sz) {
int sz;
sz = snprintf(str, str_sz - *n,
".%s", policy->table[type].name);
*n += sz;
str += sz;
}
Annotation
- Immediate include surface: `errno.h`, `poll.h`, `string.h`, `stdlib.h`, `stdio.h`, `unistd.h`, `linux/types.h`, `linux/genetlink.h`.
- Detected declarations: `function ynl_err_walk_is_sel`, `function ynl_err_walk_sel_policy`, `function ynl_err_walk_report_one`, `function ynl_err_walk`, `function ynl_attr_for_each_payload`, `function ynl_ext_ack_check`, `function ynl_attr_for_each`, `function ynl_cb_error`, `function ynl_cb_done`, `function __ynl_attr_validate`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.