netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* FIB reorg (2)
@ 2004-11-24 19:16 Robert Olsson
  2004-12-01  6:10 ` David S. Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Robert Olsson @ 2004-11-24 19:16 UTC (permalink / raw)
  To: David S. Miller; +Cc: Robert.Olsson, netdev


And a variant of fib_find_alias for fib_semantics

					--ro


--- net/ipv4/fib_hash.c.orig	Sat Nov 20 11:34:44 2004
+++ net/ipv4/fib_hash.c	Fri Nov 19 16:58:00 2004
@@ -48,6 +48,8 @@
 static kmem_cache_t *fn_hash_kmem;
 static kmem_cache_t *fn_alias_kmem;
 
+extern struct fib_alias *fib_find_alias(struct list_head *fah, u8 tos, u32 prio);
+
 struct fib_node {
 	struct hlist_node	fn_hash;
 	struct list_head	fn_alias;
@@ -404,26 +406,6 @@
 	return NULL;
 }
 
-/* Return the first fib alias matching TOS with
- * priority less than or equal to PRIO.
- */
-static struct fib_alias *fib_find_alias(struct fib_node *fn, u8 tos, u32 prio)
-{
-	if (fn) {
-		struct list_head *head = &fn->fn_alias;
-		struct fib_alias *fa;
-
-		list_for_each_entry(fa, head, fa_list) {
-			if (fa->fa_tos > tos)
-				continue;
-			if (fa->fa_info->fib_priority >= prio ||
-			    fa->fa_tos < tos)
-				return fa;
-		}
-	}
-	return NULL;
-}
-
 static int
 fn_hash_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
 	       struct nlmsghdr *n, struct netlink_skb_parms *req)
@@ -463,7 +445,11 @@
 		fn_rehash_zone(fz);
 
 	f = fib_find_node(fz, key);
-	fa = fib_find_alias(f, tos, fi->fib_priority);
+
+	if(!f)
+	  fa = NULL;
+	else
+	  fa = fib_find_alias(&f->fn_alias, tos, fi->fib_priority);
 
 	/* Now fa, if non-NULL, points to the first fib alias
 	 * with the same keys [prefix,tos,priority], if such key already
@@ -603,7 +589,11 @@
 	}
 
 	f = fib_find_node(fz, key);
-	fa = fib_find_alias(f, tos, 0);
+
+	if(!f)
+	  fa = NULL;
+	else
+	  fa = fib_find_alias(&f->fn_alias, tos, 0);
 	if (!fa)
 		return -ESRCH;
 
--- net/ipv4/fib_semantics.c.orig	Sat Nov 20 11:35:03 2004
+++ net/ipv4/fib_semantics.c	Fri Nov 19 09:00:04 2004
@@ -268,6 +268,25 @@
 	return -1;
 }
 
+/* Return the first fib alias matching TOS with
+ * priority less than or equal to PRIO.
+ */
+struct fib_alias *fib_find_alias(struct list_head *fah, u8 tos, u32 prio)
+{
+	if (fah) {
+		struct fib_alias *fa;
+		list_for_each_entry(fa, fah, fa_list) {
+			if (fa->fa_tos > tos)
+				continue;
+			if (fa->fa_info->fib_priority >= prio ||
+			    fa->fa_tos < tos)
+				return fa;
+		}
+	}
+	return NULL;
+}
+
+
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
 
 static u32 fib_get_attr32(struct rtattr *attr, int attrlen, int type)

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

* Re: FIB reorg (2)
  2004-11-24 19:16 FIB reorg (2) Robert Olsson
@ 2004-12-01  6:10 ` David S. Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2004-12-01  6:10 UTC (permalink / raw)
  To: Robert Olsson; +Cc: netdev

On Wed, 24 Nov 2004 20:16:01 +0100
Robert Olsson <Robert.Olsson@data.slu.se> wrote:

> And a variant of fib_find_alias for fib_semantics

Applied to my 2.6.11 pending tree.

I made the same fixup here as I did for the
first FIB reorg patch, namely making use of
the net/ipv4/fib_lookup.h header file.

