tcp: correct read of TFO keys on big endian systems
[linux-2.6-microblaze.git] / net / ipv4 / tcp_fastopen.c
index 19ad958..1bb8582 100644 (file)
@@ -108,6 +108,29 @@ out:
        return err;
 }
 
+int tcp_fastopen_get_cipher(struct net *net, struct inet_connection_sock *icsk,
+                           u64 *key)
+{
+       struct tcp_fastopen_context *ctx;
+       int n_keys = 0, i;
+
+       rcu_read_lock();
+       if (icsk)
+               ctx = rcu_dereference(icsk->icsk_accept_queue.fastopenq.ctx);
+       else
+               ctx = rcu_dereference(net->ipv4.tcp_fastopen_ctx);
+       if (ctx) {
+               n_keys = tcp_fastopen_context_len(ctx);
+               for (i = 0; i < n_keys; i++) {
+                       put_unaligned_le64(ctx->key[i].key[0], key + (i * 2));
+                       put_unaligned_le64(ctx->key[i].key[1], key + (i * 2) + 1);
+               }
+       }
+       rcu_read_unlock();
+
+       return n_keys;
+}
+
 static bool __tcp_fastopen_cookie_gen_cipher(struct request_sock *req,
                                             struct sk_buff *syn,
                                             const siphash_key_t *key,