2019-04-09 15:23:40

by Atul Gupta

[permalink] [raw]
Subject: [crypto 1/4] net/tls: connect routine for Inine TLS Client

Define tls_hw_connect to allow hardware setup Inline TLS
client before TLS handshake and key program.

Signed-off-by: Atul Gupta <[email protected]>
---
include/net/tls.h | 6 ++++++
net/tls/tls_main.c | 23 +++++++++++++++++++++++
2 files changed, 29 insertions(+)

diff --git a/include/net/tls.h b/include/net/tls.h
index a5a9385..655c17e 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -77,6 +77,9 @@
* void (*unhash)(struct tls_device *device, struct sock *sk);
* This function cleans listen state set by Inline TLS driver
*
+ * int (*connect)(struct tls_device *device, struct sock *sk,
+ * struct sockaddr *uaddr, int addr_len);
+ *
* void (*release)(struct kref *kref);
* Release the registered device and allocated resources
* @kref: Number of reference to tls_device
@@ -87,6 +90,8 @@ struct tls_device {
int (*feature)(struct tls_device *device);
int (*hash)(struct tls_device *device, struct sock *sk);
void (*unhash)(struct tls_device *device, struct sock *sk);
+ int (*connect)(struct tls_device *device, struct sock *sk,
+ struct sockaddr *uaddr, int addr_len);
void (*release)(struct kref *kref);
struct kref kref;
};
@@ -264,6 +269,7 @@ struct tls_context {
int __user *optlen);
int (*hash)(struct sock *sk);
void (*unhash)(struct sock *sk);
+ int (*connect)(struct sock *sk, struct sockaddr *uaddr, int addr_len);
};

struct tls_offload_context_rx {
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index df921a2..eaf60ca 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -620,6 +620,28 @@ static void tls_hw_sk_destruct(struct sock *sk)
icsk->icsk_ulp_data = NULL;
}

+static int tls_hw_connect(struct sock *sk, struct sockaddr *uaddr,
+ int addr_len)
+{
+ struct tls_device *dev;
+ int err;
+
+ spin_lock_bh(&device_spinlock);
+ list_for_each_entry(dev, &device_list, dev_list) {
+ if (dev->connect) {
+ kref_get(&dev->kref);
+ spin_unlock_bh(&device_spinlock);
+ err = dev->connect(dev, sk, uaddr, addr_len);
+ kref_put(&dev->kref, dev->release);
+ spin_lock_bh(&device_spinlock);
+ if (!err)
+ break;
+ }
+ }
+ spin_unlock_bh(&device_spinlock);
+ return err;
+}
+
static int tls_hw_prot(struct sock *sk)
{
struct tls_context *ctx;
@@ -737,6 +759,7 @@ static void build_protos(struct proto prot[TLS_NUM_CONFIG][TLS_NUM_CONFIG],
prot[TLS_HW_RECORD][TLS_HW_RECORD] = *base;
prot[TLS_HW_RECORD][TLS_HW_RECORD].hash = tls_hw_hash;
prot[TLS_HW_RECORD][TLS_HW_RECORD].unhash = tls_hw_unhash;
+ prot[TLS_HW_RECORD][TLS_HW_RECORD].connect = tls_hw_connect;
prot[TLS_HW_RECORD][TLS_HW_RECORD].close = tls_sk_proto_close;
}

--
1.8.3.1



2019-04-11 20:44:42

by kernel test robot

[permalink] [raw]
Subject: Re: [crypto 1/4] net/tls: connect routine for Inine TLS Client

Hi Atul,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on crypto/master]

url: https://github.com/0day-ci/linux/commits/Atul-Gupta/Inline-TLS-client-and-v6-support/20190412-034407
base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git master
config: i386-randconfig-x017-201914 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

net/tls/tls_main.c: In function 'tls_hw_connect':
>> net/tls/tls_main.c:641:9: warning: 'err' may be used uninitialized in this function [-Wmaybe-uninitialized]
return err;
^~~

vim +/err +641 net/tls/tls_main.c

621
622 static int tls_hw_connect(struct sock *sk, struct sockaddr *uaddr,
623 int addr_len)
624 {
625 struct tls_device *dev;
626 int err;
627
628 spin_lock_bh(&device_spinlock);
629 list_for_each_entry(dev, &device_list, dev_list) {
630 if (dev->connect) {
631 kref_get(&dev->kref);
632 spin_unlock_bh(&device_spinlock);
633 err = dev->connect(dev, sk, uaddr, addr_len);
634 kref_put(&dev->kref, dev->release);
635 spin_lock_bh(&device_spinlock);
636 if (!err)
637 break;
638 }
639 }
640 spin_unlock_bh(&device_spinlock);
> 641 return err;
642 }
643

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (1.68 kB)
.config.gz (30.33 kB)
Download all attachments