Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1476038
| From | David Howells <dhowells@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH net-next 4/9] rxrpc: Randomise epoch and starting client conn ID values |
| Date | 2016-09-04 23:20 +0200 |
| Message-ID | <sdMZz-2No-7@gated-at.bofh.it> (permalink) |
| References | <sdMPU-2JV-11@gated-at.bofh.it> |
| Organization | Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 |
Create a random epoch value rather than a time-based one on startup and set
the top bit to indicate that this is the case.
Also create a random starting client connection ID value. This will be
incremented from here as new client connections are created.
Signed-off-by: David Howells <dhowells@redhat.com>
---
include/rxrpc/packet.h | 1 +
net/rxrpc/af_rxrpc.c | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/include/rxrpc/packet.h b/include/rxrpc/packet.h
index b2017440b765..3c6128e1fdbe 100644
--- a/include/rxrpc/packet.h
+++ b/include/rxrpc/packet.h
@@ -24,6 +24,7 @@ typedef __be32 rxrpc_serial_net_t; /* on-the-wire Rx message serial number */
*/
struct rxrpc_wire_header {
__be32 epoch; /* client boot timestamp */
+#define RXRPC_RANDOM_EPOCH 0x80000000 /* Random if set, date-based if not */
__be32 cid; /* connection and channel ID */
#define RXRPC_MAXCALLS 4 /* max active calls per conn */
diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
index 32d544995dda..b66a9e6f8d04 100644
--- a/net/rxrpc/af_rxrpc.c
+++ b/net/rxrpc/af_rxrpc.c
@@ -16,6 +16,7 @@
#include <linux/net.h>
#include <linux/slab.h>
#include <linux/skbuff.h>
+#include <linux/random.h>
#include <linux/poll.h>
#include <linux/proc_fs.h>
#include <linux/key-type.h>
@@ -700,7 +701,13 @@ static int __init af_rxrpc_init(void)
BUILD_BUG_ON(sizeof(struct rxrpc_skb_priv) > FIELD_SIZEOF(struct sk_buff, cb));
- rxrpc_epoch = get_seconds();
+ get_random_bytes(&rxrpc_epoch, sizeof(rxrpc_epoch));
+ rxrpc_epoch |= RXRPC_RANDOM_EPOCH;
+ get_random_bytes(&rxrpc_client_conn_ids.cur,
+ sizeof(rxrpc_client_conn_ids.cur));
+ rxrpc_client_conn_ids.cur &= 0x3fffffff;
+ if (rxrpc_client_conn_ids.cur == 0)
+ rxrpc_client_conn_ids.cur = 1;
ret = -ENOMEM;
rxrpc_call_jar = kmem_cache_create(
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH net-next 0/9] rxrpc: Small fixes David Howells <dhowells@redhat.com> - 2016-09-04 23:10 +0200
[PATCH net-next 9/9] fs/afs/flock: Remove deprecated create_singlethread_workqueue David Howells <dhowells@redhat.com> - 2016-09-04 23:10 +0200
[PATCH net-next 5/9] rxrpc: Don't change the epoch David Howells <dhowells@redhat.com> - 2016-09-04 23:10 +0200
[PATCH net-next 6/9] fs/afs/vlocation: Remove deprecated create_singlethread_workqueue David Howells <dhowells@redhat.com> - 2016-09-04 23:20 +0200
[PATCH net-next 3/9] rxrpc: The client call state must be changed before attachment to conn David Howells <dhowells@redhat.com> - 2016-09-04 23:20 +0200
[PATCH net-next 4/9] rxrpc: Randomise epoch and starting client conn ID values David Howells <dhowells@redhat.com> - 2016-09-04 23:20 +0200
RE: [PATCH net-next 4/9] rxrpc: Randomise epoch and starting client conn ID values David Laight <David.Laight@ACULAB.COM> - 2016-09-05 17:10 +0200
Re: [PATCH net-next 4/9] rxrpc: Randomise epoch and starting client conn ID values David Howells <dhowells@redhat.com> - 2016-09-05 18:30 +0200
Re: [PATCH net-next 4/9] rxrpc: Randomise epoch and starting client conn ID values Jeffrey Altman <jaltman@auristor.com> - 2016-09-06 04:20 +0200
[PATCH net-next 7/9] fs/afs/rxrpc: Remove deprecated create_singlethread_workqueue David Howells <dhowells@redhat.com> - 2016-09-04 23:20 +0200
[PATCH net-next 8/9] fs/afs/callback: Remove deprecated create_singlethread_workqueue David Howells <dhowells@redhat.com> - 2016-09-04 23:20 +0200
Re: [PATCH net-next 0/9] rxrpc: Small fixes David Miller <davem@davemloft.net> - 2016-09-06 23:00 +0200
csiph-web