Skip to contentSkip to conversation

chtls: Register the ULP

RFC Dave Watson 3 participants 9 messages Jan 25, 2018 – Feb 8, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

<[email protected]>

Quoted 10 lines · Atul Gupta
(quoted diff) +10 -0
+static void __init chtls_init_ulp_ops(void)
+{
+	chtls_base_prot			= tcp_prot;
+	chtls_base_prot.hash		= chtls_hash;
+	chtls_base_prot.unhash		= chtls_unhash;
+	chtls_base_prot.close		= chtls_lsk_close;
+
+	chtls_cpl_prot			= chtls_base_prot;
+	chtls_init_rsk_ops(&chtls_cpl_prot, &chtls_rsk_ops,
+			   &tcp_prot, PF_INET);

Review

Quoted 10 lines
(quoted diff) +10 -0
+	chtls_cpl_prot.close		= chtls_close;
+	chtls_cpl_prot.disconnect	= chtls_disconnect;
+	chtls_cpl_prot.destroy		= chtls_destroy_sock;
+	chtls_cpl_prot.shutdown		= chtls_shutdown;
+	chtls_cpl_prot.sendmsg		= chtls_sendmsg;
+	chtls_cpl_prot.recvmsg		= chtls_recvmsg;
+	chtls_cpl_prot.sendpage		= chtls_sendpage;
+	chtls_cpl_prot.setsockopt	= chtls_setsockopt;
+	chtls_cpl_prot.getsockopt	= chtls_getsockopt;
+}

Much of this file should go in tls_main.c, reusing as much as possible. For example it doesn't look like the get/set sockopts have changed at all for chtls.

Quoted 7 lines
(quoted diff) +7 -0
+
+static int __init chtls_register(void)
+{
+	chtls_init_ulp_ops();
+	register_listen_notifier(&listen_notifier);
+	cxgb4_register_uld(CXGB4_ULD_TLS, &chtls_uld_info);
+	tcp_register_ulp(&tcp_chtls_ulp_ops);

Review

Quoted 10 lines
(quoted diff) +10 -0
+	return 0;
+}
+
+static void __exit chtls_unregister(void)
+{
+	unregister_listen_notifier(&listen_notifier);
+	tcp_unregister_ulp(&tcp_chtls_ulp_ops);
+	chtls_free_all_uld();
+	cxgb4_unregister_uld(CXGB4_ULD_TLS);
+}

The idea with ULP is that there is one ULP hook per protocol, not per driver.

#1 lore raw

-----Original Message-----
From: Dave Watson [mailto:[email protected]]
Sent: Friday, January 26, 2018 2:39 AM
To: Atul Gupta <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Boris Pismenny <[email protected]>; Ilya Lesokhin <[email protected]>
Subject: Re: [RFC crypto v3 8/9] chtls: Register the ULP

<[email protected]>

Quoted 9 lines · Atul Gupta
(quoted diff) +9 -0
+static void __init chtls_init_ulp_ops(void) {
+	chtls_base_prot			= tcp_prot;
+	chtls_base_prot.hash		= chtls_hash;
+	chtls_base_prot.unhash		= chtls_unhash;
+	chtls_base_prot.close		= chtls_lsk_close;
+
+	chtls_cpl_prot			= chtls_base_prot;
+	chtls_init_rsk_ops(&chtls_cpl_prot, &chtls_rsk_ops,
+			   &tcp_prot, PF_INET);

Review

Quoted 10 lines
(quoted diff) +10 -0
+	chtls_cpl_prot.close		= chtls_close;
+	chtls_cpl_prot.disconnect	= chtls_disconnect;
+	chtls_cpl_prot.destroy		= chtls_destroy_sock;
+	chtls_cpl_prot.shutdown		= chtls_shutdown;
+	chtls_cpl_prot.sendmsg		= chtls_sendmsg;
+	chtls_cpl_prot.recvmsg		= chtls_recvmsg;
+	chtls_cpl_prot.sendpage		= chtls_sendpage;
+	chtls_cpl_prot.setsockopt	= chtls_setsockopt;
+	chtls_cpl_prot.getsockopt	= chtls_getsockopt;
+}

