[PATCH 1/3] rtnl_route: introduce rtmsg_ctx
Mathis Marion
Mathis.Marion at silabs.com
Mon Oct 23 08:56:34 UTC 2023
From: Mathis Marion <mathis.marion at silabs.com>
---
src/rtnl_route.c | 45 +++++++++++++++++++++++++++------------------
1 file changed, 27 insertions(+), 18 deletions(-)
diff --git a/src/rtnl_route.c b/src/rtnl_route.c
index 76e7eaf11..331d35f53 100644
--- a/src/rtnl_route.c
+++ b/src/rtnl_route.c
@@ -24,6 +24,15 @@
#include "xlat/rtnl_route_attrs.h"
#include "xlat/rtnl_rta_metrics_attrs.h"
+/*
+ * This structure is necessary to inform the NLA_ENCAP decoder of the lwtunnel
+ * encapsulation type.
+ */
+struct rtmsg_ctx {
+ struct rtmsg rtmsg;
+ uint16_t lwt_encap_type;
+};
+
bool
decode_nla_rt_class(struct tcb *const tcp,
const kernel_ulong_t addr,
@@ -60,9 +69,9 @@ decode_route_addr(struct tcb *const tcp,
const unsigned int len,
const void *const opaque_data)
{
- const struct rtmsg *const rtmsg = opaque_data;
+ const struct rtmsg_ctx *const ctx = opaque_data;
- decode_inet_addr(tcp, addr, len, rtmsg->rtm_family, NULL);
+ decode_inet_addr(tcp, addr, len, ctx->rtmsg.rtm_family, NULL);
return true;
}
@@ -311,38 +320,38 @@ decode_rta_multipath(struct tcb *const tcp,
DECL_NETLINK_ROUTE_DECODER(decode_rtmsg)
{
- struct rtmsg rtmsg = { .rtm_family = family };
- size_t offset = sizeof(rtmsg.rtm_family);
+ struct rtmsg_ctx ctx = { .rtmsg.rtm_family = family };
+ size_t offset = sizeof(ctx.rtmsg.rtm_family);
bool decode_nla = false;
tprint_struct_begin();
- PRINT_FIELD_XVAL(rtmsg, rtm_family, addrfams, "AF_???");
+ PRINT_FIELD_XVAL(ctx.rtmsg, rtm_family, addrfams, "AF_???");
tprint_struct_next();
- if (len >= sizeof(rtmsg)) {
+ if (len >= sizeof(ctx.rtmsg)) {
if (!umoven_or_printaddr(tcp, addr + offset,
- sizeof(rtmsg) - offset,
- (char *) &rtmsg + offset)) {
- PRINT_FIELD_U(rtmsg, rtm_dst_len);
+ sizeof(ctx.rtmsg) - offset,
+ (char *) &ctx.rtmsg + offset)) {
+ PRINT_FIELD_U(ctx.rtmsg, rtm_dst_len);
tprint_struct_next();
- PRINT_FIELD_U(rtmsg, rtm_src_len);
+ PRINT_FIELD_U(ctx.rtmsg, rtm_src_len);
tprint_struct_next();
- PRINT_FIELD_FLAGS(rtmsg, rtm_tos,
+ PRINT_FIELD_FLAGS(ctx.rtmsg, rtm_tos,
ip_type_of_services, "IPTOS_TOS_???");
tprint_struct_next();
- PRINT_FIELD_XVAL(rtmsg, rtm_table,
+ PRINT_FIELD_XVAL(ctx.rtmsg, rtm_table,
routing_table_ids, NULL);
tprint_struct_next();
- PRINT_FIELD_XVAL(rtmsg, rtm_protocol,
+ PRINT_FIELD_XVAL(ctx.rtmsg, rtm_protocol,
routing_protocols, "RTPROT_???");
tprint_struct_next();
- PRINT_FIELD_XVAL(rtmsg, rtm_scope,
+ PRINT_FIELD_XVAL(ctx.rtmsg, rtm_scope,
routing_scopes, NULL);
tprint_struct_next();
- PRINT_FIELD_XVAL(rtmsg, rtm_type,
+ PRINT_FIELD_XVAL(ctx.rtmsg, rtm_type,
routing_types, "RTN_???");
tprint_struct_next();
- PRINT_FIELD_FLAGS(rtmsg, rtm_flags,
+ PRINT_FIELD_FLAGS(ctx.rtmsg, rtm_flags,
routing_flags, "RTM_F_???");
decode_nla = true;
}
@@ -350,12 +359,12 @@ DECL_NETLINK_ROUTE_DECODER(decode_rtmsg)
tprint_more_data_follows();
tprint_struct_end();
- offset = NLMSG_ALIGN(sizeof(rtmsg));
+ offset = NLMSG_ALIGN(sizeof(ctx.rtmsg));
if (decode_nla && len > offset) {
tprint_array_next();
decode_nlattr(tcp, addr + offset, len - offset,
rtnl_route_attrs, "RTA_???",
rtmsg_nla_decoders,
- ARRAY_SIZE(rtmsg_nla_decoders), &rtmsg);
+ ARRAY_SIZE(rtmsg_nla_decoders), &ctx);
}
}
--
2.42.0
More information about the Strace-devel
mailing list