Adds __dev_addr_delete() and __dev_addr_add() for 2.6.22
authorLuis R. Rodriguez <lrodriguez@atheros.com>
Tue, 12 Jan 2010 02:13:16 +0000 (18:13 -0800)
committerLuis R. Rodriguez <lrodriguez@atheros.com>
Tue, 12 Jan 2010 02:13:16 +0000 (18:13 -0800)
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 <lrodriguez@atheros.com>
compat/compat-2.6.23.c

index d232b1aa93721f611a5d65e8f401170305464282..136d949948e9dcf0c337c27a5101364ef65747d7 100644 (file)
 /* 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 */