Much of this file should go in tls_main.c, reusing as much as possible. For example it doesn't look like the get/set sockopts have changed at all for chtls.

Agree, should common code and anything other than TLS_BASE_TX/TLS_SW_TX prot should go in vendor specific file/driver. Since, prot require redefinition for hardware the code is kept in chtls_main.c

Quoted 5 lines
(quoted diff) +5 -0
+
+static int __init chtls_register(void) {
+	chtls_init_ulp_ops();
+	register_listen_notifier(&listen_notifier);
+	cxgb4_register_uld(CXGB4_ULD_TLS, &chtls_uld_info);

Review

Quoted 10 lines
(quoted diff) +10 -0
+	tcp_register_ulp(&tcp_chtls_ulp_ops);
+	return 0;
+}
+
+static void __exit chtls_unregister(void) {
+	unregister_listen_notifier(&listen_notifier);
+	tcp_unregister_ulp(&tcp_chtls_ulp_ops);
+	chtls_free_all_uld();
+	cxgb4_unregister_uld(CXGB4_ULD_TLS);
+}

The idea with ULP is that there is one ULP hook per protocol, not per driver.

One thought is that apps/lib calling setsockopt pass the required ulp type [tls or chtls or xtls], this enables any HW assist to define base_prot as required and keep common code [tls_main] independent of underlying HW.
If we are to have single TLS ULP hook [good from user point] then need a way to determine which Inline tls hw is used? System with multiple Inline TLS capable hw and differing functionality would require checks in tls_main to exercise that specific functionality/callback?

#2 lore raw

@Dave Watson, Did you get chance to look at my response?

What I was referring is that passing "tls" ulp type in setsockopt may be insufficient to make the decision when multi HW assist Inline TLS solution exists.
Some HW may go beyond defining sendmsg/sendpage of the prot and require additional info to setup the env? Also, we need to keep vendor specific code out of tls_main.c i.e anything other than base/sw_tx prot perhaps go to hw driver.

Sabrina echoed similar concern early last week, can we discuss or have thoughts how to address this?

Thanks
Atul

-----Original Message-----
From: Atul Gupta
Sent: Sunday, January 28, 2018 11:26 AM
To: 'Dave Watson' <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Boris Pismenny <[email protected]>; Ilya Lesokhin <[email protected]>
Subject: RE: [RFC crypto v3 8/9] chtls: Register the ULP

-----Original Message-----
From: Dave Watson [mailto:[email protected]]
Sent: Friday, January 26, 2018 2:39 AM
To: Atul Gupta <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Boris Pismenny <[email protected]>; Ilya Lesokhin <[email protected]>
Subject: Re: [RFC crypto v3 8/9] chtls: Register the ULP

<[email protected]>

Quoted 9 lines · Atul Gupta
(quoted diff) +9 -0
+static void __init chtls_init_ulp_ops(void) {
+	chtls_base_prot			= tcp_prot;
+	chtls_base_prot.hash		= chtls_hash;
+	chtls_base_prot.unhash		= chtls_unhash;
+	chtls_base_prot.close		= chtls_lsk_close;
+
+	chtls_cpl_prot			= chtls_base_prot;
+	chtls_init_rsk_ops(&chtls_cpl_prot, &chtls_rsk_ops,
+			   &tcp_prot, PF_INET);

Review

Quoted 10 lines
(quoted diff) +10 -0
+	chtls_cpl_prot.close		= chtls_close;
+	chtls_cpl_prot.disconnect	= chtls_disconnect;
+	chtls_cpl_prot.destroy		= chtls_destroy_sock;
+	chtls_cpl_prot.shutdown		= chtls_shutdown;
+	chtls_cpl_prot.sendmsg		= chtls_sendmsg;
+	chtls_cpl_prot.recvmsg		= chtls_recvmsg;
+	chtls_cpl_prot.sendpage		= chtls_sendpage;
+	chtls_cpl_prot.setsockopt	= chtls_setsockopt;
+	chtls_cpl_prot.getsockopt	= chtls_getsockopt;
+}

