mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
tools: ynl: don't use genlmsghdr in classic netlink
Make sure the codegen calls the right YNL lib helper to start the request based on family type. Classic netlink request must not include the genl header. Conversely don't expect genl headers in the responses. Reviewed-by: Jacob Keller <jacob.e.keller@intel.com> Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Link: https://patch.msgid.link/20250410014658.782120-10-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
e0a7903c32
commit
7e8ba0c7de
3 changed files with 22 additions and 8 deletions
|
@ -94,6 +94,9 @@ struct ynl_ntf_base_type {
|
||||||
unsigned char data[] __attribute__((aligned(8)));
|
unsigned char data[] __attribute__((aligned(8)));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct nlmsghdr *ynl_msg_start_req(struct ynl_sock *ys, __u32 id);
|
||||||
|
struct nlmsghdr *ynl_msg_start_dump(struct ynl_sock *ys, __u32 id);
|
||||||
|
|
||||||
struct nlmsghdr *
|
struct nlmsghdr *
|
||||||
ynl_gemsg_start_req(struct ynl_sock *ys, __u32 id, __u8 cmd, __u8 version);
|
ynl_gemsg_start_req(struct ynl_sock *ys, __u32 id, __u8 cmd, __u8 version);
|
||||||
struct nlmsghdr *
|
struct nlmsghdr *
|
||||||
|
|
|
@ -451,14 +451,14 @@ ynl_gemsg_start(struct ynl_sock *ys, __u32 id, __u16 flags,
|
||||||
return nlh;
|
return nlh;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ynl_msg_start_req(struct ynl_sock *ys, __u32 id)
|
struct nlmsghdr *ynl_msg_start_req(struct ynl_sock *ys, __u32 id)
|
||||||
{
|
{
|
||||||
ynl_msg_start(ys, id, NLM_F_REQUEST | NLM_F_ACK);
|
return ynl_msg_start(ys, id, NLM_F_REQUEST | NLM_F_ACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ynl_msg_start_dump(struct ynl_sock *ys, __u32 id)
|
struct nlmsghdr *ynl_msg_start_dump(struct ynl_sock *ys, __u32 id)
|
||||||
{
|
{
|
||||||
ynl_msg_start(ys, id, NLM_F_REQUEST | NLM_F_ACK | NLM_F_DUMP);
|
return ynl_msg_start(ys, id, NLM_F_REQUEST | NLM_F_ACK | NLM_F_DUMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct nlmsghdr *
|
struct nlmsghdr *
|
||||||
|
|
|
@ -1710,6 +1710,9 @@ def _multi_parse(ri, struct, init_lines, local_vars):
|
||||||
ri.cw.p(f'dst->{arg} = {arg};')
|
ri.cw.p(f'dst->{arg} = {arg};')
|
||||||
|
|
||||||
if ri.fixed_hdr:
|
if ri.fixed_hdr:
|
||||||
|
if ri.family.is_classic():
|
||||||
|
ri.cw.p('hdr = ynl_nlmsg_data(nlh);')
|
||||||
|
else:
|
||||||
ri.cw.p('hdr = ynl_nlmsg_data_offset(nlh, sizeof(struct genlmsghdr));')
|
ri.cw.p('hdr = ynl_nlmsg_data_offset(nlh, sizeof(struct genlmsghdr));')
|
||||||
ri.cw.p(f"memcpy(&dst->_hdr, hdr, sizeof({ri.fixed_hdr}));")
|
ri.cw.p(f"memcpy(&dst->_hdr, hdr, sizeof({ri.fixed_hdr}));")
|
||||||
for anest in sorted(all_multi):
|
for anest in sorted(all_multi):
|
||||||
|
@ -1857,6 +1860,9 @@ def print_req(ri):
|
||||||
ri.cw.block_start()
|
ri.cw.block_start()
|
||||||
ri.cw.write_func_lvar(local_vars)
|
ri.cw.write_func_lvar(local_vars)
|
||||||
|
|
||||||
|
if ri.family.is_classic():
|
||||||
|
ri.cw.p(f"nlh = ynl_msg_start_req(ys, {ri.op.enum_name});")
|
||||||
|
else:
|
||||||
ri.cw.p(f"nlh = ynl_gemsg_start_req(ys, {ri.nl.get_family_id()}, {ri.op.enum_name}, 1);")
|
ri.cw.p(f"nlh = ynl_gemsg_start_req(ys, {ri.nl.get_family_id()}, {ri.op.enum_name}, 1);")
|
||||||
|
|
||||||
ri.cw.p(f"ys->req_policy = &{ri.struct['request'].render_name}_nest;")
|
ri.cw.p(f"ys->req_policy = &{ri.struct['request'].render_name}_nest;")
|
||||||
|
@ -1926,6 +1932,9 @@ def print_dump(ri):
|
||||||
else:
|
else:
|
||||||
ri.cw.p(f'yds.rsp_cmd = {ri.op.rsp_value};')
|
ri.cw.p(f'yds.rsp_cmd = {ri.op.rsp_value};')
|
||||||
ri.cw.nl()
|
ri.cw.nl()
|
||||||
|
if ri.family.is_classic():
|
||||||
|
ri.cw.p(f"nlh = ynl_msg_start_dump(ys, {ri.op.enum_name});")
|
||||||
|
else:
|
||||||
ri.cw.p(f"nlh = ynl_gemsg_start_dump(ys, {ri.nl.get_family_id()}, {ri.op.enum_name}, 1);")
|
ri.cw.p(f"nlh = ynl_gemsg_start_dump(ys, {ri.nl.get_family_id()}, {ri.op.enum_name}, 1);")
|
||||||
|
|
||||||
if ri.fixed_hdr:
|
if ri.fixed_hdr:
|
||||||
|
@ -2736,7 +2745,9 @@ def render_user_family(family, cw, prototype):
|
||||||
if family.is_classic():
|
if family.is_classic():
|
||||||
cw.p(f'.is_classic\t= true,')
|
cw.p(f'.is_classic\t= true,')
|
||||||
cw.p(f'.classic_id\t= {family.get("protonum")},')
|
cw.p(f'.classic_id\t= {family.get("protonum")},')
|
||||||
if family.fixed_header:
|
if family.is_classic():
|
||||||
|
cw.p(f'.hdr_len\t= sizeof(struct {c_lower(family.fixed_header)}),')
|
||||||
|
elif family.fixed_header:
|
||||||
cw.p(f'.hdr_len\t= sizeof(struct genlmsghdr) + sizeof(struct {c_lower(family.fixed_header)}),')
|
cw.p(f'.hdr_len\t= sizeof(struct genlmsghdr) + sizeof(struct {c_lower(family.fixed_header)}),')
|
||||||
else:
|
else:
|
||||||
cw.p('.hdr_len\t= sizeof(struct genlmsghdr),')
|
cw.p('.hdr_len\t= sizeof(struct genlmsghdr),')
|
||||||
|
|
Loading…
Add table
Reference in a new issue