Skip to content

Commit 6c3f75e

Browse files
esyrldv-alt
andcommittedMay 30, 2018
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>
1 parent 01f39a8 commit 6c3f75e

File tree

5 files changed

+61
-1
lines changed

5 files changed

+61
-1
lines changed
 

‎nlattr.c

+13
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,19 @@ decode_nla_xval(struct tcb *const tcp,
267267
return true;
268268
}
269269

270+
bool
271+
decode_nla_ip_proto(struct tcb *const tcp,
272+
const kernel_ulong_t addr,
273+
const unsigned int len,
274+
const void *const opaque_data)
275+
{
276+
static const struct decode_nla_xlat_opts opts = {
277+
.xlat = inet_protocols, .dflt = "IPPROTO_???",
278+
};
279+
280+
return decode_nla_xval(tcp, addr, len, &opts);
281+
}
282+
270283
bool
271284
decode_nla_be16(struct tcb *const tcp,
272285
const kernel_ulong_t addr,

‎nlattr.h

+2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ DECL_NLA(str);
7373
DECL_NLA(strn);
7474
DECL_NLA(fd);
7575
DECL_NLA(ifindex);
76+
DECL_NLA(ip_proto);
7677
DECL_NLA(meminfo);
7778
DECL_NLA(rt_class);
79+
DECL_NLA(rt_proto);
7880
DECL_NLA(tc_stats);
7981

8082
#endif /* !STRACE_NLATTR_H */

‎rtnl_route.c

+15
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ decode_nla_rt_class(struct tcb *const tcp,
6161
return true;
6262
}
6363

64+
bool
65+
decode_nla_rt_proto(struct tcb *const tcp,
66+
const kernel_ulong_t addr,
67+
const unsigned int len,
68+
const void *const opaque_data)
69+
{
70+
uint8_t num;
71+
72+
if (len < sizeof(num))
73+
return false;
74+
if (!umove_or_printaddr(tcp, addr, &num))
75+
printxval_search(routing_protocols, num, "RTPROT_???");
76+
return true;
77+
}
78+
6479
static bool
6580
decode_route_addr(struct tcb *const tcp,
6681
const kernel_ulong_t addr,

‎rtnl_rule.c

+27-1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,28 @@ decode_fib_rule_uid_range(struct tcb *const tcp,
7979
#endif
8080
}
8181

82+
static bool
83+
decode_rule_port_range(struct tcb *const tcp,
84+
const kernel_ulong_t addr,
85+
const unsigned int len,
86+
const void *const opaque_data)
87+
{
88+
struct /* fib_rule_port_range */ {
89+
uint16_t start;
90+
uint16_t end;
91+
} range;
92+
93+
if (len < sizeof(range))
94+
return false;
95+
else if (!umove_or_printaddr(tcp, addr, &range)) {
96+
PRINT_FIELD_U("{", range, start);
97+
PRINT_FIELD_U(", ", range, end);
98+
tprints("}");
99+
}
100+
101+
return true;
102+
}
103+
82104
static const nla_decoder_t fib_rule_hdr_nla_decoders[] = {
83105
[FRA_DST] = decode_rule_addr,
84106
[FRA_SRC] = decode_rule_addr,
@@ -95,7 +117,11 @@ static const nla_decoder_t fib_rule_hdr_nla_decoders[] = {
95117
[FRA_OIFNAME] = decode_nla_str,
96118
[FRA_PAD] = NULL,
97119
[FRA_L3MDEV] = decode_nla_u8,
98-
[FRA_UID_RANGE] = decode_fib_rule_uid_range
120+
[FRA_UID_RANGE] = decode_fib_rule_uid_range,
121+
[FRA_PROTOCOL] = decode_nla_rt_proto,
122+
[FRA_IP_PROTO] = decode_nla_ip_proto,
123+
[FRA_SPORT_RANGE] = decode_rule_port_range,
124+
[FRA_DPORT_RANGE] = decode_rule_port_range,
99125
};
100126

101127
DECL_NETLINK_ROUTE_DECODER(decode_fib_rule_hdr)

‎xlat/rtnl_rule_attrs.in

+4
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ FRA_OIFNAME 17
1919
FRA_PAD 18
2020
FRA_L3MDEV 19
2121
FRA_UID_RANGE 20
22+
FRA_PROTOCOL 21
23+
FRA_IP_PROTO 22
24+
FRA_SPORT_RANGE 23
25+
FRA_DPORT_RANGE 24

0 commit comments

Comments
 (0)
Please sign in to comment.