From patchwork Mon Jul 25 10:01:38 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Miller X-Patchwork-Id: 1004052 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6PA3sIw030957 for ; Mon, 25 Jul 2011 10:03:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752001Ab1GYKDp (ORCPT ); Mon, 25 Jul 2011 06:03:45 -0400 Received: from shards.monkeyblade.net ([198.137.202.13]:45782 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752000Ab1GYKDl (ORCPT ); Mon, 25 Jul 2011 06:03:41 -0400 Received: from localhost (74-93-104-98-Washington.hfc.comcastbusiness.net [74.93.104.98]) (authenticated bits=0) by shards.monkeyblade.net (8.14.4/8.14.4) with ESMTP id p6PA1cpH011199 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 25 Jul 2011 03:01:39 -0700 Date: Mon, 25 Jul 2011 03:01:38 -0700 (PDT) Message-Id: <20110725.030138.969068104211274321.davem@davemloft.net> To: roland@kernel.org CC: linux-rdma@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 6/7] neigh: Add device constructor/destructor capability. From: David Miller X-Mailer: Mew version 6.3 on Emacs 23.2 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 25 Jul 2011 10:03:55 +0000 (UTC) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (shards.monkeyblade.net [198.137.202.13]); Mon, 25 Jul 2011 03:01:39 -0700 (PDT) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org If the neigh entry has device private state, it will need constructor/destructor ops. Signed-off-by: David S. Miller --- 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);