Skip to contentSkip to conversation

IPROUTE2: Fix bug in display of ipv6 cloned/cached routes

PATCH In review Sridhar Samudrala 2 participants 4 messages Jul 11, 2007 – Jul 13, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IPROUTE2: Fix bug in display of ipv6 cloned/cached routes

This patch fixes a bug in the 'ip' command to display IPv6 cloned routes.
ip -6 route ls cache
returns empty even when there are cloned routes because of of a missing else in print_route() routine.

Thanks
Sridhar

ip/iproute.c +11 -10
index 6fe4a70..08feceb 100644
@@ -176,18 +176,19 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 		if (filter.cloned) {
 			if (!(r->rtm_flags&RTM_F_CLONED))
 				return 0;
-		}
-		if (filter.tb) {
-			if (r->rtm_flags&RTM_F_CLONED)
-				return 0;
-			if (filter.tb == RT_TABLE_LOCAL) {
-				if (r->rtm_type != RTN_LOCAL)
+		} else {
+			if (filter.tb) {
+				if (r->rtm_flags&RTM_F_CLONED)
 					return 0;
-			} else if (filter.tb == RT_TABLE_MAIN) {
-				if (r->rtm_type == RTN_LOCAL)
+				if (filter.tb == RT_TABLE_LOCAL) {
+					if (r->rtm_type != RTN_LOCAL)
+						return 0;
+				} else if (filter.tb == RT_TABLE_MAIN) {
+					if (r->rtm_type == RTN_LOCAL)
+						return 0;
+				} else {
 					return 0;
-			} else {
-				return 0;
+				}
 			}
 		}
 	} else {
#1 lore raw
Quoted 5 lines · Sridhar Samudrala

This patch fixes a bug in the 'ip' command to display IPv6 cloned routes.
ip -6 route ls cache
returns empty even when there are cloned routes because of of a missing else in print_route() routine.

Looks good. The ip6_multiple_tables case seems to be missing filtering for cloned entries entirely, would you mind adding that as well?

#2 lore raw
Quoted 8 lines · Patrick McHardy
Quoted 5 lines · Sridhar Samudrala

This patch fixes a bug in the 'ip' command to display IPv6 cloned routes.
ip -6 route ls cache
returns empty even when there are cloned routes because of of a missing else in print_route() routine.

Quoted 4 lines

Looks good. The ip6_multiple_tables case seems to be missing filtering for cloned entries entirely, would you mind adding that as well?

I found an issue with my original patch. If cache/cloned is specified, it dumps the cloned routes irrespective of the table specified. I think this is a better fix and also should address the case you were mentioning above.

Thanks
Sridhar

ip/iproute.c +5 -1
index 6fe4a70..9694bc7 100644
@@ -178,7 +178,7 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 				return 0;
 		}
 		if (filter.tb) {
-			if (r->rtm_flags&RTM_F_CLONED)
+			if (!filter.cloned && r->rtm_flags&RTM_F_CLONED)
 				return 0;
 			if (filter.tb == RT_TABLE_LOCAL) {
 				if (r->rtm_type != RTN_LOCAL)
@@ -191,6 +191,10 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 			}
 		}
 	} else {
+		if (filter.cloned) {
+			if (!(r->rtm_flags&RTM_F_CLONED))
+				return 0;
+		}
 		if (filter.tb > 0 && filter.tb != table)
 			return 0;
 	}
#3 lore raw
Quoted 4 lines · Sridhar Samudrala

I found an issue with my original patch. If cache/cloned is specified, it dumps the cloned routes irrespective of the table specified. I think this is a better fix and also should address the case you were mentioning above.

Your patch looks good, thanks.