siw: MPA Reply handler tries to read beyond MPA message
Subsystems (2)
PATCH 1/1 siw: MPA Reply handler tries to read beyond MPA message
while processing MPA Reply, SIW driver is trying to read extra 4 bytes than what peer has advertised as private data length.
If a FPDU data is received before even siw_recv_mpa_rr() completed reading MPA reply, then ksock_recv() in siw_recv_mpa_rr() could also read FPDU, if "size" is larger than advertised MPA reply length.
501 static int siw_recv_mpa_rr(struct siw_cep *cep)
502 {
............. 572
573 if (rcvd > to_rcv)
574 return -EPROTO; <----- Failure here
Looks like the intention here is to throw an ERROR if the received data is more than the total private data length advertised by the peer. But reading beyond MPA message causes siw_cm to generate RDMA_CM_EVENT_CONNECT_ERROR event when TCP socket recv buffer is already queued with FPDU messages.
Hence, this function should only read upto private data length.
--- drivers/infiniband/sw/siw/siw_cm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/sw/siw/siw_cm.c +2 -2
@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct siw_cep *cep)* A private data buffer gets allocated if hdr->params.pd_len != 0. */ if (!cep->mpa.pdata) { - cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata =kmalloc (pd_len,GFP_KERNEL );if (!cep->mpa.pdata)return -ENOMEM ; } rcvd =ksock_recv ( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof (struct mpa_rr ), - to_rcv +4 ,MSG_DONTWAIT ); + to_rcv,MSG_DONTWAIT );if (rcvd <0 )return rcvd;
Signature · 1 line
2.23.0.rc0
Quoted 22 lines · Krishnamraju Eraparaju
while processing MPA Reply, SIW driver is trying to read extra 4 bytes than what peer has advertised as private data length.
If a FPDU data is received before even
siw_recv_mpa_rr()completed reading MPA reply, thenksock_recv()insiw_recv_mpa_rr()could also read FPDU, if "size" is larger than advertised MPA reply length.501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereLooks like the intention here is to throw an ERROR if the received data
is more than the total private data length advertised by the peer. But reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recv buffer is already
queued with FPDU messages.
Quoted 3 lines
Hence, this function should only read upto private data length.
Signed-off-by Krishnamraju Eraparaju <[email protected]>
Once you apply this patch, the if (rcvd > to_rcv) test you listed above in the commit message becomes dead code. So I removed it while applying the patch. Thanks.
Signature · 3 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
Quoted 23 lines · Doug Ledford
Quoted 22 lines · Krishnamraju Eraparaju
while processing MPA Reply, SIW driver is trying to read extra 4 bytes than what peer has advertised as private data length.
If a FPDU data is received before even
siw_recv_mpa_rr()completed reading MPA reply, thenksock_recv()insiw_recv_mpa_rr()could also read FPDU, if "size" is larger than advertised MPA reply length.501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereLooks like the intention here is to throw an ERROR if the received data
is more than the total private data length advertised by the peer. But reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recv buffer is already
queued with FPDU messages.
Quoted 8 lines
Quoted 3 lines
Hence, this function should only read upto private data length.
Signed-off-by Krishnamraju Eraparaju <[email protected]>Once you apply this patch, the if (rcvd >
to_rcv) test you listed above in the commit message becomes dead code. So I removed it while applying the patch. Thanks.
Thanks Doug.
Quoted 4 lines
Signature · 3 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 65 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected], [email protected], [email protected], "Krishnamraju Eraparaju" <[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messagewhile processing MPA Reply, SIW driver is trying to read extra 4 bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()completed reading MPA reply, thenksock_recv()insiw_recv_mpa_rr()could also read FPDU, if "size" is larger than advertised MPA reply length.501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereLooks like the intention here is to throw an ERROR if the received data
is more than the total private data length advertised by the peer. But
reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recv buffer is already
queued with FPDU messages.Hence, this function should only read upto private data length.
Signed-off-by Krishnamraju Eraparaju <[email protected]>---
drivers/infiniband/sw/siw/siw_cm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/infiniband/sw/siw/siw_cm.c +2
-2@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct siw_cep *cep)* A private data buffer gets allocated if hdr->params.pd_len != 0. */ if (!cep->mpa.pdata) { - cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata =kmalloc (pd_len,GFP_KERNEL );if (!cep->mpa.pdata)return -ENOMEM ; } rcvd =ksock_recv ( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof (struct mpa_rr ), - to_rcv +4 ,MSG_DONTWAIT ); + to_rcv,MSG_DONTWAIT );if (rcvd <0 )return rcvd;Signature · 1 line
2.23.0.rc0
The intention of this code is to make sure the peer does not violates the MPA handshake rules. The initiator MUST NOT send extra data after its MPA request and before receiving the MPA reply. So, for the MPA request case, this code is needed to check for protocol correctness.
You are right for the MPA reply case - if we are _not_ in peer2peer mode, the peer can immediately start sending data in RDMA mode after its MPA Reply. So we shall add appropriate code to be more specific For an error, we are (1) processing an MPA Request, OR (2) processing an MPA Reply AND we are not expected to send an initial READ/WRITE/Send as negotiated with the peer (peer2peer mode MPA handshake).
Just removing this check would make siw more permissive, but to a point where peer MPA protocol errors are tolerated. I am not in favor of that level of forgiveness.
If possible, please provide an appropriate patch or (if it causes current issues with another peer iWarp implementation) just run in MPA peer2peer mode, where the current check is appropriate. Otherwise, I would provide an appropriate fix by Monday (I am still out of office this week).
Many thanks and best regards,
Bernard.
Quoted 99 lines · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 62 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected], [email protected], [email protected], "Krishnamraju Eraparaju" <[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messagewhile processing MPA Reply, SIW driver is trying to read extra 4 bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()completed reading MPA reply, thenksock_recv()insiw_recv_mpa_rr()could also read FPDU, if "size" is larger than advertised MPA reply length.501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereLooks like the intention here is to throw an ERROR if the received data
is more than the total private data length advertised by the peer. But
reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recv buffer is already
queued with FPDU messages.Hence, this function should only read upto private data length.
Signed-off-by Krishnamraju Eraparaju <[email protected]>---
drivers/infiniband/sw/siw/siw_cm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct siw_cep *cep) * A private data buffer gets allocated if hdr->params.pd_len !=0.
*/ if (!cep->mpa.pdata) {drivers/infiniband/sw/siw/siw_cm.c +1
-1- cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata =kmalloc (pd_len,GFP_KERNEL );if (!cep->mpa.pdata) return -ENOMEM; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd - sizeof(struct
mpa_rr),drivers/infiniband/sw/siw/siw_cm.c +1
-1- to_rcv + 4, MSG_DONTWAIT); + to_rcv, MSG_DONTWAIT);Quoted 6 lines
if (rcvd < 0) return rcvd;Signature · 1 line
2.23.0.rc0The intention of this code is to make sure the peer does not violates the MPA handshake rules. The initiator MUST NOT send extra data after its MPA request and before receiving the MPA reply. So, for the MPA request case, this code is needed to check for protocol correctness.
You are right for the MPA reply case - if we are _not_ in peer2peer mode, the peer can immediately start sending data in RDMA mode after its MPA Reply. So we shall add appropriate code to be more specific For an error, we are (1) processing an MPA Request, OR (2) processing an MPA Reply AND we are not expected to send an initial READ/WRITE/Send as negotiated with the peer (peer2peer mode MPA handshake).Just removing this check would make siw more permissive, but to a point where peer MPA protocol errors are tolerated. I am not in favor of that level of forgiveness.
If possible, please provide an appropriate patch or (if it causes current issues with another peer iWarp implementation) just run in MPA peer2peer mode, where the current check is appropriate. Otherwise, I would provide an appropriate fix by Monday (I am still out of office this week).
Quoted 3 lines
Many thanks and best regards,
Bernard.
I had taken the patch, but I've since dropped it (it had only made it to my wip/dl-for-rc branch). I'll wait for the proper fix (I looked, and I could code it up, but I don't know what tests to use in the conditionals since I don't know how you track peer2peer mode on the connection).
Signature · 3 lines
Doug Ledford <[email protected]> GPG KeyID: B826A3330E572FDD Fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
Quoted 61 lines · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 59 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected], [email protected], [email protected], "Krishnamraju Eraparaju" <[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messagewhile processing MPA Reply, SIW driver is trying to read extra 4 bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()completed reading MPA reply, thenksock_recv()insiw_recv_mpa_rr()could also read FPDU, if "size" is larger than advertised MPA reply length.501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereLooks like the intention here is to throw an ERROR if the received data
is more than the total private data length advertised by the peer. But
reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recv buffer is already
queued with FPDU messages.Hence, this function should only read upto private data length.
Signed-off-by Krishnamraju Eraparaju <[email protected]>---
drivers/infiniband/sw/siw/siw_cm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/infiniband/sw/siw/siw_cm.c +2
-2@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct siw_cep *cep)* A private data buffer gets allocated if hdr->params.pd_len != 0. */ if (!cep->mpa.pdata) { - cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata =kmalloc (pd_len,GFP_KERNEL );if (!cep->mpa.pdata)return -ENOMEM ; } rcvd =ksock_recv ( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof (struct mpa_rr ), - to_rcv +4 ,MSG_DONTWAIT ); + to_rcv,MSG_DONTWAIT );
Quoted 11 lines
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c +0
-0if (rcvd <0 )return rcvd;Signature · 1 line
2.23.0.rc0The intention of this code is to make sure the peer does not violates the MPA handshake rules. The initiator MUST NOT send extra data after its MPA request and before receiving the MPA reply.
I think this is true only for MPA v2. With MPA v1, the initiator can begin sending immediately (before receiving the MPA reply), because there is no actual negotiation at the MPA layer.
With MPA v2, the negotiation exchange is required because the type of the following message is predicated by the "Enhanced mode" a|b|c|d flags present in the first 32 bits of the private data buffer.
So, it seems to me that additional logic is needed here to determine the MPA version, before sniffing additional octets from the incoming stream?
Tom.
Quoted 29 lines
So, for the MPA request case, this code is needed to check for protocol correctness.
You are right for the MPA reply case - if we are _not_ in peer2peer mode, the peer can immediately start sending data in RDMA mode after its MPA Reply. So we shall add appropriate code to be more specific For an error, we are (1) processing an MPA Request, OR (2) processing an MPA Reply AND we are not expected to send an initial READ/WRITE/Send as negotiated with the peer (peer2peer mode MPA handshake).Just removing this check would make siw more permissive, but to a point where peer MPA protocol errors are tolerated. I am not in favor of that level of forgiveness.
If possible, please provide an appropriate patch or (if it causes current issues with another peer iWarp implementation) just run in MPA peer2peer mode, where the current check is appropriate. Otherwise, I would provide an appropriate fix by Monday (I am still out of office this week).
Many thanks and best regards,
Bernard.
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 97 lines
To: "Bernard Metzler" <[email protected]>, "Krishnamraju Eraparaju" <[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/01/2019 08:54PM
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messageQuoted 7 lines · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 5 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected], [email protected], [email protected], "KrishnamrajuEraparaju"
Quoted 10 lines
Quoted 10 lines
<[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messagewhile processing MPA Reply, SIW driver is trying to read extra 4 bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()completed reading MPA reply, thenksock_recv()insiw_recv_mpa_rr()couldalso
Quoted 25 lines
Quoted 25 lines
read FPDU, if "size" is larger than advertised MPA reply length.
501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereLooks like the intention here is to throw an ERROR if the received data
is more than the total private data length advertised by the peer. But
reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recv buffer is already
queued with FPDU messages.Hence, this function should only read upto private data length.
Signed-off-by Krishnamraju Eraparaju <[email protected]>---
drivers/infiniband/sw/siw/siw_cm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct siw_cep*cep)
Quoted 1 line
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep · line 559
Quoted 1 line
drivers/infiniband/sw/siw/siw_cm.c +0
-0* A private data buffer gets allocated if hdr->params.pd_len != 0.
Quoted 12 lines
Quoted 12 lines
drivers/infiniband/sw/siw/siw_cm.c +2
-2*/ if (!cep->mpa.pdata) { - cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata =kmalloc (pd_len,GFP_KERNEL );if (!cep->mpa.pdata)return -ENOMEM ; } rcvd =ksock_recv ( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof (struct mpa_rr ), - to_rcv +4 ,MSG_DONTWAIT ); + to_rcv,MSG_DONTWAIT );Quoted 11 lines
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c +0
-0if (rcvd <0 )return rcvd;Signature · 1 line
2.23.0.rc0The intention of this code is to make sure the peer does not violates the MPA handshake rules. The initiator MUST NOT send extra data after its MPA request and before receiving the MPA reply.
I think this is true only for MPA v2. With MPA v1, the initiator can begin sending immediately (before receiving the MPA reply), because there is no actual negotiation at the MPA layer.
With MPA v2, the negotiation exchange is required because the type of the following message is predicated by the "Enhanced mode" a|b|c|d flags present in the first 32 bits of the private data buffer.
Quoted 6 lines
So, it seems to me that additional logic is needed here to determine the MPA version, before sniffing additional octets from the incoming stream?
Tom.
There still is the marker negotiation taking place. RFC 5044 says in section 7.1.2:
"Note: Since the receiver's ability to deal with Markers is
unknown until the Request and Reply Frames have been received, sending FPDUs before this occurs is not possible."
This section further discusses the responder's behavior, where it MUST receive a first FPDU from the initiator before sending its first FPDU:
"4. MPA Responder mode implementations MUST receive and validate at
least one FPDU before sending any FPDUs or Markers."
So it appears with MPA version 1, the current siw code is correct. The initiator is entering FPDU mode first, and only after receiving the MPA reply frame. Only after the initiator sent a first FPDU, the responder can start using the connection in FPDU mode. Because of this somehow broken connection establishment procedure (only the initiator can start sending data), a later MPA version makes this first FPDU exchange explicit and selectable (zero length READ/WRITE/Send).
Bernard.
Quoted 32 lines
Quoted 30 lines
So, for the MPA request case, this code is needed to check for protocol correctness.
You are right for the MPA reply case - if we are _not_ in peer2peer mode, the peer can immediately start sending data in RDMA mode after its MPA Reply. So we shall add appropriate code to be more specific For an error, we are (1) processing an MPA Request, OR (2) processing an MPA Reply AND we are not expected to send an initial READ/WRITE/Send as negotiated with the peer (peer2peer mode MPA handshake).Just removing this check would make siw more permissive, but to a point where peer MPA protocol errors are tolerated. I am not in favor of that level of forgiveness.
If possible, please provide an appropriate patch or (if it causes current issues with another peer iWarp implementation) just run in MPA peer2peer mode, where the current check is appropriate. Otherwise, I would provide an appropriate fix by Monday (I am still out of office this week).
Many thanks and best regards,
Bernard.
Quoted 120 lines · Bernard Metzler
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 97 lines
To: "Bernard Metzler" <[email protected]>, "Krishnamraju Eraparaju" <[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/01/2019 08:54PM
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messageQuoted 7 lines · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 5 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected], [email protected], [email protected], "KrishnamrajuEraparaju"
Quoted 10 lines
Quoted 10 lines
<[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messagewhile processing MPA Reply, SIW driver is trying to read extra 4 bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()completed reading MPA reply, thenksock_recv()insiw_recv_mpa_rr()couldalso
Quoted 25 lines
Quoted 25 lines
read FPDU, if "size" is larger than advertised MPA reply length.
501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereLooks like the intention here is to throw an ERROR if the received data
is more than the total private data length advertised by the peer. But
reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recv buffer is already
queued with FPDU messages.Hence, this function should only read upto private data length.
Signed-off-by Krishnamraju Eraparaju <[email protected]>---
drivers/infiniband/sw/siw/siw_cm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct siw_cep*cep)
Quoted 1 line
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep · line 559
Quoted 1 line
drivers/infiniband/sw/siw/siw_cm.c +0
-0* A private data buffer gets allocated if hdr->params.pd_len != 0.
Quoted 12 lines
Quoted 12 lines
drivers/infiniband/sw/siw/siw_cm.c +2
-2*/ if (!cep->mpa.pdata) { - cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata =kmalloc (pd_len,GFP_KERNEL );if (!cep->mpa.pdata)return -ENOMEM ; } rcvd =ksock_recv ( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof (struct mpa_rr ), - to_rcv +4 ,MSG_DONTWAIT ); + to_rcv,MSG_DONTWAIT );Quoted 11 lines
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c +0
-0if (rcvd <0 )return rcvd;Signature · 1 line
2.23.0.rc0The intention of this code is to make sure the peer does not violates the MPA handshake rules. The initiator MUST NOT send extra data after its MPA request and before receiving the MPA reply.
I think this is true only for MPA v2. With MPA v1, the initiator can begin sending immediately (before receiving the MPA reply), because there is no actual negotiation at the MPA layer.
With MPA v2, the negotiation exchange is required because the type of the following message is predicated by the "Enhanced mode" a|b|c|d flags present in the first 32 bits of the private data buffer.
Quoted 6 lines
So, it seems to me that additional logic is needed here to determine the MPA version, before sniffing additional octets from the incoming stream?
Tom.
There still is the marker negotiation taking place. RFC 5044 says in section 7.1.2:
"Note: Since the receiver's ability to deal with Markers is
unknown until the Request and Reply Frames have been received, sending FPDUs before this occurs is not possible."This section further discusses the responder's behavior, where it MUST receive a first FPDU from the initiator before sending its first FPDU:
"4. MPA Responder mode implementations MUST receive and validate at
least one FPDU before sending any FPDUs or Markers."
Quoted 9 lines
So it appears with MPA version 1, the current siw code is correct. The initiator is entering FPDU mode first, and only after receiving the MPA reply frame. Only after the initiator sent a first FPDU, the responder can start using the connection in FPDU mode. Because of this somehow broken connection establishment procedure (only the initiator can start sending data), a later MPA version makes this first FPDU exchange explicit and selectable (zero length READ/WRITE/Send).
Yeah, I guess so. Because nobody ever actually implemented markers, I think that they may more or less passively ignore this. But you're currect that it's invalid protocol behavior.
If your testing didn't uncover any issues with existing implementations failing to connect with your strict checking, I'm ok with it.
Tom.
Quoted 38 lines
Bernard.
Quoted 32 lines
Quoted 30 lines
So, for the MPA request case, this code is needed to check for protocol correctness.
You are right for the MPA reply case - if we are _not_ in peer2peer mode, the peer can immediately start sending data in RDMA mode after its MPA Reply. So we shall add appropriate code to be more specific For an error, we are (1) processing an MPA Request, OR (2) processing an MPA Reply AND we are not expected to send an initial READ/WRITE/Send as negotiated with the peer (peer2peer mode MPA handshake).Just removing this check would make siw more permissive, but to a point where peer MPA protocol errors are tolerated. I am not in favor of that level of forgiveness.
If possible, please provide an appropriate patch or (if it causes current issues with another peer iWarp implementation) just run in MPA peer2peer mode, where the current check is appropriate. Otherwise, I would provide an appropriate fix by Monday (I am still out of office this week).
Many thanks and best regards,
Bernard.
A message that is not in the archive (sent off-list or not yet received): [email protected]
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 197 lines
To: "Tom Talpey" <[email protected]>, <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/05/2019 07:26PM
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messageQuoted 4 lines · Tom Talpey
Quoted 3 lines · Bernard Metzler
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 1 line
To: "Bernard Metzler" <[email protected]>, "Krishnamraju
Eraparaju"
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
<[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/01/2019 08:54PM
Cc: [email protected], [email protected],Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[email protected], [email protected]
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handlertries
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
to read beyond MPA message
Quoted 1 line · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote:
-----
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected], [email protected], [email protected], "KrishnamrajuEraparaju"
Quoted 2 lines
Quoted 2 lines
<[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Reply handlertries to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
read beyond MPA message
while processing MPA Reply, SIW driver is trying to read extra
4
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()completed
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
reading MPA reply, then
ksock_recv()insiw_recv_mpa_rr()could
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
also
Quoted 1 line
Quoted 1 line
read FPDU, if "size" is larger than advertised MPA reply
length.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereLooks like the intention here is to throw an ERROR if the
received
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
data
is more than the total private data length advertised by thepeer.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
But
reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recv bufferis
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
already
queued with FPDU messages.Hence, this function should only read upto private data
length.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Signed-off-by Krishnamraju Eraparaju <[email protected]>---
drivers/infiniband/sw/siw/siw_cm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct
siw_cepQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
*cep)
Quoted 1 line
Quoted 1 line
drivers/infiniband/sw/siw/siw_cm.c +0
-0* A private data buffer gets allocated if hdr->params.pd_len !=
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
0.
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct · line 567
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1*/ if (!cep->mpa.pdata) { - cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata =kmalloc (pd_len,GFP_KERNEL );if (!cep->mpa.pdata)return -ENOMEM ; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd - sizeof(struct
mpa_rr),Quoted 39 lines
Quoted 39 lines
Quoted 25 lines
Quoted 14 lines
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1- to_rcv + 4, MSG_DONTWAIT); + to_rcv, MSG_DONTWAIT);if (rcvd <0 )return rcvd;Signature · 1 line
2.23.0.rc0The intention of this code is to make sure the peer does not violates the MPA handshake rules. The initiator MUST NOT send extra data after its MPA request and before receiving the MPA reply.
I think this is true only for MPA v2. With MPA v1, the initiator can begin sending immediately (before receiving the MPA reply), because there is no actual negotiation at the MPA layer.
With MPA v2, the negotiation exchange is required because the type of the following message is predicated by the "Enhanced mode" a|b|c|d flags present in the first 32 bits of the private data buffer.
Quoted 6 lines
So, it seems to me that additional logic is needed here to determine the MPA version, before sniffing additional octets from the incoming stream?
Tom.
There still is the marker negotiation taking place. RFC 5044 says in section 7.1.2:
"Note: Since the receiver's ability to deal with Markers is
unknown until the Request and Reply Frames have been received, sending FPDUs before this occurs is not possible."Quoted 5 lines
Quoted 5 lines
This section further discusses the responder's behavior, where it MUST receive a first FPDU from the initiator before sending its first FPDU:
"4. MPA Responder mode implementations MUST receive and validate
at
Quoted 12 lines
Quoted 11 lines
least one FPDU before sending any FPDUs or Markers."
So it appears with MPA version 1, the current siw code is correct. The initiator is entering FPDU mode first, and only after receiving the MPA reply frame. Only after the initiator sent a first FPDU, the responder can start using the connection in FPDU mode. Because of this somehow broken connection establishment procedure (only the initiator can start sending data), a later MPA version makes this first FPDU exchange explicit and selectable (zero length READ/WRITE/Send).
Quoted 2 lines
Yeah, I guess so. Because nobody ever actually implemented markers, I think that they may more or less passively ignore this. But
you're
Quoted 3 lines
currect that it's invalid protocol behavior.
If your testing didn't uncover any issues with existing
implementations
Quoted 1 line
failing to connect with your strict checking, I'm ok with it.
Tom & Bernard,
Thanks for the insight on MPA negotiation.Could the below patch be considered as a proper fix?
drivers/infiniband/sw/siw/siw_cm.c +1
-0@@ -503,6 +503,7 @@ static int siw_recv_mpa_rr(struct siw_cep *cep)struct socket *s = cep->sock;u16 pd_len;int rcvd, to_rcv; +int extra_data_check =4 ;/* 4Bytes, for MPA rules violation checking */
if (
cep->mpa.bytes_rcvd<sizeof(struct mpa_rr)) {
rcvd = ksock_recv(s, (char *)hdr +cep->mpa.bytes_rcvd,drivers/infiniband/sw/siw/siw_cm.c +2
-0@@ -553,23 +554,37 @@ static int siw_recv_mpa_rr(struct siw_cep *cep)return -EPROTO ; } +/* +* Peer must not send any extra data other than MPA messages until MPA
+ * negotiation is completed, an exception is MPA V2
client-server Mode,
+ * IE, in this mode the peer after sending MPA Reply can
immediately
drivers/infiniband/sw/siw/siw_cm.c
Quoted 2 lines
drivers/infiniband/sw/siw/siw_cm.c +2
-0+* start sending data in RDMA mode. +*/
This is unfortunately not true. The responder NEVER sends an FPDU without having seen an FPDU from the initiator. I just checked RFC 6581 again. The RTR (ready-to-receive) indication from the initiator is still needed, but now provided by the protocol and not the application: w/o 'enhanced MPA setup', the initiator sends the first FPDU as an application message. With 'enhanced MPA setup', the initiator protocol entity sends (w/o application interaction) a zero length READ/WRITE/Send as a first FPDU, as previously negotiated with the responder. Again: only after the responder has seen the first FPDU, it can start sending in FPDU mode.
Sorry for the confusion. But the current
siw code appears to be just correct.
Thanks
Bernard
Quoted 85 lines
+ if ((
__mpa_rr_revision(cep->mpa.hdr.params.bits)==MPA_REVISION_2) &&drivers/infiniband/sw/siw/siw_cm.c +3
-0+ (cep->state == SIW_EPSTATE_AWAIT_MPAREP)) { + int mpa_p2p_mode = cep->mpa.v2_ctrl_req.ord & + (MPA_V2_RDMA_WRITE_RTR |
MPA_V2_RDMA_READ_RTR);drivers/infiniband/sw/siw/siw_cm.c +4
-0+if (!mpa_p2p_mode) + extra_data_check =0 ; + } +/* * At this point, we must have hdr->params.pd_len != 0. * A private data buffer gets allocated if hdr->params.pd_len !=
* 0. */ if (!cep->mpa.pdata) {drivers/infiniband/sw/siw/siw_cm.c +1
-1- cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata = kmalloc(pd_len + extra_data_check,GFP_KERNEL); if (!cep->mpa.pdata) return -ENOMEM; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof(struct
mpa_rr),drivers/infiniband/sw/siw/siw_cm.c +2
-3- to_rcv + 4, MSG_DONTWAIT); + to_rcv + extra_data_check, MSG_DONTWAIT);if (rcvd <0 )return rcvd; -if (rcvd > to_rcv) +if (extra_data_check && (rcvd > to_rcv))return -EPROTO ; cep->mpa.bytes_rcvd += rcvd; -Krishna.Quoted 43 lines
Tom.
Quoted 38 lines
Bernard.
Quoted 32 lines
Quoted 30 lines
So, for the MPA request case, this code is needed to check for protocol correctness.
You are right for the MPA reply case - if we are _not_ in peer2peer mode, the peer can immediately start sending data in RDMA mode after its MPA Reply. So we shall add appropriate code to be more specific For an error, we are (1) processing an MPA Request, OR (2) processing an MPA Reply AND we are not expected to send an initial READ/WRITE/Send as negotiated with the peer (peer2peer mode MPA handshake).Just removing this check would make siw more permissive, but to a point where peer MPA protocol errors are tolerated. I am not in favor of that level of forgiveness.
If possible, please provide an appropriate patch or (if it causes current issues with another peer iWarp implementation) just run in MPA peer2peer mode, where the current check is appropriate. Otherwise, I would provide an appropriate fix by Monday (I am still out of office this week).
Many thanks and best regards,
Bernard.
Quoted 206 lines · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 197 lines
To: "Tom Talpey" <[email protected]>, <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/05/2019 07:26PM
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messageQuoted 4 lines · Tom Talpey
Quoted 3 lines · Bernard Metzler
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 1 line
To: "Bernard Metzler" <[email protected]>, "Krishnamraju
Eraparaju"
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
<[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/01/2019 08:54PM
Cc: [email protected], [email protected],Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[email protected], [email protected]
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handlertries
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
to read beyond MPA message
Quoted 1 line · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote:
-----
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected], [email protected], [email protected], "KrishnamrajuEraparaju"
Quoted 2 lines
Quoted 2 lines
<[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Reply handlertries to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
read beyond MPA message
while processing MPA Reply, SIW driver is trying to read extra
4
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()completed
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
reading MPA reply, then
ksock_recv()insiw_recv_mpa_rr()could
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
also
Quoted 1 line
Quoted 1 line
read FPDU, if "size" is larger than advertised MPA reply
length.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereLooks like the intention here is to throw an ERROR if the
received
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
data
is more than the total private data length advertised by thepeer.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
But
reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recv bufferis
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
already
queued with FPDU messages.Hence, this function should only read upto private data
length.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Signed-off-by Krishnamraju Eraparaju <[email protected]>---
drivers/infiniband/sw/siw/siw_cm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct
siw_cepQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
*cep)
Quoted 1 line
Quoted 1 line
drivers/infiniband/sw/siw/siw_cm.c +0
-0* A private data buffer gets allocated if hdr->params.pd_len !=
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
0.
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct · line 567
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1*/ if (!cep->mpa.pdata) { - cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata =kmalloc (pd_len,GFP_KERNEL );if (!cep->mpa.pdata)return -ENOMEM ; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd - sizeof(struct
mpa_rr),Quoted 39 lines
Quoted 39 lines
Quoted 25 lines
Quoted 14 lines
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1- to_rcv + 4, MSG_DONTWAIT); + to_rcv, MSG_DONTWAIT);if (rcvd <0 )return rcvd;Signature · 1 line
2.23.0.rc0The intention of this code is to make sure the peer does not violates the MPA handshake rules. The initiator MUST NOT send extra data after its MPA request and before receiving the MPA reply.
I think this is true only for MPA v2. With MPA v1, the initiator can begin sending immediately (before receiving the MPA reply), because there is no actual negotiation at the MPA layer.
With MPA v2, the negotiation exchange is required because the type of the following message is predicated by the "Enhanced mode" a|b|c|d flags present in the first 32 bits of the private data buffer.
Quoted 6 lines
So, it seems to me that additional logic is needed here to determine the MPA version, before sniffing additional octets from the incoming stream?
Tom.
There still is the marker negotiation taking place. RFC 5044 says in section 7.1.2:
"Note: Since the receiver's ability to deal with Markers is
unknown until the Request and Reply Frames have been received, sending FPDUs before this occurs is not possible."Quoted 5 lines
Quoted 5 lines
This section further discusses the responder's behavior, where it MUST receive a first FPDU from the initiator before sending its first FPDU:
"4. MPA Responder mode implementations MUST receive and validate
at
Quoted 12 lines
Quoted 11 lines
least one FPDU before sending any FPDUs or Markers."
So it appears with MPA version 1, the current siw code is correct. The initiator is entering FPDU mode first, and only after receiving the MPA reply frame. Only after the initiator sent a first FPDU, the responder can start using the connection in FPDU mode. Because of this somehow broken connection establishment procedure (only the initiator can start sending data), a later MPA version makes this first FPDU exchange explicit and selectable (zero length READ/WRITE/Send).
Quoted 2 lines
Yeah, I guess so. Because nobody ever actually implemented markers, I think that they may more or less passively ignore this. But
you're
Quoted 3 lines
currect that it's invalid protocol behavior.
If your testing didn't uncover any issues with existing
implementations
Quoted 1 line
failing to connect with your strict checking, I'm ok with it.
Tom & Bernard,
Thanks for the insight on MPA negotiation.Could the below patch be considered as a proper fix?
drivers/infiniband/sw/siw/siw_cm.c +1
-0@@ -503,6 +503,7 @@ static int siw_recv_mpa_rr(struct siw_cep *cep)struct socket *s = cep->sock;u16 pd_len;int rcvd, to_rcv; +int extra_data_check =4 ;/* 4Bytes, for MPA rules violation checking */
if (
cep->mpa.bytes_rcvd<sizeof(struct mpa_rr)) {
rcvd = ksock_recv(s, (char *)hdr +cep->mpa.bytes_rcvd,drivers/infiniband/sw/siw/siw_cm.c +2
-0@@ -553,23 +554,37 @@ static int siw_recv_mpa_rr(struct siw_cep *cep)return -EPROTO ; } +/* +* Peer must not send any extra data other than MPA messages until MPA
+ * negotiation is completed, an exception is MPA V2
client-server Mode,
+ * IE, in this mode the peer after sending MPA Reply can
immediatelydrivers/infiniband/sw/siw/siw_cm.c
Quoted 2 lines
drivers/infiniband/sw/siw/siw_cm.c +2
-0+* start sending data in RDMA mode. +*/ This is unfortunately not true. The responder NEVER sends an FPDU without having seen an FPDU from the initiator. I just checked RFC 6581 again. The RTR (ready-to-receive) indication from the initiator is still needed, but now
Quoted 8 lines
provided by the protocol and not the application: w/o 'enhanced MPA setup', the initiator sends the first FPDU as an application message. With 'enhanced MPA setup', the initiator protocol entity sends (w/o application interaction) a zero length READ/WRITE/Send as a first FPDU, as previously negotiated with the responder. Again: only after the responder has seen the first FPDU, it can start sending in FPDU mode.
If I understand your statements correctly: in MPA v2 clint-server mode, the responder application should have some logic to wait(after ESTABLISH event) until the first FPDU message is received from the initiator?
Thanks,
Krishna.
Quoted 95 lines
Sorry for the confusion. But the current
siw code appears to be just correct.Thanks
BernardQuoted 85 lines
+ if ((
__mpa_rr_revision(cep->mpa.hdr.params.bits)==MPA_REVISION_2) &&drivers/infiniband/sw/siw/siw_cm.c +3
-0+ (cep->state == SIW_EPSTATE_AWAIT_MPAREP)) { + int mpa_p2p_mode = cep->mpa.v2_ctrl_req.ord & + (MPA_V2_RDMA_WRITE_RTR |
MPA_V2_RDMA_READ_RTR);drivers/infiniband/sw/siw/siw_cm.c +4
-0+if (!mpa_p2p_mode) + extra_data_check =0 ; + } +/* * At this point, we must have hdr->params.pd_len != 0. * A private data buffer gets allocated if hdr->params.pd_len !=
* 0. */ if (!cep->mpa.pdata) {drivers/infiniband/sw/siw/siw_cm.c +1
-1- cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata = kmalloc(pd_len + extra_data_check,GFP_KERNEL); if (!cep->mpa.pdata) return -ENOMEM; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof(struct
mpa_rr),drivers/infiniband/sw/siw/siw_cm.c +2
-3- to_rcv + 4, MSG_DONTWAIT); + to_rcv + extra_data_check, MSG_DONTWAIT);if (rcvd <0 )return rcvd; -if (rcvd > to_rcv) +if (extra_data_check && (rcvd > to_rcv))return -EPROTO ; cep->mpa.bytes_rcvd += rcvd; -Krishna.Quoted 43 lines
Tom.
Quoted 38 lines
Bernard.
Quoted 32 lines
Quoted 30 lines
So, for the MPA request case, this code is needed to check for protocol correctness.
You are right for the MPA reply case - if we are _not_ in peer2peer mode, the peer can immediately start sending data in RDMA mode after its MPA Reply. So we shall add appropriate code to be more specific For an error, we are (1) processing an MPA Request, OR (2) processing an MPA Reply AND we are not expected to send an initial READ/WRITE/Send as negotiated with the peer (peer2peer mode MPA handshake).Just removing this check would make siw more permissive, but to a point where peer MPA protocol errors are tolerated. I am not in favor of that level of forgiveness.
If possible, please provide an appropriate patch or (if it causes current issues with another peer iWarp implementation) just run in MPA peer2peer mode, where the current check is appropriate. Otherwise, I would provide an appropriate fix by Monday (I am still out of office this week).
Many thanks and best regards,
Bernard.
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 240 lines
To: "Bernard Metzler" <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/08/2019 06:47PM
Cc: "Tom Talpey" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messageQuoted 8 lines · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 6 lines
To: "Tom Talpey" <[email protected]>, <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/05/2019 07:26PM
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan"Quoted 1 line
Quoted 1 line
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler
tries
Quoted 3 lines
Quoted 3 lines
to read beyond MPA message
On Friday, August 08/02/19, 2019 at 18:17:37 +0530, Tom Talpey
Quoted 24 lines · wrote:
Quoted 24 lines
Quoted 4 lines · Bernard Metzler
Quoted 3 lines
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 1 line
To: "Bernard Metzler" <[email protected]>, "Krishnamraju
Eraparaju"
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
<[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/01/2019 08:54PM
Cc: [email protected], [email protected],Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[email protected], [email protected]
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handlertries
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
to read beyond MPA message
Quoted 1 line · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote:
-----
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected], [email protected], [email protected], "KrishnamrajuQuoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Eraparaju"
Quoted 2 lines
Quoted 2 lines
<[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Reply handlertries to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
read beyond MPA message
while processing MPA Reply, SIW driver is trying to read
extra
Quoted 19 lines
Quoted 19 lines
4
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()completed
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
reading MPA reply, then
ksock_recv()insiw_recv_mpa_rr()could
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
also
Quoted 1 line
Quoted 1 line
read FPDU, if "size" is larger than advertised MPA reply
length.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereQuoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Looks like the intention here is to throw an ERROR if the
received
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
data
is more than the total private data length advertised bythe
Quoted 4 lines
Quoted 4 lines
peer.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
But
reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recvbuffer
Quoted 8 lines
Quoted 8 lines
is
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
already
queued with FPDU messages.Hence, this function should only read upto private data
length.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Krishnamraju EraparajuQuoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct
Quoted 10 lines
---
drivers/infiniband/sw/siw/siw_cm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct
siw_cepQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
*cep)
Quoted 1 line
Quoted 1 line
drivers/infiniband/sw/siw/siw_cm.c +0
-0* A private data buffer gets allocated if
hdr->params.pd_lenQuoted 51 lines
Quoted 51 lines
!=
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
0.
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct · line 567
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1*/ if (!cep->mpa.pdata) { - cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata =kmalloc (pd_len,GFP_KERNEL );if (!cep->mpa.pdata)return -ENOMEM ; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd - sizeof(struct
mpa_rr),Quoted 39 lines
Quoted 39 lines
Quoted 25 lines
Quoted 14 lines
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1- to_rcv + 4, MSG_DONTWAIT); + to_rcv, MSG_DONTWAIT);if (rcvd <0 )return rcvd;Signature · 1 line
2.23.0.rc0The intention of this code is to make sure the peer does not violates the MPA handshake rules. The initiator MUST NOT send extra data after its MPA request and before receiving the MPA reply.
I think this is true only for MPA v2. With MPA v1, the initiator can begin sending immediately (before receiving the MPA reply), because there is no actual negotiation at the MPA layer.
With MPA v2, the negotiation exchange is required because the type of the following message is predicated by the "Enhanced mode" a|b|c|d flags present in the first 32 bits of the private data buffer.
Quoted 6 lines
So, it seems to me that additional logic is needed here to determine the MPA version, before sniffing additional octets from the incoming stream?
Tom.
There still is the marker negotiation taking place. RFC 5044 says in section 7.1.2:
"Note: Since the receiver's ability to deal with Markers is
unknown until the Request and Reply Frames have been received, sending FPDUs before this occurs is not possible."Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
This section further discusses the responder's behavior, where it MUST receive a first FPDU from the initiator before sending its first FPDU:
"4. MPA Responder mode implementations MUST receive and
validate
Quoted 13 lines
Quoted 13 lines
at
Quoted 12 lines
Quoted 11 lines
least one FPDU before sending any FPDUs or Markers."
So it appears with MPA version 1, the current siw code is correct. The initiator is entering FPDU mode first, and only after receiving the MPA reply frame. Only after the initiator sent a first FPDU, the responder can start using the connection in FPDU mode. Because of this somehow broken connection establishment procedure (only the initiator can start sending data), a later MPA version makes this first FPDU exchange explicit and selectable (zero length READ/WRITE/Send).
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yeah, I guess so. Because nobody ever actually implemented
markers,
Quoted 10 lines
Quoted 10 lines
Quoted 1 line
I think that they may more or less passively ignore this. But
you're
Quoted 3 lines
currect that it's invalid protocol behavior.
If your testing didn't uncover any issues with existing
implementations
Quoted 1 line
failing to connect with your strict checking, I'm ok with it.
Tom & Bernard,
Thanks for the insight on MPA negotiation.Quoted 8 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep
Quoted 8 lines
Could the below patch be considered as a proper fix?
drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -503,6 +503,7 @@ static int siw_recv_mpa_rr(struct siw_cep*cep)
Quoted 4 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep · line 506
Quoted 4 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-0struct socket *s = cep->sock;u16 pd_len;int rcvd, to_rcv; +int extra_data_check =4 ;/* 4Bytes, for MPA rules violation
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep
Quoted 6 lines
checking */
if (
cep->mpa.bytes_rcvd<sizeof(struct mpa_rr)) {
rcvd = ksock_recv(s, (char *)hdr +cep->mpa.bytes_rcvd,drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -553,23 +554,37 @@ static int siw_recv_mpa_rr(struct siw_cep*cep)
Quoted 5 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep · line 558
Quoted 5 lines
drivers/infiniband/sw/siw/siw_cm.c +2
-0return -EPROTO ; } +/* +* Peer must not send any extra data other than MPA messages
Quoted 8 lines
drivers/infiniband/sw/siw/siw_cm.c
Quoted 7 lines
until MPA
+ * negotiation is completed, an exception is MPA V2
client-server Mode,
+ * IE, in this mode the peer after sending MPA Reply can
immediatelydrivers/infiniband/sw/siw/siw_cm.c +2
-0+* start sending data in RDMA mode. +*/ Quoted 12 lines
This is unfortunately not true. The responder NEVER sends an FPDU without having seen an FPDU from the initiator. I just checked RFC 6581 again. The RTR (ready-to-receive) indication from the initiator is still needed, but now provided by the protocol and not the application: w/o 'enhanced MPA setup', the initiator sends the first FPDU as an application message. With 'enhanced MPA setup', the initiator protocol entity sends (w/o application interaction) a zero length READ/WRITE/Send as a first FPDU, as previously negotiated with the responder. Again: only after the responder has seen the first FPDU, it can start sending in FPDU mode.
Quoted 8 lines
If I understand your statements correctly: in MPA v2 clint-server mode,
the responder application should have some logic to wait(after ESTABLISH
event) until the first FPDU message is received from the initiator?Thanks,
Krishna.
The responder may either delay the established event until it sees the first peer FPDU, or it delays sending the first (now already posted) FPDU, until it sees the first initiator FPDU. This, since (theoretically), the responder does not know yet the result of CRC and Marker negotiation. siw delays the established event, which seems the more clear path to me.
This MPA handshake is cumbersome. siw is permissive for violations of these rules to the extend, that the responder shall not send back to back the first FPDU with the MPA reply. If a (Chelsio ?) iWarp adapter would send the first responder FPDU only after it got TCP acked its MPA reply, the chances are high the (siw) iWarp initiator has already transitioned to RTS and it would accept that FPU, even if not having sent it's first FPDU.
siw sticks to this rule to that extend, since all receive processing is triggered by socket callbacks (from sk->sk_data_ready()). As long as the QP is not
in RTS, all TCP bytestream processing is done by the MPA protocol (code in siw_cm.c). If the QP reaches RTS, RX processing is done bt the full iWarp protocol (code in siw_qp_rx.c for RX).
Now, if the higher layer (application) protocol has a semantic where the responder sends the first message, we could end up in an infinite wait for that packet at initiator application side.
This, since the complete first FPDU was already received at the TCP socket, while the QP was not in RTS. It will not trigger any additional sk->sk_data_ready() and we are stuck with a FPDU in the socket rx buffer.
I implemented that 4 bytes extra data testing only to keep the siw protocol state machine as simple as possible (it is already unfortunately complex, if you count the lines in siw_cm.c), while following the protocol rules.
I suggest to correctly implement peer2peer mode and delay the established event at the responder side until it got the negotiated first zero length FPDU. Out of the possible options, siw supports both zero length WRITE and READ, but no SEND, since this would consume an extra receive WQE.
As a last resort, I might consider extending the siw state machine to handle those - non-complaint - cases gracefully. But, that would result in different code than just avoiding checking for peer protocol violation.
Thanks,
Bernard.
Quoted 99 lines
Quoted 22 lines
Sorry for the confusion. But the current
siw code appears to be just correct.Thanks
BernardQuoted 13 lines
+ if ((
__mpa_rr_revision(cep->mpa.hdr.params.bits)==MPA_REVISION_2) &&drivers/infiniband/sw/siw/siw_cm.c +3
-0+ (cep->state == SIW_EPSTATE_AWAIT_MPAREP)) { + int mpa_p2p_mode = cep->mpa.v2_ctrl_req.ord & + (MPA_V2_RDMA_WRITE_RTR |
MPA_V2_RDMA_READ_RTR);drivers/infiniband/sw/siw/siw_cm.c +4
-0+if (!mpa_p2p_mode) + extra_data_check =0 ; + } +/* * At this point, we must have hdr->params.pd_len != 0. * A private data buffer gets allocated if
hdr->params.pd_lenQuoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c
Quoted 6 lines
!=
* 0. */ if (!cep->mpa.pdata) {drivers/infiniband/sw/siw/siw_cm.c +1
-1- cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata = kmalloc(pd_len +
extra_data_check,Quoted 67 lines
Quoted 66 lines
GFP_KERNEL); if (!cep->mpa.pdata) return -ENOMEM; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof(struct
mpa_rr),drivers/infiniband/sw/siw/siw_cm.c +2
-3- to_rcv + 4, MSG_DONTWAIT); + to_rcv + extra_data_check, MSG_DONTWAIT);if (rcvd <0 )return rcvd; -if (rcvd > to_rcv) +if (extra_data_check && (rcvd > to_rcv))return -EPROTO ; cep->mpa.bytes_rcvd += rcvd; -Krishna.Quoted 43 lines
Tom.
Quoted 38 lines
Bernard.
Quoted 32 lines
Quoted 30 lines
So, for the MPA request case, this code is needed to check for protocol correctness.
You are right for the MPA reply case - if we are _not_ in peer2peer mode, the peer can immediately start sending data in RDMA mode after its MPA Reply. So we shall add appropriate code to be more specific For an error, we are (1) processing an MPA Request, OR (2) processing an MPA Reply AND we are not expected to send an initial READ/WRITE/Send as negotiated with the peer (peer2peer mode MPA handshake).Just removing this check would make siw more permissive, but to a point where peer MPA protocol errors are tolerated. I am not in favor of that level of forgiveness.
If possible, please provide an appropriate patch or (if it causes current issues with another peer iWarp implementation) just run in MPA peer2peer mode, where the current check is appropriate. Otherwise, I would provide an appropriate fix by Monday (I am still out of office this week).
Many thanks and best regards,
Bernard.
Quoted 298 lines · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 240 lines
To: "Bernard Metzler" <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/08/2019 06:47PM
Cc: "Tom Talpey" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messageQuoted 8 lines · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 6 lines
To: "Tom Talpey" <[email protected]>, <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/05/2019 07:26PM
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan"Quoted 1 line
Quoted 1 line
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler
tries
Quoted 3 lines
Quoted 3 lines
to read beyond MPA message
On Friday, August 08/02/19, 2019 at 18:17:37 +0530, Tom Talpey
Quoted 24 lines · wrote:
Quoted 24 lines
Quoted 4 lines · Bernard Metzler
Quoted 3 lines
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 1 line
To: "Bernard Metzler" <[email protected]>, "Krishnamraju
Eraparaju"
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
<[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/01/2019 08:54PM
Cc: [email protected], [email protected],Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[email protected], [email protected]
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handlertries
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
to read beyond MPA message
Quoted 1 line · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote:
-----
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected], [email protected], [email protected], "KrishnamrajuQuoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Eraparaju"
Quoted 2 lines
Quoted 2 lines
<[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Reply handlertries to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
read beyond MPA message
while processing MPA Reply, SIW driver is trying to read
extra
Quoted 19 lines
Quoted 19 lines
4
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()completed
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
reading MPA reply, then
ksock_recv()insiw_recv_mpa_rr()could
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
also
Quoted 1 line
Quoted 1 line
read FPDU, if "size" is larger than advertised MPA reply
length.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereQuoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Looks like the intention here is to throw an ERROR if the
received
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
data
is more than the total private data length advertised bythe
Quoted 4 lines
Quoted 4 lines
peer.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
But
reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recvbuffer
Quoted 8 lines
Quoted 8 lines
is
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
already
queued with FPDU messages.Hence, this function should only read upto private data
length.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Krishnamraju EraparajuQuoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct
Quoted 10 lines
---
drivers/infiniband/sw/siw/siw_cm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct
siw_cepQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
*cep)
Quoted 1 line
Quoted 1 line
drivers/infiniband/sw/siw/siw_cm.c +0
-0* A private data buffer gets allocated if
hdr->params.pd_lenQuoted 51 lines
Quoted 51 lines
!=
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
0.
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct · line 567
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1*/ if (!cep->mpa.pdata) { - cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata =kmalloc (pd_len,GFP_KERNEL );if (!cep->mpa.pdata)return -ENOMEM ; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd - sizeof(struct
mpa_rr),Quoted 39 lines
Quoted 39 lines
Quoted 25 lines
Quoted 14 lines
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1- to_rcv + 4, MSG_DONTWAIT); + to_rcv, MSG_DONTWAIT);if (rcvd <0 )return rcvd;Signature · 1 line
2.23.0.rc0The intention of this code is to make sure the peer does not violates the MPA handshake rules. The initiator MUST NOT send extra data after its MPA request and before receiving the MPA reply.
I think this is true only for MPA v2. With MPA v1, the initiator can begin sending immediately (before receiving the MPA reply), because there is no actual negotiation at the MPA layer.
With MPA v2, the negotiation exchange is required because the type of the following message is predicated by the "Enhanced mode" a|b|c|d flags present in the first 32 bits of the private data buffer.
Quoted 6 lines
So, it seems to me that additional logic is needed here to determine the MPA version, before sniffing additional octets from the incoming stream?
Tom.
There still is the marker negotiation taking place. RFC 5044 says in section 7.1.2:
"Note: Since the receiver's ability to deal with Markers is
unknown until the Request and Reply Frames have been received, sending FPDUs before this occurs is not possible."Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
This section further discusses the responder's behavior, where it MUST receive a first FPDU from the initiator before sending its first FPDU:
"4. MPA Responder mode implementations MUST receive and
validate
Quoted 13 lines
Quoted 13 lines
at
Quoted 12 lines
Quoted 11 lines
least one FPDU before sending any FPDUs or Markers."
So it appears with MPA version 1, the current siw code is correct. The initiator is entering FPDU mode first, and only after receiving the MPA reply frame. Only after the initiator sent a first FPDU, the responder can start using the connection in FPDU mode. Because of this somehow broken connection establishment procedure (only the initiator can start sending data), a later MPA version makes this first FPDU exchange explicit and selectable (zero length READ/WRITE/Send).
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yeah, I guess so. Because nobody ever actually implemented
markers,
Quoted 10 lines
Quoted 10 lines
Quoted 1 line
I think that they may more or less passively ignore this. But
you're
Quoted 3 lines
currect that it's invalid protocol behavior.
If your testing didn't uncover any issues with existing
implementations
Quoted 1 line
failing to connect with your strict checking, I'm ok with it.
Tom & Bernard,
Thanks for the insight on MPA negotiation.Quoted 8 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep
Quoted 8 lines
Could the below patch be considered as a proper fix?
drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -503,6 +503,7 @@ static int siw_recv_mpa_rr(struct siw_cep*cep)
Quoted 4 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep · line 506
Quoted 4 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-0struct socket *s = cep->sock;u16 pd_len;int rcvd, to_rcv; +int extra_data_check =4 ;/* 4Bytes, for MPA rules violation
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep
Quoted 6 lines
checking */
if (
cep->mpa.bytes_rcvd<sizeof(struct mpa_rr)) {
rcvd = ksock_recv(s, (char *)hdr +cep->mpa.bytes_rcvd,drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -553,23 +554,37 @@ static int siw_recv_mpa_rr(struct siw_cep*cep)
Quoted 5 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep · line 558
Quoted 5 lines
drivers/infiniband/sw/siw/siw_cm.c +2
-0return -EPROTO ; } +/* +* Peer must not send any extra data other than MPA messages
Quoted 8 lines
drivers/infiniband/sw/siw/siw_cm.c
Quoted 7 lines
until MPA
+ * negotiation is completed, an exception is MPA V2
client-server Mode,
+ * IE, in this mode the peer after sending MPA Reply can
immediatelydrivers/infiniband/sw/siw/siw_cm.c +2
-0+* start sending data in RDMA mode. +*/ Quoted 12 lines
This is unfortunately not true. The responder NEVER sends an FPDU without having seen an FPDU from the initiator. I just checked RFC 6581 again. The RTR (ready-to-receive) indication from the initiator is still needed, but now provided by the protocol and not the application: w/o 'enhanced MPA setup', the initiator sends the first FPDU as an application message. With 'enhanced MPA setup', the initiator protocol entity sends (w/o application interaction) a zero length READ/WRITE/Send as a first FPDU, as previously negotiated with the responder. Again: only after the responder has seen the first FPDU, it can start sending in FPDU mode.
Quoted 8 lines
If I understand your statements correctly: in MPA v2 clint-server mode,
the responder application should have some logic to wait(after ESTABLISH
event) until the first FPDU message is received from the initiator?Thanks,
Krishna.The responder may either delay the established event until it sees the first peer FPDU, or it delays sending the first (now already posted) FPDU, until it sees the first initiator FPDU. This, since (theoretically), the responder does not know yet the result of CRC and Marker negotiation. siw delays the established event, which seems the more clear path to me.
This MPA handshake is cumbersome. siw is permissive for violations of these rules to the extend, that the responder shall not send back to back the first FPDU with the MPA reply. If a (Chelsio ?) iWarp adapter would send the first responder FPDU only after it got TCP acked its MPA reply, the chances are high the (siw) iWarp initiator has already transitioned to RTS and it would accept that FPU, even if not having sent it's first FPDU.
siw sticks to this rule to that extend, since all receive processing is triggered by socket callbacks (from
sk->sk_data_ready()). As long as the QP is not
in RTS, all TCP bytestream processing is done by the MPA protocol (code insiw_cm.c). If the QP reaches RTS, RX processing is done bt the full iWarp protocol (code insiw_qp_rx.cfor RX).
Now, if the higher layer (application) protocol has a semantic where the responder sends the first message, we could end up in an infinite wait for that packet at initiator application side.
This, since the complete first FPDU was already received at the TCP socket, while the QP was not in RTS. It will not trigger any additionalsk->sk_data_ready()and we are stuck with a FPDU in the socket rx buffer.I implemented that 4 bytes extra data testing only to keep the siw protocol state machine as simple as possible (it is already unfortunately complex, if you count the lines in
siw_cm.c), while following the protocol rules.I suggest to correctly implement peer2peer mode and delay the established event at the responder side until it got the negotiated first zero length FPDU. Out of the possible options, siw supports both zero length WRITE and READ, but no SEND, since this would consume an extra receive WQE.
Quoted 5 lines
As a last resort, I might consider extending the siw state machine to handle those - non-complaint - cases gracefully. But, that would result in different code than just avoiding checking for peer protocol violation.
Bernard, everything you describe in siw seems perfectly valid to me, and in fact that's why the MPA enhanced connection mode was designed the way it is. I disagree that it's "cumbersome", but that's a nit.
The issue is that the responder reaches RTS at a different time than the initiator reaches RTR. The original iWARP connection model did not make any requirement, and races were possible. MPAv2 fixes those.
SIW is certainly within its rights to prevent peers from sending prior to responder RTR. I'd suggest that if possible, you try to detect the deadlock rather than flatly rejecting any incoming bytes. The Internet Principle (be liberal in what you accept...), after all.
This same dance happens in IB/RoCE, btw. Just via different messages.
Tom.
Quoted 92 lines
Thanks,
Bernard.Quoted 87 lines
Quoted 22 lines
Sorry for the confusion. But the current
siw code appears to be just correct.Thanks
BernardQuoted 13 lines
+ if ((
__mpa_rr_revision(cep->mpa.hdr.params.bits)==MPA_REVISION_2) &&drivers/infiniband/sw/siw/siw_cm.c +3
-0+ (cep->state == SIW_EPSTATE_AWAIT_MPAREP)) { + int mpa_p2p_mode = cep->mpa.v2_ctrl_req.ord & + (MPA_V2_RDMA_WRITE_RTR |
MPA_V2_RDMA_READ_RTR);drivers/infiniband/sw/siw/siw_cm.c +4
-0+if (!mpa_p2p_mode) + extra_data_check =0 ; + } +/* * At this point, we must have hdr->params.pd_len != 0. * A private data buffer gets allocated if
hdr->params.pd_lenQuoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c
Quoted 6 lines
!=
* 0. */ if (!cep->mpa.pdata) {drivers/infiniband/sw/siw/siw_cm.c +1
-1- cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata = kmalloc(pd_len +
extra_data_check,Quoted 57 lines
Quoted 57 lines
GFP_KERNEL); if (!cep->mpa.pdata) return -ENOMEM; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof(struct
mpa_rr),drivers/infiniband/sw/siw/siw_cm.c +2
-3- to_rcv + 4, MSG_DONTWAIT); + to_rcv + extra_data_check, MSG_DONTWAIT);if (rcvd <0 )return rcvd; -if (rcvd > to_rcv) +if (extra_data_check && (rcvd > to_rcv))return -EPROTO ; cep->mpa.bytes_rcvd += rcvd; -Krishna.Quoted 36 lines
Tom.
Quoted 31 lines
Bernard.
Quoted 28 lines
Quoted 28 lines
So, for the MPA request case, this code is needed to check for protocol correctness.
You are right for the MPA reply case - if we are _not_ in peer2peer mode, the peer can immediately start sending data in RDMA mode after its MPA Reply. So we shall add appropriate code to be more specific For an error, we are (1) processing an MPA Request, OR (2) processing an MPA Reply AND we are not expected to send an initial READ/WRITE/Send as negotiated with the peer (peer2peer mode MPA handshake).Just removing this check would make siw more permissive, but to a point where peer MPA protocol errors are tolerated. I am not in favor of that level of forgiveness.
If possible, please provide an appropriate patch or (if it causes current issues with another peer iWarp implementation) just run in MPA peer2peer mode, where the current check is appropriate. Otherwise, I would provide an appropriate fix by Monday (I am still out of office this week).
Many thanks and best regards,
Bernard.
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 325 lines
To: "Bernard Metzler" <[email protected]>, "Krishnamraju Eraparaju" <[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/09/2019 02:27PM
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messageQuoted 7 lines · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 5 lines
To: "Bernard Metzler" <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/08/2019 06:47PM
Cc: "Tom Talpey" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>,"Potnuri
Quoted 3 lines
Quoted 3 lines
Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handlertries
Quoted 3 lines
Quoted 3 lines
to read beyond MPA message
On Thursday, August 08/08/19, 2019 at 15:05:12 +0000, Bernard
Metzler
Quoted 144 lines
Quoted 144 lines
Quoted 8 lines · wrote:
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 6 lines
To: "Tom Talpey" <[email protected]>, <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/05/2019 07:26PM
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan"Quoted 1 line
Quoted 1 line
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler
tries
Quoted 3 lines
Quoted 3 lines
to read beyond MPA message
On Friday, August 08/02/19, 2019 at 18:17:37 +0530, Tom Talpey
Quoted 24 lines · wrote:
Quoted 24 lines
Quoted 4 lines · Bernard Metzler
Quoted 3 lines
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 1 line
To: "Bernard Metzler" <[email protected]>, "Krishnamraju
Eraparaju"
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
<[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/01/2019 08:54PM
Cc: [email protected], [email protected],Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[email protected], [email protected]
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handlertries
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
to read beyond MPA message
Quoted 1 line · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote:
-----
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected], [email protected], [email protected], "KrishnamrajuQuoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Eraparaju"
Quoted 2 lines
Quoted 2 lines
<[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Reply handlertries to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
read beyond MPA message
while processing MPA Reply, SIW driver is trying to read
extra
Quoted 19 lines
Quoted 19 lines
4
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()completed
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
reading MPA reply, then
ksock_recv()insiw_recv_mpa_rr()could
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
also
Quoted 1 line
Quoted 1 line
read FPDU, if "size" is larger than advertised MPA reply
length.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereQuoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Looks like the intention here is to throw an ERROR if the
received
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
data
is more than the total private data length advertised bythe
Quoted 4 lines
Quoted 4 lines
peer.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
But
reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recvbuffer
Quoted 8 lines
Quoted 8 lines
is
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
already
queued with FPDU messages.Hence, this function should only read upto private data
length.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Krishnamraju EraparajuQuoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct
Quoted 10 lines
---
drivers/infiniband/sw/siw/siw_cm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct
siw_cepQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
*cep)
Quoted 1 line
Quoted 1 line
drivers/infiniband/sw/siw/siw_cm.c +0
-0* A private data buffer gets allocated if
hdr->params.pd_lenQuoted 44 lines
Quoted 44 lines
!=
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
0.
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct · line 567
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1*/ if (!cep->mpa.pdata) { - cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata =kmalloc (pd_len,GFP_KERNEL );if (!cep->mpa.pdata)return -ENOMEM ; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd - sizeof(struct
mpa_rr),Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 14 lines
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1- to_rcv + 4, MSG_DONTWAIT); + to_rcv, MSG_DONTWAIT);if (rcvd <0 )return rcvd;Signature · 1 line
2.23.0.rc0The intention of this code is to make sure the peer does not violates the MPA handshake rules. The initiator MUST NOT send extra data after its MPA request and before receiving the MPA reply.
I think this is true only for MPA v2. With MPA v1, the initiator can begin sending immediately (before receiving the MPA reply), because there is no actual negotiation at the MPA layer.
With MPA v2, the negotiation exchange is required because the type of the following message is predicated by the "Enhanced mode" a|b|c|d flags present in the first 32 bits of the private data buffer.
So, it seems to me that additional logic is needed here to determine the MPA version, before sniffing additional octets from the incoming stream?
Tom.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
There still is the marker negotiation taking place. RFC 5044 says in section 7.1.2:
"Note: Since the receiver's ability to deal with Markers is
unknown until the Request and Reply Frames have been received, sending FPDUs before this occurs is notpossible."
Quoted 79 lines
Quoted 79 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
This section further discusses the responder's behavior, where it MUST receive a first FPDU from the initiator before sending its first FPDU:
"4. MPA Responder mode implementations MUST receive and
validate
Quoted 13 lines
Quoted 13 lines
at
Quoted 12 lines
Quoted 11 lines
least one FPDU before sending any FPDUs or Markers."
So it appears with MPA version 1, the current siw code is correct. The initiator is entering FPDU mode first, and only after receiving the MPA reply frame. Only after the initiator sent a first FPDU, the responder can start using the connection in FPDU mode. Because of this somehow broken connection establishment procedure (only the initiator can start sending data), a later MPA version makes this first FPDU exchange explicit and selectable (zero length READ/WRITE/Send).
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yeah, I guess so. Because nobody ever actually implemented
markers,
Quoted 10 lines
Quoted 10 lines
Quoted 1 line
I think that they may more or less passively ignore this. But
you're
Quoted 3 lines
currect that it's invalid protocol behavior.
If your testing didn't uncover any issues with existing
implementations
Quoted 1 line
failing to connect with your strict checking, I'm ok with it.
Tom & Bernard,
Thanks for the insight on MPA negotiation.Quoted 8 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep
Quoted 8 lines
Could the below patch be considered as a proper fix?
drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -503,6 +503,7 @@ static int siw_recv_mpa_rr(struct siw_cep*cep)
Quoted 4 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep · line 506
Quoted 4 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-0struct socket *s = cep->sock;u16 pd_len;int rcvd, to_rcv; +int extra_data_check =4 ;/* 4Bytes, for MPA rules violation
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep
Quoted 6 lines
checking */
if (
cep->mpa.bytes_rcvd<sizeof(struct mpa_rr)) {
rcvd = ksock_recv(s, (char *)hdr +cep->mpa.bytes_rcvd,drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -553,23 +554,37 @@ static int siw_recv_mpa_rr(struct siw_cep*cep)
Quoted 5 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep · line 558
Quoted 5 lines
drivers/infiniband/sw/siw/siw_cm.c +2
-0return -EPROTO ; } +/* +* Peer must not send any extra data other than MPA messages
Quoted 20 lines
drivers/infiniband/sw/siw/siw_cm.c
Quoted 7 lines
until MPA
+ * negotiation is completed, an exception is MPA V2
client-server Mode,
+ * IE, in this mode the peer after sending MPA Reply can
immediatelydrivers/infiniband/sw/siw/siw_cm.c +2
-0+* start sending data in RDMA mode. +*/ This is unfortunately not true. The responder NEVER sends an FPDU without having seen an FPDU from the initiator. I just checked RFC 6581 again. The RTR (ready-to-receive) indication from the initiator is still needed, but now provided by the protocol and not the application: w/o 'enhanced MPA setup', the initiator sends the first FPDU as an application message. With 'enhanced MPA setup', the initiator protocol entity sends (w/o application interaction) a zero length READ/WRITE/Send as a first FPDU, as previously negotiated with the responder. Again: only after the responder has seen the first FPDU, it can start sending in FPDU mode.
Quoted 5 lines
Quoted 5 lines
If I understand your statements correctly: in MPA v2 clint-server mode,
the responder application should have some logic to wait(after ESTABLISH
event) until the first FPDU message is received from theinitiator?
Quoted 51 lines
Quoted 3 lines
Thanks,
Krishna.The responder may either delay the established event until it sees the first peer FPDU, or it delays sending the first (now already posted) FPDU, until it sees the first initiator FPDU. This, since (theoretically), the responder does not know yet the result of CRC and Marker negotiation. siw delays the established event, which seems the more clear path to me.
This MPA handshake is cumbersome. siw is permissive for violations of these rules to the extend, that the responder shall not send back to back the first FPDU with the MPA reply. If a (Chelsio ?) iWarp adapter would send the first responder FPDU only after it got TCP acked its MPA reply, the chances are high the (siw) iWarp initiator has already transitioned to RTS and it would accept that FPU, even if not having sent it's first FPDU.
siw sticks to this rule to that extend, since all receive processing is triggered by socket callbacks (from
sk->sk_data_ready()). As long as the QP is not
in RTS, all TCP bytestream processing is done by the MPA protocol (code insiw_cm.c). If the QP reaches RTS, RX processing is done bt the full iWarp protocol (code insiw_qp_rx.cfor RX).
Now, if the higher layer (application) protocol has a semantic where the responder sends the first message, we could end up in an infinite wait for that packet at initiator application side.
This, since the complete first FPDU was already received at the TCP socket, while the QP was not in RTS. It will not trigger any additionalsk->sk_data_ready()and we are stuck with a FPDU in the socket rx buffer.I implemented that 4 bytes extra data testing only to keep the siw protocol state machine as simple as possible (it is already unfortunately complex, if you count the lines in
siw_cm.c), while following the protocol rules.I suggest to correctly implement peer2peer mode and delay the established event at the responder side until it got the negotiated first zero length FPDU. Out of the possible options, siw supports both zero length WRITE and READ, but no SEND, since this would consume an extra receive WQE.
Quoted 5 lines
As a last resort, I might consider extending the siw state machine to handle those - non-complaint - cases gracefully. But, that would result in different code than just avoiding checking for peer protocol violation.
Bernard, everything you describe in siw seems perfectly valid to me, and in fact that's why the MPA enhanced connection mode was designed the way it is. I disagree that it's "cumbersome", but that's a nit.
Quoted 5 lines
The issue is that the responder reaches RTS at a different time than the initiator reaches RTR. The original iWARP connection model did not make any requirement, and races were possible. MPAv2 fixes those.
Tom, thanks, exactly. MPAv2 fixes it. And an implementation of that fix MUST adhere to the defined rules. If one negotiates an extra handshake to synchronize, it MUST adhere to that handshake rules. There is no point in negotiating an extra handshake, and right away ignoring it. If the responder wants a zero length WRITE, it MUST use its reception to synchronize its transition to RTS.
Shall we extend the siw state machine to support silly peer behavior? As said, if I read there is no way of making the peer implementation RFC compliant (it would be unexpected), I'll look into the applicability of Postel's Rule. But let's make those things explicit.
Quoted 9 lines
SIW is certainly within its rights to prevent peers from sending prior to responder RTR. I'd suggest that if possible, you try to detect the deadlock rather than flatly rejecting any incoming bytes. The Internet Principle (be liberal in what you accept...), after all.
This same dance happens in IB/RoCE, btw. Just via different messages.
Interesting!
Thanks
Bernard.
Quoted 98 lines
Tom.
Quoted 33 lines
Thanks,
Bernard.Quoted 28 lines
Quoted 22 lines
Sorry for the confusion. But the current
siw code appears to be just correct.Thanks
BernardQuoted 13 lines
+ if ((
__mpa_rr_revision(cep->mpa.hdr.params.bits)==MPA_REVISION_2) &&drivers/infiniband/sw/siw/siw_cm.c +3
-0+ (cep->state == SIW_EPSTATE_AWAIT_MPAREP)) { + int mpa_p2p_mode = cep->mpa.v2_ctrl_req.ord & + (MPA_V2_RDMA_WRITE_RTR |
MPA_V2_RDMA_READ_RTR);drivers/infiniband/sw/siw/siw_cm.c +4
-0+if (!mpa_p2p_mode) + extra_data_check =0 ; + } +/* * At this point, we must have hdr->params.pd_len != 0. * A private data buffer gets allocated if
hdr->params.pd_lenQuoted 5 lines
Quoted 5 lines
!=
* 0. */ if (!cep->mpa.pdata) {-
cep->mpa.pdata= kmalloc(pd_len + 4,
GFP_KERNEL);Quoted 59 lines
Quoted 59 lines
Quoted 1 line
Quoted 1 line
+
cep->mpa.pdata= kmalloc(pd_len +
extra_data_check,Quoted 57 lines
Quoted 57 lines
GFP_KERNEL); if (!cep->mpa.pdata) return -ENOMEM; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof(struct
mpa_rr),drivers/infiniband/sw/siw/siw_cm.c +2
-3- to_rcv + 4, MSG_DONTWAIT); + to_rcv + extra_data_check, MSG_DONTWAIT);if (rcvd <0 )return rcvd; -if (rcvd > to_rcv) +if (extra_data_check && (rcvd > to_rcv))return -EPROTO ; cep->mpa.bytes_rcvd += rcvd; -Krishna.Quoted 36 lines
Tom.
Quoted 31 lines
Bernard.
Quoted 28 lines
Quoted 28 lines
So, for the MPA request case, this code is needed to check for protocol correctness.
You are right for the MPA reply case - if we are _not_ in peer2peer mode, the peer can immediately start sending data in RDMA mode after its MPA Reply. So we shall add appropriate code to be more specific For an error, we are (1) processing an MPA Request, OR (2) processing an MPA Reply AND we are not expected to send an initial READ/WRITE/Send as negotiated with the peer (peer2peer mode MPA handshake).Just removing this check would make siw more permissive, but to a point where peer MPA protocol errors are tolerated. I am not in favor of that level of forgiveness.
If possible, please provide an appropriate patch or (if it causes current issues with another peer iWarp implementation) just run in MPA peer2peer mode, where the current check is appropriate. Otherwise, I would provide an appropriate fix by Monday (I am still out of office this week).
Many thanks and best regards,
Bernard.
Quoted 340 lines · Bernard Metzler
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 325 lines
To: "Bernard Metzler" <[email protected]>, "Krishnamraju Eraparaju" <[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/09/2019 02:27PM
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messageQuoted 7 lines · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 5 lines
To: "Bernard Metzler" <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/08/2019 06:47PM
Cc: "Tom Talpey" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>,"Potnuri
Quoted 3 lines
Quoted 3 lines
Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handlertries
Quoted 3 lines
Quoted 3 lines
to read beyond MPA message
On Thursday, August 08/08/19, 2019 at 15:05:12 +0000, Bernard
Metzler
Quoted 144 lines
Quoted 144 lines
Quoted 8 lines · wrote:
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 6 lines
To: "Tom Talpey" <[email protected]>, <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/05/2019 07:26PM
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan"Quoted 1 line
Quoted 1 line
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler
tries
Quoted 3 lines
Quoted 3 lines
to read beyond MPA message
On Friday, August 08/02/19, 2019 at 18:17:37 +0530, Tom Talpey
Quoted 24 lines · wrote:
Quoted 24 lines
Quoted 4 lines · Bernard Metzler
Quoted 3 lines
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 1 line
To: "Bernard Metzler" <[email protected]>, "Krishnamraju
Eraparaju"
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
<[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/01/2019 08:54PM
Cc: [email protected], [email protected],Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[email protected], [email protected]
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handlertries
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
to read beyond MPA message
Quoted 1 line · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote:
-----
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected], [email protected], [email protected], "KrishnamrajuQuoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Eraparaju"
Quoted 2 lines
Quoted 2 lines
<[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Reply handlertries to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
read beyond MPA message
while processing MPA Reply, SIW driver is trying to read
extra
Quoted 19 lines
Quoted 19 lines
4
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()completed
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
reading MPA reply, then
ksock_recv()insiw_recv_mpa_rr()could
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
also
Quoted 1 line
Quoted 1 line
read FPDU, if "size" is larger than advertised MPA reply
length.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereQuoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Looks like the intention here is to throw an ERROR if the
received
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
data
is more than the total private data length advertised bythe
Quoted 4 lines
Quoted 4 lines
peer.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
But
reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recvbuffer
Quoted 8 lines
Quoted 8 lines
is
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
already
queued with FPDU messages.Hence, this function should only read upto private data
length.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Krishnamraju EraparajuQuoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct
Quoted 10 lines
---
drivers/infiniband/sw/siw/siw_cm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct
siw_cepQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
*cep)
Quoted 1 line
Quoted 1 line
drivers/infiniband/sw/siw/siw_cm.c +0
-0* A private data buffer gets allocated if
hdr->params.pd_lenQuoted 44 lines
Quoted 44 lines
!=
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
0.
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct · line 567
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1*/ if (!cep->mpa.pdata) { - cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata =kmalloc (pd_len,GFP_KERNEL );if (!cep->mpa.pdata)return -ENOMEM ; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd - sizeof(struct
mpa_rr),Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 14 lines
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1- to_rcv + 4, MSG_DONTWAIT); + to_rcv, MSG_DONTWAIT);if (rcvd <0 )return rcvd;Signature · 1 line
2.23.0.rc0The intention of this code is to make sure the peer does not violates the MPA handshake rules. The initiator MUST NOT send extra data after its MPA request and before receiving the MPA reply.
I think this is true only for MPA v2. With MPA v1, the initiator can begin sending immediately (before receiving the MPA reply), because there is no actual negotiation at the MPA layer.
With MPA v2, the negotiation exchange is required because the type of the following message is predicated by the "Enhanced mode" a|b|c|d flags present in the first 32 bits of the private data buffer.
So, it seems to me that additional logic is needed here to determine the MPA version, before sniffing additional octets from the incoming stream?
Tom.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
There still is the marker negotiation taking place. RFC 5044 says in section 7.1.2:
"Note: Since the receiver's ability to deal with Markers is
unknown until the Request and Reply Frames have been received, sending FPDUs before this occurs is notpossible."
Quoted 79 lines
Quoted 79 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
This section further discusses the responder's behavior, where it MUST receive a first FPDU from the initiator before sending its first FPDU:
"4. MPA Responder mode implementations MUST receive and
validate
Quoted 13 lines
Quoted 13 lines
at
Quoted 12 lines
Quoted 11 lines
least one FPDU before sending any FPDUs or Markers."
So it appears with MPA version 1, the current siw code is correct. The initiator is entering FPDU mode first, and only after receiving the MPA reply frame. Only after the initiator sent a first FPDU, the responder can start using the connection in FPDU mode. Because of this somehow broken connection establishment procedure (only the initiator can start sending data), a later MPA version makes this first FPDU exchange explicit and selectable (zero length READ/WRITE/Send).
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yeah, I guess so. Because nobody ever actually implemented
markers,
Quoted 10 lines
Quoted 10 lines
Quoted 1 line
I think that they may more or less passively ignore this. But
you're
Quoted 3 lines
currect that it's invalid protocol behavior.
If your testing didn't uncover any issues with existing
implementations
Quoted 1 line
failing to connect with your strict checking, I'm ok with it.
Tom & Bernard,
Thanks for the insight on MPA negotiation.Quoted 8 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep
Quoted 8 lines
Could the below patch be considered as a proper fix?
drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -503,6 +503,7 @@ static int siw_recv_mpa_rr(struct siw_cep*cep)
Quoted 4 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep · line 506
Quoted 4 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-0struct socket *s = cep->sock;u16 pd_len;int rcvd, to_rcv; +int extra_data_check =4 ;/* 4Bytes, for MPA rules violation
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep
Quoted 6 lines
checking */
if (
cep->mpa.bytes_rcvd<sizeof(struct mpa_rr)) {
rcvd = ksock_recv(s, (char *)hdr +cep->mpa.bytes_rcvd,drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -553,23 +554,37 @@ static int siw_recv_mpa_rr(struct siw_cep*cep)
Quoted 5 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep · line 558
Quoted 5 lines
drivers/infiniband/sw/siw/siw_cm.c +2
-0return -EPROTO ; } +/* +* Peer must not send any extra data other than MPA messages
Quoted 20 lines
drivers/infiniband/sw/siw/siw_cm.c
Quoted 7 lines
until MPA
+ * negotiation is completed, an exception is MPA V2
client-server Mode,
+ * IE, in this mode the peer after sending MPA Reply can
immediatelydrivers/infiniband/sw/siw/siw_cm.c +2
-0+* start sending data in RDMA mode. +*/ This is unfortunately not true. The responder NEVER sends an FPDU without having seen an FPDU from the initiator. I just checked RFC 6581 again. The RTR (ready-to-receive) indication from the initiator is still needed, but now provided by the protocol and not the application: w/o 'enhanced MPA setup', the initiator sends the first FPDU as an application message. With 'enhanced MPA setup', the initiator protocol entity sends (w/o application interaction) a zero length READ/WRITE/Send as a first FPDU, as previously negotiated with the responder. Again: only after the responder has seen the first FPDU, it can start sending in FPDU mode.
Quoted 5 lines
Quoted 5 lines
If I understand your statements correctly: in MPA v2 clint-server mode,
the responder application should have some logic to wait(after ESTABLISH
event) until the first FPDU message is received from theinitiator?
Quoted 51 lines
Quoted 3 lines
Thanks,
Krishna.The responder may either delay the established event until it sees the first peer FPDU, or it delays sending the first (now already posted) FPDU, until it sees the first initiator FPDU. This, since (theoretically), the responder does not know yet the result of CRC and Marker negotiation. siw delays the established event, which seems the more clear path to me.
This MPA handshake is cumbersome. siw is permissive for violations of these rules to the extend, that the responder shall not send back to back the first FPDU with the MPA reply. If a (Chelsio ?) iWarp adapter would send the first responder FPDU only after it got TCP acked its MPA reply, the chances are high the (siw) iWarp initiator has already transitioned to RTS and it would accept that FPU, even if not having sent it's first FPDU.
siw sticks to this rule to that extend, since all receive processing is triggered by socket callbacks (from
sk->sk_data_ready()). As long as the QP is not
in RTS, all TCP bytestream processing is done by the MPA protocol (code insiw_cm.c). If the QP reaches RTS, RX processing is done bt the full iWarp protocol (code insiw_qp_rx.cfor RX).
Now, if the higher layer (application) protocol has a semantic where the responder sends the first message, we could end up in an infinite wait for that packet at initiator application side.
This, since the complete first FPDU was already received at the TCP socket, while the QP was not in RTS. It will not trigger any additionalsk->sk_data_ready()and we are stuck with a FPDU in the socket rx buffer.I implemented that 4 bytes extra data testing only to keep the siw protocol state machine as simple as possible (it is already unfortunately complex, if you count the lines in
siw_cm.c), while following the protocol rules.I suggest to correctly implement peer2peer mode and delay the established event at the responder side until it got the negotiated first zero length FPDU. Out of the possible options, siw supports both zero length WRITE and READ, but no SEND, since this would consume an extra receive WQE.
Quoted 5 lines
As a last resort, I might consider extending the siw state machine to handle those - non-complaint - cases gracefully. But, that would result in different code than just avoiding checking for peer protocol violation.
Bernard, everything you describe in siw seems perfectly valid to me, and in fact that's why the MPA enhanced connection mode was designed the way it is. I disagree that it's "cumbersome", but that's a nit.
Quoted 5 lines
The issue is that the responder reaches RTS at a different time than the initiator reaches RTR. The original iWARP connection model did not make any requirement, and races were possible. MPAv2 fixes those.
Tom, thanks, exactly. MPAv2 fixes it. And an implementation of that fix MUST adhere to the defined rules. If one negotiates an extra handshake to synchronize, it MUST adhere to that handshake rules. There is no point in negotiating an extra handshake, and right away ignoring it. If the responder wants a zero length WRITE, it MUST use its reception to synchronize its transition to RTS.
Quoted 2 lines
Shall we extend the siw state machine to support silly peer behavior? As said, if I read there is no way of
Of course the right answer to this is "no", but I'd reserve drawing that conclusion until I am certain it won't cause trouble. If existing iWARP implementations don't enforce this, and SIW becomes the odd duck failing connections, then I'm afraid I would have to say "yes" instead.
Quoted 3 lines
making the peer implementation RFC compliant (it would be unexpected), I'll look into the applicability of Postel's Rule. But let's make those things explicit.
Explicit is best, agreed.
Tom.
Quoted 116 lines
Quoted 10 lines
SIW is certainly within its rights to prevent peers from sending prior to responder RTR. I'd suggest that if possible, you try to detect the deadlock rather than flatly rejecting any incoming bytes. The Internet Principle (be liberal in what you accept...), after all.
This same dance happens in IB/RoCE, btw. Just via different messages.
Interesting!
Thanks
Bernard.Quoted 98 lines
Tom.
Quoted 33 lines
Thanks,
Bernard.Quoted 28 lines
Quoted 22 lines
Sorry for the confusion. But the current
siw code appears to be just correct.Thanks
BernardQuoted 13 lines
+ if ((
__mpa_rr_revision(cep->mpa.hdr.params.bits)==MPA_REVISION_2) &&drivers/infiniband/sw/siw/siw_cm.c +3
-0+ (cep->state == SIW_EPSTATE_AWAIT_MPAREP)) { + int mpa_p2p_mode = cep->mpa.v2_ctrl_req.ord & + (MPA_V2_RDMA_WRITE_RTR |
MPA_V2_RDMA_READ_RTR);drivers/infiniband/sw/siw/siw_cm.c +4
-0+if (!mpa_p2p_mode) + extra_data_check =0 ; + } +/* * At this point, we must have hdr->params.pd_len != 0. * A private data buffer gets allocated if
hdr->params.pd_lenQuoted 5 lines
Quoted 5 lines
!=
* 0. */ if (!cep->mpa.pdata) {-
cep->mpa.pdata= kmalloc(pd_len + 4,
GFP_KERNEL);Quoted 59 lines
Quoted 59 lines
Quoted 1 line
Quoted 1 line
+
cep->mpa.pdata= kmalloc(pd_len +
extra_data_check,Quoted 57 lines
Quoted 57 lines
GFP_KERNEL); if (!cep->mpa.pdata) return -ENOMEM; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof(struct
mpa_rr),drivers/infiniband/sw/siw/siw_cm.c +2
-3- to_rcv + 4, MSG_DONTWAIT); + to_rcv + extra_data_check, MSG_DONTWAIT);if (rcvd <0 )return rcvd; -if (rcvd > to_rcv) +if (extra_data_check && (rcvd > to_rcv))return -EPROTO ; cep->mpa.bytes_rcvd += rcvd; -Krishna.Quoted 36 lines
Tom.
Quoted 31 lines
Bernard.
Quoted 28 lines
Quoted 28 lines
So, for the MPA request case, this code is needed to check for protocol correctness.
You are right for the MPA reply case - if we are _not_ in peer2peer mode, the peer can immediately start sending data in RDMA mode after its MPA Reply. So we shall add appropriate code to be more specific For an error, we are (1) processing an MPA Request, OR (2) processing an MPA Reply AND we are not expected to send an initial READ/WRITE/Send as negotiated with the peer (peer2peer mode MPA handshake).Just removing this check would make siw more permissive, but to a point where peer MPA protocol errors are tolerated. I am not in favor of that level of forgiveness.
If possible, please provide an appropriate patch or (if it causes current issues with another peer iWarp implementation) just run in MPA peer2peer mode, where the current check is appropriate. Otherwise, I would provide an appropriate fix by Monday (I am still out of office this week).
Many thanks and best regards,
Bernard.
Quoted 328 lines · Tom Talpey
Quoted 327 lines · Bernard Metzler
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 325 lines
To: "Bernard Metzler" <[email protected]>, "Krishnamraju Eraparaju" <[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/09/2019 02:27PM
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messageQuoted 7 lines · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 5 lines
To: "Bernard Metzler" <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/08/2019 06:47PM
Cc: "Tom Talpey" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>,"Potnuri
Quoted 3 lines
Quoted 3 lines
Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handlertries
Quoted 3 lines
Quoted 3 lines
to read beyond MPA message
On Thursday, August 08/08/19, 2019 at 15:05:12 +0000, Bernard
Metzler
Quoted 144 lines
Quoted 144 lines
Quoted 8 lines · wrote:
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 6 lines
To: "Tom Talpey" <[email protected]>, <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/05/2019 07:26PM
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan"Quoted 1 line
Quoted 1 line
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler
tries
Quoted 3 lines
Quoted 3 lines
to read beyond MPA message
On Friday, August 08/02/19, 2019 at 18:17:37 +0530, Tom Talpey
Quoted 24 lines · wrote:
Quoted 24 lines
Quoted 4 lines · Bernard Metzler
Quoted 3 lines
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 1 line
To: "Bernard Metzler" <[email protected]>, "Krishnamraju
Eraparaju"
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
<[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/01/2019 08:54PM
Cc: [email protected], [email protected],Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[email protected], [email protected]
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handlertries
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
to read beyond MPA message
Quoted 1 line · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote:
-----
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected], [email protected], [email protected], "KrishnamrajuQuoted 7 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Eraparaju"
Quoted 2 lines
Quoted 2 lines
<[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Reply handlertries to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
read beyond MPA message
while processing MPA Reply, SIW driver is trying to read
extra
Quoted 19 lines
Quoted 19 lines
4
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()completed
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
reading MPA reply, then
ksock_recv()insiw_recv_mpa_rr()could
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
also
Quoted 1 line
Quoted 1 line
read FPDU, if "size" is larger than advertised MPA reply
length.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereQuoted 4 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Looks like the intention here is to throw an ERROR if the
received
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
data
is more than the total private data length advertised bythe
Quoted 4 lines
Quoted 4 lines
peer.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
But
reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recvbuffer
Quoted 8 lines
Quoted 8 lines
is
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
already
queued with FPDU messages.Hence, this function should only read upto private data
length.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by Krishnamraju EraparajuQuoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct
Quoted 10 lines
---
drivers/infiniband/sw/siw/siw_cm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct
siw_cepQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
*cep)
Quoted 1 line
Quoted 1 line
drivers/infiniband/sw/siw/siw_cm.c +0
-0* A private data buffer gets allocated if
hdr->params.pd_lenQuoted 44 lines
Quoted 44 lines
!=
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
0.
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct · line 567
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1*/ if (!cep->mpa.pdata) { - cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata =kmalloc (pd_len,GFP_KERNEL );if (!cep->mpa.pdata)return -ENOMEM ; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd - sizeof(struct
mpa_rr),Quoted 32 lines
Quoted 32 lines
Quoted 31 lines
Quoted 14 lines
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1- to_rcv + 4, MSG_DONTWAIT); + to_rcv, MSG_DONTWAIT);if (rcvd <0 )return rcvd;Signature · 1 line
2.23.0.rc0The intention of this code is to make sure the peer does not violates the MPA handshake rules. The initiator MUST NOT send extra data after its MPA request and before receiving the MPA reply.
I think this is true only for MPA v2. With MPA v1, the initiator can begin sending immediately (before receiving the MPA reply), because there is no actual negotiation at the MPA layer.
With MPA v2, the negotiation exchange is required because the type of the following message is predicated by the "Enhanced mode" a|b|c|d flags present in the first 32 bits of the private data buffer.
So, it seems to me that additional logic is needed here to determine the MPA version, before sniffing additional octets from the incoming stream?
Tom.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
There still is the marker negotiation taking place. RFC 5044 says in section 7.1.2:
"Note: Since the receiver's ability to deal with Markers is
unknown until the Request and Reply Frames have been received, sending FPDUs before this occurs is notpossible."
Quoted 79 lines
Quoted 79 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
This section further discusses the responder's behavior, where it MUST receive a first FPDU from the initiator before sending its first FPDU:
"4. MPA Responder mode implementations MUST receive and
validate
Quoted 13 lines
Quoted 13 lines
at
Quoted 12 lines
Quoted 11 lines
least one FPDU before sending any FPDUs or Markers."
So it appears with MPA version 1, the current siw code is correct. The initiator is entering FPDU mode first, and only after receiving the MPA reply frame. Only after the initiator sent a first FPDU, the responder can start using the connection in FPDU mode. Because of this somehow broken connection establishment procedure (only the initiator can start sending data), a later MPA version makes this first FPDU exchange explicit and selectable (zero length READ/WRITE/Send).
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yeah, I guess so. Because nobody ever actually implemented
markers,
Quoted 10 lines
Quoted 10 lines
Quoted 1 line
I think that they may more or less passively ignore this. But
you're
Quoted 3 lines
currect that it's invalid protocol behavior.
If your testing didn't uncover any issues with existing
implementations
Quoted 1 line
failing to connect with your strict checking, I'm ok with it.
Tom & Bernard,
Thanks for the insight on MPA negotiation.Quoted 8 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep
Quoted 8 lines
Could the below patch be considered as a proper fix?
drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -503,6 +503,7 @@ static int siw_recv_mpa_rr(struct siw_cep*cep)
Quoted 4 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep · line 506
Quoted 4 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-0struct socket *s = cep->sock;u16 pd_len;int rcvd, to_rcv; +int extra_data_check =4 ;/* 4Bytes, for MPA rules violation
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep
Quoted 6 lines
checking */
if (
cep->mpa.bytes_rcvd<sizeof(struct mpa_rr)) {
rcvd = ksock_recv(s, (char *)hdr +cep->mpa.bytes_rcvd,drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -553,23 +554,37 @@ static int siw_recv_mpa_rr(struct siw_cep*cep)
Quoted 5 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct siw_cep · line 558
Quoted 5 lines
drivers/infiniband/sw/siw/siw_cm.c +2
-0return -EPROTO ; } +/* +* Peer must not send any extra data other than MPA messages
Quoted 20 lines
drivers/infiniband/sw/siw/siw_cm.c
Quoted 7 lines
until MPA
+ * negotiation is completed, an exception is MPA V2
client-server Mode,
+ * IE, in this mode the peer after sending MPA Reply can
immediatelydrivers/infiniband/sw/siw/siw_cm.c +2
-0+* start sending data in RDMA mode. +*/ This is unfortunately not true. The responder NEVER sends an FPDU without having seen an FPDU from the initiator. I just checked RFC 6581 again. The RTR (ready-to-receive) indication from the initiator is still needed, but now provided by the protocol and not the application: w/o 'enhanced MPA setup', the initiator sends the first FPDU as an application message. With 'enhanced MPA setup', the initiator protocol entity sends (w/o application interaction) a zero length READ/WRITE/Send as a first FPDU, as previously negotiated with the responder. Again: only after the responder has seen the first FPDU, it can start sending in FPDU mode.
Quoted 5 lines
Quoted 5 lines
If I understand your statements correctly: in MPA v2 clint-server mode,
the responder application should have some logic to wait(after ESTABLISH
event) until the first FPDU message is received from theinitiator?
Quoted 51 lines
Quoted 3 lines
Thanks,
Krishna.The responder may either delay the established event until it sees the first peer FPDU, or it delays sending the first (now already posted) FPDU, until it sees the first initiator FPDU. This, since (theoretically), the responder does not know yet the result of CRC and Marker negotiation. siw delays the established event, which seems the more clear path to me.
This MPA handshake is cumbersome. siw is permissive for violations of these rules to the extend, that the responder shall not send back to back the first FPDU with the MPA reply. If a (Chelsio ?) iWarp adapter would send the first responder FPDU only after it got TCP acked its MPA reply, the chances are high the (siw) iWarp initiator has already transitioned to RTS and it would accept that FPU, even if not having sent it's first FPDU.
siw sticks to this rule to that extend, since all receive processing is triggered by socket callbacks (from
sk->sk_data_ready()). As long as the QP is not
in RTS, all TCP bytestream processing is done by the MPA protocol (code insiw_cm.c). If the QP reaches RTS, RX processing is done bt the full iWarp protocol (code insiw_qp_rx.cfor RX).
Now, if the higher layer (application) protocol has a semantic where the responder sends the first message, we could end up in an infinite wait for that packet at initiator application side.
This, since the complete first FPDU was already received at the TCP socket, while the QP was not in RTS. It will not trigger any additionalsk->sk_data_ready()and we are stuck with a FPDU in the socket rx buffer.I implemented that 4 bytes extra data testing only to keep the siw protocol state machine as simple as possible (it is already unfortunately complex, if you count the lines in
siw_cm.c), while following the protocol rules.I suggest to correctly implement peer2peer mode and delay the established event at the responder side until it got the negotiated first zero length FPDU. Out of the possible options, siw supports both zero length WRITE and READ, but no SEND, since this would consume an extra receive WQE.
Quoted 5 lines
As a last resort, I might consider extending the siw state machine to handle those - non-complaint - cases gracefully. But, that would result in different code than just avoiding checking for peer protocol violation.
Bernard, everything you describe in siw seems perfectly valid to me, and in fact that's why the MPA enhanced connection mode was designed the way it is. I disagree that it's "cumbersome", but that's a nit.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
The issue is that the responder reaches RTS at a different time than the initiator reaches RTR. The original iWARP connection model did not make any requirement, and races were possible. MPAv2 fixes those.
Tom, thanks, exactly. MPAv2 fixes it. And an implementation
Thanks Bernard & Tom,
Could you also please consider making MPA ehanced connection mode(with RTR handshake) as default for SIW, as MPA V2 peer- to-peer mode seems to be more promising that MPA V2 client-server Mode, wrt race conditions.
Currently SIW has MPA V2 client-server Mode as default.
In siw_main.c:
const bool peer_to_peer = 1;
Between, as per my observations, the chances of hitting this 'connect
error' issue is higher with: SIW(initator)<--->(responder)SIW
than: SIW(initator) <---> (responder)hard-iwarp
Quoted 140 lines
Quoted 9 lines
of that fix MUST adhere to the defined rules. If one negotiates an extra handshake to synchronize, it MUST adhere to that handshake rules. There is no point in negotiating an extra handshake, and right away ignoring it. If the responder wants a zero length WRITE, it MUST use its reception to synchronize its transition to RTS.
Shall we extend the siw state machine to support silly peer behavior? As said, if I read there is no way of
Of course the right answer to this is "no", but I'd reserve drawing that conclusion until I am certain it won't cause trouble. If existing iWARP implementations don't enforce this, and SIW becomes the odd duck failing connections, then I'm afraid I would have to say "yes" instead.
Quoted 3 lines
making the peer implementation RFC compliant (it would be unexpected), I'll look into the applicability of Postel's Rule. But let's make those things explicit.
Explicit is best, agreed.
Tom.
Quoted 116 lines
Quoted 10 lines
SIW is certainly within its rights to prevent peers from sending prior to responder RTR. I'd suggest that if possible, you try to detect the deadlock rather than flatly rejecting any incoming bytes. The Internet Principle (be liberal in what you accept...), after all.
This same dance happens in IB/RoCE, btw. Just via different messages.
Interesting!
Thanks
Bernard.Quoted 98 lines
Tom.
Quoted 33 lines
Thanks,
Bernard.Quoted 28 lines
Quoted 22 lines
Sorry for the confusion. But the current
siw code appears to be just correct.Thanks
BernardQuoted 13 lines
+ if ((
__mpa_rr_revision(cep->mpa.hdr.params.bits)==MPA_REVISION_2) &&drivers/infiniband/sw/siw/siw_cm.c +3
-0+ (cep->state == SIW_EPSTATE_AWAIT_MPAREP)) { + int mpa_p2p_mode = cep->mpa.v2_ctrl_req.ord & + (MPA_V2_RDMA_WRITE_RTR |
MPA_V2_RDMA_READ_RTR);drivers/infiniband/sw/siw/siw_cm.c +4
-0+if (!mpa_p2p_mode) + extra_data_check =0 ; + } +/* * At this point, we must have hdr->params.pd_len != 0. * A private data buffer gets allocated if
hdr->params.pd_lenQuoted 5 lines
Quoted 5 lines
!=
* 0. */ if (!cep->mpa.pdata) {-
cep->mpa.pdata= kmalloc(pd_len + 4,
GFP_KERNEL);Quoted 59 lines
Quoted 59 lines
Quoted 1 line
Quoted 1 line
+
cep->mpa.pdata= kmalloc(pd_len +
extra_data_check,Quoted 57 lines
Quoted 57 lines
GFP_KERNEL); if (!cep->mpa.pdata) return -ENOMEM; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof(struct
mpa_rr),drivers/infiniband/sw/siw/siw_cm.c +2
-3- to_rcv + 4, MSG_DONTWAIT); + to_rcv + extra_data_check, MSG_DONTWAIT);if (rcvd <0 )return rcvd; -if (rcvd > to_rcv) +if (extra_data_check && (rcvd > to_rcv))return -EPROTO ; cep->mpa.bytes_rcvd += rcvd; -Krishna.Quoted 36 lines
Tom.
Quoted 31 lines
Bernard.
Quoted 28 lines
Quoted 28 lines
So, for the MPA request case, this code is needed to check for protocol correctness.
You are right for the MPA reply case - if we are _not_ in peer2peer mode, the peer can immediately start sending data in RDMA mode after its MPA Reply. So we shall add appropriate code to be more specific For an error, we are (1) processing an MPA Request, OR (2) processing an MPA Reply AND we are not expected to send an initial READ/WRITE/Send as negotiated with the peer (peer2peer mode MPA handshake).Just removing this check would make siw more permissive, but to a point where peer MPA protocol errors are tolerated. I am not in favor of that level of forgiveness.
If possible, please provide an appropriate patch or (if it causes current issues with another peer iWarp implementation) just run in MPA peer2peer mode, where the current check is appropriate. Otherwise, I would provide an appropriate fix by Monday (I am still out of office this week).
Many thanks and best regards,
Bernard.
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 389 lines
To: "Bernard Metzler" <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/12/2019 11:59AM
Cc: "Tom Talpey" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messageQuoted 4 lines · Tom Talpey
Quoted 3 lines · Bernard Metzler
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 1 line
To: "Bernard Metzler" <[email protected]>, "Krishnamraju
Eraparaju"
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
<[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/09/2019 02:27PM
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan"Quoted 1 line
Quoted 1 line
Quoted 1 line
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler
tries
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
to read beyond MPA message
Quoted 1 line · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote:
-----
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
To: "Bernard Metzler" <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/08/2019 06:47PM
Cc: "Tom Talpey" <[email protected]>, "[email protected]"Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
"Potnuri
Quoted 3 lines
Quoted 3 lines
Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handlerQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
tries
Quoted 3 lines
Quoted 3 lines
to read beyond MPA message
On Thursday, August 08/08/19, 2019 at 15:05:12 +0000, Bernard
Metzler
Quoted 2 lines
Quoted 2 lines
Quoted 1 line · wrote:
-----"Krishnamraju Eraparaju" <[email protected]> wrote:
-----
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
To: "Tom Talpey" <[email protected]>, <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/05/2019 07:26PM
Cc: "[email protected]" <[email protected]>,Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
<[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan"
Quoted 1 line
Quoted 1 line
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply
handler
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
tries
Quoted 3 lines
Quoted 3 lines
to read beyond MPA message
On Friday, August 08/02/19, 2019 at 18:17:37 +0530, Tom
Talpey
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines · Bernard Metzler
Quoted 3 lines
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 1 line
To: "Bernard Metzler" <[email protected]>, "Krishnamraju
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Eraparaju"
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
<[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/01/2019 08:54PM
Cc: [email protected], [email protected],Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[email protected], [email protected]
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Replyhandler
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
tries
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
to read beyond MPA message
Quoted 1 line · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]>
Quoted 7 lines · wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
-----
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected],
[email protected], [email protected],"Krishnamraju
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Eraparaju"
Quoted 2 lines
Quoted 2 lines
<[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Replyhandler
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
tries to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
read beyond MPA message
while processing MPA Reply, SIW driver is trying to
read
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
extra
Quoted 5 lines
Quoted 5 lines
4
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
completed
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
reading MPA reply, then ksock_recv() in
siw_recv_mpa_rr()Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
could
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
also
Quoted 1 line
Quoted 1 line
read FPDU, if "size" is larger than advertised MPA
reply
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
length.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
501 static int siw_recv_mpa_rr(struct siw_cep *cep)
502 {
.............
572
573 if (rcvd > to_rcv)
574 return -EPROTO; <----- Failurehere
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Looks like the intention here is to throw an ERROR if
the
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
received
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
data
is more than the total private data length advertisedby
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
the
Quoted 4 lines
Quoted 4 lines
peer.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
But
reading beyond MPA message causes siw_cm to generate
RDMA_CM_EVENT_CONNECT_ERROR event when TCP socket recvbuffer
Quoted 8 lines
Quoted 8 lines
is
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
already
queued with FPDU messages.Hence, this function should only read upto private data
length.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by: Krishnamraju Eraparaju
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
---
drivers/infiniband/sw/siw/siw_cm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)diff --git a/drivers/infiniband/sw/siw/siw_cm.c
b/drivers/infiniband/sw/siw/siw_cm.c
index a7cde98e73e8..8dc8cea2566c 100644
--- a/drivers/infiniband/sw/siw/siw_cm.c
+++ b/drivers/infiniband/sw/siw/siw_cm.c
@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct
siw_cepQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
*cep)
Quoted 1 line
Quoted 1 line
* A private data buffer gets allocated if
hdr->params.pd_lenQuoted 2 lines
Quoted 2 lines
!=
Quoted 1 line
Quoted 1 line
Quoted 1 line
0.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
*/
if (!cep->mpa.pdata) {
- cep->mpa.pdata = kmalloc(pd_len + 4, GFP_KERNEL);
+ cep->mpa.pdata = kmalloc(pd_len, GFP_KERNEL);
if (!cep->mpa.pdata)
return -ENOMEM;
}
rcvd = ksock_recv(
s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof(struct
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
mpa_rr),Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 9 lines
- to_rcv + 4, MSG_DONTWAIT);
+ to_rcv, MSG_DONTWAIT);if (rcvd < 0)
return rcvd;
--
2.23.0.rc0The intention of this code is to make sure the peer does not violates the MPA handshake rules. The initiator MUST NOT send extra data after its MPA request and before receiving the MPA reply.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
I think this is true only for MPA v2. With MPA v1, the initiator can begin sending immediately (before receiving the MPA reply), because there is no actual negotiation at the MPA layer.
With MPA v2, the negotiation exchange is required because the type of the following message is predicated by the "Enhanced mode" a|b|c|d flags present in the first 32
bits
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
of the private data buffer.
So, it seems to me that additional logic is needed here
to
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
determine the MPA version, before sniffing additional
octets
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
from the incoming stream?
Tom.
There still is the marker negotiation taking place. RFC 5044 says in section 7.1.2:
"Note: Since the receiver's ability to deal with Markers
is
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
unknown until the Request and Reply Frames have been received, sending FPDUs before this occurs is not
possible."
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
This section further discusses the responder's behavior, where it MUST receive a first FPDU from the initiator before sending its first FPDU:
"4. MPA Responder mode implementations MUST receive and
validate
Quoted 2 lines
Quoted 2 lines
at
Quoted 1 line
Quoted 1 line
least one FPDU before sending any FPDUs or
Markers."
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
So it appears with MPA version 1, the current siw code is correct. The initiator is entering FPDU mode first, and only after receiving the MPA reply frame. Only after the initiator sent a first FPDU, the responder can start using the connection in FPDU mode. Because of this somehow broken connection establishment procedure (only the initiator can start sending data), a later MPA version makes this first FPDU exchange explicit and selectable (zero length READ/WRITE/Send).
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yeah, I guess so. Because nobody ever actually implemented
markers,
Quoted 1 line
Quoted 1 line
Quoted 1 line
I think that they may more or less passively ignore this.
But
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
you're
Quoted 3 lines
currect that it's invalid protocol behavior.
If your testing didn't uncover any issues with existing
implementations
Quoted 1 line
failing to connect with your strict checking, I'm ok with
it.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct
Quoted 11 lines
Tom & Bernard,
Thanks for the insight on MPA negotiation.Could the below patch be considered as a proper fix?
drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -503,6 +503,7 @@ static int siw_recv_mpa_rr(struct
siw_cepQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
*cep)
Quoted 4 lines
Quoted 4 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-0struct socket *s = cep->sock;u16 pd_len;int rcvd, to_rcv; +int extra_data_check =4 ;/* 4Bytes, for MPA rules Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
violation
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct
Quoted 6 lines
checking */
if (
cep->mpa.bytes_rcvd<sizeof(struct mpa_rr)) {
rcvd = ksock_recv(s, (char *)hdr +cep->mpa.bytes_rcvd,drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -553,23 +554,37 @@ static int siw_recv_mpa_rr(struct
siw_cepQuoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
*cep)
Quoted 5 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct · line 558
Quoted 5 lines
drivers/infiniband/sw/siw/siw_cm.c +2
-0return -EPROTO ; } +/* +* Peer must not send any extra data other than MPA messages
Quoted 4 lines
Quoted 4 lines
until MPA
+ * negotiation is completed, an exception is MPA V2
client-server Mode,
+ * IE, in this mode the peer after sending MPA Replycan
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/infiniband/sw/siw/siw_cm.c
Quoted 3 lines
immediately
drivers/infiniband/sw/siw/siw_cm.c +2
-0+* start sending data in RDMA mode. +*/ This is unfortunately not true. The responder NEVER sends an FPDU without having seen an FPDU from the initiator. I just checked RFC 6581 again. The RTR (ready-to-receive) indication from the initiator is still needed, but now provided by the protocol and not the application: w/o 'enhanced MPA setup', the initiator sends the first FPDU as an application message. With 'enhanced MPA setup', the initiator protocol entity sends (w/o application interaction) a zero length READ/WRITE/Send as a first FPDU, as previously negotiated with the responder. Again: only after the responder has seen the first FPDU, it can start sending in FPDU mode.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
If I understand your statements correctly: in MPA v2
clint-server
Quoted 67 lines
Quoted 67 lines
Quoted 67 lines
Quoted 4 lines
Quoted 4 lines
mode,
the responder application should have some logic to wait(after ESTABLISH
event) until the first FPDU message is received from theinitiator?
Quoted 51 lines
Quoted 3 lines
Thanks,
Krishna.The responder may either delay the established event until it sees the first peer FPDU, or it delays sending the first (now already posted) FPDU, until it sees the first initiator FPDU. This, since (theoretically), the responder does not know yet the result of CRC and Marker negotiation. siw delays the established event, which seems the more clear path to me.
This MPA handshake is cumbersome. siw is permissive for violations of these rules to the extend, that the responder shall not send back to back the first FPDU with the MPA reply. If a (Chelsio ?) iWarp adapter would send the first responder FPDU only after it got TCP acked its MPA reply, the chances are high the (siw) iWarp initiator has already transitioned to RTS and it would accept that FPU, even if not having sent it's first FPDU.
siw sticks to this rule to that extend, since all receive processing is triggered by socket callbacks (from
sk->sk_data_ready()). As long as the QP is not
in RTS, all TCP bytestream processing is done by the MPA protocol (code insiw_cm.c). If the QP reaches RTS, RX processing is done bt the full iWarp protocol (code insiw_qp_rx.cfor RX).
Now, if the higher layer (application) protocol has a semantic where the responder sends the first message, we could end up in an infinite wait for that packet at initiator application side.
This, since the complete first FPDU was already received at the TCP socket, while the QP was not in RTS. It will not trigger any additionalsk->sk_data_ready()and we are stuck with a FPDU in the socket rx buffer.I implemented that 4 bytes extra data testing only to keep the siw protocol state machine as simple as possible (it is already unfortunately complex, if you count the lines in
siw_cm.c), while following the protocol rules.I suggest to correctly implement peer2peer mode and delay the established event at the responder side until it got the negotiated first zero length FPDU. Out of the possible options, siw supports both zero length WRITE and READ, but no SEND, since this would consume an extra receive WQE.
Quoted 5 lines
As a last resort, I might consider extending the siw state machine to handle those - non-complaint - cases gracefully. But, that would result in different code than just avoiding checking for peer protocol violation.
Bernard, everything you describe in siw seems perfectly valid to me, and in fact that's why the MPA enhanced connection mode was designed the way it is. I disagree that it's "cumbersome", but that's a nit.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
The issue is that the responder reaches RTS at a different time than the initiator reaches RTR. The original iWARP connection model did not make any requirement, and races were possible. MPAv2 fixes those.
Tom, thanks, exactly. MPAv2 fixes it. And an implementation
Thanks Bernard & Tom,
Could you also please consider making MPA ehanced connection mode(with RTR handshake) as default for SIW, as MPA V2 peer- to-peer mode seems to be more promising that MPA V2 client-server Mode, wrt race conditions.
Currently SIW has MPA V2 client-server Mode as default.
Quoted 7 lines
In
siw_main.c:const bool peer_to_peer = 1;Between, as per my observations, the chances of hitting this 'connect
error' issue is higher with: SIW(initator)<--->(responder)SIW
than: SIW(initator) <---> (responder)hard-iwarp
Good to know! Yes, siw is permissive at responder side, it's applications responsibility to delay the first message, if p2p mode is not selected.
What application are you using here (which let's
the responder immediately start using the SQ)? Just to let me re-create the case w/o effort.
I might produce a fix for siw which can handle that case for the non-p2p-mode case.
Setting p2p mode as default is another option. I am not immediately happy with that suggestion, since it adds another wire transfer as default. The future shall see those parameters settable. These were module parameters, but we abandoned that. We should probably come up with an extension to the RDMA netlink interface, which makes those protocol specific modes and flavors settable per device...?
Thanks
Bernard.
Quoted 146 lines
Quoted 18 lines
Quoted 11 lines
of that fix MUST adhere to the defined rules. If one negotiates an extra handshake to synchronize, it MUST adhere to that handshake rules. There is no point in negotiating an extra handshake, and right away ignoring it. If the responder wants a zero length WRITE, it MUST use its reception to synchronize its transition to RTS.
Shall we extend the siw state machine to support silly peer behavior? As said, if I read there is no way of
Of course the right answer to this is "no", but I'd reserve drawing that conclusion until I am certain it won't cause trouble. If existing iWARP implementations don't enforce this, and SIW becomes the odd duck failing connections, then I'm afraid I would have to say "yes" instead.
Quoted 44 lines
Quoted 3 lines
making the peer implementation RFC compliant (it would be unexpected), I'll look into the applicability of Postel's Rule. But let's make those things explicit.
Explicit is best, agreed.
Tom.
Quoted 36 lines
Quoted 10 lines
SIW is certainly within its rights to prevent peers from sending prior to responder RTR. I'd suggest that if possible, you try to detect the deadlock rather than flatly rejecting any incoming bytes. The Internet Principle (be liberal in what you accept...), after all.
This same dance happens in IB/RoCE, btw. Just via different messages.
Interesting!
Thanks
Bernard.Quoted 21 lines
Tom.
Quoted 18 lines
Thanks,
Bernard.Quoted 13 lines
Quoted 13 lines
Sorry for the confusion. But the current
siw code appears to be just correct.Thanks
BernardQuoted 4 lines
+ if ((
__mpa_rr_revision(cep->mpa.hdr.params.bits)==MPA_REVISION_2) &&drivers/infiniband/sw/siw/siw_cm.c +2
-0+ (cep->state == SIW_EPSTATE_AWAIT_MPAREP)) { +int mpa_p2p_mode = cep->mpa.v2_ctrl_req.ord&
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/infiniband/sw/siw/siw_cm.c
Quoted 8 lines
+ (
MPA_V2_RDMA_WRITE_RTR|MPA_V2_RDMA_READ_RTR);drivers/infiniband/sw/siw/siw_cm.c +4
-0+if (!mpa_p2p_mode) + extra_data_check =0 ; + } +/* * At this point, we must have hdr->params.pd_len != 0.
Quoted 72 lines
Quoted 72 lines
Quoted 69 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
* A private data buffer gets allocated if
hdr->params.pd_lenQuoted 5 lines
Quoted 5 lines
!=
* 0. */ if (!cep->mpa.pdata) {-
cep->mpa.pdata= kmalloc(pd_len + 4,
GFP_KERNEL);Quoted 59 lines
Quoted 59 lines
Quoted 1 line
Quoted 1 line
+
cep->mpa.pdata= kmalloc(pd_len +
extra_data_check,Quoted 57 lines
Quoted 57 lines
GFP_KERNEL); if (!cep->mpa.pdata) return -ENOMEM; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof(struct
mpa_rr),drivers/infiniband/sw/siw/siw_cm.c +2
-3- to_rcv + 4, MSG_DONTWAIT); + to_rcv + extra_data_check, MSG_DONTWAIT);if (rcvd <0 )return rcvd; -if (rcvd > to_rcv) +if (extra_data_check && (rcvd > to_rcv))return -EPROTO ; cep->mpa.bytes_rcvd += rcvd; -Krishna.Quoted 36 lines
Tom.
Quoted 31 lines
Bernard.
Quoted 28 lines
Quoted 28 lines
So, for the MPA request case, this code is needed to check for protocol correctness.
You are right for the MPA reply case - if we are _not_ in peer2peer mode, the peer can immediately start sending data in RDMA mode after its MPA Reply. So we shall add appropriate code to be more specific For an error, we are (1) processing an MPA Request, OR (2) processing an MPA Reply AND we are not expected to send an initial READ/WRITE/Send as negotiated with the peer (peer2peer mode MPA handshake).Just removing this check would make siw more permissive, but to a point where peer MPA protocol errors are tolerated. I am not in favor of that level of forgiveness.
If possible, please provide an appropriate patch or (if it causes current issues with another peer iWarp implementation) just run in MPA peer2peer mode, where the current check is appropriate. Otherwise, I would provide an appropriate fix by Monday (I am still out of office this week).
Many thanks and best regards,
Bernard.
Quoted 399 lines · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 389 lines
To: "Bernard Metzler" <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/12/2019 11:59AM
Cc: "Tom Talpey" <[email protected]>, "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messageQuoted 4 lines · Tom Talpey
Quoted 3 lines · Bernard Metzler
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 1 line
To: "Bernard Metzler" <[email protected]>, "Krishnamraju
Eraparaju"
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
<[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/09/2019 02:27PM
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan"Quoted 1 line
Quoted 1 line
Quoted 1 line
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler
tries
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
to read beyond MPA message
Quoted 1 line · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote:
-----
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
To: "Bernard Metzler" <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/08/2019 06:47PM
Cc: "Tom Talpey" <[email protected]>, "[email protected]"Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
"Potnuri
Quoted 3 lines
Quoted 3 lines
Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handlerQuoted 7 lines
Quoted 7 lines
Quoted 7 lines
tries
Quoted 3 lines
Quoted 3 lines
to read beyond MPA message
On Thursday, August 08/08/19, 2019 at 15:05:12 +0000, Bernard
Metzler
Quoted 2 lines
Quoted 2 lines
Quoted 1 line · wrote:
-----"Krishnamraju Eraparaju" <[email protected]> wrote:
-----
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
To: "Tom Talpey" <[email protected]>, <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/05/2019 07:26PM
Cc: "[email protected]" <[email protected]>,Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
<[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan"
Quoted 1 line
Quoted 1 line
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply
handler
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
tries
Quoted 3 lines
Quoted 3 lines
to read beyond MPA message
On Friday, August 08/02/19, 2019 at 18:17:37 +0530, Tom
Talpey
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines · Bernard Metzler
Quoted 3 lines
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 1 line
To: "Bernard Metzler" <[email protected]>, "Krishnamraju
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Eraparaju"
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
<[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/01/2019 08:54PM
Cc: [email protected], [email protected],Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[email protected], [email protected]
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Replyhandler
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
tries
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
to read beyond MPA message
Quoted 1 line · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]>
Quoted 7 lines · wrote:
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
-----
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected],
[email protected], [email protected],"Krishnamraju
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Eraparaju"
Quoted 2 lines
<[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Replyhandler
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
tries to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
read beyond MPA message
while processing MPA Reply, SIW driver is trying to
read
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
extra
Quoted 5 lines
Quoted 5 lines
4
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
completed
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
reading MPA reply, then ksock_recv() in
siw_recv_mpa_rr()Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
could
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
also
Quoted 1 line
read FPDU, if "size" is larger than advertised MPA
reply
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
length.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
501 static int siw_recv_mpa_rr(struct siw_cep *cep)
502 {
.............
572
573 if (rcvd > to_rcv)
574 return -EPROTO; <----- Failurehere
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Looks like the intention here is to throw an ERROR if
the
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
received
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
data
is more than the total private data length advertisedby
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
the
Quoted 4 lines
Quoted 4 lines
peer.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
But
reading beyond MPA message causes siw_cm to generate
RDMA_CM_EVENT_CONNECT_ERROR event when TCP socket recvbuffer
Quoted 8 lines
Quoted 8 lines
is
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
already
queued with FPDU messages.Hence, this function should only read upto private data
length.
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Signed-off-by: Krishnamraju Eraparaju
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
---
drivers/infiniband/sw/siw/siw_cm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)diff --git a/drivers/infiniband/sw/siw/siw_cm.c
b/drivers/infiniband/sw/siw/siw_cm.c
index a7cde98e73e8..8dc8cea2566c 100644
--- a/drivers/infiniband/sw/siw/siw_cm.c
+++ b/drivers/infiniband/sw/siw/siw_cm.c
@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct
siw_cepQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
*cep)
Quoted 1 line
* A private data buffer gets allocated if
hdr->params.pd_lenQuoted 2 lines
Quoted 2 lines
!=
Quoted 1 line
Quoted 1 line
Quoted 1 line
0.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
*/
if (!cep->mpa.pdata) {
- cep->mpa.pdata = kmalloc(pd_len + 4, GFP_KERNEL);
+ cep->mpa.pdata = kmalloc(pd_len, GFP_KERNEL);
if (!cep->mpa.pdata)
return -ENOMEM;
}
rcvd = ksock_recv(
s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof(struct
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
mpa_rr),Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
- to_rcv + 4, MSG_DONTWAIT);
+ to_rcv, MSG_DONTWAIT);if (rcvd < 0)
return rcvd;
--
2.23.0.rc0The intention of this code is to make sure the
peer does not violates the MPA handshake rules.
The initiator MUST NOT send extra data after its
MPA request and before receiving the MPA reply.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
I think this is true only for MPA v2. With MPA v1, the initiator can begin sending immediately (before receiving the MPA reply), because there is no actual negotiation at the MPA layer.
With MPA v2, the negotiation exchange is required because the type of the following message is predicated by the "Enhanced mode" a|b|c|d flags present in the first 32
bits
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
of the private data buffer.
So, it seems to me that additional logic is needed here
to
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
determine the MPA version, before sniffing additional
octets
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
from the incoming stream?
Tom.
There still is the marker negotiation taking place. RFC 5044 says in section 7.1.2:
"Note: Since the receiver's ability to deal with Markers
is
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
unknown until the Request and Reply Frames have been received, sending FPDUs before this occurs is not
possible."
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
This section further discusses the responder's behavior, where it MUST receive a first FPDU from the initiator before sending its first FPDU:
"4. MPA Responder mode implementations MUST receive and
validate
Quoted 2 lines
Quoted 2 lines
at
Quoted 1 line
Quoted 1 line
least one FPDU before sending any FPDUs or
Markers."
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
So it appears with MPA version 1, the current siw code is correct. The initiator is entering FPDU mode first, and only after receiving the MPA reply frame. Only after the initiator sent a first FPDU, the responder can start using the connection in FPDU mode. Because of this somehow broken connection establishment procedure (only the initiator can start sending data), a later MPA version makes this first FPDU exchange explicit and selectable (zero length READ/WRITE/Send).
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Yeah, I guess so. Because nobody ever actually implemented
markers,
Quoted 1 line
Quoted 1 line
Quoted 1 line
I think that they may more or less passively ignore this.
But
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
you're
Quoted 3 lines
currect that it's invalid protocol behavior.
If your testing didn't uncover any issues with existing
implementations
Quoted 1 line
failing to connect with your strict checking, I'm ok with
it.
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct
Quoted 11 lines
Tom & Bernard,
Thanks for the insight on MPA negotiation.Could the below patch be considered as a proper fix?
drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -503,6 +503,7 @@ static int siw_recv_mpa_rr(struct
siw_cepQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
*cep)
Quoted 4 lines
Quoted 4 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-0struct socket *s = cep->sock;u16 pd_len;int rcvd, to_rcv; +int extra_data_check =4 ;/* 4Bytes, for MPA rules Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
violation
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct
Quoted 6 lines
checking */
if (
cep->mpa.bytes_rcvd<sizeof(struct mpa_rr)) {
rcvd = ksock_recv(s, (char *)hdr +cep->mpa.bytes_rcvd,drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -553,23 +554,37 @@ static int siw_recv_mpa_rr(struct
siw_cepQuoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
*cep)
Quoted 5 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct · line 558
Quoted 5 lines
drivers/infiniband/sw/siw/siw_cm.c +2
-0return -EPROTO ; } +/* +* Peer must not send any extra data other than MPA messages
Quoted 4 lines
Quoted 4 lines
until MPA
+ * negotiation is completed, an exception is MPA V2
client-server Mode,
+ * IE, in this mode the peer after sending MPA Replycan
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/infiniband/sw/siw/siw_cm.c
Quoted 3 lines
immediately
drivers/infiniband/sw/siw/siw_cm.c +2
-0+* start sending data in RDMA mode. +*/ This is unfortunately not true. The responder NEVER sends an FPDU without having seen an FPDU from the initiator. I just checked RFC 6581 again. The RTR (ready-to-receive) indication from the initiator is still needed, but now provided by the protocol and not the application: w/o 'enhanced MPA setup', the initiator sends the first FPDU as an application message. With 'enhanced MPA setup', the initiator protocol entity sends (w/o application interaction) a zero length READ/WRITE/Send as a first FPDU, as previously negotiated with the responder. Again: only after the responder has seen the first FPDU, it can start sending in FPDU mode.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
If I understand your statements correctly: in MPA v2
clint-server
Quoted 67 lines
Quoted 67 lines
Quoted 67 lines
Quoted 4 lines
Quoted 4 lines
mode,
the responder application should have some logic to wait(after ESTABLISH
event) until the first FPDU message is received from theinitiator?
Quoted 51 lines
Quoted 3 lines
Thanks,
Krishna.The responder may either delay the established event until it sees the first peer FPDU, or it delays sending the first (now already posted) FPDU, until it sees the first initiator FPDU. This, since (theoretically), the responder does not know yet the result of CRC and Marker negotiation. siw delays the established event, which seems the more clear path to me.
This MPA handshake is cumbersome. siw is permissive for violations of these rules to the extend, that the responder shall not send back to back the first FPDU with the MPA reply. If a (Chelsio ?) iWarp adapter would send the first responder FPDU only after it got TCP acked its MPA reply, the chances are high the (siw) iWarp initiator has already transitioned to RTS and it would accept that FPU, even if not having sent it's first FPDU.
siw sticks to this rule to that extend, since all receive processing is triggered by socket callbacks (from
sk->sk_data_ready()). As long as the QP is not
in RTS, all TCP bytestream processing is done by the MPA protocol (code insiw_cm.c). If the QP reaches RTS, RX processing is done bt the full iWarp protocol (code insiw_qp_rx.cfor RX).
Now, if the higher layer (application) protocol has a semantic where the responder sends the first message, we could end up in an infinite wait for that packet at initiator application side.
This, since the complete first FPDU was already received at the TCP socket, while the QP was not in RTS. It will not trigger any additionalsk->sk_data_ready()and we are stuck with a FPDU in the socket rx buffer.I implemented that 4 bytes extra data testing only to keep the siw protocol state machine as simple as possible (it is already unfortunately complex, if you count the lines in
siw_cm.c), while following the protocol rules.I suggest to correctly implement peer2peer mode and delay the established event at the responder side until it got the negotiated first zero length FPDU. Out of the possible options, siw supports both zero length WRITE and READ, but no SEND, since this would consume an extra receive WQE.
Quoted 5 lines
As a last resort, I might consider extending the siw state machine to handle those - non-complaint - cases gracefully. But, that would result in different code than just avoiding checking for peer protocol violation.
Bernard, everything you describe in siw seems perfectly valid to me, and in fact that's why the MPA enhanced connection mode was designed the way it is. I disagree that it's "cumbersome", but that's a nit.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
The issue is that the responder reaches RTS at a different time than the initiator reaches RTR. The original iWARP connection model did not make any requirement, and races were possible. MPAv2 fixes those.
Tom, thanks, exactly. MPAv2 fixes it. And an implementation
Thanks Bernard & Tom,
Could you also please consider making MPA ehanced connection mode(with RTR handshake) as default for SIW, as MPA V2 peer- to-peer mode seems to be more promising that MPA V2 client-server Mode, wrt race conditions.
Currently SIW has MPA V2 client-server Mode as default.
Quoted 7 lines
In
siw_main.c:const bool peer_to_peer = 1;Between, as per my observations, the chances of hitting this 'connect
error' issue is higher with: SIW(initator)<--->(responder)SIW
than: SIW(initator) <---> (responder)hard-iwarp
Quoted 8 lines
Good to know! Yes, siw is permissive at responder side, it's applications responsibility to delay the first message, if p2p mode is not selected.
What application are you using here (which let's
the responder immediately start using the SQ)? Just to let me re-create the case w/o effort.
I might produce a fix for siw which can handle that case for the non-p2p-mode case.
I originally noticed this issue with a bidirectional bandwidth measurement tool(that we use internally).
Later I wrote a small program to quickly recreate this issue. please follow the below steps:
- git clone https://github.com/krishna-e/rdma-example-programs
- cd rdma-example-programs/IBV_WR_RDMA_WRITE_for_SIW_plus_4_issue/
- server side:
# cc -g server.c -libverbs -lrdmacm -o server # ./server <any_integer_data>
- client side:
# echo -n 'module siw +p' >
# /sys/kernel/debug/dynamic_debug/control
(just to slow down the client processing by enabling traces)# cc -g client.c -libverbs -lrdmacm -o client # ./client <ip_address>
output:
Unexpected event : RDMA_CM_EVENT_CONNECT_ERROR
Quoted 159 lines
Setting p2p mode as default is another option. I am not immediately happy with that suggestion, since it adds another wire transfer as default. The future shall see those parameters settable. These were module parameters, but we abandoned that. We should probably come up with an extension to the RDMA netlink interface, which makes those protocol specific modes and flavors settable per device...?
Thanks
Bernard.Quoted 146 lines
Quoted 18 lines
Quoted 11 lines
of that fix MUST adhere to the defined rules. If one negotiates an extra handshake to synchronize, it MUST adhere to that handshake rules. There is no point in negotiating an extra handshake, and right away ignoring it. If the responder wants a zero length WRITE, it MUST use its reception to synchronize its transition to RTS.
Shall we extend the siw state machine to support silly peer behavior? As said, if I read there is no way of
Of course the right answer to this is "no", but I'd reserve drawing that conclusion until I am certain it won't cause trouble. If existing iWARP implementations don't enforce this, and SIW becomes the odd duck failing connections, then I'm afraid I would have to say "yes" instead.
Quoted 44 lines
Quoted 3 lines
making the peer implementation RFC compliant (it would be unexpected), I'll look into the applicability of Postel's Rule. But let's make those things explicit.
Explicit is best, agreed.
Tom.
Quoted 36 lines
Quoted 10 lines
SIW is certainly within its rights to prevent peers from sending prior to responder RTR. I'd suggest that if possible, you try to detect the deadlock rather than flatly rejecting any incoming bytes. The Internet Principle (be liberal in what you accept...), after all.
This same dance happens in IB/RoCE, btw. Just via different messages.
Interesting!
Thanks
Bernard.Quoted 21 lines
Tom.
Quoted 18 lines
Thanks,
Bernard.Quoted 13 lines
Quoted 13 lines
Sorry for the confusion. But the current
siw code appears to be just correct.Thanks
BernardQuoted 4 lines
+ if ((
__mpa_rr_revision(cep->mpa.hdr.params.bits)==MPA_REVISION_2) &&drivers/infiniband/sw/siw/siw_cm.c +2
-0+ (cep->state == SIW_EPSTATE_AWAIT_MPAREP)) { +int mpa_p2p_mode = cep->mpa.v2_ctrl_req.ord&
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/infiniband/sw/siw/siw_cm.c
Quoted 8 lines
+ (
MPA_V2_RDMA_WRITE_RTR|MPA_V2_RDMA_READ_RTR);drivers/infiniband/sw/siw/siw_cm.c +4
-0+if (!mpa_p2p_mode) + extra_data_check =0 ; + } +/* * At this point, we must have hdr->params.pd_len != 0.
Quoted 72 lines
Quoted 72 lines
Quoted 69 lines
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
* A private data buffer gets allocated if
hdr->params.pd_lenQuoted 5 lines
Quoted 5 lines
!=
* 0. */ if (!cep->mpa.pdata) {-
cep->mpa.pdata= kmalloc(pd_len + 4,
GFP_KERNEL);Quoted 59 lines
Quoted 59 lines
Quoted 1 line
Quoted 1 line
+
cep->mpa.pdata= kmalloc(pd_len +
extra_data_check,Quoted 57 lines
Quoted 57 lines
GFP_KERNEL); if (!cep->mpa.pdata) return -ENOMEM; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof(struct
mpa_rr),drivers/infiniband/sw/siw/siw_cm.c +2
-3- to_rcv + 4, MSG_DONTWAIT); + to_rcv + extra_data_check, MSG_DONTWAIT);if (rcvd <0 )return rcvd; -if (rcvd > to_rcv) +if (extra_data_check && (rcvd > to_rcv))return -EPROTO ; cep->mpa.bytes_rcvd += rcvd; -Krishna.Quoted 36 lines
Tom.
Quoted 31 lines
Bernard.
Quoted 28 lines
Quoted 28 lines
So, for the MPA request case, this code is needed
to check for protocol correctness.
You are right for the MPA reply case - if we are
_not_ in peer2peer mode, the peer can immediately
start sending data in RDMA mode after its MPA Reply.
So we shall add appropriate code to be more specific
For an error, we are (1) processing an MPA Request,
OR (2) processing an MPA Reply AND we are not expected
to send an initial READ/WRITE/Send as negotiated with
the peer (peer2peer mode MPA handshake).Just removing this check would make siw more permissive,
but to a point where peer MPA protocol errors are
tolerated. I am not in favor of that level of
forgiveness.If possible, please provide an appropriate patch
or (if it causes current issues with another peer
iWarp implementation) just run in MPA peer2peer mode,
where the current check is appropriate.
Otherwise, I would provide an appropriate fix by Monday
(I am still out of office this week).Many thanks and best regards,
Bernard.
Quoted 215 lines · Krishnamraju Eraparaju
Quoted 206 lines · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote: -----
Quoted 197 lines
To: "Tom Talpey" <[email protected]>, <[email protected]>
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 08/05/2019 07:26PM
Cc: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>, "Potnuri Bharat Teja" <[email protected]>, "Nirranjan Kirubaharan" <[email protected]>
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handler tries to read beyond MPA messageQuoted 4 lines · Tom Talpey
Quoted 3 lines · Bernard Metzler
-----"Tom Talpey" <[email protected]> wrote: -----
Quoted 1 line
To: "Bernard Metzler" <[email protected]>, "Krishnamraju
Eraparaju"
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
<[email protected]>
From: "Tom Talpey" <[email protected]>
Date: 08/01/2019 08:54PM
Cc: [email protected], [email protected],Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[email protected], [email protected]
Subject: [EXTERNAL] Re: [PATCH for-rc] siw: MPA Reply handlertries
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
to read beyond MPA message
Quoted 1 line · Bernard Metzler
-----"Krishnamraju Eraparaju" <[email protected]> wrote:
-----
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
To: [email protected], [email protected]
From: "Krishnamraju Eraparaju" <[email protected]>
Date: 07/31/2019 12:34PM
Cc: [email protected], [email protected], [email protected], [email protected], "KrishnamrajuEraparaju"
Quoted 2 lines
Quoted 2 lines
<[email protected]>
Subject: [EXTERNAL] [PATCH for-rc] siw: MPA Reply handlertries to
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
read beyond MPA message
while processing MPA Reply, SIW driver is trying to read extra
4
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
bytes
than what peer has advertised as private data length.If a FPDU data is received before even
siw_recv_mpa_rr()completed
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
reading MPA reply, then
ksock_recv()insiw_recv_mpa_rr()could
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
also
Quoted 1 line
Quoted 1 line
read FPDU, if "size" is larger than advertised MPA reply
length.
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
501 static int
siw_recv_mpa_rr(struct siw_cep *cep)502 { .............572
573 if (rcvd >to_rcv)
574 return-EPROTO; <----- Failure hereLooks like the intention here is to throw an ERROR if the
received
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
data
is more than the total private data length advertised by thepeer.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
But
reading beyond MPA message causessiw_cmto generateRDMA_CM_EVENT_CONNECT_ERRORevent when TCP socket recv bufferis
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
already
queued with FPDU messages.Hence, this function should only read upto private data
length.
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Signed-off-by Krishnamraju Eraparaju <[email protected]>---
drivers/infiniband/sw/siw/siw_cm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct
Quoted 6 lines
drivers/infiniband/sw/siw/siw_cm.c +0
-0@@ -559,13 +559,13 @@ static int siw_recv_mpa_rr(struct
siw_cepQuoted 2 lines
Quoted 2 lines
Quoted 2 lines
*cep)
Quoted 1 line
Quoted 1 line
drivers/infiniband/sw/siw/siw_cm.c +0
-0* A private data buffer gets allocated if hdr->params.pd_len !=
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
0.
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c static int siw_recv_mpa_rr(struct · line 567
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1*/ if (!cep->mpa.pdata) { - cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata =kmalloc (pd_len,GFP_KERNEL );if (!cep->mpa.pdata)return -ENOMEM ; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd - sizeof(struct
mpa_rr),Quoted 39 lines
Quoted 39 lines
Quoted 25 lines
Quoted 14 lines
Quoted 9 lines
drivers/infiniband/sw/siw/siw_cm.c +1
-1- to_rcv + 4, MSG_DONTWAIT); + to_rcv, MSG_DONTWAIT);if (rcvd <0 )return rcvd;Signature · 1 line
2.23.0.rc0The intention of this code is to make sure the peer does not violates the MPA handshake rules. The initiator MUST NOT send extra data after its MPA request and before receiving the MPA reply.
I think this is true only for MPA v2. With MPA v1, the initiator can begin sending immediately (before receiving the MPA reply), because there is no actual negotiation at the MPA layer.
With MPA v2, the negotiation exchange is required because the type of the following message is predicated by the "Enhanced mode" a|b|c|d flags present in the first 32 bits of the private data buffer.
Quoted 6 lines
So, it seems to me that additional logic is needed here to determine the MPA version, before sniffing additional octets from the incoming stream?
Tom.
There still is the marker negotiation taking place. RFC 5044 says in section 7.1.2:
"Note: Since the receiver's ability to deal with Markers is
unknown until the Request and Reply Frames have been received, sending FPDUs before this occurs is not possible."Quoted 5 lines
Quoted 5 lines
This section further discusses the responder's behavior, where it MUST receive a first FPDU from the initiator before sending its first FPDU:
"4. MPA Responder mode implementations MUST receive and validate
at
Quoted 12 lines
Quoted 11 lines
least one FPDU before sending any FPDUs or Markers."
So it appears with MPA version 1, the current siw code is correct. The initiator is entering FPDU mode first, and only after receiving the MPA reply frame. Only after the initiator sent a first FPDU, the responder can start using the connection in FPDU mode. Because of this somehow broken connection establishment procedure (only the initiator can start sending data), a later MPA version makes this first FPDU exchange explicit and selectable (zero length READ/WRITE/Send).
Quoted 2 lines
Yeah, I guess so. Because nobody ever actually implemented markers, I think that they may more or less passively ignore this. But
you're
Quoted 3 lines
currect that it's invalid protocol behavior.
If your testing didn't uncover any issues with existing
implementations
Quoted 1 line
failing to connect with your strict checking, I'm ok with it.
Tom & Bernard,
Thanks for the insight on MPA negotiation.Could the below patch be considered as a proper fix?
drivers/infiniband/sw/siw/siw_cm.c +1
-0@@ -503,6 +503,7 @@ static int siw_recv_mpa_rr(struct siw_cep *cep)struct socket *s = cep->sock;u16 pd_len;int rcvd, to_rcv; +int extra_data_check =4 ;/* 4Bytes, for MPA rules violation checking */
if (
cep->mpa.bytes_rcvd<sizeof(struct mpa_rr)) {
rcvd = ksock_recv(s, (char *)hdr +cep->mpa.bytes_rcvd,drivers/infiniband/sw/siw/siw_cm.c +2
-0@@ -553,23 +554,37 @@ static int siw_recv_mpa_rr(struct siw_cep *cep)return -EPROTO ; } +/* +* Peer must not send any extra data other than MPA messages until MPA
+ * negotiation is completed, an exception is MPA V2
client-server Mode,
+ * IE, in this mode the peer after sending MPA Reply can
immediatelydrivers/infiniband/sw/siw/siw_cm.c
Quoted 2 lines
drivers/infiniband/sw/siw/siw_cm.c +2
-0+* start sending data in RDMA mode. +*/ This is unfortunately not true. The responder NEVER sends an FPDU without having seen an FPDU from the initiator. I just checked RFC 6581 again. The RTR (ready-to-receive) indication from the initiator is still needed, but now
Quoted 8 lines
provided by the protocol and not the application: w/o 'enhanced MPA setup', the initiator sends the first FPDU as an application message. With 'enhanced MPA setup', the initiator protocol entity sends (w/o application interaction) a zero length READ/WRITE/Send as a first FPDU, as previously negotiated with the responder. Again: only after the responder has seen the first FPDU, it can start sending in FPDU mode.
Quoted 3 lines
If I understand your statements correctly: in MPA v2 clint-server mode, the responder application should have some logic to wait(after ESTABLISH event) until the first FPDU message is received from the initiator?
Krishna, this is not the application's responsibility. This is MPA, and the iWARP provider's domain.
Tom.
Quoted 100 lines
Thanks,
Krishna.Quoted 95 lines
Sorry for the confusion. But the current
siw code appears to be just correct.Thanks
BernardQuoted 85 lines
+ if ((
__mpa_rr_revision(cep->mpa.hdr.params.bits)==MPA_REVISION_2) &&drivers/infiniband/sw/siw/siw_cm.c +3
-0+ (cep->state == SIW_EPSTATE_AWAIT_MPAREP)) { + int mpa_p2p_mode = cep->mpa.v2_ctrl_req.ord & + (MPA_V2_RDMA_WRITE_RTR |
MPA_V2_RDMA_READ_RTR);drivers/infiniband/sw/siw/siw_cm.c +4
-0+if (!mpa_p2p_mode) + extra_data_check =0 ; + } +/* * At this point, we must have hdr->params.pd_len != 0. * A private data buffer gets allocated if hdr->params.pd_len !=
* 0. */ if (!cep->mpa.pdata) {drivers/infiniband/sw/siw/siw_cm.c +1
-1- cep->mpa.pdata =kmalloc (pd_len +4 ,GFP_KERNEL ); + cep->mpa.pdata = kmalloc(pd_len + extra_data_check,GFP_KERNEL); if (!cep->mpa.pdata) return -ENOMEM; } rcvd = ksock_recv( s, cep->mpa.pdata + cep->mpa.bytes_rcvd -sizeof(struct
mpa_rr),drivers/infiniband/sw/siw/siw_cm.c +2
-3- to_rcv + 4, MSG_DONTWAIT); + to_rcv + extra_data_check, MSG_DONTWAIT);if (rcvd <0 )return rcvd; -if (rcvd > to_rcv) +if (extra_data_check && (rcvd > to_rcv))return -EPROTO ; cep->mpa.bytes_rcvd += rcvd; -Krishna.Quoted 43 lines
Tom.
Quoted 38 lines
Bernard.
Quoted 32 lines
Quoted 30 lines
So, for the MPA request case, this code is needed to check for protocol correctness.
You are right for the MPA reply case - if we are _not_ in peer2peer mode, the peer can immediately start sending data in RDMA mode after its MPA Reply. So we shall add appropriate code to be more specific For an error, we are (1) processing an MPA Request, OR (2) processing an MPA Reply AND we are not expected to send an initial READ/WRITE/Send as negotiated with the peer (peer2peer mode MPA handshake).Just removing this check would make siw more permissive, but to a point where peer MPA protocol errors are tolerated. I am not in favor of that level of forgiveness.
If possible, please provide an appropriate patch or (if it causes current issues with another peer iWarp implementation) just run in MPA peer2peer mode, where the current check is appropriate. Otherwise, I would provide an appropriate fix by Monday (I am still out of office this week).
Many thanks and best regards,
Bernard.