[XFRM] IPV6: Update outbound state timestamp for each sending.
authorMasahide NAKAMURA <nakam@linux-ipv6.org>
Thu, 24 Aug 2006 01:20:16 +0000 (18:20 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Fri, 22 Sep 2006 22:06:43 +0000 (15:06 -0700)
With this patch transformation state is updated last used time
for each sending. Xtime is used for it like other state lifetime
expiration.
Mobile IPv6 enabled nodes will want to know traffic status of each
binding (e.g. judgement to request binding refresh by correspondent node,
or to keep home/care-of nonce alive by mobile node).
The last used timestamp is an important hint about it.
Based on MIPL2 kernel patch.

This patch was also written by: Henrik Petander <petander@tcs.hut.fi>

Signed-off-by: Masahide NAKAMURA <nakam@linux-ipv6.org>
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/xfrm.h
include/net/xfrm.h
net/ipv6/xfrm6_output.c
net/xfrm/xfrm_user.c

index b53f799189af9418734b4316931e4b4bc9969177..1d8c1f22c12d10c8d2fc9cfd4daa730ff195c651 100644 (file)
@@ -236,6 +236,7 @@ enum xfrm_attr_type_t {
        XFRMA_ETIMER_THRESH,
        XFRMA_SRCADDR,          /* xfrm_address_t */
        XFRMA_COADDR,           /* xfrm_address_t */
+       XFRMA_LASTUSED,
        __XFRMA_MAX
 
 #define XFRMA_MAX (__XFRMA_MAX - 1)
index 872a2a4022b254c45e7be4ca3bac2b3331837fee..248874ecf8dff59f1f602638d7465112aa7be015 100644 (file)
@@ -167,6 +167,9 @@ struct xfrm_state
        struct xfrm_lifetime_cur curlft;
        struct timer_list       timer;
 
+       /* Last used time */
+       u64                     lastused;
+
        /* Reference to data common to all the instances of this
         * transformer. */
        struct xfrm_type        *type;
index b4628fbf8ff598013f484147286a98fbe62653ff..db58104e710b447e31546a812d8169b65919bb56 100644 (file)
@@ -75,6 +75,8 @@ static int xfrm6_output_one(struct sk_buff *skb)
 
                x->curlft.bytes += skb->len;
                x->curlft.packets++;
+               if (x->props.mode == XFRM_MODE_ROUTEOPTIMIZATION)
+                       x->lastused = (u64)xtime.tv_sec;
 
                spin_unlock_bh(&x->lock);
 
index 939808de9e2049027700d44edffeceed673e71e7..f643063a1cbd2bff60150ea3625f34fda796b0ff 100644 (file)
@@ -595,6 +595,9 @@ static int dump_one_state(struct xfrm_state *x, int count, void *ptr)
        if (x->coaddr)
                RTA_PUT(skb, XFRMA_COADDR, sizeof(*x->coaddr), x->coaddr);
 
+       if (x->lastused)
+               RTA_PUT(skb, XFRMA_LASTUSED, sizeof(x->lastused), &x->lastused);
+
        nlh->nlmsg_len = skb->tail - b;
 out:
        sp->this_idx++;