container.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * lib/route/cls/ematch/container.c Container Ematch
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation version 2.1
  7. * of the License.
  8. *
  9. * Copyright (c) 2008-2013 Thomas Graf <tgraf@suug.ch>
  10. */
  11. #include <netlink-private/netlink.h>
  12. #include <netlink-private/tc.h>
  13. #include <netlink/netlink.h>
  14. #include <netlink/route/cls/ematch.h>
  15. static int container_parse(struct rtnl_ematch *e, void *data, size_t len __attribute__((unused)))
  16. {
  17. /*
  18. The kernel may provide more than 4 bytes of data in the future and we want
  19. older libnl versions to be ok with that. We want interfaces to be growable
  20. so we only ever enforce a minimum data length and copy as much as we are
  21. aware of. Thomas Graf.
  22. */
  23. memcpy(e->e_data, data, sizeof(uint32_t));
  24. return 0;
  25. }
  26. static int container_fill(struct rtnl_ematch *e, struct nl_msg *msg)
  27. {
  28. return nlmsg_append(msg, e->e_data, sizeof(uint32_t), 0);
  29. }
  30. static struct rtnl_ematch_ops container_ops = {
  31. .eo_kind = TCF_EM_CONTAINER,
  32. .eo_name = "container",
  33. .eo_minlen = sizeof(uint32_t),
  34. .eo_datalen = sizeof(uint32_t),
  35. .eo_parse = container_parse,
  36. .eo_fill = container_fill,
  37. };
  38. static void __init container_init(void)
  39. {
  40. rtnl_ematch_register(&container_ops);
  41. }