rtnl_rule: decode new FRA_* attributes

* nlattr.h (DECL_NLA(ip_proto), DECL_NLA(rt_proto)): New declarations.
* nlattr.c (decode_nla_ip_proto): New function.
* rtnl_route.c (decode_nla_rt_proto): Likewise.
* rtnl_rule.c (decode_rule_port_rang): Likewise.
(fib_rule_hdr_nla_decoders) <[FRA_PROTOCOL]>: New attribute, introduced
by Linux commit v4.17-rc1~148^2~371.
(fib_rule_hdr_nla_decoders) <[FRA_IP_PROTO], [FRA_SPORT_RANGE],
[FRA_DPORT_RANGE]>: New attributes, introduced by Linux commit
v4.17-rc1~148^2~328^2~4.
* xlat/rtnl_rule_attrs.in (FRA_PROTOCOL, FRA_IP_PROTO, FRA_SPORT_RANGE,
FRA_DPORT_RANGE): New constants.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
This commit is contained in:
Eugene Syromyatnikov 2018-04-16 02:02:18 +02:00 committed by Dmitry V. Levin
parent 01f39a8001
commit 6c3f75ecfa
5 changed files with 61 additions and 1 deletions

View File

@ -267,6 +267,19 @@ decode_nla_xval(struct tcb *const tcp,
return true;
}
bool
decode_nla_ip_proto(struct tcb *const tcp,
const kernel_ulong_t addr,
const unsigned int len,
const void *const opaque_data)
{
static const struct decode_nla_xlat_opts opts = {
.xlat = inet_protocols, .dflt = "IPPROTO_???",
};
return decode_nla_xval(tcp, addr, len, &opts);
}
bool
decode_nla_be16(struct tcb *const tcp,
const kernel_ulong_t addr,

View File

@ -73,8 +73,10 @@ DECL_NLA(str);
DECL_NLA(strn);
DECL_NLA(fd);
DECL_NLA(ifindex);
DECL_NLA(ip_proto);
DECL_NLA(meminfo);
DECL_NLA(rt_class);
DECL_NLA(rt_proto);
DECL_NLA(tc_stats);
#endif /* !STRACE_NLATTR_H */

View File

@ -61,6 +61,21 @@ decode_nla_rt_class(struct tcb *const tcp,
return true;
}
bool
decode_nla_rt_proto(struct tcb *const tcp,
const kernel_ulong_t addr,
const unsigned int len,
const void *const opaque_data)
{
uint8_t num;
if (len < sizeof(num))
return false;
if (!umove_or_printaddr(tcp, addr, &num))
printxval_search(routing_protocols, num, "RTPROT_???");
return true;
}
static bool
decode_route_addr(struct tcb *const tcp,
const kernel_ulong_t addr,

View File

@ -79,6 +79,28 @@ decode_fib_rule_uid_range(struct tcb *const tcp,
#endif
}
static bool
decode_rule_port_range(struct tcb *const tcp,
const kernel_ulong_t addr,
const unsigned int len,
const void *const opaque_data)
{
struct /* fib_rule_port_range */ {
uint16_t start;
uint16_t end;
} range;
if (len < sizeof(range))
return false;
else if (!umove_or_printaddr(tcp, addr, &range)) {
PRINT_FIELD_U("{", range, start);
PRINT_FIELD_U(", ", range, end);
tprints("}");
}
return true;
}
static const nla_decoder_t fib_rule_hdr_nla_decoders[] = {
[FRA_DST] = decode_rule_addr,
[FRA_SRC] = decode_rule_addr,
@ -95,7 +117,11 @@ static const nla_decoder_t fib_rule_hdr_nla_decoders[] = {
[FRA_OIFNAME] = decode_nla_str,
[FRA_PAD] = NULL,
[FRA_L3MDEV] = decode_nla_u8,
[FRA_UID_RANGE] = decode_fib_rule_uid_range
[FRA_UID_RANGE] = decode_fib_rule_uid_range,
[FRA_PROTOCOL] = decode_nla_rt_proto,
[FRA_IP_PROTO] = decode_nla_ip_proto,
[FRA_SPORT_RANGE] = decode_rule_port_range,
[FRA_DPORT_RANGE] = decode_rule_port_range,
};
DECL_NETLINK_ROUTE_DECODER(decode_fib_rule_hdr)

View File

@ -19,3 +19,7 @@ FRA_OIFNAME 17
FRA_PAD 18
FRA_L3MDEV 19
FRA_UID_RANGE 20
FRA_PROTOCOL 21
FRA_IP_PROTO 22
FRA_SPORT_RANGE 23
FRA_DPORT_RANGE 24