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_nsid.c 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2016 Fabien Siron <fabien.siron@epita.fr>
  3. * Copyright (c) 2017 JingPiao Chen <chenjingpiao@gmail.com>
  4. * Copyright (c) 2016-2019 The strace developers.
  5. * All rights reserved.
  6. *
  7. * SPDX-License-Identifier: LGPL-2.1-or-later
  8. */
  9. #include "defs.h"
  10. #include "netlink_route.h"
  11. #include "nlattr.h"
  12. #include "print_fields.h"
  13. #include "netlink.h"
  14. #include <linux/rtnetlink.h>
  15. #include "xlat/rtnl_nsid_attrs.h"
  16. static const nla_decoder_t rtgenmsg_nla_decoders[] = {
  17. [NETNSA_NSID] = decode_nla_s32,
  18. [NETNSA_PID] = decode_nla_u32,
  19. [NETNSA_FD] = decode_nla_fd,
  20. [NETNSA_TARGET_NSID] = decode_nla_s32,
  21. [NETNSA_CURRENT_NSID] = decode_nla_s32
  22. };
  23. DECL_NETLINK_ROUTE_DECODER(decode_rtgenmsg)
  24. {
  25. struct rtgenmsg rtgenmsg = { .rtgen_family = family };
  26. PRINT_FIELD_XVAL("{", rtgenmsg, rtgen_family, addrfams, "AF_???");
  27. tprints("}");
  28. const size_t offset = NLMSG_ALIGN(sizeof(rtgenmsg));
  29. if (len > offset) {
  30. tprints(", ");
  31. decode_nlattr(tcp, addr + offset, len - offset,
  32. rtnl_nsid_attrs, "NETNSA_???",
  33. rtgenmsg_nla_decoders,
  34. ARRAY_SIZE(rtgenmsg_nla_decoders), NULL);
  35. }
  36. }