xfrm_device.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * xfrm_device.c - IPsec device offloading code.
  3. *
  4. * Copyright (c) 2015 secunet Security Networks AG
  5. *
  6. * Author:
  7. * Steffen Klassert <steffen.klassert@secunet.com>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #include <linux/errno.h>
  15. #include <linux/module.h>
  16. #include <linux/netdevice.h>
  17. #include <linux/skbuff.h>
  18. #include <linux/slab.h>
  19. #include <linux/spinlock.h>
  20. #include <net/dst.h>
  21. #include <net/xfrm.h>
  22. #include <linux/notifier.h>
  23. static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void *ptr)
  24. {
  25. struct net_device *dev = netdev_notifier_info_to_dev(ptr);
  26. switch (event) {
  27. case NETDEV_DOWN:
  28. xfrm_garbage_collect(dev_net(dev));
  29. }
  30. return NOTIFY_DONE;
  31. }
  32. static struct notifier_block xfrm_dev_notifier = {
  33. .notifier_call = xfrm_dev_event,
  34. };
  35. void __net_init xfrm_dev_init(void)
  36. {
  37. register_netdevice_notifier(&xfrm_dev_notifier);
  38. }