[zebra] Record NEWADDR metric on PF_ROUTE, print CACHEINFO debug on netlink

2006-01-17 Paul Jakma <paul.jakma@sun.com>

	* kernel_socket.c: (ifam_read) Read metric from RTM_NEWADDR.
	  If interface is an alias, pass the alias as a label for
	  connected_add_ipv{4,6}.
	* rt_netlink.c: (netlink_interface_addr) print out
	  IFA_CACHEINFO info, if present, when debugging kernel
	  messages.
diff --git a/zebra/ChangeLog b/zebra/ChangeLog
index 169f0a6..a40d3e9 100644
--- a/zebra/ChangeLog
+++ b/zebra/ChangeLog
@@ -1,3 +1,12 @@
+2006-01-17 Paul Jakma <paul.jakma@sun.com>
+
+	* kernel_socket.c: (ifam_read) Read metric from RTM_NEWADDR.
+	  If interface is an alias, pass the alias as a label for
+	  connected_add_ipv{4,6}.
+	* rt_netlink.c: (netlink_interface_addr) print out
+	  IFA_CACHEINFO info, if present, when debugging kernel
+	  messages.
+
 2006-01-17 Gunnar Stigen <gunnar.stigen@axxessit.no>
 
 	* connected.c: (connected_up_ipv{4,6}) Include interface metric on
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index c4c1f2c..ae19ef8 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -544,6 +544,8 @@
   if (ifnlen && strncmp (ifp->name, ifname, INTERFACE_NAMSIZ))
     isalias = 1;
   
+  ifp->metric = ifam->ifam_metric;
+  
   /* Check interface flag for implicit up of the interface. */
   if_refresh (ifp);
 
@@ -554,7 +556,8 @@
       if (ifam->ifam_type == RTM_NEWADDR)
 	connected_add_ipv4 (ifp, 0, &addr.sin.sin_addr, 
 			    ip_masklen (mask.sin.sin_addr),
-			    &brd.sin.sin_addr, NULL);
+			    &brd.sin.sin_addr,
+			    (isalias ? ifname : NULL));
       else
 	connected_delete_ipv4 (ifp, 0, &addr.sin.sin_addr, 
 			       ip_masklen (mask.sin.sin_addr),
@@ -571,7 +574,8 @@
 	connected_add_ipv6 (ifp,
 			    &addr.sin6.sin6_addr, 
 			    ip6_masklen (mask.sin6.sin6_addr),
-			    &brd.sin6.sin6_addr, NULL);
+			    &brd.sin6.sin6_addr,
+			    (isalias ? ifname : NULL));
       else
 	connected_delete_ipv6 (ifp,
 			       &addr.sin6.sin6_addr, 
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c
index 6e91408..f1c1a30 100644
--- a/zebra/rt_netlink.c
+++ b/zebra/rt_netlink.c
@@ -628,6 +628,13 @@
 			       buf, BUFSIZ), ifa->ifa_prefixlen);
       if (tb[IFA_LABEL] && strcmp (ifp->name, RTA_DATA (tb[IFA_LABEL])))
         zlog_debug ("  IFA_LABEL     %s", (char *)RTA_DATA (tb[IFA_LABEL]));
+      
+      if (tb[IFA_CACHEINFO])
+        {
+          struct ifa_cacheinfo *ci = RTA_DATA (tb[IFA_CACHEINFO]);
+          zlog_debug ("  IFA_CACHEINFO pref %d, valid %d",
+                      ci->ifa_prefered, ci->ifa_valid);
+        }
     }
   
   if (tb[IFA_ADDRESS] == NULL)