Much of this file should go in tls_main.c, reusing as much as possible. For example it doesn't look like the get/set sockopts have changed at all for chtls.

Agree, should common code and anything other than TLS_BASE_TX/TLS_SW_TX prot should go in vendor specific file/driver. Since, prot require redefinition for hardware the code is kept in chtls_main.c

Quoted 5 lines
(quoted diff) +5 -0
+
+static int __init chtls_register(void) {
+	chtls_init_ulp_ops();
+	register_listen_notifier(&listen_notifier);
+	cxgb4_register_uld(CXGB4_ULD_TLS, &chtls_uld_info);

Review

Quoted 10 lines
(quoted diff) +10 -0
+	tcp_register_ulp(&tcp_chtls_ulp_ops);
+	return 0;
+}
+
+static void __exit chtls_unregister(void) {
+	unregister_listen_notifier(&listen_notifier);
+	tcp_unregister_ulp(&tcp_chtls_ulp_ops);
+	chtls_free_all_uld();
+	cxgb4_unregister_uld(CXGB4_ULD_TLS);
+}

The idea with ULP is that there is one ULP hook per protocol, not per driver.

One thought is that apps/lib calling setsockopt pass the required ulp type [tls or chtls or xtls], this enables any HW assist to define base_prot as required and keep common code [tls_main] independent of underlying HW.
If we are to have single TLS ULP hook [good from user point] then need a way to determine which Inline tls hw is used? System with multiple Inline TLS capable hw and differing functionality would require checks in tls_main to exercise that specific functionality/callback?

#3 lore raw
Quoted 3 lines · Atul Gupta

What I was referring is that passing "tls" ulp type in setsockopt may be insufficient to make the decision when multi HW assist Inline TLS solution exists.

Setting the ULP doesn't choose HW or SW implementation, I think that should be done later when setting up crypto with

setsockopt(SOL_TLS, TLS_TX, struct crypto_info).

Any reason we can't use ethtool to choose HW vs SW implementation, if available on the device?

Quoted 4 lines

Some HW may go beyond defining sendmsg/sendpage of the prot and require additional info to setup the env? Also, we need to keep vendor specific code out of tls_main.c i.e anything other than base/sw_tx prot perhaps go to hw driver.

Sure, but I think we can add hooks to tls_main to do this without a new ULP.

#4 lore raw
Quoted 9 lines · Dave Watson
Quoted 3 lines · Atul Gupta

What I was referring is that passing "tls" ulp type in setsockopt may be insufficient to make the decision when multi HW assist Inline TLS solution exists.

Setting the ULP doesn't choose HW or SW implementation, I think that should be done later when setting up crypto with

setsockopt(SOL_TLS, TLS_TX, struct crypto_info).

setsockpot [mentioned above] is quite late for driver to enable HW implementation, we require something as early as tls_init [setsockopt(sock, SOL_TCP, TCP_ULP, "tls", sizeof("tls"))], for driver to set HW prot and offload connection beside Inline Tx/Rx.

Quoted 3 lines

Any reason we can't use ethtool to choose HW vs SW implementation, if available on the device?

Thought about it,  the interface index is not available to fetch netdev and caps check to set HW prot eg. bind [prot.hash] --> tls_hash to program HW.

Quoted 7 lines
Quoted 5 lines

Some HW may go beyond defining sendmsg/sendpage of the prot and require additional info to setup the env? Also, we need to keep vendor specific code out of tls_main.c i.e anything other than base/sw_tx prot perhaps go to hw driver.

Sure, but I think we can add hooks to tls_main to do this without a new ULP.

Current code calls update_sk_prot for TLS_BASE_TX and TLS_SW_TX, future Inline TLS assist HWs will add TLS_HW_TX, TLS_OFLD, ... etc additional hooks to update sk prots can make code confusing?

#5 lore raw
Quoted 17 lines · Atul Gupta
Quoted 9 lines · Dave Watson
Quoted 3 lines · Atul Gupta

What I was referring is that passing "tls" ulp type in setsockopt may be insufficient to make the decision when multi HW assist Inline TLS solution exists.

