]> granicus.if.org Git - strace/commitdiff
nlattr: provide common AF_INET{,6} address decoders
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sun, 19 Aug 2018 12:37:12 +0000 (14:37 +0200)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 1 Sep 2018 13:02:04 +0000 (13:02 +0000)
Rename decode_ifla_inet6_token to decode_nla_in6_addr,
add a sister function decode_nla_in_addr for future use.

* nlattr.c (decode_nla_in_addr, decode_nla_in6_addr): New functions.
* nlattr.h (DECL_NLA(in_addr), DECL_NLA(in6_addr)): New declarations.
* rtnl_link.c (decode_ifla_inet6_token): Remove.
(ifla_inet6_nla_decoders) <[IFLA_INET6_TOKEN]>: Use decode_nla_in6_addr.

nlattr.c
nlattr.h
rtnl_link.c

index af7cc162e3606bd09fd8a40fa3caaca99b7869f3..e7ea5330794716f67d455ba16230ccbd72244511 100644 (file)
--- a/nlattr.c
+++ b/nlattr.c
@@ -357,6 +357,38 @@ decode_nla_ip_proto(struct tcb *const tcp,
        return decode_nla_xval(tcp, addr, len, &opts);
 }
 
+bool
+decode_nla_in_addr(struct tcb *const tcp,
+                  const kernel_ulong_t addr,
+                  const unsigned int len,
+                  const void *const opaque_data)
+{
+       struct in_addr in;
+
+       if (len < sizeof(in))
+               return false;
+       else if (!umove_or_printaddr(tcp, addr, &in))
+               print_inet_addr(AF_INET, &in, sizeof(in), NULL);
+
+       return true;
+}
+
+bool
+decode_nla_in6_addr(struct tcb *const tcp,
+                   const kernel_ulong_t addr,
+                   const unsigned int len,
+                   const void *const opaque_data)
+{
+       struct in6_addr in6;
+
+       if (len < sizeof(in6))
+               return false;
+       else if (!umove_or_printaddr(tcp, addr, &in6))
+               print_inet_addr(AF_INET6, &in6, sizeof(in6), NULL);
+
+       return true;
+}
+
 bool
 decode_nla_flags(struct tcb *const tcp,
                 const kernel_ulong_t addr,
index 27ffdebd8341f57a1ab309a6ea7736062108b7ef..fd54af477dfaf247c02bdbd04efd4f0122fee357 100644 (file)
--- a/nlattr.h
+++ b/nlattr.h
@@ -102,6 +102,8 @@ DECL_NLA(gid);
 DECL_NLA(ifindex);
 DECL_NLA(ether_proto);
 DECL_NLA(ip_proto);
+DECL_NLA(in_addr);
+DECL_NLA(in6_addr);
 DECL_NLA(meminfo);
 DECL_NLA(rt_class);
 DECL_NLA(rt_proto);
index 41c5efbaf915dc025a42026f441fab6cf618921f..01450993506075410317b6f3710f5b046d514f32 100644 (file)
@@ -761,22 +761,6 @@ decode_ifla_inet6_icmp6_stats(struct tcb *const tcp,
        return true;
 }
 
-static bool
-decode_ifla_inet6_token(struct tcb *const tcp,
-                       const kernel_ulong_t addr,
-                       const unsigned int len,
-                       const void *const opaque_data)
-{
-       struct in6_addr in6;
-
-       if (len < sizeof(in6))
-               return false;
-       else if (!umove_or_printaddr(tcp, addr, &in6))
-               print_inet_addr(AF_INET6, &in6, sizeof(in6), NULL);
-
-       return true;
-}
-
 static bool
 decode_ifla_inet6_agm(struct tcb *const tcp,
                      const kernel_ulong_t addr,
@@ -799,7 +783,7 @@ static const nla_decoder_t ifla_inet6_nla_decoders[] = {
        [IFLA_INET6_MCAST]              = NULL, /* unused */
        [IFLA_INET6_CACHEINFO]          = decode_ifla_inet6_cacheinfo,
        [IFLA_INET6_ICMP6STATS]         = decode_ifla_inet6_icmp6_stats,
-       [IFLA_INET6_TOKEN]              = decode_ifla_inet6_token,
+       [IFLA_INET6_TOKEN]              = decode_nla_in6_addr,
        [IFLA_INET6_ADDR_GEN_MODE]      = decode_ifla_inet6_agm,
 };