Thanks Robert.

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/11/30 21:45:25-08:00 robert.olsson@data.slu.se 
#   [IPV4]: FIB cleanup, fib_find_alias()
#   
#   Abstract out fib_node arg usage in fib_find_alias(),
#   move to fib_semantics.c
#   
#   Signed-off-by: David S. Miller <davem@davemloft.net>
# 
# net/ipv4/fib_semantics.c
#   2004/11/30 21:44:45-08:00 robert.olsson@data.slu.se +18 -0
#   [IPV4]: FIB cleanup, fib_find_alias()
# 
# net/ipv4/fib_lookup.h
#   2004/11/30 21:44:45-08:00 robert.olsson@data.slu.se +2 -0
#   [IPV4]: FIB cleanup, fib_find_alias()
# 
# net/ipv4/fib_hash.c
#   2004/11/30 21:44:45-08:00 robert.olsson@data.slu.se +10 -22
#   [IPV4]: FIB cleanup, fib_find_alias()
# 
diff -Nru a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
--- a/net/ipv4/fib_hash.c	2004-11-30 21:45:41 -08:00
+++ b/net/ipv4/fib_hash.c	2004-11-30 21:45:41 -08:00
@@ -399,26 +399,6 @@
 	return NULL;
 }
 
-/* Return the first fib alias matching TOS with
- * priority less than or equal to PRIO.
- */
-static struct fib_alias *fib_find_alias(struct fib_node *fn, u8 tos, u32 prio)
-{
-	if (fn) {
-		struct list_head *head = &fn->fn_alias;
-		struct fib_alias *fa;
-
-		list_for_each_entry(fa, head, fa_list) {
-			if (fa->fa_tos > tos)
-				continue;
-			if (fa->fa_info->fib_priority >= prio ||
-			    fa->fa_tos < tos)
-				return fa;
-		}
-	}
-	return NULL;
-}
-
 static int
 fn_hash_insert(struct fib_table *tb, struct rtmsg *r, struct kern_rta *rta,
 	       struct nlmsghdr *n, struct netlink_skb_parms *req)
@@ -458,7 +438,11 @@
 		fn_rehash_zone(fz);
 
 	f = fib_find_node(fz, key);
-	fa = fib_find_alias(f, tos, fi->fib_priority);
+
+	if (!f)
+		fa = NULL;
+	else
+		fa = fib_find_alias(&f->fn_alias, tos, fi->fib_priority);
 
 	/* Now fa, if non-NULL, points to the first fib alias
 	 * with the same keys [prefix,tos,priority], if such key already
@@ -598,7 +582,11 @@
 	}
 
 	f = fib_find_node(fz, key);
-	fa = fib_find_alias(f, tos, 0);
+
+	if (!f)
+		fa = NULL;
+	else
+		fa = fib_find_alias(&f->fn_alias, tos, 0);
 	if (!fa)
 		return -ESRCH;
 
diff -Nru a/net/ipv4/fib_lookup.h b/net/ipv4/fib_lookup.h
--- a/net/ipv4/fib_lookup.h	2004-11-30 21:45:41 -08:00
+++ b/net/ipv4/fib_lookup.h	2004-11-30 21:45:41 -08:00
@@ -33,5 +33,7 @@
 extern void rtmsg_fib(int event, u32 key, struct fib_alias *fa,
 		      int z, int tb_id,
 		      struct nlmsghdr *n, struct netlink_skb_parms *req);
+extern struct fib_alias *fib_find_alias(struct list_head *fah,
+					u8 tos, u32 prio);
 
 #endif /* _FIB_LOOKUP_H */
diff -Nru a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
--- a/net/ipv4/fib_semantics.c	2004-11-30 21:45:41 -08:00
+++ b/net/ipv4/fib_semantics.c	2004-11-30 21:45:41 -08:00
@@ -297,6 +297,24 @@
 		netlink_unicast(rtnl, skb, pid, MSG_DONTWAIT);
 }
 
+/* Return the first fib alias matching TOS with
+ * priority less than or equal to PRIO.
+ */
+struct fib_alias *fib_find_alias(struct list_head *fah, u8 tos, u32 prio)
+{
+	if (fah) {
+		struct fib_alias *fa;
+		list_for_each_entry(fa, fah, fa_list) {
+			if (fa->fa_tos > tos)
+				continue;
+			if (fa->fa_info->fib_priority >= prio ||
+			    fa->fa_tos < tos)
+				return fa;
+		}
+	}
+	return NULL;
+}
+
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
 
 static u32 fib_get_attr32(struct rtattr *attr, int attrlen, int type)

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

end of thread, other threads:[~2004-12-01  6:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-24 19:16 FIB reorg (2) Robert Olsson
2004-12-01  6:10 ` David S. 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).