Setting the ULP doesn't choose HW or SW implementation, I think that should be done later when setting up crypto with

setsockopt(SOL_TLS, TLS_TX, struct crypto_info).

setsockpot [mentioned above] is quite late for driver to enable HW implementation, we require something as early as tls_init [setsockopt(sock, SOL_TCP, TCP_ULP, "tls", sizeof("tls"))], for driver to set HW prot and offload connection beside Inline Tx/Rx.

Quoted 1 line
Quoted 4 lines
Quoted 2 lines

Any reason we can't use ethtool to choose HW vs SW implementation, if available on the device?

Thought about it,  the interface index is not available to fetch netdev and caps check to set HW prot eg. bind [prot.hash] --> tls_hash to program HW.

Perhaps this is the part I don't follow - why do you need to override hash and check for LISTEN? I briefly looked through the patch named "CPL handler definition", this looks like it is a full TCP offload?

#6 lore raw

-----Original Message-----
From: Dave Watson [mailto:[email protected]]
Sent: Wednesday, January 31, 2018 10:14 PM
To: Atul Gupta <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Boris Pismenny <[email protected]>; Ilya Lesokhin <[email protected]>
Subject: Re: [RFC crypto v3 8/9] chtls: Register the ULP

Quoted 17 lines · Atul Gupta
Quoted 9 lines · Dave Watson
Quoted 3 lines · Atul Gupta

What I was referring is that passing "tls" ulp type in setsockopt may be insufficient to make the decision when multi HW assist Inline TLS solution exists.

Setting the ULP doesn't choose HW or SW implementation, I think that should be done later when setting up crypto with

setsockopt(SOL_TLS, TLS_TX, struct crypto_info).

setsockpot [mentioned above] is quite late for driver to enable HW implementation, we require something as early as tls_init [setsockopt(sock, SOL_TCP, TCP_ULP, "tls", sizeof("tls"))], for driver to set HW prot and offload connection beside Inline Tx/Rx.

Quoted 1 line
Quoted 4 lines
Quoted 2 lines

Any reason we can't use ethtool to choose HW vs SW implementation, if available on the device?

Thought about it,  the interface index is not available to fetch
netdev and caps check to set HW prot eg. bind [prot.hash] --> tls_hash to program HW.

Perhaps this is the part I don't follow - why do you need to override hash and check for LISTEN? I briefly looked through the patch named "CPL handler definition", this looks like it is a full TCP offload?

Yes, this is connection and record layer offload, and the reason I used different ulp type, need to see what additional info or check can help setup the required sk prot.

#7 lore raw

I thought about this and approach below can avoid new ulp type:

1. Register Inline TLS driver to net TLS
2. enable ethtool -K <interface> tls-hw-record-offload on
3. Issue " setsockopt(fd, SOL_TCP, TCP_ULP, "tls", sizeof("tls")) " after Bind, this will enable user fetch net_device corresponding to ipaadr bound to interface, if dev found is the one registered and record-offload enabled, program the sk->sk_prot as required.
4. fallback to SW TLS for any other case, bind to inaddr_any falls in this category and need proper handling?

tls-hw-record-offload is TLS record offload to HW, which does tx/rx and record creation Inline.

enum {
TLS_BASE_TX,
TLS_SW_TX,
TLS_RECORD_HW, /* TLS record processed Inline */ TLS_NUM_CONFIG,
};

-----Original Message-----
From: Dave Watson [mailto:[email protected]]
Sent: Wednesday, January 31, 2018 10:14 PM
To: Atul Gupta <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Boris Pismenny <[email protected]>; Ilya Lesokhin <[email protected]>
Subject: Re: [RFC crypto v3 8/9] chtls: Register the ULP

Quoted 17 lines · Atul Gupta
Quoted 9 lines · Dave Watson
Quoted 3 lines · Atul Gupta

What I was referring is that passing "tls" ulp type in setsockopt may be insufficient to make the decision when multi HW assist Inline TLS solution exists.

