]> granicus.if.org Git - strace/commitdiff
rtnl_rule: decode new FRA_* attributes
authorEugene Syromyatnikov <evgsyr@gmail.com>
Mon, 16 Apr 2018 00:02:18 +0000 (02:02 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 30 May 2018 20:50:29 +0000 (20:50 +0000)
* 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>
nlattr.c
nlattr.h
rtnl_route.c
rtnl_rule.c
xlat/rtnl_rule_attrs.in

index 39e0544ccf9b5c966b8b05043a694a8d638ba4f7..057e051a1c5dbe7e9ec77bed77f91c93fcbd05dc 100644 (file)
--- a/nlattr.c
+++ b/nlattr.c
@@ -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,
index d145fdbf9b362e82f7e8dcbac90754f3295731d8..7f0ee0cd2fe02628b623fba777b432ba1212d574 100644 (file)
--- a/nlattr.h
+++ b/nlattr.h
@@ -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 */
index 1cc93392a2608c5602596bc7cc26ec18043fe7e3..ec5d69f43999ed625dd6706928fc410efabb33ec 100644 (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,
index 1ab4fd26cc9227b8e979345b116ce8be1da13aaa..740b0902594249e5005f07892e336f5640e61c2a 100644 (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)
index 971f1180f03b126de95b4114cf0b5ce46bd1707e..96ab44275964370a2cccfc418a68cf0ae1d5ca7f 100644 (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