blob: 5de61aaad586686734c85842f738cda9d26ea03c [file] [log] [blame]
Neil Horman9a8afc82009-03-11 09:51:26 +00001/*
2 * Monitoring code for network dropped packet alerts
3 *
4 * Copyright (C) 2009 Neil Horman <nhorman@tuxdriver.com>
5 */
6
Joe Perchese005d192012-05-16 19:58:40 +00007#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
8
Neil Horman9a8afc82009-03-11 09:51:26 +00009#include <linux/netdevice.h>
10#include <linux/etherdevice.h>
11#include <linux/string.h>
12#include <linux/if_arp.h>
13#include <linux/inetdevice.h>
14#include <linux/inet.h>
15#include <linux/interrupt.h>
16#include <linux/netpoll.h>
17#include <linux/sched.h>
18#include <linux/delay.h>
19#include <linux/types.h>
20#include <linux/workqueue.h>
21#include <linux/netlink.h>
22#include <linux/net_dropmon.h>
23#include <linux/percpu.h>
24#include <linux/timer.h>
25#include <linux/bitops.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090026#include <linux/slab.h>
Neil Hormancad456d2012-05-17 10:04:00 +000027#include <linux/module.h>
Neil Horman9a8afc82009-03-11 09:51:26 +000028#include <net/genetlink.h>
Neil Horman4ea7e382009-05-21 07:36:08 +000029#include <net/netevent.h>
Neil Horman9a8afc82009-03-11 09:51:26 +000030
Steven Rostedtad8d75f2009-04-14 19:39:12 -040031#include <trace/events/skb.h>
David S. Miller9cbc1cb2009-06-15 03:02:23 -070032#include <trace/events/napi.h>
Neil Horman9a8afc82009-03-11 09:51:26 +000033
34#include <asm/unaligned.h>
35
36#define TRACE_ON 1
37#define TRACE_OFF 0
38
Neil Horman9a8afc82009-03-11 09:51:26 +000039/*
40 * Globals, our netlink socket pointer
41 * and the work handle that will send up
42 * netlink alerts
43 */
Neil Horman4ea7e382009-05-21 07:36:08 +000044static int trace_state = TRACE_OFF;
Neil Hormancde2e9a2012-04-27 10:11:48 +000045static DEFINE_MUTEX(trace_state_mutex);
Neil Horman9a8afc82009-03-11 09:51:26 +000046
47struct per_cpu_dm_data {
Eric Dumazetbec45962012-06-04 00:18:19 +000048 spinlock_t lock;
49 struct sk_buff *skb;
50 struct work_struct dm_alert_work;
51 struct timer_list send_timer;
Neil Horman9a8afc82009-03-11 09:51:26 +000052};
53
Neil Horman4ea7e382009-05-21 07:36:08 +000054struct dm_hw_stat_delta {
55 struct net_device *dev;
Neil Horman5848cc02009-09-02 14:37:45 -070056 unsigned long last_rx;
Neil Horman4ea7e382009-05-21 07:36:08 +000057 struct list_head list;
58 struct rcu_head rcu;
59 unsigned long last_drop_val;
60};
61
Neil Horman9a8afc82009-03-11 09:51:26 +000062static struct genl_family net_drop_monitor_family = {
63 .id = GENL_ID_GENERATE,
64 .hdrsize = 0,
65 .name = "NET_DM",
Neil Horman683703a2009-04-27 03:17:31 -070066 .version = 2,
Neil Horman9a8afc82009-03-11 09:51:26 +000067};
68
69static DEFINE_PER_CPU(struct per_cpu_dm_data, dm_cpu_data);
70
71static int dm_hit_limit = 64;
72static int dm_delay = 1;
Neil Horman4ea7e382009-05-21 07:36:08 +000073static unsigned long dm_hw_check_delta = 2*HZ;
74static LIST_HEAD(hw_stats_list);
Neil Horman9a8afc82009-03-11 09:51:26 +000075
Eric Dumazetbec45962012-06-04 00:18:19 +000076static struct sk_buff *reset_per_cpu_data(struct per_cpu_dm_data *data)
Neil Horman9a8afc82009-03-11 09:51:26 +000077{
78 size_t al;
79 struct net_dm_alert_msg *msg;
Neil Horman683703a2009-04-27 03:17:31 -070080 struct nlattr *nla;
Neil Horman3885ca72012-04-27 10:11:49 +000081 struct sk_buff *skb;
Eric Dumazetbec45962012-06-04 00:18:19 +000082 unsigned long flags;
Reiter Wolfgang9f7551e2016-12-31 21:11:57 +010083 void *msg_header;
Neil Horman9a8afc82009-03-11 09:51:26 +000084
85 al = sizeof(struct net_dm_alert_msg);
86 al += dm_hit_limit * sizeof(struct net_dm_drop_point);
Neil Horman683703a2009-04-27 03:17:31 -070087 al += sizeof(struct nlattr);
88
Neil Horman3885ca72012-04-27 10:11:49 +000089 skb = genlmsg_new(al, GFP_KERNEL);
90
Reiter Wolfgang9f7551e2016-12-31 21:11:57 +010091 if (!skb)
92 goto err;
Neil Horman3885ca72012-04-27 10:11:49 +000093
Reiter Wolfgang9f7551e2016-12-31 21:11:57 +010094 msg_header = genlmsg_put(skb, 0, 0, &net_drop_monitor_family,
95 0, NET_DM_CMD_ALERT);
96 if (!msg_header) {
97 nlmsg_free(skb);
98 skb = NULL;
99 goto err;
100 }
101 nla = nla_reserve(skb, NLA_UNSPEC,
102 sizeof(struct net_dm_alert_msg));
103 if (!nla) {
104 nlmsg_free(skb);
105 skb = NULL;
106 goto err;
107 }
108 msg = nla_data(nla);
109 memset(msg, 0, al);
110 genlmsg_end(skb, msg_header);
111 goto out;
112
113err:
114 mod_timer(&data->send_timer, jiffies + HZ / 10);
115out:
Eric Dumazetbec45962012-06-04 00:18:19 +0000116 spin_lock_irqsave(&data->lock, flags);
117 swap(data->skb, skb);
118 spin_unlock_irqrestore(&data->lock, flags);
119
120 return skb;
Neil Horman9a8afc82009-03-11 09:51:26 +0000121}
122
stephen hemminger85bae4b2016-08-31 15:15:23 -0700123static const struct genl_multicast_group dropmon_mcgrps[] = {
Johannes Berg2a94fe42013-11-19 15:19:39 +0100124 { .name = "events", },
Johannes Berge5dcecb2013-11-19 15:19:32 +0100125};
126
Eric Dumazetbec45962012-06-04 00:18:19 +0000127static void send_dm_alert(struct work_struct *work)
Neil Horman9a8afc82009-03-11 09:51:26 +0000128{
129 struct sk_buff *skb;
Eric Dumazetbec45962012-06-04 00:18:19 +0000130 struct per_cpu_dm_data *data;
Neil Horman9a8afc82009-03-11 09:51:26 +0000131
Eric Dumazetbec45962012-06-04 00:18:19 +0000132 data = container_of(work, struct per_cpu_dm_data, dm_alert_work);
Neil Horman4fdcfa12012-05-01 08:18:02 +0000133
Eric Dumazetbec45962012-06-04 00:18:19 +0000134 skb = reset_per_cpu_data(data);
Neil Horman9a8afc82009-03-11 09:51:26 +0000135
Neil Horman3885ca72012-04-27 10:11:49 +0000136 if (skb)
Johannes Berg68eb5502013-11-19 15:19:38 +0100137 genlmsg_multicast(&net_drop_monitor_family, skb, 0,
Johannes Berg2a94fe42013-11-19 15:19:39 +0100138 0, GFP_KERNEL);
Neil Horman9a8afc82009-03-11 09:51:26 +0000139}
140
141/*
142 * This is the timer function to delay the sending of an alert
143 * in the event that more drops will arrive during the
Eric Dumazetbec45962012-06-04 00:18:19 +0000144 * hysteresis period.
Neil Horman9a8afc82009-03-11 09:51:26 +0000145 */
Eric Dumazetbec45962012-06-04 00:18:19 +0000146static void sched_send_work(unsigned long _data)
Neil Horman9a8afc82009-03-11 09:51:26 +0000147{
Eric Dumazetbec45962012-06-04 00:18:19 +0000148 struct per_cpu_dm_data *data = (struct per_cpu_dm_data *)_data;
Neil Horman9a8afc82009-03-11 09:51:26 +0000149
Eric Dumazetbec45962012-06-04 00:18:19 +0000150 schedule_work(&data->dm_alert_work);
Neil Horman9a8afc82009-03-11 09:51:26 +0000151}
152
Neil Horman4ea7e382009-05-21 07:36:08 +0000153static void trace_drop_common(struct sk_buff *skb, void *location)
Neil Horman9a8afc82009-03-11 09:51:26 +0000154{
155 struct net_dm_alert_msg *msg;
156 struct nlmsghdr *nlh;
Neil Horman683703a2009-04-27 03:17:31 -0700157 struct nlattr *nla;
Neil Horman9a8afc82009-03-11 09:51:26 +0000158 int i;
Neil Horman3885ca72012-04-27 10:11:49 +0000159 struct sk_buff *dskb;
Eric Dumazetbec45962012-06-04 00:18:19 +0000160 struct per_cpu_dm_data *data;
161 unsigned long flags;
Neil Horman9a8afc82009-03-11 09:51:26 +0000162
Eric Dumazetbec45962012-06-04 00:18:19 +0000163 local_irq_save(flags);
Christoph Lameter903ceff2014-08-17 12:30:35 -0500164 data = this_cpu_ptr(&dm_cpu_data);
Eric Dumazetbec45962012-06-04 00:18:19 +0000165 spin_lock(&data->lock);
166 dskb = data->skb;
Neil Horman3885ca72012-04-27 10:11:49 +0000167
168 if (!dskb)
169 goto out;
170
Neil Horman3885ca72012-04-27 10:11:49 +0000171 nlh = (struct nlmsghdr *)dskb->data;
Neil Horman683703a2009-04-27 03:17:31 -0700172 nla = genlmsg_data(nlmsg_data(nlh));
173 msg = nla_data(nla);
Neil Horman9a8afc82009-03-11 09:51:26 +0000174 for (i = 0; i < msg->entries; i++) {
175 if (!memcmp(&location, msg->points[i].pc, sizeof(void *))) {
176 msg->points[i].count++;
177 goto out;
178 }
179 }
Eric Dumazetbec45962012-06-04 00:18:19 +0000180 if (msg->entries == dm_hit_limit)
181 goto out;
Neil Horman9a8afc82009-03-11 09:51:26 +0000182 /*
183 * We need to create a new entry
184 */
Neil Horman3885ca72012-04-27 10:11:49 +0000185 __nla_reserve_nohdr(dskb, sizeof(struct net_dm_drop_point));
Neil Horman683703a2009-04-27 03:17:31 -0700186 nla->nla_len += NLA_ALIGN(sizeof(struct net_dm_drop_point));
Neil Horman9a8afc82009-03-11 09:51:26 +0000187 memcpy(msg->points[msg->entries].pc, &location, sizeof(void *));
188 msg->points[msg->entries].count = 1;
189 msg->entries++;
190
191 if (!timer_pending(&data->send_timer)) {
192 data->send_timer.expires = jiffies + dm_delay * HZ;
Eric Dumazetbec45962012-06-04 00:18:19 +0000193 add_timer(&data->send_timer);
Neil Horman9a8afc82009-03-11 09:51:26 +0000194 }
195
196out:
Eric Dumazetbec45962012-06-04 00:18:19 +0000197 spin_unlock_irqrestore(&data->lock, flags);
Neil Horman9a8afc82009-03-11 09:51:26 +0000198}
199
Steven Rostedt38516ab2010-04-20 17:04:50 -0400200static void trace_kfree_skb_hit(void *ignore, struct sk_buff *skb, void *location)
Neil Horman4ea7e382009-05-21 07:36:08 +0000201{
202 trace_drop_common(skb, location);
203}
204
Jesper Dangaard Brouer1db19db2016-07-07 18:01:32 +0200205static void trace_napi_poll_hit(void *ignore, struct napi_struct *napi,
206 int work, int budget)
Neil Horman4ea7e382009-05-21 07:36:08 +0000207{
208 struct dm_hw_stat_delta *new_stat;
209
210 /*
Neil Horman5848cc02009-09-02 14:37:45 -0700211 * Don't check napi structures with no associated device
Neil Horman4ea7e382009-05-21 07:36:08 +0000212 */
Neil Horman5848cc02009-09-02 14:37:45 -0700213 if (!napi->dev)
Neil Horman4ea7e382009-05-21 07:36:08 +0000214 return;
215
216 rcu_read_lock();
217 list_for_each_entry_rcu(new_stat, &hw_stats_list, list) {
Neil Horman5848cc02009-09-02 14:37:45 -0700218 /*
219 * only add a note to our monitor buffer if:
220 * 1) this is the dev we received on
221 * 2) its after the last_rx delta
222 * 3) our rx_dropped count has gone up
223 */
Neil Horman4ea7e382009-05-21 07:36:08 +0000224 if ((new_stat->dev == napi->dev) &&
Neil Horman5848cc02009-09-02 14:37:45 -0700225 (time_after(jiffies, new_stat->last_rx + dm_hw_check_delta)) &&
Neil Horman4ea7e382009-05-21 07:36:08 +0000226 (napi->dev->stats.rx_dropped != new_stat->last_drop_val)) {
227 trace_drop_common(NULL, NULL);
228 new_stat->last_drop_val = napi->dev->stats.rx_dropped;
Neil Horman5848cc02009-09-02 14:37:45 -0700229 new_stat->last_rx = jiffies;
Neil Horman4ea7e382009-05-21 07:36:08 +0000230 break;
231 }
232 }
233 rcu_read_unlock();
234}
235
Neil Horman9a8afc82009-03-11 09:51:26 +0000236static int set_all_monitor_traces(int state)
237{
238 int rc = 0;
Neil Horman4ea7e382009-05-21 07:36:08 +0000239 struct dm_hw_stat_delta *new_stat = NULL;
240 struct dm_hw_stat_delta *temp;
241
Neil Hormancde2e9a2012-04-27 10:11:48 +0000242 mutex_lock(&trace_state_mutex);
Neil Horman9a8afc82009-03-11 09:51:26 +0000243
Neil Horman4b706372010-07-20 04:52:09 +0000244 if (state == trace_state) {
245 rc = -EAGAIN;
246 goto out_unlock;
247 }
248
Neil Horman9a8afc82009-03-11 09:51:26 +0000249 switch (state) {
250 case TRACE_ON:
Neil Hormancad456d2012-05-17 10:04:00 +0000251 if (!try_module_get(THIS_MODULE)) {
252 rc = -ENODEV;
253 break;
254 }
255
Steven Rostedt38516ab2010-04-20 17:04:50 -0400256 rc |= register_trace_kfree_skb(trace_kfree_skb_hit, NULL);
257 rc |= register_trace_napi_poll(trace_napi_poll_hit, NULL);
Neil Horman9a8afc82009-03-11 09:51:26 +0000258 break;
Neil Hormancad456d2012-05-17 10:04:00 +0000259
Neil Horman9a8afc82009-03-11 09:51:26 +0000260 case TRACE_OFF:
Steven Rostedt38516ab2010-04-20 17:04:50 -0400261 rc |= unregister_trace_kfree_skb(trace_kfree_skb_hit, NULL);
262 rc |= unregister_trace_napi_poll(trace_napi_poll_hit, NULL);
Neil Horman9a8afc82009-03-11 09:51:26 +0000263
264 tracepoint_synchronize_unregister();
Neil Horman4ea7e382009-05-21 07:36:08 +0000265
266 /*
267 * Clean the device list
268 */
269 list_for_each_entry_safe(new_stat, temp, &hw_stats_list, list) {
270 if (new_stat->dev == NULL) {
271 list_del_rcu(&new_stat->list);
Lai Jiangshanfa81c0e2011-03-18 11:39:43 +0800272 kfree_rcu(new_stat, rcu);
Neil Horman4ea7e382009-05-21 07:36:08 +0000273 }
274 }
Neil Hormancad456d2012-05-17 10:04:00 +0000275
276 module_put(THIS_MODULE);
277
Neil Horman9a8afc82009-03-11 09:51:26 +0000278 break;
279 default:
280 rc = 1;
281 break;
282 }
283
Neil Horman4ea7e382009-05-21 07:36:08 +0000284 if (!rc)
285 trace_state = state;
Neil Horman4b706372010-07-20 04:52:09 +0000286 else
287 rc = -EINPROGRESS;
Neil Horman4ea7e382009-05-21 07:36:08 +0000288
Neil Horman4b706372010-07-20 04:52:09 +0000289out_unlock:
Neil Hormancde2e9a2012-04-27 10:11:48 +0000290 mutex_unlock(&trace_state_mutex);
Neil Horman4ea7e382009-05-21 07:36:08 +0000291
Neil Horman9a8afc82009-03-11 09:51:26 +0000292 return rc;
293}
294
295
296static int net_dm_cmd_config(struct sk_buff *skb,
297 struct genl_info *info)
298{
299 return -ENOTSUPP;
300}
301
302static int net_dm_cmd_trace(struct sk_buff *skb,
303 struct genl_info *info)
304{
305 switch (info->genlhdr->cmd) {
306 case NET_DM_CMD_START:
307 return set_all_monitor_traces(TRACE_ON);
Neil Horman9a8afc82009-03-11 09:51:26 +0000308 case NET_DM_CMD_STOP:
309 return set_all_monitor_traces(TRACE_OFF);
Neil Horman9a8afc82009-03-11 09:51:26 +0000310 }
311
312 return -ENOTSUPP;
313}
314
Neil Horman4ea7e382009-05-21 07:36:08 +0000315static int dropmon_net_event(struct notifier_block *ev_block,
Jiri Pirko351638e2013-05-28 01:30:21 +0000316 unsigned long event, void *ptr)
Neil Horman4ea7e382009-05-21 07:36:08 +0000317{
Jiri Pirko351638e2013-05-28 01:30:21 +0000318 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
Neil Horman4ea7e382009-05-21 07:36:08 +0000319 struct dm_hw_stat_delta *new_stat = NULL;
320 struct dm_hw_stat_delta *tmp;
321
322 switch (event) {
323 case NETDEV_REGISTER:
324 new_stat = kzalloc(sizeof(struct dm_hw_stat_delta), GFP_KERNEL);
325
326 if (!new_stat)
327 goto out;
328
329 new_stat->dev = dev;
Neil Horman5848cc02009-09-02 14:37:45 -0700330 new_stat->last_rx = jiffies;
Neil Hormancde2e9a2012-04-27 10:11:48 +0000331 mutex_lock(&trace_state_mutex);
Neil Horman4ea7e382009-05-21 07:36:08 +0000332 list_add_rcu(&new_stat->list, &hw_stats_list);
Neil Hormancde2e9a2012-04-27 10:11:48 +0000333 mutex_unlock(&trace_state_mutex);
Neil Horman4ea7e382009-05-21 07:36:08 +0000334 break;
335 case NETDEV_UNREGISTER:
Neil Hormancde2e9a2012-04-27 10:11:48 +0000336 mutex_lock(&trace_state_mutex);
Neil Horman4ea7e382009-05-21 07:36:08 +0000337 list_for_each_entry_safe(new_stat, tmp, &hw_stats_list, list) {
338 if (new_stat->dev == dev) {
339 new_stat->dev = NULL;
340 if (trace_state == TRACE_OFF) {
341 list_del_rcu(&new_stat->list);
Lai Jiangshanfa81c0e2011-03-18 11:39:43 +0800342 kfree_rcu(new_stat, rcu);
Neil Horman4ea7e382009-05-21 07:36:08 +0000343 break;
344 }
345 }
346 }
Neil Hormancde2e9a2012-04-27 10:11:48 +0000347 mutex_unlock(&trace_state_mutex);
Neil Horman4ea7e382009-05-21 07:36:08 +0000348 break;
349 }
350out:
351 return NOTIFY_DONE;
352}
Neil Horman9a8afc82009-03-11 09:51:26 +0000353
Johannes Berg4534de82013-11-14 17:14:46 +0100354static const struct genl_ops dropmon_ops[] = {
Neil Horman9a8afc82009-03-11 09:51:26 +0000355 {
356 .cmd = NET_DM_CMD_CONFIG,
357 .doit = net_dm_cmd_config,
358 },
359 {
360 .cmd = NET_DM_CMD_START,
361 .doit = net_dm_cmd_trace,
362 },
363 {
364 .cmd = NET_DM_CMD_STOP,
365 .doit = net_dm_cmd_trace,
366 },
367};
368
Neil Horman4ea7e382009-05-21 07:36:08 +0000369static struct notifier_block dropmon_net_notifier = {
370 .notifier_call = dropmon_net_event
371};
372
Neil Horman9a8afc82009-03-11 09:51:26 +0000373static int __init init_net_drop_monitor(void)
374{
Neil Horman9a8afc82009-03-11 09:51:26 +0000375 struct per_cpu_dm_data *data;
Changli Gaoa256be72010-07-26 20:59:42 -0700376 int cpu, rc;
377
Joe Perchese005d192012-05-16 19:58:40 +0000378 pr_info("Initializing network drop monitor service\n");
Neil Horman9a8afc82009-03-11 09:51:26 +0000379
380 if (sizeof(void *) > 8) {
Joe Perchese005d192012-05-16 19:58:40 +0000381 pr_err("Unable to store program counters on this arch, Drop monitor failed\n");
Neil Horman9a8afc82009-03-11 09:51:26 +0000382 return -ENOSPC;
383 }
384
Johannes Berg2a94fe42013-11-19 15:19:39 +0100385 rc = genl_register_family_with_ops_groups(&net_drop_monitor_family,
386 dropmon_ops, dropmon_mcgrps);
Changli Gaoa256be72010-07-26 20:59:42 -0700387 if (rc) {
Joe Perchese005d192012-05-16 19:58:40 +0000388 pr_err("Could not create drop monitor netlink family\n");
Changli Gaoa256be72010-07-26 20:59:42 -0700389 return rc;
Neil Horman9a8afc82009-03-11 09:51:26 +0000390 }
Johannes Berg2a94fe42013-11-19 15:19:39 +0100391 WARN_ON(net_drop_monitor_family.mcgrp_offset != NET_DM_GRP_ALERT);
Johannes Berge5dcecb2013-11-19 15:19:32 +0100392
Neil Horman4ea7e382009-05-21 07:36:08 +0000393 rc = register_netdevice_notifier(&dropmon_net_notifier);
394 if (rc < 0) {
Joe Perchese005d192012-05-16 19:58:40 +0000395 pr_crit("Failed to register netdevice notifier\n");
Neil Horman4ea7e382009-05-21 07:36:08 +0000396 goto out_unreg;
397 }
398
Neil Horman9a8afc82009-03-11 09:51:26 +0000399 rc = 0;
400
Neil Hormancad456d2012-05-17 10:04:00 +0000401 for_each_possible_cpu(cpu) {
Neil Horman9a8afc82009-03-11 09:51:26 +0000402 data = &per_cpu(dm_cpu_data, cpu);
Neil Horman9a8afc82009-03-11 09:51:26 +0000403 INIT_WORK(&data->dm_alert_work, send_dm_alert);
404 init_timer(&data->send_timer);
Eric Dumazetbec45962012-06-04 00:18:19 +0000405 data->send_timer.data = (unsigned long)data;
Neil Horman9a8afc82009-03-11 09:51:26 +0000406 data->send_timer.function = sched_send_work;
Eric Dumazetbec45962012-06-04 00:18:19 +0000407 spin_lock_init(&data->lock);
Neil Horman4fdcfa12012-05-01 08:18:02 +0000408 reset_per_cpu_data(data);
Neil Horman9a8afc82009-03-11 09:51:26 +0000409 }
Neil Horman4ea7e382009-05-21 07:36:08 +0000410
Neil Horman3885ca72012-04-27 10:11:49 +0000411
Neil Horman9a8afc82009-03-11 09:51:26 +0000412 goto out;
413
414out_unreg:
415 genl_unregister_family(&net_drop_monitor_family);
416out:
417 return rc;
418}
419
Neil Hormancad456d2012-05-17 10:04:00 +0000420static void exit_net_drop_monitor(void)
421{
422 struct per_cpu_dm_data *data;
423 int cpu;
424
425 BUG_ON(unregister_netdevice_notifier(&dropmon_net_notifier));
426
427 /*
428 * Because of the module_get/put we do in the trace state change path
429 * we are guarnateed not to have any current users when we get here
430 * all we need to do is make sure that we don't have any running timers
431 * or pending schedule calls
432 */
433
434 for_each_possible_cpu(cpu) {
435 data = &per_cpu(dm_cpu_data, cpu);
436 del_timer_sync(&data->send_timer);
437 cancel_work_sync(&data->dm_alert_work);
438 /*
439 * At this point, we should have exclusive access
440 * to this struct and can free the skb inside it
441 */
442 kfree_skb(data->skb);
443 }
444
445 BUG_ON(genl_unregister_family(&net_drop_monitor_family));
446}
447
448module_init(init_net_drop_monitor);
449module_exit(exit_net_drop_monitor);
450
451MODULE_LICENSE("GPL v2");
452MODULE_AUTHOR("Neil Horman <nhorman@tuxdriver.com>");
Neil Horman3fdcbd42012-05-29 09:30:42 +0000453MODULE_ALIAS_GENL_FAMILY("NET_DM");