* [net-next PATCH 1/3] dcb: Use ifindex instead of ifname
@ 2011-10-06 18:52 John Fastabend
2011-10-06 18:52 ` [net-next PATCH 2/3] dcb: add DCBX mode to event notifier attributes John Fastabend
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: John Fastabend @ 2011-10-06 18:52 UTC (permalink / raw)
To: davem; +Cc: john.r.fastabend, netdev, gospo
From: Mark Rustad <mark.d.rustad@intel.com>
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>
---
include/net/dcbnl.h | 2 +-
net/dcb/dcbnl.c | 24 ++++++++++++------------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index f5aa399..263aa3a 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -23,7 +23,7 @@
#include <linux/dcbnl.h>
struct dcb_app_type {
- char name[IFNAMSIZ];
+ int ifindex;
struct dcb_app app;
struct list_head list;
};
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 3cb56af..e508593 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1255,7 +1255,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
spin_lock(&dcb_lock);
list_for_each_entry(itr, &dcb_app_list, list) {
- if (strncmp(itr->name, netdev->name, IFNAMSIZ) == 0) {
+ if (itr->ifindex == netdev->ifindex) {
err = nla_put(skb, DCB_ATTR_IEEE_APP, sizeof(itr->app),
&itr->app);
if (err) {
@@ -1412,7 +1412,7 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
goto dcb_unlock;
list_for_each_entry(itr, &dcb_app_list, list) {
- if (strncmp(itr->name, netdev->name, IFNAMSIZ) == 0) {
+ if (itr->ifindex == netdev->ifindex) {
struct nlattr *app_nest = nla_nest_start(skb,
DCB_ATTR_APP);
if (!app_nest)
@@ -2050,7 +2050,7 @@ u8 dcb_getapp(struct net_device *dev, struct dcb_app *app)
list_for_each_entry(itr, &dcb_app_list, list) {
if (itr->app.selector == app->selector &&
itr->app.protocol == app->protocol &&
- (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
+ itr->ifindex == dev->ifindex) {
prio = itr->app.priority;
break;
}
@@ -2073,7 +2073,7 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new)
struct dcb_app_type *itr;
struct dcb_app_type event;
- memcpy(&event.name, dev->name, sizeof(event.name));
+ event.ifindex = dev->ifindex;
memcpy(&event.app, new, sizeof(event.app));
spin_lock(&dcb_lock);
@@ -2081,7 +2081,7 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new)
list_for_each_entry(itr, &dcb_app_list, list) {
if (itr->app.selector == new->selector &&
itr->app.protocol == new->protocol &&
- (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
+ itr->ifindex == dev->ifindex) {
if (new->priority)
itr->app.priority = new->priority;
else {
@@ -2101,7 +2101,7 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new)
}
memcpy(&entry->app, new, sizeof(*new));
- strncpy(entry->name, dev->name, IFNAMSIZ);
+ entry->ifindex = dev->ifindex;
list_add(&entry->list, &dcb_app_list);
}
out:
@@ -2127,7 +2127,7 @@ u8 dcb_ieee_getapp_mask(struct net_device *dev, struct dcb_app *app)
list_for_each_entry(itr, &dcb_app_list, list) {
if (itr->app.selector == app->selector &&
itr->app.protocol == app->protocol &&
- (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
+ itr->ifindex == dev->ifindex) {
prio |= 1 << itr->app.priority;
}
}
@@ -2150,7 +2150,7 @@ int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new)
struct dcb_app_type event;
int err = 0;
- memcpy(&event.name, dev->name, sizeof(event.name));
+ event.ifindex = dev->ifindex;
memcpy(&event.app, new, sizeof(event.app));
spin_lock(&dcb_lock);
@@ -2159,7 +2159,7 @@ int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new)
if (itr->app.selector == new->selector &&
itr->app.protocol == new->protocol &&
itr->app.priority == new->priority &&
- (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
+ itr->ifindex == dev->ifindex) {
err = -EEXIST;
goto out;
}
@@ -2173,7 +2173,7 @@ int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new)
}
memcpy(&entry->app, new, sizeof(*new));
- strncpy(entry->name, dev->name, IFNAMSIZ);
+ entry->ifindex = dev->ifindex;
list_add(&entry->list, &dcb_app_list);
out:
spin_unlock(&dcb_lock);
@@ -2194,7 +2194,7 @@ int dcb_ieee_delapp(struct net_device *dev, struct dcb_app *del)
struct dcb_app_type event;
int err = -ENOENT;
- memcpy(&event.name, dev->name, sizeof(event.name));
+ event.ifindex = dev->ifindex;
memcpy(&event.app, del, sizeof(event.app));
spin_lock(&dcb_lock);
@@ -2203,7 +2203,7 @@ int dcb_ieee_delapp(struct net_device *dev, struct dcb_app *del)
if (itr->app.selector == del->selector &&
itr->app.protocol == del->protocol &&
itr->app.priority == del->priority &&
- (strncmp(itr->name, dev->name, IFNAMSIZ) == 0)) {
+ itr->ifindex == dev->ifindex) {
list_del(&itr->list);
kfree(itr);
err = 0;
^ permalink raw reply related [flat|nested] 6+ messages in thread* [net-next PATCH 2/3] dcb: add DCBX mode to event notifier attributes
2011-10-06 18:52 [net-next PATCH 1/3] dcb: Use ifindex instead of ifname John Fastabend
@ 2011-10-06 18:52 ` John Fastabend
2011-10-06 19:50 ` David Miller
2011-10-06 18:52 ` [net-next PATCH 3/3] dcb: Add stub routines for !CONFIG_DCB John Fastabend
2011-10-06 19:50 ` [net-next PATCH 1/3] dcb: Use ifindex instead of ifname David Miller
2 siblings, 1 reply; 6+ messages in thread
From: John Fastabend @ 2011-10-06 18:52 UTC (permalink / raw)
To: davem; +Cc: john.r.fastabend, netdev, gospo
Add DCBX mode to event notifiers so listeners can learn
currently enabled mode.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
include/net/dcbnl.h | 1 +
net/dcb/dcbnl.c | 6 ++++++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h
index 263aa3a..2cd66d0 100644
--- a/include/net/dcbnl.h
+++ b/include/net/dcbnl.h
@@ -26,6 +26,7 @@ struct dcb_app_type {
int ifindex;
struct dcb_app app;
struct list_head list;
+ u8 dcbx;
};
int dcb_setapp(struct net_device *, struct dcb_app *);
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index e508593..9bfbc1d 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -2075,6 +2075,8 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new)
event.ifindex = dev->ifindex;
memcpy(&event.app, new, sizeof(event.app));
+ if (dev->dcbnl_ops->getdcbx)
+ event.dcbx = dev->dcbnl_ops->getdcbx(dev);
spin_lock(&dcb_lock);
/* Search for existing match and replace */
@@ -2152,6 +2154,8 @@ int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new)
event.ifindex = dev->ifindex;
memcpy(&event.app, new, sizeof(event.app));
+ if (dev->dcbnl_ops->getdcbx)
+ event.dcbx = dev->dcbnl_ops->getdcbx(dev);
spin_lock(&dcb_lock);
/* Search for existing match and abort if found */
@@ -2196,6 +2200,8 @@ int dcb_ieee_delapp(struct net_device *dev, struct dcb_app *del)
event.ifindex = dev->ifindex;
memcpy(&event.app, del, sizeof(event.app));
+ if (dev->dcbnl_ops->getdcbx)
+ event.dcbx = dev->dcbnl_ops->getdcbx(dev);
spin_lock(&dcb_lock);
/* Search for existing match and remove it. */
^ permalink raw reply related [flat|nested] 6+ messages in thread* [net-next PATCH 3/3] dcb: Add stub routines for !CONFIG_DCB
2011-10-06 18:52 [net-next PATCH 1/3] dcb: Use ifindex instead of ifname John Fastabend
2011-10-06 18:52 ` [net-next PATCH 2/3] dcb: add DCBX mode to event notifier attributes John Fastabend
@ 2011-10-06 18:52 ` John Fastabend
2011-10-06 19:50 ` David Miller
2011-10-06 19:50 ` [net-next PATCH 1/3] dcb: Use ifindex instead of ifname David Miller
2 siblings, 1 reply; 6+ messages in thread
From: John Fastabend @ 2011-10-06 18:52 UTC (permalink / raw)
To: davem; +Cc: john.r.fastabend, netdev, gospo
To avoid ifdefs in the other code that supports DCB notifiers
add stub routines. This method seems popular in other net code
for example 8021Q.
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
---
include/net/dcbevent.h | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/include/net/dcbevent.h b/include/net/dcbevent.h
index bc1e7ef..443626e 100644
--- a/include/net/dcbevent.h
+++ b/include/net/dcbevent.h
@@ -24,8 +24,26 @@ enum dcbevent_notif_type {
DCB_APP_EVENT = 1,
};
+#ifdef CONFIG_DCB
extern int register_dcbevent_notifier(struct notifier_block *nb);
extern int unregister_dcbevent_notifier(struct notifier_block *nb);
extern int call_dcbevent_notifiers(unsigned long val, void *v);
+#else
+static inline int
+register_dcbevent_notifier(struct notifier_block *nb)
+{
+ return 0;
+}
+
+static inline int unregister_dcbevent_notifier(struct notifier_block *nb)
+{
+ return 0;
+}
+
+static inline int call_dcbevent_notifiers(unsigned long val, void *v)
+{
+ return 0;
+}
+#endif /* CONFIG_DCB */
#endif
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [net-next PATCH 1/3] dcb: Use ifindex instead of ifname
2011-10-06 18:52 [net-next PATCH 1/3] dcb: Use ifindex instead of ifname John Fastabend
2011-10-06 18:52 ` [net-next PATCH 2/3] dcb: add DCBX mode to event notifier attributes John Fastabend
2011-10-06 18:52 ` [net-next PATCH 3/3] dcb: Add stub routines for !CONFIG_DCB John Fastabend
@ 2011-10-06 19:50 ` David Miller
2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2011-10-06 19:50 UTC (permalink / raw)
To: john.r.fastabend; +Cc: netdev, gospo
From: John Fastabend <john.r.fastabend@intel.com>
Date: Thu, 06 Oct 2011 11:52:33 -0700
> From: Mark Rustad <mark.d.rustad@intel.com>
>
> 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>
Applied.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-10-06 19:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-06 18:52 [net-next PATCH 1/3] dcb: Use ifindex instead of ifname John Fastabend
2011-10-06 18:52 ` [net-next PATCH 2/3] dcb: add DCBX mode to event notifier attributes John Fastabend
2011-10-06 19:50 ` David Miller
2011-10-06 18:52 ` [net-next PATCH 3/3] dcb: Add stub routines for !CONFIG_DCB John Fastabend
2011-10-06 19:50 ` David Miller
2011-10-06 19:50 ` [net-next PATCH 1/3] dcb: Use ifindex instead of ifname David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).