All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 6/7] neigh: Add device constructor/destructor capability.
@ 2011-07-25 10:01 David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2011-07-25 10:01 UTC (permalink / raw)
  To: roland-DgEjT+Ai2ygdnm+yROfE0A
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA


If the neigh entry has device private state, it will need
constructor/destructor ops.

Signed-off-by: David S. Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
---
 include/linux/netdevice.h |    2 ++
 net/core/neighbour.c      |   15 ++++++++++++++-
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index a50f6d6..016bb4e 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -943,6 +943,8 @@ struct net_device_ops {
 						    u32 features);
 	int			(*ndo_set_features)(struct net_device *dev,
 						    u32 features);
+	int			(*ndo_neigh_construct)(struct neighbour *n);
+	int			(*ndo_neigh_destroy)(struct neighbour *n);
 };
 
 /*
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 96ae4e4..ee5ce7e 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -488,6 +488,14 @@ struct neighbour *neigh_create(struct neigh_table *tbl, const void *pkey,
 		goto out_neigh_release;
 	}
 
+	if (dev->netdev_ops->ndo_neigh_construct) {
+		error = dev->netdev_ops->ndo_neigh_construct(n);
+		if (error < 0) {
+			rc = ERR_PTR(error);
+			goto out_neigh_release;
+		}
+	}
+
 	/* Device specific setup. */
 	if (n->parms->neigh_setup &&
 	    (error = n->parms->neigh_setup(n)) < 0) {
@@ -691,6 +699,8 @@ static inline void neigh_parms_put(struct neigh_parms *parms)
  */
 void neigh_destroy(struct neighbour *neigh)
 {
+	struct net_device *dev = neigh->dev;
+
 	NEIGH_CACHE_STAT_INC(neigh->tbl, destroys);
 
 	if (!neigh->dead) {
@@ -705,7 +715,10 @@ void neigh_destroy(struct neighbour *neigh)
 
 	skb_queue_purge(&neigh->arp_queue);
 
-	dev_put(neigh->dev);
+	if (dev->netdev_ops->ndo_neigh_destroy)
+		dev->netdev_ops->ndo_neigh_destroy(neigh);
+
+	dev_put(dev);
 	neigh_parms_put(neigh->parms);
 
 	NEIGH_PRINTK2("neigh %p is destroyed.\n", neigh);
-- 
1.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 6/7] neigh: Add device constructor/destructor capability.
  2011-12-01 19:08 ` Ben Hutchings
@ 2011-12-01 19:16   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2011-12-01 19:16 UTC (permalink / raw)
  To: bhutchings; +Cc: netdev

From: Ben Hutchings <bhutchings@solarflare.com>
Date: Thu, 1 Dec 2011 19:08:35 +0000

> On Wed, 2011-11-30 at 22:41 -0500, David Miller wrote:
>> If the neigh entry has device private state, it will need
>> constructor/destructor ops.
>> 
>> Signed-off-by: David S. Miller <davem@davemloft.net>
>> ---
>>  include/linux/netdevice.h |    2 ++
>>  net/core/neighbour.c      |   15 ++++++++++++++-
>>  2 files changed, 16 insertions(+), 1 deletions(-)
>> 
>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>> index 5462c2c..1c4ddb3 100644
>> --- a/include/linux/netdevice.h
>> +++ b/include/linux/netdevice.h
>> @@ -974,6 +974,8 @@ struct net_device_ops {
>>  						    netdev_features_t features);
>>  	int			(*ndo_set_features)(struct net_device *dev,
>>  						    netdev_features_t features);
>> +	int			(*ndo_neigh_construct)(struct neighbour *n);
>> +	int			(*ndo_neigh_destroy)(struct neighbour *n);
> 
> ndo_neigh_destroy should return void, since the return value is not
> used:

Agreed:

--
net: Make ndo_neigh_destroy return void.

The return value isn't used.

Suggested by Ben Hucthings.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 include/linux/netdevice.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 1c4ddb3..21440e3 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -975,7 +975,7 @@ struct net_device_ops {
 	int			(*ndo_set_features)(struct net_device *dev,
 						    netdev_features_t features);
 	int			(*ndo_neigh_construct)(struct neighbour *n);
-	int			(*ndo_neigh_destroy)(struct neighbour *n);
+	void			(*ndo_neigh_destroy)(struct neighbour *n);
 };
 
 /*
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 6/7] neigh: Add device constructor/destructor capability.
  2011-12-01  3:41 David Miller
@ 2011-12-01 19:08 ` Ben Hutchings
  2011-12-01 19:16   ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Ben Hutchings @ 2011-12-01 19:08 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

On Wed, 2011-11-30 at 22:41 -0500, David Miller wrote:
> If the neigh entry has device private state, it will need
> constructor/destructor ops.
> 
> Signed-off-by: David S. Miller <davem@davemloft.net>
> ---
>  include/linux/netdevice.h |    2 ++
>  net/core/neighbour.c      |   15 ++++++++++++++-
>  2 files changed, 16 insertions(+), 1 deletions(-)
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 5462c2c..1c4ddb3 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -974,6 +974,8 @@ struct net_device_ops {
>  						    netdev_features_t features);
>  	int			(*ndo_set_features)(struct net_device *dev,
>  						    netdev_features_t features);
> +	int			(*ndo_neigh_construct)(struct neighbour *n);
> +	int			(*ndo_neigh_destroy)(struct neighbour *n);

ndo_neigh_destroy should return void, since the return value is not
used:

[...]
> @@ -707,7 +717,10 @@ void neigh_destroy(struct neighbour *neigh)
>  	skb_queue_purge(&neigh->arp_queue);
>  	neigh->arp_queue_len_bytes = 0;
>  
> -	dev_put(neigh->dev);
> +	if (dev->netdev_ops->ndo_neigh_destroy)
> +		dev->netdev_ops->ndo_neigh_destroy(neigh);
> +
> +	dev_put(dev);
>  	neigh_parms_put(neigh->parms);
>  
>  	NEIGH_PRINTK2("neigh %p is destroyed.\n", neigh);

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 6/7] neigh: Add device constructor/destructor capability.
@ 2011-12-01  3:41 David Miller
  2011-12-01 19:08 ` Ben Hutchings
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2011-12-01  3:41 UTC (permalink / raw)
  To: netdev


If the neigh entry has device private state, it will need
constructor/destructor ops.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 include/linux/netdevice.h |    2 ++
 net/core/neighbour.c      |   15 ++++++++++++++-
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 5462c2c..1c4ddb3 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -974,6 +974,8 @@ struct net_device_ops {
 						    netdev_features_t features);
 	int			(*ndo_set_features)(struct net_device *dev,
 						    netdev_features_t features);
+	int			(*ndo_neigh_construct)(struct neighbour *n);
+	int			(*ndo_neigh_destroy)(struct neighbour *n);
 };
 
 /*
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index ef750ff..cdf8dc3 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -489,6 +489,14 @@ struct neighbour *neigh_create(struct neigh_table *tbl, const void *pkey,
 		goto out_neigh_release;
 	}
 
+	if (dev->netdev_ops->ndo_neigh_construct) {
+		error = dev->netdev_ops->ndo_neigh_construct(n);
+		if (error < 0) {
+			rc = ERR_PTR(error);
+			goto out_neigh_release;
+		}
+	}
+
 	/* Device specific setup. */
 	if (n->parms->neigh_setup &&
 	    (error = n->parms->neigh_setup(n)) < 0) {
@@ -692,6 +700,8 @@ static inline void neigh_parms_put(struct neigh_parms *parms)
  */
 void neigh_destroy(struct neighbour *neigh)
 {
+	struct net_device *dev = neigh->dev;
+
 	NEIGH_CACHE_STAT_INC(neigh->tbl, destroys);
 
 	if (!neigh->dead) {
@@ -707,7 +717,10 @@ void neigh_destroy(struct neighbour *neigh)
 	skb_queue_purge(&neigh->arp_queue);
 	neigh->arp_queue_len_bytes = 0;
 
-	dev_put(neigh->dev);
+	if (dev->netdev_ops->ndo_neigh_destroy)
+		dev->netdev_ops->ndo_neigh_destroy(neigh);
+
+	dev_put(dev);
 	neigh_parms_put(neigh->parms);
 
 	NEIGH_PRINTK2("neigh %p is destroyed.\n", neigh);
-- 
1.7.6.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-12-01 19:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-25 10:01 [PATCH 6/7] neigh: Add device constructor/destructor capability David Miller
2011-12-01  3:41 David Miller
2011-12-01 19:08 ` Ben Hutchings
2011-12-01 19:16   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.