forked from Minki/linux
net/smc: add v2 format of CLC decline message
The CLC decline message changed with SMC-Rv2 and supports up to 4 additional diagnosis codes. Signed-off-by: Karsten Graul <kgraul@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e49300a6bf
commit
8ade200c26
@ -400,6 +400,24 @@ smc_clc_msg_acc_conf_valid(struct smc_clc_msg_accept_confirm_v2 *clc_v2)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check arriving CLC decline */
|
||||||
|
static bool
|
||||||
|
smc_clc_msg_decl_valid(struct smc_clc_msg_decline *dclc)
|
||||||
|
{
|
||||||
|
struct smc_clc_msg_hdr *hdr = &dclc->hdr;
|
||||||
|
|
||||||
|
if (hdr->typev1 != SMC_TYPE_R && hdr->typev1 != SMC_TYPE_D)
|
||||||
|
return false;
|
||||||
|
if (hdr->version == SMC_V1) {
|
||||||
|
if (ntohs(hdr->length) != sizeof(struct smc_clc_msg_decline))
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
if (ntohs(hdr->length) != sizeof(struct smc_clc_msg_decline_v2))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static void smc_clc_fill_fce(struct smc_clc_first_contact_ext *fce, int *len)
|
static void smc_clc_fill_fce(struct smc_clc_first_contact_ext *fce, int *len)
|
||||||
{
|
{
|
||||||
memset(fce, 0, sizeof(*fce));
|
memset(fce, 0, sizeof(*fce));
|
||||||
@ -441,9 +459,9 @@ static bool smc_clc_msg_hdr_valid(struct smc_clc_msg_hdr *clcm, bool check_trl)
|
|||||||
break;
|
break;
|
||||||
case SMC_CLC_DECLINE:
|
case SMC_CLC_DECLINE:
|
||||||
dclc = (struct smc_clc_msg_decline *)clcm;
|
dclc = (struct smc_clc_msg_decline *)clcm;
|
||||||
if (ntohs(dclc->hdr.length) != sizeof(*dclc))
|
if (!smc_clc_msg_decl_valid(dclc))
|
||||||
return false;
|
return false;
|
||||||
trl = &dclc->trl;
|
check_trl = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
@ -742,15 +760,16 @@ out:
|
|||||||
/* send CLC DECLINE message across internal TCP socket */
|
/* send CLC DECLINE message across internal TCP socket */
|
||||||
int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info, u8 version)
|
int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info, u8 version)
|
||||||
{
|
{
|
||||||
struct smc_clc_msg_decline dclc;
|
struct smc_clc_msg_decline *dclc_v1;
|
||||||
|
struct smc_clc_msg_decline_v2 dclc;
|
||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
|
int len, send_len;
|
||||||
struct kvec vec;
|
struct kvec vec;
|
||||||
int len;
|
|
||||||
|
|
||||||
|
dclc_v1 = (struct smc_clc_msg_decline *)&dclc;
|
||||||
memset(&dclc, 0, sizeof(dclc));
|
memset(&dclc, 0, sizeof(dclc));
|
||||||
memcpy(dclc.hdr.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER));
|
memcpy(dclc.hdr.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER));
|
||||||
dclc.hdr.type = SMC_CLC_DECLINE;
|
dclc.hdr.type = SMC_CLC_DECLINE;
|
||||||
dclc.hdr.length = htons(sizeof(struct smc_clc_msg_decline));
|
|
||||||
dclc.hdr.version = version;
|
dclc.hdr.version = version;
|
||||||
dclc.os_type = version == SMC_V1 ? 0 : SMC_CLC_OS_LINUX;
|
dclc.os_type = version == SMC_V1 ? 0 : SMC_CLC_OS_LINUX;
|
||||||
dclc.hdr.typev2 = (peer_diag_info == SMC_CLC_DECL_SYNCERR) ?
|
dclc.hdr.typev2 = (peer_diag_info == SMC_CLC_DECL_SYNCERR) ?
|
||||||
@ -760,14 +779,22 @@ int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info, u8 version)
|
|||||||
memcpy(dclc.id_for_peer, local_systemid,
|
memcpy(dclc.id_for_peer, local_systemid,
|
||||||
sizeof(local_systemid));
|
sizeof(local_systemid));
|
||||||
dclc.peer_diagnosis = htonl(peer_diag_info);
|
dclc.peer_diagnosis = htonl(peer_diag_info);
|
||||||
memcpy(dclc.trl.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER));
|
if (version == SMC_V1) {
|
||||||
|
memcpy(dclc_v1->trl.eyecatcher, SMC_EYECATCHER,
|
||||||
|
sizeof(SMC_EYECATCHER));
|
||||||
|
send_len = sizeof(*dclc_v1);
|
||||||
|
} else {
|
||||||
|
memcpy(dclc.trl.eyecatcher, SMC_EYECATCHER,
|
||||||
|
sizeof(SMC_EYECATCHER));
|
||||||
|
send_len = sizeof(dclc);
|
||||||
|
}
|
||||||
|
dclc.hdr.length = htons(send_len);
|
||||||
|
|
||||||
memset(&msg, 0, sizeof(msg));
|
memset(&msg, 0, sizeof(msg));
|
||||||
vec.iov_base = &dclc;
|
vec.iov_base = &dclc;
|
||||||
vec.iov_len = sizeof(struct smc_clc_msg_decline);
|
vec.iov_len = send_len;
|
||||||
len = kernel_sendmsg(smc->clcsock, &msg, &vec, 1,
|
len = kernel_sendmsg(smc->clcsock, &msg, &vec, 1, send_len);
|
||||||
sizeof(struct smc_clc_msg_decline));
|
if (len < 0 || len < send_len)
|
||||||
if (len < 0 || len < sizeof(struct smc_clc_msg_decline))
|
|
||||||
len = -EPROTO;
|
len = -EPROTO;
|
||||||
return len > 0 ? 0 : len;
|
return len > 0 ? 0 : len;
|
||||||
}
|
}
|
||||||
|
@ -281,6 +281,24 @@ struct smc_clc_msg_decline { /* clc decline message */
|
|||||||
struct smc_clc_msg_trail trl; /* eye catcher "SMCD" or "SMCR" EBCDIC */
|
struct smc_clc_msg_trail trl; /* eye catcher "SMCD" or "SMCR" EBCDIC */
|
||||||
} __aligned(4);
|
} __aligned(4);
|
||||||
|
|
||||||
|
#define SMC_DECL_DIAG_COUNT_V2 4 /* no. of additional peer diagnosis codes */
|
||||||
|
|
||||||
|
struct smc_clc_msg_decline_v2 { /* clc decline message */
|
||||||
|
struct smc_clc_msg_hdr hdr;
|
||||||
|
u8 id_for_peer[SMC_SYSTEMID_LEN]; /* sender peer_id */
|
||||||
|
__be32 peer_diagnosis; /* diagnosis information */
|
||||||
|
#if defined(__BIG_ENDIAN_BITFIELD)
|
||||||
|
u8 os_type : 4,
|
||||||
|
reserved : 4;
|
||||||
|
#elif defined(__LITTLE_ENDIAN_BITFIELD)
|
||||||
|
u8 reserved : 4,
|
||||||
|
os_type : 4;
|
||||||
|
#endif
|
||||||
|
u8 reserved2[3];
|
||||||
|
__be32 peer_diagnosis_v2[SMC_DECL_DIAG_COUNT_V2];
|
||||||
|
struct smc_clc_msg_trail trl; /* eye catcher "SMCD" or "SMCR" EBCDIC */
|
||||||
|
} __aligned(4);
|
||||||
|
|
||||||
/* determine start of the prefix area within the proposal message */
|
/* determine start of the prefix area within the proposal message */
|
||||||
static inline struct smc_clc_msg_proposal_prefix *
|
static inline struct smc_clc_msg_proposal_prefix *
|
||||||
smc_clc_proposal_get_prefix(struct smc_clc_msg_proposal *pclc)
|
smc_clc_proposal_get_prefix(struct smc_clc_msg_proposal *pclc)
|
||||||
|
Loading…
Reference in New Issue
Block a user