From 4e981e75b58ee17a2253b83aeadfbb840f8563df Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 18:13:16 -0800 Subject: [PATCH] Adds __dev_addr_delete() and __dev_addr_add() for 2.6.22 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Not sure how to port this yet though: CC [M] /home/mcgrof/compat/compat/compat-2.6.32.o /home/mcgrof/compat/compat/compat-2.6.32.c: In function ‘__dev_addr_sync’: /home/mcgrof/compat/compat/compat-2.6.32.c:84: error: ‘struct dev_mc_list’ has no member named ‘da_synced’ /home/mcgrof/compat/compat/compat-2.6.32.c:89: error: ‘struct dev_mc_list’ has no member named ‘da_synced’ /home/mcgrof/compat/compat/compat-2.6.32.c: In function ‘__dev_addr_unsync’: /home/mcgrof/compat/compat/compat-2.6.32.c:111: error: ‘struct dev_mc_list’ has no member named ‘da_synced’ /home/mcgrof/compat/compat/compat-2.6.32.c:114: error: ‘struct dev_mc_list’ has no member named ‘da_synced’ make[3]: *** [/home/mcgrof/compat/compat/compat-2.6.32.o] Error 1 Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.23.c | 64 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/compat/compat-2.6.23.c b/compat/compat-2.6.23.c index d232b1aa9372..136d949948e9 100644 --- a/compat/compat-2.6.23.c +++ b/compat/compat-2.6.23.c @@ -13,6 +13,70 @@ /* All things not in 2.6.22 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) +/* On net/core/dev.c as of 2.6.24 */ +int __dev_addr_delete(struct dev_addr_list **list, int *count, + void *addr, int alen, int glbl) +{ + struct dev_addr_list *da; + + for (; (da = *list) != NULL; list = &da->next) { + if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && + alen == da->da_addrlen) { + if (glbl) { + int old_glbl = da->da_gusers; + da->da_gusers = 0; + if (old_glbl == 0) + break; + } + if (--da->da_users) + return 0; + + *list = da->next; + kfree(da); + (*count)--; + return 0; + } + } + return -ENOENT; +} +EXPORT_SYMBOL(__dev_addr_delete); + +/* On net/core/dev.c as of 2.6.24. This is not yet used by mac80211 but + * might as well add it */ +int __dev_addr_add(struct dev_addr_list **list, int *count, + void *addr, int alen, int glbl) +{ + struct dev_addr_list *da; + + for (da = *list; da != NULL; da = da->next) { + if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && + da->da_addrlen == alen) { + if (glbl) { + int old_glbl = da->da_gusers; + da->da_gusers = 1; + if (old_glbl) + return 0; + } + da->da_users++; + return 0; + } + } + + da = kmalloc(sizeof(*da), GFP_ATOMIC); + if (da == NULL) + return -ENOMEM; + memcpy(da->da_addr, addr, alen); + da->da_addrlen = alen; + da->da_users = 1; + da->da_gusers = glbl ? 1 : 0; + da->next = *list; + *list = da; + (*count)++; + return 0; +} +EXPORT_SYMBOL(__dev_addr_add); + + /* Part of net/core/dev_mcast.c as of 2.6.23. This is a slightly different version. * Since da->da_synced is not part of 2.6.22 we need to take longer route when * syncing */ -- 2.30.2