Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rtnl_addrlabel.c 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) 2016 Fabien Siron <fabien.siron@epita.fr>
  3. * Copyright (c) 2017 JingPiao Chen <chenjingpiao@gmail.com>
  4. * Copyright (c) 2016-2018 The strace developers.
  5. * All rights reserved.
  6. *
  7. * SPDX-License-Identifier: LGPL-2.1-or-later
  8. */
  9. #include "defs.h"
  10. #ifdef HAVE_STRUCT_IFADDRLBLMSG
  11. # include "netlink_route.h"
  12. # include "nlattr.h"
  13. # include "print_fields.h"
  14. # include <linux/if_addrlabel.h>
  15. # include "netlink.h"
  16. # include "xlat/rtnl_addrlabel_attrs.h"
  17. static bool
  18. decode_ifal_address(struct tcb *const tcp,
  19. const kernel_ulong_t addr,
  20. const unsigned int len,
  21. const void *const opaque_data)
  22. {
  23. const struct ifaddrlblmsg *const ifal = opaque_data;
  24. decode_inet_addr(tcp, addr, len, ifal->ifal_family, NULL);
  25. return true;
  26. }
  27. static const nla_decoder_t ifaddrlblmsg_nla_decoders[] = {
  28. [IFAL_ADDRESS] = decode_ifal_address,
  29. [IFAL_LABEL] = decode_nla_u32
  30. };
  31. DECL_NETLINK_ROUTE_DECODER(decode_ifaddrlblmsg)
  32. {
  33. struct ifaddrlblmsg ifal = { .ifal_family = family };
  34. size_t offset = sizeof(ifal.ifal_family);
  35. bool decode_nla = false;
  36. PRINT_FIELD_XVAL("{", ifal, ifal_family, addrfams, "AF_???");
  37. tprints(", ");
  38. if (len >= sizeof(ifal)) {
  39. if (!umoven_or_printaddr(tcp, addr + offset,
  40. sizeof(ifal) - offset,
  41. (char *) &ifal + offset)) {
  42. PRINT_FIELD_U("", ifal, ifal_prefixlen);
  43. PRINT_FIELD_U(", ", ifal, ifal_flags);
  44. PRINT_FIELD_IFINDEX(", ", ifal, ifal_index);
  45. PRINT_FIELD_U(", ", ifal, ifal_seq);
  46. decode_nla = true;
  47. }
  48. } else
  49. tprints("...");
  50. tprints("}");
  51. offset = NLMSG_ALIGN(sizeof(ifal));
  52. if (decode_nla && len > offset) {
  53. tprints(", ");
  54. decode_nlattr(tcp, addr + offset, len - offset,
  55. rtnl_addrlabel_attrs, "IFAL_???",
  56. ifaddrlblmsg_nla_decoders,
  57. ARRAY_SIZE(ifaddrlblmsg_nla_decoders), &ifal);
  58. }
  59. }
  60. #endif