Setting the ULP doesn't choose HW or SW implementation, I think that should be done later when setting up crypto with

setsockopt(SOL_TLS, TLS_TX, struct crypto_info).

setsockpot [mentioned above] is quite late for driver to enable HW implementation, we require something as early as tls_init [setsockopt(sock, SOL_TCP, TCP_ULP, "tls", sizeof("tls"))], for driver to set HW prot and offload connection beside Inline Tx/Rx.

Quoted 1 line
Quoted 4 lines
Quoted 2 lines

Any reason we can't use ethtool to choose HW vs SW implementation, if available on the device?

Thought about it,  the interface index is not available to fetch
netdev and caps check to set HW prot eg. bind [prot.hash] --> tls_hash to program HW.

Perhaps this is the part I don't follow - why do you need to override hash and check for LISTEN? I briefly looked through the patch named "CPL handler definition", this looks like it is a full TCP offload?

Yes, this is connection and record layer offload, and the reason I used different ulp type, need to see what additional info or check can help setup the required sk prot.

#8 lore raw
Quoted 13 lines

-----Original Message-----
From: [email protected] [mailto:linux-crypto- [email protected]] On Behalf Of Atul Gupta
Sent: Thursday, February 8, 2018 3:56 PM
To: Dave Watson <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; Boris Pismenny <[email protected]>; Ilya Lesokhin <[email protected]>
Subject: RE: [RFC crypto v3 8/9] chtls: Register the ULP

Quoted 8 lines

I thought about this and approach below can avoid new ulp type:

1. Register Inline TLS driver to net TLS
2. enable ethtool -K <interface> tls-hw-record-offload on
3. Issue " setsockopt(fd, SOL_TCP, TCP_ULP, "tls", sizeof("tls")) " after Bind, this will enable user fetch net_device corresponding to ipaadr bound to interface, if dev found is the one registered and record-offload enabled, program the sk->sk_prot as required.

What happens in case of TLS clients which do not explicitly call bind() and rely on kernel to choose an ephemeral port for socket?
Does calling setsockopt after the connection is established fix the problem?

Quoted 54 lines

4. fallback to SW TLS for any other case, bind to inaddr_any falls in this category and need proper handling?

tls-hw-record-offload is TLS record offload to HW, which does tx/rx and record creation Inline.

enum {
TLS_BASE_TX,
TLS_SW_TX,
TLS_RECORD_HW, /* TLS record processed Inline */ TLS_NUM_CONFIG,
};

-----Original Message-----
From: Dave Watson [mailto:[email protected]]
Sent: Wednesday, January 31, 2018 10:14 PM
To: Atul Gupta <[email protected]>
Cc: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; Boris Pismenny <[email protected]>; Ilya Lesokhin <[email protected]>
Subject: Re: [RFC crypto v3 8/9] chtls: Register the ULP

Quoted 17 lines · Atul Gupta
Quoted 9 lines · Dave Watson
Quoted 3 lines · Atul Gupta

What I was referring is that passing "tls" ulp type in setsockopt may be insufficient to make the decision when multi HW assist Inline TLS solution exists.

Setting the ULP doesn't choose HW or SW implementation, I think that should be done later when setting up crypto with

setsockopt(SOL_TLS, TLS_TX, struct crypto_info).

setsockpot [mentioned above] is quite late for driver to enable HW implementation, we require something as early as tls_init [setsockopt(sock, SOL_TCP, TCP_ULP, "tls", sizeof("tls"))], for driver to set HW prot and offload connection beside Inline Tx/Rx.

Quoted 1 line
Quoted 4 lines
Quoted 2 lines

Any reason we can't use ethtool to choose HW vs SW implementation, if available on the device?

Thought about it,  the interface index is not available to fetch netdev and caps check to set HW prot eg. bind [prot.hash] --> tls_hash to

program HW.

Perhaps this is the part I don't follow - why do you need to override hash and check for LISTEN? I briefly looked through the patch named "CPL handler definition", this looks like it is a full TCP offload?

Yes, this is connection and record layer offload, and the reason I used different ulp type, need to see what additional info or check can help setup the required sk prot.