blob: 4ffc224faa7fa1961b30d282195379c8dc78501f [file] [log] [blame]
Sean Hefty7025fcd2006-06-17 20:37:28 -07001/*
2 * Copyright (c) 2005 Voltaire Inc. All rights reserved.
3 * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
4 * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved.
5 * Copyright (c) 2005 Intel Corporation. All rights reserved.
6 *
Sean Heftya9474912008-07-14 23:48:43 -07007 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU
9 * General Public License (GPL) Version 2, available from the file
10 * COPYING in the main directory of this source tree, or the
11 * OpenIB.org BSD license below:
Sean Hefty7025fcd2006-06-17 20:37:28 -070012 *
Sean Heftya9474912008-07-14 23:48:43 -070013 * Redistribution and use in source and binary forms, with or
14 * without modification, are permitted provided that the following
15 * conditions are met:
Sean Hefty7025fcd2006-06-17 20:37:28 -070016 *
Sean Heftya9474912008-07-14 23:48:43 -070017 * - Redistributions of source code must retain the above
18 * copyright notice, this list of conditions and the following
19 * disclaimer.
Sean Hefty7025fcd2006-06-17 20:37:28 -070020 *
Sean Heftya9474912008-07-14 23:48:43 -070021 * - Redistributions in binary form must reproduce the above
22 * copyright notice, this list of conditions and the following
23 * disclaimer in the documentation and/or other materials
24 * provided with the distribution.
Sean Hefty7025fcd2006-06-17 20:37:28 -070025 *
Sean Heftya9474912008-07-14 23:48:43 -070026 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
30 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE.
Sean Hefty7025fcd2006-06-17 20:37:28 -070034 */
35
36#include <linux/mutex.h>
37#include <linux/inetdevice.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090038#include <linux/slab.h>
Sean Hefty7025fcd2006-06-17 20:37:28 -070039#include <linux/workqueue.h>
Sean Hefty7025fcd2006-06-17 20:37:28 -070040#include <net/arp.h>
41#include <net/neighbour.h>
42#include <net/route.h>
Tom Tuckere795d092006-07-30 20:44:19 -070043#include <net/netevent.h>
Aleksey Senin38617c62008-12-24 10:16:37 -080044#include <net/addrconf.h>
45#include <net/ip6_route.h>
Sean Hefty7025fcd2006-06-17 20:37:28 -070046#include <rdma/ib_addr.h>
47
48MODULE_AUTHOR("Sean Hefty");
49MODULE_DESCRIPTION("IB Address Translation");
50MODULE_LICENSE("Dual BSD/GPL");
51
52struct addr_req {
53 struct list_head list;
Aleksey Senin38617c62008-12-24 10:16:37 -080054 struct sockaddr_storage src_addr;
55 struct sockaddr_storage dst_addr;
Sean Hefty7025fcd2006-06-17 20:37:28 -070056 struct rdma_dev_addr *addr;
Sean Hefty7a118df2006-10-31 11:12:59 -080057 struct rdma_addr_client *client;
Sean Hefty7025fcd2006-06-17 20:37:28 -070058 void *context;
59 void (*callback)(int status, struct sockaddr *src_addr,
60 struct rdma_dev_addr *addr, void *context);
61 unsigned long timeout;
62 int status;
63};
64
David Howellsc4028952006-11-22 14:57:56 +000065static void process_req(struct work_struct *work);
Sean Hefty7025fcd2006-06-17 20:37:28 -070066
67static DEFINE_MUTEX(lock);
68static LIST_HEAD(req_list);
David Howellsc4028952006-11-22 14:57:56 +000069static DECLARE_DELAYED_WORK(work, process_req);
Sean Hefty7025fcd2006-06-17 20:37:28 -070070static struct workqueue_struct *addr_wq;
71
Sean Hefty7a118df2006-10-31 11:12:59 -080072void rdma_addr_register_client(struct rdma_addr_client *client)
73{
74 atomic_set(&client->refcount, 1);
75 init_completion(&client->comp);
76}
77EXPORT_SYMBOL(rdma_addr_register_client);
78
79static inline void put_client(struct rdma_addr_client *client)
80{
81 if (atomic_dec_and_test(&client->refcount))
82 complete(&client->comp);
83}
84
85void rdma_addr_unregister_client(struct rdma_addr_client *client)
86{
87 put_client(client);
88 wait_for_completion(&client->comp);
89}
90EXPORT_SYMBOL(rdma_addr_unregister_client);
91
Tom Tucker07ebafb2006-08-03 16:02:42 -050092int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
93 const unsigned char *dst_dev_addr)
Sean Hefty7025fcd2006-06-17 20:37:28 -070094{
Sean Heftyc4315d82009-11-19 12:57:18 -080095 dev_addr->dev_type = dev->type;
Sean Hefty7025fcd2006-06-17 20:37:28 -070096 memcpy(dev_addr->src_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
97 memcpy(dev_addr->broadcast, dev->broadcast, MAX_ADDR_LEN);
98 if (dst_dev_addr)
99 memcpy(dev_addr->dst_dev_addr, dst_dev_addr, MAX_ADDR_LEN);
Sean Hefty6266ed62009-11-19 12:55:22 -0800100 dev_addr->bound_dev_if = dev->ifindex;
Sean Hefty7025fcd2006-06-17 20:37:28 -0700101 return 0;
102}
Tom Tucker07ebafb2006-08-03 16:02:42 -0500103EXPORT_SYMBOL(rdma_copy_addr);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700104
105int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
106{
107 struct net_device *dev;
Aleksey Senin38617c62008-12-24 10:16:37 -0800108 int ret = -EADDRNOTAVAIL;
Sean Hefty7025fcd2006-06-17 20:37:28 -0700109
Sean Hefty6266ed62009-11-19 12:55:22 -0800110 if (dev_addr->bound_dev_if) {
111 dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
112 if (!dev)
113 return -ENODEV;
114 ret = rdma_copy_addr(dev_addr, dev, NULL);
115 dev_put(dev);
116 return ret;
117 }
118
Aleksey Senin38617c62008-12-24 10:16:37 -0800119 switch (addr->sa_family) {
120 case AF_INET:
121 dev = ip_dev_find(&init_net,
122 ((struct sockaddr_in *) addr)->sin_addr.s_addr);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700123
Aleksey Senin38617c62008-12-24 10:16:37 -0800124 if (!dev)
125 return ret;
126
127 ret = rdma_copy_addr(dev_addr, dev, NULL);
128 dev_put(dev);
129 break;
Roland Dreier2c4ab622008-12-29 23:37:14 -0800130
131#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
Aleksey Senin38617c62008-12-24 10:16:37 -0800132 case AF_INET6:
Eric Dumazet22f4fbd2010-11-24 11:41:56 -0800133 rcu_read_lock();
134 for_each_netdev_rcu(&init_net, dev) {
Aleksey Senin38617c62008-12-24 10:16:37 -0800135 if (ipv6_chk_addr(&init_net,
136 &((struct sockaddr_in6 *) addr)->sin6_addr,
137 dev, 1)) {
138 ret = rdma_copy_addr(dev_addr, dev, NULL);
139 break;
140 }
141 }
Eric Dumazet22f4fbd2010-11-24 11:41:56 -0800142 rcu_read_unlock();
Aleksey Senin38617c62008-12-24 10:16:37 -0800143 break;
Roland Dreier2c4ab622008-12-29 23:37:14 -0800144#endif
Aleksey Senin38617c62008-12-24 10:16:37 -0800145 }
Sean Hefty7025fcd2006-06-17 20:37:28 -0700146 return ret;
147}
148EXPORT_SYMBOL(rdma_translate_ip);
149
150static void set_timeout(unsigned long time)
151{
152 unsigned long delay;
153
154 cancel_delayed_work(&work);
155
156 delay = time - jiffies;
157 if ((long)delay <= 0)
158 delay = 1;
159
160 queue_delayed_work(addr_wq, &work, delay);
161}
162
163static void queue_req(struct addr_req *req)
164{
165 struct addr_req *temp_req;
166
167 mutex_lock(&lock);
168 list_for_each_entry_reverse(temp_req, &req_list, list) {
Krishna Kumarf115db42006-10-17 10:09:09 +0530169 if (time_after_eq(req->timeout, temp_req->timeout))
Sean Hefty7025fcd2006-06-17 20:37:28 -0700170 break;
171 }
172
173 list_add(&req->list, &temp_req->list);
174
175 if (req_list.next == &req->list)
176 set_timeout(req->timeout);
177 mutex_unlock(&lock);
178}
179
Sean Hefty923c1002009-11-19 13:26:51 -0800180static int addr4_resolve(struct sockaddr_in *src_in,
181 struct sockaddr_in *dst_in,
182 struct rdma_dev_addr *addr)
Sean Hefty7025fcd2006-06-17 20:37:28 -0700183{
Al Viro1b90c132008-03-29 03:10:28 +0000184 __be32 src_ip = src_in->sin_addr.s_addr;
185 __be32 dst_ip = dst_in->sin_addr.s_addr;
Sean Hefty7025fcd2006-06-17 20:37:28 -0700186 struct rtable *rt;
187 struct neighbour *neigh;
188 int ret;
189
David S. Miller78fbfd82011-03-12 00:00:52 -0500190 rt = ip_route_output(&init_net, dst_ip, src_ip, 0, addr->bound_dev_if);
David S. Millerb23dd4f2011-03-02 14:31:35 -0800191 if (IS_ERR(rt)) {
192 ret = PTR_ERR(rt);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700193 goto out;
David S. Millerb23dd4f2011-03-02 14:31:35 -0800194 }
Sean Hefty923c1002009-11-19 13:26:51 -0800195 src_in->sin_family = AF_INET;
196 src_in->sin_addr.s_addr = rt->rt_src;
197
Eric Dumazet72cdd1d2010-11-11 07:14:07 +0000198 if (rt->dst.dev->flags & IFF_LOOPBACK) {
Sean Hefty923c1002009-11-19 13:26:51 -0800199 ret = rdma_translate_ip((struct sockaddr *) dst_in, addr);
200 if (!ret)
201 memcpy(addr->dst_dev_addr, addr->src_dev_addr, MAX_ADDR_LEN);
202 goto put;
203 }
204
Sean Hefty7025fcd2006-06-17 20:37:28 -0700205 /* If the device does ARP internally, return 'done' */
Eric Dumazet72cdd1d2010-11-11 07:14:07 +0000206 if (rt->dst.dev->flags & IFF_NOARP) {
Sean Hefty1bdd6382011-03-17 23:35:39 +0000207 ret = rdma_copy_addr(addr, rt->dst.dev, NULL);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700208 goto put;
209 }
210
Eric Dumazet72cdd1d2010-11-11 07:14:07 +0000211 neigh = neigh_lookup(&arp_tbl, &rt->rt_gateway, rt->dst.dev);
Sean Hefty923c1002009-11-19 13:26:51 -0800212 if (!neigh || !(neigh->nud_state & NUD_VALID)) {
Changli Gaod8d1f302010-06-10 23:31:35 -0700213 neigh_event_send(rt->dst.neighbour, NULL);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700214 ret = -ENODATA;
Sean Hefty923c1002009-11-19 13:26:51 -0800215 if (neigh)
216 goto release;
Sean Hefty7025fcd2006-06-17 20:37:28 -0700217 goto put;
218 }
219
Tom Tucker07ebafb2006-08-03 16:02:42 -0500220 ret = rdma_copy_addr(addr, neigh->dev, neigh->ha);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700221release:
222 neigh_release(neigh);
223put:
224 ip_rt_put(rt);
225out:
226 return ret;
227}
228
Roland Dreier2c4ab622008-12-29 23:37:14 -0800229#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
Sean Heftyd14714d2009-11-19 16:46:25 -0800230static int addr6_resolve(struct sockaddr_in6 *src_in,
231 struct sockaddr_in6 *dst_in,
232 struct rdma_dev_addr *addr)
Aleksey Senin38617c62008-12-24 10:16:37 -0800233{
David S. Miller4c9483b2011-03-12 16:22:43 -0500234 struct flowi6 fl6;
Aleksey Senin38617c62008-12-24 10:16:37 -0800235 struct neighbour *neigh;
236 struct dst_entry *dst;
Sean Heftyd14714d2009-11-19 16:46:25 -0800237 int ret;
Aleksey Senin38617c62008-12-24 10:16:37 -0800238
David S. Miller4c9483b2011-03-12 16:22:43 -0500239 memset(&fl6, 0, sizeof fl6);
240 ipv6_addr_copy(&fl6.daddr, &dst_in->sin6_addr);
241 ipv6_addr_copy(&fl6.saddr, &src_in->sin6_addr);
242 fl6.flowi6_oif = addr->bound_dev_if;
Aleksey Senin38617c62008-12-24 10:16:37 -0800243
David S. Miller4c9483b2011-03-12 16:22:43 -0500244 dst = ip6_route_output(&init_net, NULL, &fl6);
Sean Heftyd14714d2009-11-19 16:46:25 -0800245 if ((ret = dst->error))
246 goto put;
Aleksey Senin38617c62008-12-24 10:16:37 -0800247
David S. Miller4c9483b2011-03-12 16:22:43 -0500248 if (ipv6_addr_any(&fl6.saddr)) {
Sean Heftyd14714d2009-11-19 16:46:25 -0800249 ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev,
David S. Miller4c9483b2011-03-12 16:22:43 -0500250 &fl6.daddr, 0, &fl6.saddr);
Sean Heftyd14714d2009-11-19 16:46:25 -0800251 if (ret)
252 goto put;
253
254 src_in->sin6_family = AF_INET6;
David S. Miller4c9483b2011-03-12 16:22:43 -0500255 ipv6_addr_copy(&src_in->sin6_addr, &fl6.saddr);
Aleksey Senin38617c62008-12-24 10:16:37 -0800256 }
257
Sean Heftyd14714d2009-11-19 16:46:25 -0800258 if (dst->dev->flags & IFF_LOOPBACK) {
259 ret = rdma_translate_ip((struct sockaddr *) dst_in, addr);
260 if (!ret)
261 memcpy(addr->dst_dev_addr, addr->src_dev_addr, MAX_ADDR_LEN);
262 goto put;
263 }
264
265 /* If the device does ARP internally, return 'done' */
266 if (dst->dev->flags & IFF_NOARP) {
267 ret = rdma_copy_addr(addr, dst->dev, NULL);
268 goto put;
269 }
270
271 neigh = dst->neighbour;
272 if (!neigh || !(neigh->nud_state & NUD_VALID)) {
273 neigh_event_send(dst->neighbour, NULL);
274 ret = -ENODATA;
275 goto put;
276 }
277
278 ret = rdma_copy_addr(addr, dst->dev, neigh->ha);
279put:
Aleksey Senin38617c62008-12-24 10:16:37 -0800280 dst_release(dst);
281 return ret;
282}
Roland Dreier2c4ab622008-12-29 23:37:14 -0800283#else
Sean Heftyd14714d2009-11-19 16:46:25 -0800284static int addr6_resolve(struct sockaddr_in6 *src_in,
285 struct sockaddr_in6 *dst_in,
286 struct rdma_dev_addr *addr)
Roland Dreier2c4ab622008-12-29 23:37:14 -0800287{
288 return -EADDRNOTAVAIL;
289}
290#endif
Aleksey Senin38617c62008-12-24 10:16:37 -0800291
Sean Hefty923c1002009-11-19 13:26:51 -0800292static int addr_resolve(struct sockaddr *src_in,
293 struct sockaddr *dst_in,
294 struct rdma_dev_addr *addr)
Aleksey Senin38617c62008-12-24 10:16:37 -0800295{
296 if (src_in->sa_family == AF_INET) {
Sean Hefty923c1002009-11-19 13:26:51 -0800297 return addr4_resolve((struct sockaddr_in *) src_in,
Aleksey Senin38617c62008-12-24 10:16:37 -0800298 (struct sockaddr_in *) dst_in, addr);
299 } else
Sean Heftyd14714d2009-11-19 16:46:25 -0800300 return addr6_resolve((struct sockaddr_in6 *) src_in,
Aleksey Senin38617c62008-12-24 10:16:37 -0800301 (struct sockaddr_in6 *) dst_in, addr);
302}
303
David Howellsc4028952006-11-22 14:57:56 +0000304static void process_req(struct work_struct *work)
Sean Hefty7025fcd2006-06-17 20:37:28 -0700305{
306 struct addr_req *req, *temp_req;
Aleksey Senin38617c62008-12-24 10:16:37 -0800307 struct sockaddr *src_in, *dst_in;
Sean Hefty7025fcd2006-06-17 20:37:28 -0700308 struct list_head done_list;
309
310 INIT_LIST_HEAD(&done_list);
311
312 mutex_lock(&lock);
313 list_for_each_entry_safe(req, temp_req, &req_list, list) {
Krishna Kumarc78bb842006-11-24 16:02:34 +0530314 if (req->status == -ENODATA) {
Aleksey Senin38617c62008-12-24 10:16:37 -0800315 src_in = (struct sockaddr *) &req->src_addr;
316 dst_in = (struct sockaddr *) &req->dst_addr;
Sean Hefty923c1002009-11-19 13:26:51 -0800317 req->status = addr_resolve(src_in, dst_in, req->addr);
Krishna Kumarc78bb842006-11-24 16:02:34 +0530318 if (req->status && time_after_eq(jiffies, req->timeout))
319 req->status = -ETIMEDOUT;
320 else if (req->status == -ENODATA)
321 continue;
Sean Hefty7025fcd2006-06-17 20:37:28 -0700322 }
Roland Dreier04699a12006-11-29 15:33:09 -0800323 list_move_tail(&req->list, &done_list);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700324 }
325
326 if (!list_empty(&req_list)) {
327 req = list_entry(req_list.next, struct addr_req, list);
328 set_timeout(req->timeout);
329 }
330 mutex_unlock(&lock);
331
332 list_for_each_entry_safe(req, temp_req, &done_list, list) {
333 list_del(&req->list);
Aleksey Senin38617c62008-12-24 10:16:37 -0800334 req->callback(req->status, (struct sockaddr *) &req->src_addr,
335 req->addr, req->context);
Sean Hefty7a118df2006-10-31 11:12:59 -0800336 put_client(req->client);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700337 kfree(req);
338 }
339}
340
Sean Hefty7a118df2006-10-31 11:12:59 -0800341int rdma_resolve_ip(struct rdma_addr_client *client,
342 struct sockaddr *src_addr, struct sockaddr *dst_addr,
Sean Hefty7025fcd2006-06-17 20:37:28 -0700343 struct rdma_dev_addr *addr, int timeout_ms,
344 void (*callback)(int status, struct sockaddr *src_addr,
345 struct rdma_dev_addr *addr, void *context),
346 void *context)
347{
Aleksey Senin38617c62008-12-24 10:16:37 -0800348 struct sockaddr *src_in, *dst_in;
Sean Hefty7025fcd2006-06-17 20:37:28 -0700349 struct addr_req *req;
350 int ret = 0;
351
Yoann Padioleaudd00cc42007-07-19 01:49:03 -0700352 req = kzalloc(sizeof *req, GFP_KERNEL);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700353 if (!req)
354 return -ENOMEM;
Sean Hefty7025fcd2006-06-17 20:37:28 -0700355
Sean Heftyd2e08862009-11-19 12:55:22 -0800356 src_in = (struct sockaddr *) &req->src_addr;
357 dst_in = (struct sockaddr *) &req->dst_addr;
358
359 if (src_addr) {
360 if (src_addr->sa_family != dst_addr->sa_family) {
361 ret = -EINVAL;
362 goto err;
363 }
364
365 memcpy(src_in, src_addr, ip_addr_size(src_addr));
366 } else {
367 src_in->sa_family = dst_addr->sa_family;
368 }
369
370 memcpy(dst_in, dst_addr, ip_addr_size(dst_addr));
Sean Hefty7025fcd2006-06-17 20:37:28 -0700371 req->addr = addr;
372 req->callback = callback;
373 req->context = context;
Sean Hefty7a118df2006-10-31 11:12:59 -0800374 req->client = client;
375 atomic_inc(&client->refcount);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700376
Sean Heftyd14714d2009-11-19 16:46:25 -0800377 req->status = addr_resolve(src_in, dst_in, addr);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700378 switch (req->status) {
379 case 0:
380 req->timeout = jiffies;
381 queue_req(req);
382 break;
383 case -ENODATA:
384 req->timeout = msecs_to_jiffies(timeout_ms) + jiffies;
385 queue_req(req);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700386 break;
387 default:
388 ret = req->status;
Sean Hefty7a118df2006-10-31 11:12:59 -0800389 atomic_dec(&client->refcount);
Sean Heftyd2e08862009-11-19 12:55:22 -0800390 goto err;
Sean Hefty7025fcd2006-06-17 20:37:28 -0700391 }
392 return ret;
Sean Heftyd2e08862009-11-19 12:55:22 -0800393err:
394 kfree(req);
395 return ret;
Sean Hefty7025fcd2006-06-17 20:37:28 -0700396}
397EXPORT_SYMBOL(rdma_resolve_ip);
398
399void rdma_addr_cancel(struct rdma_dev_addr *addr)
400{
401 struct addr_req *req, *temp_req;
402
403 mutex_lock(&lock);
404 list_for_each_entry_safe(req, temp_req, &req_list, list) {
405 if (req->addr == addr) {
406 req->status = -ECANCELED;
407 req->timeout = jiffies;
Roland Dreier04699a12006-11-29 15:33:09 -0800408 list_move(&req->list, &req_list);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700409 set_timeout(req->timeout);
410 break;
411 }
412 }
413 mutex_unlock(&lock);
414}
415EXPORT_SYMBOL(rdma_addr_cancel);
416
Roland Dreier3cd96562006-09-22 15:22:46 -0700417static int netevent_callback(struct notifier_block *self, unsigned long event,
Tom Tuckere795d092006-07-30 20:44:19 -0700418 void *ctx)
Sean Hefty7025fcd2006-06-17 20:37:28 -0700419{
Roland Dreier3cd96562006-09-22 15:22:46 -0700420 if (event == NETEVENT_NEIGH_UPDATE) {
Tom Tuckere795d092006-07-30 20:44:19 -0700421 struct neighbour *neigh = ctx;
Sean Hefty7025fcd2006-06-17 20:37:28 -0700422
Steve Wise1f126672007-01-23 19:03:17 -0600423 if (neigh->nud_state & NUD_VALID) {
Tom Tuckere795d092006-07-30 20:44:19 -0700424 set_timeout(jiffies);
425 }
426 }
Sean Hefty7025fcd2006-06-17 20:37:28 -0700427 return 0;
428}
429
Tom Tuckere795d092006-07-30 20:44:19 -0700430static struct notifier_block nb = {
431 .notifier_call = netevent_callback
Sean Hefty7025fcd2006-06-17 20:37:28 -0700432};
433
Peter Huewe716abb12009-06-23 10:38:42 -0700434static int __init addr_init(void)
Sean Hefty7025fcd2006-06-17 20:37:28 -0700435{
Sean Heftyc7f743a2007-02-01 12:23:37 -0800436 addr_wq = create_singlethread_workqueue("ib_addr");
Sean Hefty7025fcd2006-06-17 20:37:28 -0700437 if (!addr_wq)
438 return -ENOMEM;
439
Tom Tuckere795d092006-07-30 20:44:19 -0700440 register_netevent_notifier(&nb);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700441 return 0;
442}
443
Peter Huewe716abb12009-06-23 10:38:42 -0700444static void __exit addr_cleanup(void)
Sean Hefty7025fcd2006-06-17 20:37:28 -0700445{
Tom Tuckere795d092006-07-30 20:44:19 -0700446 unregister_netevent_notifier(&nb);
Sean Hefty7025fcd2006-06-17 20:37:28 -0700447 destroy_workqueue(addr_wq);
448}
449
450module_init(addr_init);
451module_exit(addr_cleanup);