[IPSEC] Move dst->child loop from dst_ifdown to xfrm_dst_ifdown
diff mbox series

Message ID 20050208012929.GA30659@gondor.apana.org.au
State New, archived
Headers show
Series
  • [IPSEC] Move dst->child loop from dst_ifdown to xfrm_dst_ifdown
Related show

Commit Message

Herbert Xu Feb. 8, 2005, 1:29 a.m. UTC
On Sun, Feb 06, 2005 at 05:51:17PM +1100, herbert wrote:
> 
> The idea is to move the check into dst->ops->ifdown.  By definition
> ipv6_dst_ifdown will only see rt6_info entries.  So dst_dev_event
> will become

Here are the patches to do this.  Do they look sane?

This one moves the dst->child processing from dst_ifdown into
xfrm_dst_ifdown.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Cheers,

Comments

Herbert Xu Feb. 8, 2005, 1:31 a.m. UTC | #1
On Tue, Feb 08, 2005 at 12:29:29PM +1100, herbert wrote:
> 
> This one moves the dst->child processing from dst_ifdown into
> xfrm_dst_ifdown.

This patch adds a net_device argument to ifdown.  After all,
it's a bit silly to notify someone of an ifdown event without
telling them what which device it was for :)

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Cheers,
David Miller Feb. 15, 2005, 10:53 p.m. UTC | #2
On Tue, 8 Feb 2005 12:31:40 +1100
Herbert Xu <herbert@gondor.apana.org.au> wrote:

> On Tue, Feb 08, 2005 at 12:29:29PM +1100, herbert wrote:
> > 
> > This one moves the dst->child processing from dst_ifdown into
> > xfrm_dst_ifdown.
> 
> This patch adds a net_device argument to ifdown.  After all,
> it's a bit silly to notify someone of an ifdown event without
> telling them what which device it was for :)
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Ok, I'm going to try and get these two patches into 2.6.11
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Patch
diff mbox series

===== net/core/dst.c 1.26 vs edited =====
--- 1.26/net/core/dst.c	2005-02-06 14:23:59 +11:00
+++ edited/net/core/dst.c	2005-02-08 12:11:39 +11:00
@@ -220,31 +220,26 @@ 
  *
  * Commented and originally written by Alexey.
  */
-static void dst_ifdown(struct dst_entry *dst, int unregister)
+static inline void dst_ifdown(struct dst_entry *dst, int unregister)
 {
 	struct net_device *dev = dst->dev;
 
+	if (dst->ops->ifdown)
+		dst->ops->ifdown(dst, unregister);
+
 	if (!unregister) {
 		dst->input = dst_discard_in;
 		dst->output = dst_discard_out;
-	}
-
-	do {
-		if (unregister) {
-			dst->dev = &loopback_dev;
-			dev_hold(&loopback_dev);
+	} else {
+		dst->dev = &loopback_dev;
+		dev_hold(&loopback_dev);
+		dev_put(dev);
+		if (dst->neighbour && dst->neighbour->dev == dev) {
+			dst->neighbour->dev = &loopback_dev;
 			dev_put(dev);
-			if (dst->neighbour && dst->neighbour->dev == dev) {
-				dst->neighbour->dev = &loopback_dev;
-				dev_put(dev);
-				dev_hold(&loopback_dev);
-			}
+			dev_hold(&loopback_dev);
 		}
-
-		if (dst->ops->ifdown)
-			dst->ops->ifdown(dst, unregister);
-	} while ((dst = dst->child) && dst->flags & DST_NOHASH &&
-		 dst->dev == dev);
+	}
 }
 
 static int dst_dev_event(struct notifier_block *this, unsigned long event, void *ptr)
===== net/xfrm/xfrm_policy.c 1.63 vs edited =====
--- 1.63/net/xfrm/xfrm_policy.c	2005-01-19 07:08:19 +11:00
+++ edited/net/xfrm/xfrm_policy.c	2005-02-08 12:10:47 +11:00
@@ -1027,6 +1027,20 @@ 
 	dst->xfrm = NULL;
 }
 
+static void xfrm_dst_ifdown(struct dst_entry *dst, int unregister)
+{
+	struct net_device *dev = dst->dev;
+
+	if (!unregister)
+		return;
+
+	while ((dst = dst->child) && dst->xfrm && dst->dev == dev) {
+		dst->dev = &loopback_dev;
+		dev_hold(&loopback_dev);
+		dev_put(dev);
+	}
+}
+
 static void xfrm_link_failure(struct sk_buff *skb)
 {
 	/* Impossible. Such dst must be popped before reaches point of failure. */
@@ -1150,6 +1164,8 @@ 
 			dst_ops->check = xfrm_dst_check;
 		if (likely(dst_ops->destroy == NULL))
 			dst_ops->destroy = xfrm_dst_destroy;
+		if (likely(dst_ops->ifdown == NULL))
+			dst_ops->ifdown = xfrm_dst_ifdown;
 		if (likely(dst_ops->negative_advice == NULL))
 			dst_ops->negative_advice = xfrm_negative_advice;
 		if (likely(dst_ops->link_failure == NULL))
@@ -1181,6 +1197,7 @@ 
 			dst_ops->kmem_cachep = NULL;
 			dst_ops->check = NULL;
 			dst_ops->destroy = NULL;
+			dst_ops->ifdown = NULL;
 			dst_ops->negative_advice = NULL;
 			dst_ops->link_failure = NULL;
 			dst_ops->get_mss = NULL;