net/tipc/netlink_compat.c
Source file repositories/reference/linux-study-clean/net/tipc/netlink_compat.c
File Facts
- System
- Linux kernel
- Corpus path
net/tipc/netlink_compat.c- Extension
.c- Size
- 35484 bytes
- Lines
- 1374
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source 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.
- 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
core.hbearer.hlink.hname_table.hsocket.hnode.hnet.hnet/genetlink.hlinux/string_helpers.hlinux/tipc_config.h
Detected Declarations
struct tipc_nl_compat_msgstruct tipc_nl_compat_cmd_dumpstruct tipc_nl_compat_cmd_doitfunction tipc_skb_tailroomfunction TLV_GET_DATA_LENfunction tipc_add_tlvfunction tipc_tlv_initfunction __printffunction __tipc_nl_compat_dumpitfunction nlmsg_for_each_msgfunction tipc_nl_compat_dumpitfunction __tipc_nl_compat_doitfunction tipc_nl_compat_doitfunction tipc_nl_compat_bearer_dumpfunction tipc_nl_compat_bearer_enablefunction tipc_nl_compat_bearer_disablefunction percfunction __fill_bc_link_statfunction tipc_nl_compat_link_stat_dumpfunction tipc_nl_compat_link_dumpfunction __tipc_add_link_propfunction tipc_nl_compat_media_setfunction tipc_nl_compat_bearer_setfunction __tipc_nl_compat_link_setfunction tipc_nl_compat_link_setfunction tipc_nl_compat_link_reset_statsfunction tipc_nl_compat_name_table_dump_headerfunction tipc_nl_compat_name_table_dumpfunction __tipc_nl_compat_publ_dumpfunction tipc_nl_compat_publ_dumpfunction tipc_nl_compat_sk_dumpfunction tipc_nl_compat_media_dumpfunction tipc_nl_compat_node_dumpfunction tipc_nl_compat_net_setfunction tipc_nl_compat_net_dumpfunction tipc_cmd_show_stats_compatfunction tipc_nl_compat_handlefunction tipc_nl_compat_recvfunction tipc_netlink_compat_startfunction tipc_netlink_compat_stop
Annotated Snippet
struct tipc_nl_compat_msg {
u16 cmd;
int rep_type;
int rep_size;
int req_type;
int req_size;
struct net *net;
struct sk_buff *rep;
struct tlv_desc *req;
struct sock *dst_sk;
};
struct tipc_nl_compat_cmd_dump {
int (*header)(struct tipc_nl_compat_msg *);
int (*dumpit)(struct sk_buff *, struct netlink_callback *);
int (*format)(struct tipc_nl_compat_msg *msg, struct nlattr **attrs);
};
struct tipc_nl_compat_cmd_doit {
int (*doit)(struct sk_buff *skb, struct genl_info *info);
int (*transcode)(struct tipc_nl_compat_cmd_doit *cmd,
struct sk_buff *skb, struct tipc_nl_compat_msg *msg);
};
static int tipc_skb_tailroom(struct sk_buff *skb)
{
int tailroom;
int limit;
tailroom = skb_tailroom(skb);
limit = TIPC_SKB_MAX - skb->len;
if (tailroom < limit)
return tailroom;
return limit;
}
static inline int TLV_GET_DATA_LEN(struct tlv_desc *tlv)
{
return TLV_GET_LEN(tlv) - TLV_SPACE(0);
}
static int tipc_add_tlv(struct sk_buff *skb, u16 type, void *data, u16 len)
{
struct tlv_desc *tlv = (struct tlv_desc *)skb_tail_pointer(skb);
if (tipc_skb_tailroom(skb) < TLV_SPACE(len))
return -EMSGSIZE;
skb_put(skb, TLV_SPACE(len));
memset(tlv, 0, TLV_SPACE(len));
tlv->tlv_type = htons(type);
tlv->tlv_len = htons(TLV_LENGTH(len));
if (len && data)
memcpy(TLV_DATA(tlv), data, len);
return 0;
}
static void tipc_tlv_init(struct sk_buff *skb, u16 type)
{
struct tlv_desc *tlv = (struct tlv_desc *)skb->data;
TLV_SET_LEN(tlv, 0);
TLV_SET_TYPE(tlv, type);
skb_put(skb, sizeof(struct tlv_desc));
}
static __printf(2, 3) int tipc_tlv_sprintf(struct sk_buff *skb,
const char *fmt, ...)
{
int n;
u16 len;
u32 rem;
char *buf;
struct tlv_desc *tlv;
va_list args;
rem = tipc_skb_tailroom(skb);
tlv = (struct tlv_desc *)skb->data;
len = TLV_GET_LEN(tlv);
buf = TLV_DATA(tlv) + len;
va_start(args, fmt);
n = vscnprintf(buf, rem, fmt, args);
va_end(args);
TLV_SET_LEN(tlv, n + len);
Annotation
- Immediate include surface: `core.h`, `bearer.h`, `link.h`, `name_table.h`, `socket.h`, `node.h`, `net.h`, `net/genetlink.h`.
- Detected declarations: `struct tipc_nl_compat_msg`, `struct tipc_nl_compat_cmd_dump`, `struct tipc_nl_compat_cmd_doit`, `function tipc_skb_tailroom`, `function TLV_GET_DATA_LEN`, `function tipc_add_tlv`, `function tipc_tlv_init`, `function __printf`, `function __tipc_nl_compat_dumpit`, `function nlmsg_for_each_msg`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.