xfrm: Add mode handlers for IPsec on layer 2
[linux-block.git] / net / xfrm / xfrm_device.c
CommitLineData
21f42cc9
SK
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
15#include <linux/errno.h>
16#include <linux/module.h>
17#include <linux/netdevice.h>
18#include <linux/skbuff.h>
19#include <linux/slab.h>
20#include <linux/spinlock.h>
21#include <net/dst.h>
22#include <net/xfrm.h>
23#include <linux/notifier.h>
24
25static int xfrm_dev_event(struct notifier_block *this, unsigned long event, void *ptr)
26{
27 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
28
29 switch (event) {
30 case NETDEV_DOWN:
31 xfrm_garbage_collect(dev_net(dev));
32 }
33 return NOTIFY_DONE;
34}
35
36static struct notifier_block xfrm_dev_notifier = {
37 .notifier_call = xfrm_dev_event,
38};
39
40void __net_init xfrm_dev_init(void)
41{
42 register_netdevice_notifier(&xfrm_dev_notifier);
43}