1 #include <linux/types.h>
3 #include <linux/slab.h>
4 #include <linux/time.h>
15 #define dprintk(format, args...) \
16 printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args)
18 #define dprintk(format, args...) \
20 printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\
25 #define ddprintk(format, args...) \
26 printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args)
28 #define ddprintk(format, args...) \
30 printk(KERN_DEBUG "mpoa:%s: " format, __FILE__, ##args);\
41 while (entry !=
NULL) {
42 if (entry->
ctrl_info.in_dst_ip == dst_ip) {
62 while (entry !=
NULL) {
63 if ((entry->
ctrl_info.in_dst_ip & mask) == (dst_ip & mask)) {
83 while (entry !=
NULL) {
102 pr_info(
"mpoa: mpoa_caches.c: new_in_cache_entry: out of memory\n");
106 dprintk(
"adding an ingress entry, ip = %pI4\n", &dst_ip);
109 dprintk(
"new_in_cache_entry: about to lock\n");
127 dprintk(
"new_in_cache_entry: unlocked\n");
163 dprintk(
"(%s) threshold exceeded for ip %pI4, sending MPOA res req\n",
197 dprintk(
"removing an ingress entry, ip = %pI4\n",
206 client->
in_ops->put(entry);
216 if (eg_entry !=
NULL) {
217 client->
eg_ops->put(eg_entry);
226 static void clear_count_and_expired(
struct mpoa_client *client)
235 while (entry !=
NULL) {
237 next_entry = entry->
next;
238 if ((now.tv_sec - entry->
tv.tv_sec)
240 dprintk(
"holding time expired, ip = %pI4\n",
242 client->
in_ops->remove_entry(entry, client);
250 static void check_resolving_entries(
struct mpoa_client *client)
262 while (entry !=
NULL) {
264 if ((now.tv_sec - entry->
hold_down.tv_sec) <
300 static void refresh_entries(
struct mpoa_client *client)
309 while (entry !=
NULL) {
315 dprintk(
"refreshing an entry.\n");
325 static void in_destroy_cache(
struct mpoa_client *mpc)
340 while (entry !=
NULL) {
341 if (entry->
ctrl_info.cache_id == cache_id) {
361 while (entry !=
NULL) {
383 while (entry !=
NULL) {
403 while (entry !=
NULL) {
434 dprintk(
"removing an egress entry.\n");
441 client->
eg_ops->put(entry);
450 if (in_entry !=
NULL) {
451 client->
in_ops->put(in_entry);
468 dprintk(
"adding an egress entry, ip = %pI4, this should be our IP\n",
472 dprintk(
"new_eg_cache_entry: about to lock\n");
484 dprintk(
"new_eg_cache_entry cache_id %u\n",
490 dprintk(
"new_eg_cache_entry: unlocked\n");
499 entry->
ctrl_info.holding_time = holding_time;
502 static void clear_expired(
struct mpoa_client *client)
512 while (entry !=
NULL) {
513 next_entry = entry->
next;
514 if ((now.tv_sec - entry->
tv.tv_sec)
518 dprintk(
"egress_cache: holding time expired, cache_id = %u.\n",
521 client->
eg_ops->remove_entry(entry, client);
528 static void eg_destroy_cache(
struct mpoa_client *mpc)
540 in_cache_get_with_mask,
543 in_cache_remove_entry,
545 clear_count_and_expired,
546 check_resolving_entries,
553 eg_cache_get_by_cache_id,
556 eg_cache_get_by_src_ip,
558 eg_cache_remove_entry,
559 update_eg_cache_entry,
567 mpc->
in_ops = &ingress_ops;
568 mpc->
eg_ops = &egress_ops;