Commit e290ed81307ca7d92675f0d9c683add693c2f377

Authored by Mark Rustad
Committed by David S. Miller
1 parent e878d78b9a

dcb: Use ifindex instead of ifname

Use ifindex instead of ifname in the DCB app ring. This makes for a smaller
data structure and faster comparisons. It also avoids possible issues when
a net device is renamed.

Signed-off-by: Mark Rustad <mark.d.rustad@intel.com>
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 2 changed files with 13 additions and 13 deletions Side-by-side Diff

... ... @@ -23,7 +23,7 @@
23 23 #include <linux/dcbnl.h>
24 24  
25 25 struct dcb_app_type {
26   - char name[IFNAMSIZ];
  26 + int ifindex;
27 27 struct dcb_app app;
28 28 struct list_head list;
29 29 };
... ... @@ -1255,7 +1255,7 @@
1255 1255  
1256 1256 spin_lock(&dcb_lock);
1257 1257 list_for_each_entry(itr, &dcb_app_list, list) {
1258   - if (strncmp(itr->name, netdev->name, IFNAMSIZ) == 0) {
  1258 + if (itr->ifindex == netdev->ifindex) {
1259 1259 err = nla_put(skb, DCB_ATTR_IEEE_APP, sizeof(itr->app),
1260 1260 &itr->app);
1261 1261 if (err) {
... ... @@ -1412,7 +1412,7 @@
1412 1412 goto dcb_unlock;
1413 1413  
1414 1414 list_for_each_entry(itr, &dcb_app_list, list) {
1415   - if (strncmp(itr->name, netdev->name, IFNAMSIZ) == 0) {
  1415 + if (itr->ifindex == netdev->ifindex) {
1416 1416 struct nlattr *app_nest = nla_nest_start(skb,
1417 1417 DCB_ATTR_APP);
1418 1418 if (!app_nest)
... ... @@ -2050,7 +2050,7 @@
2050 2050 list_for_each_entry(itr, &dcb_app_list, list) {
2051 2051 if (itr->app.selector == app->selector &&
2052 2052 itr->app.protocol == app->protocol &&
2053   - (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
  2053 + itr->ifindex == dev->ifindex) {
2054 2054 prio = itr->app.priority;
2055 2055 break;
2056 2056 }
... ... @@ -2073,7 +2073,7 @@
2073 2073 struct dcb_app_type *itr;
2074 2074 struct dcb_app_type event;
2075 2075  
2076   - memcpy(&event.name, dev->name, sizeof(event.name));
  2076 + event.ifindex = dev->ifindex;
2077 2077 memcpy(&event.app, new, sizeof(event.app));
2078 2078  
2079 2079 spin_lock(&dcb_lock);
... ... @@ -2081,7 +2081,7 @@
2081 2081 list_for_each_entry(itr, &dcb_app_list, list) {
2082 2082 if (itr->app.selector == new->selector &&
2083 2083 itr->app.protocol == new->protocol &&
2084   - (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
  2084 + itr->ifindex == dev->ifindex) {
2085 2085 if (new->priority)
2086 2086 itr->app.priority = new->priority;
2087 2087 else {
... ... @@ -2101,7 +2101,7 @@
2101 2101 }
2102 2102  
2103 2103 memcpy(&entry->app, new, sizeof(*new));
2104   - strncpy(entry->name, dev->name, IFNAMSIZ);
  2104 + entry->ifindex = dev->ifindex;
2105 2105 list_add(&entry->list, &dcb_app_list);
2106 2106 }
2107 2107 out:
... ... @@ -2127,7 +2127,7 @@
2127 2127 list_for_each_entry(itr, &dcb_app_list, list) {
2128 2128 if (itr->app.selector == app->selector &&
2129 2129 itr->app.protocol == app->protocol &&
2130   - (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
  2130 + itr->ifindex == dev->ifindex) {
2131 2131 prio |= 1 << itr->app.priority;
2132 2132 }
2133 2133 }
... ... @@ -2150,7 +2150,7 @@
2150 2150 struct dcb_app_type event;
2151 2151 int err = 0;
2152 2152  
2153   - memcpy(&event.name, dev->name, sizeof(event.name));
  2153 + event.ifindex = dev->ifindex;
2154 2154 memcpy(&event.app, new, sizeof(event.app));
2155 2155  
2156 2156 spin_lock(&dcb_lock);
... ... @@ -2159,7 +2159,7 @@
2159 2159 if (itr->app.selector == new->selector &&
2160 2160 itr->app.protocol == new->protocol &&
2161 2161 itr->app.priority == new->priority &&
2162   - (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
  2162 + itr->ifindex == dev->ifindex) {
2163 2163 err = -EEXIST;
2164 2164 goto out;
2165 2165 }
... ... @@ -2173,7 +2173,7 @@
2173 2173 }
2174 2174  
2175 2175 memcpy(&entry->app, new, sizeof(*new));
2176   - strncpy(entry->name, dev->name, IFNAMSIZ);
  2176 + entry->ifindex = dev->ifindex;
2177 2177 list_add(&entry->list, &dcb_app_list);
2178 2178 out:
2179 2179 spin_unlock(&dcb_lock);
... ... @@ -2194,7 +2194,7 @@
2194 2194 struct dcb_app_type event;
2195 2195 int err = -ENOENT;
2196 2196  
2197   - memcpy(&event.name, dev->name, sizeof(event.name));
  2197 + event.ifindex = dev->ifindex;
2198 2198 memcpy(&event.app, del, sizeof(event.app));
2199 2199  
2200 2200 spin_lock(&dcb_lock);
... ... @@ -2203,7 +2203,7 @@
2203 2203 if (itr->app.selector == del->selector &&
2204 2204 itr->app.protocol == del->protocol &&
2205 2205 itr->app.priority == del->priority &&
2206   - (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
  2206 + itr->ifindex == dev->ifindex) {
2207 2207 list_del(&itr->list);
2208 2208 kfree(itr);
2209 2209 err = 0;