projects
/
linux-2.6-microblaze.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
[linux-2.6-microblaze.git]
/
net
/
tls
/
tls_device.c
diff --git
a/net/tls/tls_device.c
b/net/tls/tls_device.c
index
ec6f4b6
..
b3e2a30
100644
(file)
--- a/
net/tls/tls_device.c
+++ b/
net/tls/tls_device.c
@@
-38,6
+38,7
@@
#include <net/tcp.h>
#include <net/tls.h>
#include <net/tcp.h>
#include <net/tls.h>
+#include "tls.h"
#include "trace.h"
/* device_offload_lock is used to synchronize tls_dev_add
#include "trace.h"
/* device_offload_lock is used to synchronize tls_dev_add
@@
-97,13
+98,16
@@
static void tls_device_queue_ctx_destruction(struct tls_context *ctx)
unsigned long flags;
spin_lock_irqsave(&tls_device_lock, flags);
unsigned long flags;
spin_lock_irqsave(&tls_device_lock, flags);
+ if (unlikely(!refcount_dec_and_test(&ctx->refcount)))
+ goto unlock;
+
list_move_tail(&ctx->list, &tls_device_gc_list);
/* schedule_work inside the spinlock
* to make sure tls_device_down waits for that work.
*/
schedule_work(&tls_device_gc_work);
list_move_tail(&ctx->list, &tls_device_gc_list);
/* schedule_work inside the spinlock
* to make sure tls_device_down waits for that work.
*/
schedule_work(&tls_device_gc_work);
-
+unlock:
spin_unlock_irqrestore(&tls_device_lock, flags);
}
spin_unlock_irqrestore(&tls_device_lock, flags);
}
@@
-194,8
+198,7
@@
void tls_device_sk_destruct(struct sock *sk)
clean_acked_data_disable(inet_csk(sk));
}
clean_acked_data_disable(inet_csk(sk));
}
- if (refcount_dec_and_test(&tls_ctx->refcount))
- tls_device_queue_ctx_destruction(tls_ctx);
+ tls_device_queue_ctx_destruction(tls_ctx);
}
EXPORT_SYMBOL_GPL(tls_device_sk_destruct);
}
EXPORT_SYMBOL_GPL(tls_device_sk_destruct);
@@
-562,7
+565,7
@@
int tls_device_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
lock_sock(sk);
if (unlikely(msg->msg_controllen)) {
lock_sock(sk);
if (unlikely(msg->msg_controllen)) {
- rc = tls_proc
c
ess_cmsg(sk, msg, &record_type);
+ rc = tls_process_cmsg(sk, msg, &record_type);
if (rc)
goto out;
}
if (rc)
goto out;
}
@@
-888,25
+891,29
@@
static void tls_device_core_ctrl_rx_resync(struct tls_context *tls_ctx,
}
}
}
}
-static int tls_device_reencrypt(struct sock *sk, struct sk_buff *skb)
+static int
+tls_device_reencrypt(struct sock *sk, struct tls_sw_context_rx *sw_ctx)
{
{
- struct strp_msg *rxm = strp_msg(skb);
- int err = 0, offset = rxm->offset, copy, nsg, data_len, pos;
- struct sk_buff *skb_iter, *unused;
+ int err, offset, copy, data_len, pos;
+ struct sk_buff *skb, *skb_iter;
struct scatterlist sg[1];
struct scatterlist sg[1];
+ struct strp_msg *rxm;
char *orig_buf, *buf;
char *orig_buf, *buf;
+ rxm = strp_msg(tls_strp_msg(sw_ctx));
orig_buf = kmalloc(rxm->full_len + TLS_HEADER_SIZE +
TLS_CIPHER_AES_GCM_128_IV_SIZE, sk->sk_allocation);
if (!orig_buf)
return -ENOMEM;
buf = orig_buf;
orig_buf = kmalloc(rxm->full_len + TLS_HEADER_SIZE +
TLS_CIPHER_AES_GCM_128_IV_SIZE, sk->sk_allocation);
if (!orig_buf)
return -ENOMEM;
buf = orig_buf;
- nsg = skb_cow_data(skb, 0, &unused);
- if (unlikely(nsg < 0)) {
- err = nsg;
+ err = tls_strp_msg_cow(sw_ctx);
+ if (unlikely(err))
goto free_buf;
goto free_buf;
- }
+
+ skb = tls_strp_msg(sw_ctx);
+ rxm = strp_msg(skb);
+ offset = rxm->offset;
sg_init_table(sg, 1);
sg_set_buf(&sg[0], buf,
sg_init_table(sg, 1);
sg_set_buf(&sg[0], buf,
@@
-918,7
+925,7
@@
static int tls_device_reencrypt(struct sock *sk, struct sk_buff *skb)
goto free_buf;
/* We are interested only in the decrypted data not the auth */
goto free_buf;
/* We are interested only in the decrypted data not the auth */
- err = decrypt_skb(sk, s
kb, s
g);
+ err = decrypt_skb(sk, sg);
if (err != -EBADMSG)
goto free_buf;
else
if (err != -EBADMSG)
goto free_buf;
else
@@
-973,10
+980,12
@@
free_buf:
return err;
}
return err;
}
-int tls_device_decrypted(struct sock *sk, struct tls_context *tls_ctx,
- struct sk_buff *skb, struct strp_msg *rxm)
+int tls_device_decrypted(struct sock *sk, struct tls_context *tls_ctx)
{
struct tls_offload_context_rx *ctx = tls_offload_ctx_rx(tls_ctx);
{
struct tls_offload_context_rx *ctx = tls_offload_ctx_rx(tls_ctx);
+ struct tls_sw_context_rx *sw_ctx = tls_sw_ctx_rx(tls_ctx);
+ struct sk_buff *skb = tls_strp_msg(sw_ctx);
+ struct strp_msg *rxm = strp_msg(skb);
int is_decrypted = skb->decrypted;
int is_encrypted = !is_decrypted;
struct sk_buff *skb_iter;
int is_decrypted = skb->decrypted;
int is_encrypted = !is_decrypted;
struct sk_buff *skb_iter;
@@
-999,7
+1008,7
@@
int tls_device_decrypted(struct sock *sk, struct tls_context *tls_ctx,
* likely have initial fragments decrypted, and final ones not
* decrypted. We need to reencrypt that single SKB.
*/
* likely have initial fragments decrypted, and final ones not
* decrypted. We need to reencrypt that single SKB.
*/
- return tls_device_reencrypt(sk, s
kb
);
+ return tls_device_reencrypt(sk, s
w_ctx
);
}
/* Return immediately if the record is either entirely plaintext or
}
/* Return immediately if the record is either entirely plaintext or
@@
-1016,7
+1025,7
@@
int tls_device_decrypted(struct sock *sk, struct tls_context *tls_ctx,
}
ctx->resync_nh_reset = 1;
}
ctx->resync_nh_reset = 1;
- return tls_device_reencrypt(sk, s
kb
);
+ return tls_device_reencrypt(sk, s
w_ctx
);
}
static void tls_device_attach(struct tls_context *ctx, struct sock *sk,
}
static void tls_device_attach(struct tls_context *ctx, struct sock *sk,
@@
-1374,8
+1383,13
@@
static int tls_device_down(struct net_device *netdev)
* by tls_device_free_ctx. rx_conf and tx_conf stay in TLS_HW.
* Now release the ref taken above.
*/
* by tls_device_free_ctx. rx_conf and tx_conf stay in TLS_HW.
* Now release the ref taken above.
*/
- if (refcount_dec_and_test(&ctx->refcount))
+ if (refcount_dec_and_test(&ctx->refcount)) {
+ /* sk_destruct ran after tls_device_down took a ref, and
+ * it returned early. Complete the destruction here.
+ */
+ list_del(&ctx->list);
tls_device_free_ctx(ctx);
tls_device_free_ctx(ctx);
+ }
}
up_write(&device_offload_lock);
}
up_write(&device_offload_lock);
@@
-1419,9
+1433,9
@@
static struct notifier_block tls_dev_notifier = {
.notifier_call = tls_dev_event,
};
.notifier_call = tls_dev_event,
};
-
void
__init tls_device_init(void)
+
int
__init tls_device_init(void)
{
{
- register_netdevice_notifier(&tls_dev_notifier);
+ re
turn re
gister_netdevice_notifier(&tls_dev_notifier);
}
void __exit tls_device_cleanup(void)
}
void __exit tls_device_cleanup(void)