Thread (3 messages) flat view 3 messages, 2 authors, 2007-09-21

Re: [PATCH 3/3 Rev4] Initialize and fill IPv6 route age

From: Varun Chandramohan <hidden>
Date: 2007-09-21 04:29:25

Krishna Kumar2 wrote:
Varun Chandramohan [off-list ref] wrote on 09/20/2007 08:59:03
PM:

  
quoted
@@ -2123,6 +2131,7 @@ static int rt6_fill_node(struct sk_buff
 {
    struct rtmsg *rtm;
    struct nlmsghdr *nlh;
+   struct timeval tv;
    long expires;
    u32 table;
@@ -2186,6 +2195,11 @@ static int rt6_fill_node(struct sk_buff
       if (ipv6_get_saddr(&rt->u.dst, dst, &saddr_buf) == 0)
          NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf);
    }
+
+   do_gettimeofday(&tv);
+   if (rt->rt6i_age) {
+      NLA_PUT_U32(skb, RTA_AGE, (tv.tv_sec - rt->rt6i_age));
+   }
    
Will rt6i_age ever be zero with this new patch? If it can be zero,
the code should really be keeping the "tv" declaration and
do_gettimeofday() inside the "if (rt->rt6i_age)" check.

  
No, it will be zero only if some new code added doesnt initialize the
route age. I will update this change in my next patch release.
quoted hunk ↗ jump to hunk
And from your Patch2/3:

int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
-                          u32 tb_id, u8 type, u8 scope, __be32 dst, int
dst_len, u8 tos,
+                          u32 tb_id, u8 type, u8 scope, __be32 dst, int
dst_len, u8 tos, time_t age,
                           struct fib_info *fi, unsigned int flags)
 {
             struct nlmsghdr *nlh;
             struct rtmsg *rtm;
+            struct timeval tv;

             nlh = nlmsg_put(skb, pid, seq, event, sizeof(*rtm), flags);
             if (nlh == NULL)
@@ -985,6 +987,11 @@ int fib_dump_info(struct sk_buff *skb, u
                                     NLA_PUT_U32(skb, RTA_FLOW,
fi->fib_nh[0].nh_tclassid);
 #endif
             }
+
+            do_gettimeofday(&tv);
+            if (age) {
+                        NLA_PUT_U32(skb, RTA_AGE, (tv.tv_sec - age));
+            }

Don't you want to return time the first time (and get zero)? Otherwise
RTA_AGE is not returned to user. Something like:

  
The first time it will be zero.
            do_gettimeofday(&tv);
            NLA_PUT_U32(skb, RTA_AGE, (tv.tv_sec - age));

Once again, can age ever be zero?

  
same as above.
- KK

  
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help