diff options
author | Michael S. Tsirkin <mst@mellanox.co.il> | 2006-03-21 01:25:41 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-03-21 01:25:41 -0500 |
commit | c5ecd62c25400a3c6856e009f84257d5bd03f03b (patch) | |
tree | a0aeb88552772396bba986cce176028348ec041f | |
parent | 53dcb0e38c1786aa82ada4641b4607be315b610a (diff) |
[NET]: Move destructor from neigh->ops to neigh_params
struct neigh_ops currently has a destructor field, which no in-kernel
drivers outside of infiniband use. The infiniband/ulp/ipoib in-tree
driver stashes some info in the neighbour structure (the results of
the second-stage lookup from ARP results to real link-level path), and
it uses neigh->ops->destructor to get a callback so it can clean up
this extra info when a neighbour is freed. We've run into problems
with this: since the destructor is in an ops field that is shared
between neighbours that may belong to different net devices, there's
no way to set/clear it safely.
The following patch moves this field to neigh_parms where it can be
safely set, together with its twin neigh_setup. Two additional
patches in the patch series update ipoib to use this new interface.
Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/infiniband/ulp/ipoib/ipoib_main.c | 16 | ||||
-rw-r--r-- | include/net/neighbour.h | 2 | ||||
-rw-r--r-- | net/core/neighbour.c | 4 |
3 files changed, 4 insertions, 18 deletions
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index c3b5f79d1168..9d9cecd4753b 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
@@ -247,7 +247,6 @@ static void path_free(struct net_device *dev, struct ipoib_path *path) | |||
247 | if (neigh->ah) | 247 | if (neigh->ah) |
248 | ipoib_put_ah(neigh->ah); | 248 | ipoib_put_ah(neigh->ah); |
249 | *to_ipoib_neigh(neigh->neighbour) = NULL; | 249 | *to_ipoib_neigh(neigh->neighbour) = NULL; |
250 | neigh->neighbour->ops->destructor = NULL; | ||
251 | kfree(neigh); | 250 | kfree(neigh); |
252 | } | 251 | } |
253 | 252 | ||
@@ -530,7 +529,6 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev) | |||
530 | err: | 529 | err: |
531 | *to_ipoib_neigh(skb->dst->neighbour) = NULL; | 530 | *to_ipoib_neigh(skb->dst->neighbour) = NULL; |
532 | list_del(&neigh->list); | 531 | list_del(&neigh->list); |
533 | neigh->neighbour->ops->destructor = NULL; | ||
534 | kfree(neigh); | 532 | kfree(neigh); |
535 | 533 | ||
536 | ++priv->stats.tx_dropped; | 534 | ++priv->stats.tx_dropped; |
@@ -769,21 +767,9 @@ static void ipoib_neigh_destructor(struct neighbour *n) | |||
769 | ipoib_put_ah(ah); | 767 | ipoib_put_ah(ah); |
770 | } | 768 | } |
771 | 769 | ||
772 | static int ipoib_neigh_setup(struct neighbour *neigh) | ||
773 | { | ||
774 | /* | ||
775 | * Is this kosher? I can't find anybody in the kernel that | ||
776 | * sets neigh->destructor, so we should be able to set it here | ||
777 | * without trouble. | ||
778 | */ | ||
779 | neigh->ops->destructor = ipoib_neigh_destructor; | ||
780 | |||
781 | return 0; | ||
782 | } | ||
783 | |||
784 | static int ipoib_neigh_setup_dev(struct net_device *dev, struct neigh_parms *parms) | 770 | static int ipoib_neigh_setup_dev(struct net_device *dev, struct neigh_parms *parms) |
785 | { | 771 | { |
786 | parms->neigh_setup = ipoib_neigh_setup; | 772 | parms->neigh_destructor = ipoib_neigh_destructor; |
787 | 773 | ||
788 | return 0; | 774 | return 0; |
789 | } | 775 | } |
diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 6fa9ae190741..b0666d66293f 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h | |||
@@ -68,6 +68,7 @@ struct neigh_parms | |||
68 | struct net_device *dev; | 68 | struct net_device *dev; |
69 | struct neigh_parms *next; | 69 | struct neigh_parms *next; |
70 | int (*neigh_setup)(struct neighbour *); | 70 | int (*neigh_setup)(struct neighbour *); |
71 | void (*neigh_destructor)(struct neighbour *); | ||
71 | struct neigh_table *tbl; | 72 | struct neigh_table *tbl; |
72 | 73 | ||
73 | void *sysctl_table; | 74 | void *sysctl_table; |
@@ -145,7 +146,6 @@ struct neighbour | |||
145 | struct neigh_ops | 146 | struct neigh_ops |
146 | { | 147 | { |
147 | int family; | 148 | int family; |
148 | void (*destructor)(struct neighbour *); | ||
149 | void (*solicit)(struct neighbour *, struct sk_buff*); | 149 | void (*solicit)(struct neighbour *, struct sk_buff*); |
150 | void (*error_report)(struct neighbour *, struct sk_buff*); | 150 | void (*error_report)(struct neighbour *, struct sk_buff*); |
151 | int (*output)(struct sk_buff*); | 151 | int (*output)(struct sk_buff*); |
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 6ba1cdea18e8..0c8666872d10 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -586,8 +586,8 @@ void neigh_destroy(struct neighbour *neigh) | |||
586 | kfree(hh); | 586 | kfree(hh); |
587 | } | 587 | } |
588 | 588 | ||
589 | if (neigh->ops && neigh->ops->destructor) | 589 | if (neigh->parms->neigh_destructor) |
590 | (neigh->ops->destructor)(neigh); | 590 | (neigh->parms->neigh_destructor)(neigh); |
591 | 591 | ||
592 | skb_queue_purge(&neigh->arp_queue); | 592 | skb_queue_purge(&neigh->arp_queue); |
593 | 593 | ||