diff options
author | Jeremy Kerr <jk@codeconstruct.com.au> | 2021-09-29 15:26:09 +0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-09-29 11:00:11 +0100 |
commit | 7b14e15ae6f4850392800482efb54d5cf4ae300c (patch) | |
tree | 4857420af83ce1abaa4ff581b31303fcc5c5c109 /net/mctp/route.c | |
parent | 43f55f23f70881e9c397557f15c8090b368d0af2 (diff) | |
download | linux-7b14e15ae6f4850392800482efb54d5cf4ae300c.tar.gz |
mctp: Implement a timeout for tags
Currently, a MCTP (local-eid,remote-eid,tag) tuple is allocated to a
socket on send, and only expires when the socket is closed.
This change introduces a tag timeout, freeing the tuple after a fixed
expiry - currently six seconds. This is greater than (but close to) the
max response timeout in upper-layer bindings.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mctp/route.c')
-rw-r--r-- | net/mctp/route.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/net/mctp/route.c b/net/mctp/route.c index 37aa67847a5a..c342adf4f97f 100644 --- a/net/mctp/route.c +++ b/net/mctp/route.c @@ -24,6 +24,8 @@ #include <net/sock.h> static const unsigned int mctp_message_maxlen = 64 * 1024; +static const unsigned long mctp_key_lifetime = 6 * CONFIG_HZ; + /* route output callbacks */ static int mctp_route_discard(struct mctp_route *route, struct sk_buff *skb) @@ -175,6 +177,9 @@ static int mctp_key_add(struct mctp_sk_key *key, struct mctp_sock *msk) if (!rc) { refcount_inc(&key->refs); + key->expiry = jiffies + mctp_key_lifetime; + timer_reduce(&msk->key_expiry, key->expiry); + hlist_add_head(&key->hlist, &net->mctp.keys); hlist_add_head(&key->sklist, &msk->keys); } @@ -497,6 +502,9 @@ static void mctp_reserve_tag(struct net *net, struct mctp_sk_key *key, lockdep_assert_held(&mns->keys_lock); + key->expiry = jiffies + mctp_key_lifetime; + timer_reduce(&msk->key_expiry, key->expiry); + /* we hold the net->key_lock here, allowing updates to both * then net and sk */ |