Commit 4e4f2f69 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

dcbnl: Move dcb app allocation into dcb_app_add()

Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 716b31ab
...@@ -1732,6 +1732,21 @@ static struct dcb_app_type *dcb_app_lookup(const struct dcb_app *app, ...@@ -1732,6 +1732,21 @@ static struct dcb_app_type *dcb_app_lookup(const struct dcb_app *app,
return NULL; return NULL;
} }
static int dcb_app_add(const struct dcb_app *app, int ifindex)
{
struct dcb_app_type *entry;
entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
if (!entry)
return -ENOMEM;
memcpy(&entry->app, app, sizeof(*app));
entry->ifindex = ifindex;
list_add(&entry->list, &dcb_app_list);
return 0;
}
/** /**
* dcb_getapp - retrieve the DCBX application user priority * dcb_getapp - retrieve the DCBX application user priority
* *
...@@ -1764,6 +1779,7 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new) ...@@ -1764,6 +1779,7 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new)
{ {
struct dcb_app_type *itr; struct dcb_app_type *itr;
struct dcb_app_type event; struct dcb_app_type event;
int err = 0;
event.ifindex = dev->ifindex; event.ifindex = dev->ifindex;
memcpy(&event.app, new, sizeof(event.app)); memcpy(&event.app, new, sizeof(event.app));
...@@ -1782,22 +1798,13 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new) ...@@ -1782,22 +1798,13 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new)
goto out; goto out;
} }
/* App type does not exist add new application type */ /* App type does not exist add new application type */
if (new->priority) { if (new->priority)
struct dcb_app_type *entry; err = dcb_app_add(new, dev->ifindex);
entry = kmalloc(sizeof(struct dcb_app_type), GFP_ATOMIC);
if (!entry) {
spin_unlock(&dcb_lock);
return -ENOMEM;
}
memcpy(&entry->app, new, sizeof(*new));
entry->ifindex = dev->ifindex;
list_add(&entry->list, &dcb_app_list);
}
out: out:
spin_unlock(&dcb_lock); spin_unlock(&dcb_lock);
call_dcbevent_notifiers(DCB_APP_EVENT, &event); if (!err)
return 0; call_dcbevent_notifiers(DCB_APP_EVENT, &event);
return err;
} }
EXPORT_SYMBOL(dcb_setapp); EXPORT_SYMBOL(dcb_setapp);
...@@ -1831,7 +1838,6 @@ EXPORT_SYMBOL(dcb_ieee_getapp_mask); ...@@ -1831,7 +1838,6 @@ EXPORT_SYMBOL(dcb_ieee_getapp_mask);
*/ */
int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new) int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new)
{ {
struct dcb_app_type *entry;
struct dcb_app_type event; struct dcb_app_type event;
int err = 0; int err = 0;
...@@ -1847,16 +1853,7 @@ int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new) ...@@ -1847,16 +1853,7 @@ int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new)
goto out; goto out;
} }
/* App entry does not exist add new entry */ err = dcb_app_add(new, dev->ifindex);
entry = kmalloc(sizeof(struct dcb_app_type), GFP_ATOMIC);
if (!entry) {
err = -ENOMEM;
goto out;
}
memcpy(&entry->app, new, sizeof(*new));
entry->ifindex = dev->ifindex;
list_add(&entry->list, &dcb_app_list);
out: out:
spin_unlock(&dcb_lock); spin_unlock(&dcb_lock);
if (!err) if (!err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment