License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2017-01-09 23:55:16 +08:00
|
|
|
/*
|
|
|
|
* Shared Memory Communications over RDMA (SMC-R) and RoCE
|
|
|
|
*
|
|
|
|
* CLC (connection layer control) handshake over initial TCP socket to
|
|
|
|
* prepare for RDMA traffic
|
|
|
|
*
|
2018-03-16 22:06:40 +08:00
|
|
|
* Copyright IBM Corp. 2016, 2018
|
2017-01-09 23:55:16 +08:00
|
|
|
*
|
|
|
|
* Author(s): Ursula Braun <ubraun@linux.vnet.ibm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/in.h>
|
2018-03-01 20:51:27 +08:00
|
|
|
#include <linux/inetdevice.h>
|
2017-01-12 21:57:15 +08:00
|
|
|
#include <linux/if_ether.h>
|
2017-02-02 15:35:14 +08:00
|
|
|
#include <linux/sched/signal.h>
|
|
|
|
|
2018-03-16 22:06:40 +08:00
|
|
|
#include <net/addrconf.h>
|
2017-01-09 23:55:16 +08:00
|
|
|
#include <net/sock.h>
|
|
|
|
#include <net/tcp.h>
|
|
|
|
|
|
|
|
#include "smc.h"
|
2017-01-09 23:55:17 +08:00
|
|
|
#include "smc_core.h"
|
2017-01-09 23:55:16 +08:00
|
|
|
#include "smc_clc.h"
|
|
|
|
#include "smc_ib.h"
|
2018-06-29 01:05:09 +08:00
|
|
|
#include "smc_ism.h"
|
|
|
|
|
|
|
|
#define SMCR_CLC_ACCEPT_CONFIRM_LEN 68
|
|
|
|
#define SMCD_CLC_ACCEPT_CONFIRM_LEN 48
|
2020-07-08 23:05:15 +08:00
|
|
|
#define SMC_CLC_RECV_BUF_LEN 100
|
2017-01-09 23:55:16 +08:00
|
|
|
|
2018-03-01 20:51:26 +08:00
|
|
|
/* eye catcher "SMCR" EBCDIC for CLC messages */
|
|
|
|
static const char SMC_EYECATCHER[4] = {'\xe2', '\xd4', '\xc3', '\xd9'};
|
2018-06-29 01:05:09 +08:00
|
|
|
/* eye catcher "SMCD" EBCDIC for CLC messages */
|
|
|
|
static const char SMCD_EYECATCHER[4] = {'\xe2', '\xd4', '\xc3', '\xc4'};
|
2018-03-01 20:51:26 +08:00
|
|
|
|
2017-12-07 20:38:49 +08:00
|
|
|
/* check if received message has a correct header length and contains valid
|
|
|
|
* heading and trailing eyecatchers
|
|
|
|
*/
|
2020-07-08 23:05:15 +08:00
|
|
|
static bool smc_clc_msg_hdr_valid(struct smc_clc_msg_hdr *clcm, bool check_trl)
|
2017-12-07 20:38:49 +08:00
|
|
|
{
|
|
|
|
struct smc_clc_msg_proposal_prefix *pclc_prfx;
|
|
|
|
struct smc_clc_msg_accept_confirm *clc;
|
|
|
|
struct smc_clc_msg_proposal *pclc;
|
|
|
|
struct smc_clc_msg_decline *dclc;
|
|
|
|
struct smc_clc_msg_trail *trl;
|
|
|
|
|
2018-06-29 01:05:09 +08:00
|
|
|
if (memcmp(clcm->eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER)) &&
|
|
|
|
memcmp(clcm->eyecatcher, SMCD_EYECATCHER, sizeof(SMCD_EYECATCHER)))
|
2017-12-07 20:38:49 +08:00
|
|
|
return false;
|
|
|
|
switch (clcm->type) {
|
|
|
|
case SMC_CLC_PROPOSAL:
|
|
|
|
pclc = (struct smc_clc_msg_proposal *)clcm;
|
|
|
|
pclc_prfx = smc_clc_proposal_get_prefix(pclc);
|
2020-07-08 23:05:15 +08:00
|
|
|
if (ntohs(pclc->hdr.length) <
|
2017-12-07 20:38:49 +08:00
|
|
|
sizeof(*pclc) + ntohs(pclc->iparea_offset) +
|
|
|
|
sizeof(*pclc_prfx) +
|
|
|
|
pclc_prfx->ipv6_prefixes_cnt *
|
|
|
|
sizeof(struct smc_clc_ipv6_prefix) +
|
|
|
|
sizeof(*trl))
|
|
|
|
return false;
|
|
|
|
trl = (struct smc_clc_msg_trail *)
|
|
|
|
((u8 *)pclc + ntohs(pclc->hdr.length) - sizeof(*trl));
|
|
|
|
break;
|
|
|
|
case SMC_CLC_ACCEPT:
|
|
|
|
case SMC_CLC_CONFIRM:
|
2018-06-29 01:05:09 +08:00
|
|
|
if (clcm->path != SMC_TYPE_R && clcm->path != SMC_TYPE_D)
|
|
|
|
return false;
|
2017-12-07 20:38:49 +08:00
|
|
|
clc = (struct smc_clc_msg_accept_confirm *)clcm;
|
2018-06-29 01:05:09 +08:00
|
|
|
if ((clcm->path == SMC_TYPE_R &&
|
|
|
|
ntohs(clc->hdr.length) != SMCR_CLC_ACCEPT_CONFIRM_LEN) ||
|
|
|
|
(clcm->path == SMC_TYPE_D &&
|
|
|
|
ntohs(clc->hdr.length) != SMCD_CLC_ACCEPT_CONFIRM_LEN))
|
2017-12-07 20:38:49 +08:00
|
|
|
return false;
|
2018-06-29 01:05:09 +08:00
|
|
|
trl = (struct smc_clc_msg_trail *)
|
|
|
|
((u8 *)clc + ntohs(clc->hdr.length) - sizeof(*trl));
|
2017-12-07 20:38:49 +08:00
|
|
|
break;
|
|
|
|
case SMC_CLC_DECLINE:
|
|
|
|
dclc = (struct smc_clc_msg_decline *)clcm;
|
|
|
|
if (ntohs(dclc->hdr.length) != sizeof(*dclc))
|
|
|
|
return false;
|
|
|
|
trl = &dclc->trl;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
2020-07-08 23:05:15 +08:00
|
|
|
if (check_trl &&
|
|
|
|
memcmp(trl->eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER)) &&
|
2018-06-29 01:05:09 +08:00
|
|
|
memcmp(trl->eyecatcher, SMCD_EYECATCHER, sizeof(SMCD_EYECATCHER)))
|
2017-12-07 20:38:49 +08:00
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-03-16 22:06:39 +08:00
|
|
|
/* find ipv4 addr on device and get the prefix len, fill CLC proposal msg */
|
|
|
|
static int smc_clc_prfx_set4_rcu(struct dst_entry *dst, __be32 ipv4,
|
|
|
|
struct smc_clc_msg_proposal_prefix *prop)
|
|
|
|
{
|
|
|
|
struct in_device *in_dev = __in_dev_get_rcu(dst->dev);
|
2019-06-01 00:27:07 +08:00
|
|
|
const struct in_ifaddr *ifa;
|
2018-03-16 22:06:39 +08:00
|
|
|
|
|
|
|
if (!in_dev)
|
|
|
|
return -ENODEV;
|
2019-06-01 00:27:07 +08:00
|
|
|
|
|
|
|
in_dev_for_each_ifa_rcu(ifa, in_dev) {
|
2018-03-16 22:06:39 +08:00
|
|
|
if (!inet_ifa_match(ipv4, ifa))
|
|
|
|
continue;
|
|
|
|
prop->prefix_len = inet_mask_len(ifa->ifa_mask);
|
|
|
|
prop->outgoing_subnet = ifa->ifa_address & ifa->ifa_mask;
|
|
|
|
/* prop->ipv6_prefixes_cnt = 0; already done by memset before */
|
|
|
|
return 0;
|
2019-06-01 00:27:07 +08:00
|
|
|
}
|
2018-03-16 22:06:39 +08:00
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2018-03-16 22:06:40 +08:00
|
|
|
/* fill CLC proposal msg with ipv6 prefixes from device */
|
|
|
|
static int smc_clc_prfx_set6_rcu(struct dst_entry *dst,
|
|
|
|
struct smc_clc_msg_proposal_prefix *prop,
|
|
|
|
struct smc_clc_ipv6_prefix *ipv6_prfx)
|
|
|
|
{
|
|
|
|
#if IS_ENABLED(CONFIG_IPV6)
|
|
|
|
struct inet6_dev *in6_dev = __in6_dev_get(dst->dev);
|
|
|
|
struct inet6_ifaddr *ifa;
|
|
|
|
int cnt = 0;
|
|
|
|
|
|
|
|
if (!in6_dev)
|
|
|
|
return -ENODEV;
|
|
|
|
/* use a maximum of 8 IPv6 prefixes from device */
|
|
|
|
list_for_each_entry(ifa, &in6_dev->addr_list, if_list) {
|
|
|
|
if (ipv6_addr_type(&ifa->addr) & IPV6_ADDR_LINKLOCAL)
|
|
|
|
continue;
|
|
|
|
ipv6_addr_prefix(&ipv6_prfx[cnt].prefix,
|
|
|
|
&ifa->addr, ifa->prefix_len);
|
|
|
|
ipv6_prfx[cnt].prefix_len = ifa->prefix_len;
|
|
|
|
cnt++;
|
|
|
|
if (cnt == SMC_CLC_MAX_V6_PREFIX)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
prop->ipv6_prefixes_cnt = cnt;
|
|
|
|
if (cnt)
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2018-03-16 22:06:39 +08:00
|
|
|
/* retrieve and set prefixes in CLC proposal msg */
|
|
|
|
static int smc_clc_prfx_set(struct socket *clcsock,
|
2018-03-16 22:06:40 +08:00
|
|
|
struct smc_clc_msg_proposal_prefix *prop,
|
|
|
|
struct smc_clc_ipv6_prefix *ipv6_prfx)
|
2018-03-01 20:51:27 +08:00
|
|
|
{
|
|
|
|
struct dst_entry *dst = sk_dst_get(clcsock->sk);
|
2018-03-16 22:06:39 +08:00
|
|
|
struct sockaddr_storage addrs;
|
2018-03-16 22:06:40 +08:00
|
|
|
struct sockaddr_in6 *addr6;
|
2018-03-16 22:06:39 +08:00
|
|
|
struct sockaddr_in *addr;
|
2018-03-01 20:51:27 +08:00
|
|
|
int rc = -ENOENT;
|
|
|
|
|
|
|
|
if (!dst) {
|
|
|
|
rc = -ENOTCONN;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (!dst->dev) {
|
|
|
|
rc = -ENODEV;
|
|
|
|
goto out_rel;
|
|
|
|
}
|
|
|
|
/* get address to which the internal TCP socket is bound */
|
2018-03-16 22:06:39 +08:00
|
|
|
kernel_getsockname(clcsock, (struct sockaddr *)&addrs);
|
|
|
|
/* analyze IP specific data of net_device belonging to TCP socket */
|
2018-03-16 22:06:40 +08:00
|
|
|
addr6 = (struct sockaddr_in6 *)&addrs;
|
2018-03-01 20:51:27 +08:00
|
|
|
rcu_read_lock();
|
2018-03-16 22:06:39 +08:00
|
|
|
if (addrs.ss_family == PF_INET) {
|
|
|
|
/* IPv4 */
|
|
|
|
addr = (struct sockaddr_in *)&addrs;
|
|
|
|
rc = smc_clc_prfx_set4_rcu(dst, addr->sin_addr.s_addr, prop);
|
2018-03-16 22:06:40 +08:00
|
|
|
} else if (ipv6_addr_v4mapped(&addr6->sin6_addr)) {
|
|
|
|
/* mapped IPv4 address - peer is IPv4 only */
|
|
|
|
rc = smc_clc_prfx_set4_rcu(dst, addr6->sin6_addr.s6_addr32[3],
|
|
|
|
prop);
|
|
|
|
} else {
|
|
|
|
/* IPv6 */
|
|
|
|
rc = smc_clc_prfx_set6_rcu(dst, prop, ipv6_prfx);
|
2018-03-16 22:06:39 +08:00
|
|
|
}
|
|
|
|
rcu_read_unlock();
|
|
|
|
out_rel:
|
|
|
|
dst_release(dst);
|
|
|
|
out:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* match ipv4 addrs of dev against addr in CLC proposal */
|
|
|
|
static int smc_clc_prfx_match4_rcu(struct net_device *dev,
|
|
|
|
struct smc_clc_msg_proposal_prefix *prop)
|
|
|
|
{
|
|
|
|
struct in_device *in_dev = __in_dev_get_rcu(dev);
|
2019-06-01 00:27:07 +08:00
|
|
|
const struct in_ifaddr *ifa;
|
2018-03-16 22:06:39 +08:00
|
|
|
|
|
|
|
if (!in_dev)
|
|
|
|
return -ENODEV;
|
2019-06-01 00:27:07 +08:00
|
|
|
in_dev_for_each_ifa_rcu(ifa, in_dev) {
|
2018-03-16 22:06:39 +08:00
|
|
|
if (prop->prefix_len == inet_mask_len(ifa->ifa_mask) &&
|
|
|
|
inet_ifa_match(prop->outgoing_subnet, ifa))
|
|
|
|
return 0;
|
2019-06-01 00:27:07 +08:00
|
|
|
}
|
2018-03-01 20:51:27 +08:00
|
|
|
|
2018-03-16 22:06:39 +08:00
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2018-03-16 22:06:40 +08:00
|
|
|
/* match ipv6 addrs of dev against addrs in CLC proposal */
|
|
|
|
static int smc_clc_prfx_match6_rcu(struct net_device *dev,
|
|
|
|
struct smc_clc_msg_proposal_prefix *prop)
|
|
|
|
{
|
|
|
|
#if IS_ENABLED(CONFIG_IPV6)
|
|
|
|
struct inet6_dev *in6_dev = __in6_dev_get(dev);
|
|
|
|
struct smc_clc_ipv6_prefix *ipv6_prfx;
|
|
|
|
struct inet6_ifaddr *ifa;
|
|
|
|
int i, max;
|
|
|
|
|
|
|
|
if (!in6_dev)
|
|
|
|
return -ENODEV;
|
|
|
|
/* ipv6 prefix list starts behind smc_clc_msg_proposal_prefix */
|
|
|
|
ipv6_prfx = (struct smc_clc_ipv6_prefix *)((u8 *)prop + sizeof(*prop));
|
|
|
|
max = min_t(u8, prop->ipv6_prefixes_cnt, SMC_CLC_MAX_V6_PREFIX);
|
|
|
|
list_for_each_entry(ifa, &in6_dev->addr_list, if_list) {
|
|
|
|
if (ipv6_addr_type(&ifa->addr) & IPV6_ADDR_LINKLOCAL)
|
|
|
|
continue;
|
|
|
|
for (i = 0; i < max; i++) {
|
|
|
|
if (ifa->prefix_len == ipv6_prfx[i].prefix_len &&
|
|
|
|
ipv6_prefix_equal(&ifa->addr, &ipv6_prfx[i].prefix,
|
|
|
|
ifa->prefix_len))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2018-03-16 22:06:39 +08:00
|
|
|
/* check if proposed prefixes match one of our device prefixes */
|
|
|
|
int smc_clc_prfx_match(struct socket *clcsock,
|
|
|
|
struct smc_clc_msg_proposal_prefix *prop)
|
|
|
|
{
|
|
|
|
struct dst_entry *dst = sk_dst_get(clcsock->sk);
|
2018-03-16 22:06:40 +08:00
|
|
|
int rc;
|
2018-03-16 22:06:39 +08:00
|
|
|
|
|
|
|
if (!dst) {
|
|
|
|
rc = -ENOTCONN;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (!dst->dev) {
|
|
|
|
rc = -ENODEV;
|
|
|
|
goto out_rel;
|
|
|
|
}
|
|
|
|
rcu_read_lock();
|
|
|
|
if (!prop->ipv6_prefixes_cnt)
|
|
|
|
rc = smc_clc_prfx_match4_rcu(dst->dev, prop);
|
2018-03-16 22:06:40 +08:00
|
|
|
else
|
|
|
|
rc = smc_clc_prfx_match6_rcu(dst->dev, prop);
|
2018-03-16 22:06:39 +08:00
|
|
|
rcu_read_unlock();
|
2018-03-01 20:51:27 +08:00
|
|
|
out_rel:
|
|
|
|
dst_release(dst);
|
|
|
|
out:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2017-01-09 23:55:16 +08:00
|
|
|
/* Wait for data on the tcp-socket, analyze received data
|
|
|
|
* Returns:
|
|
|
|
* 0 if success and it was not a decline that we received.
|
|
|
|
* SMC_CLC_DECL_REPLY if decline received for fallback w/o another decl send.
|
|
|
|
* clcsock error, -EINTR, -ECONNRESET, -EPROTO otherwise.
|
|
|
|
*/
|
|
|
|
int smc_clc_wait_msg(struct smc_sock *smc, void *buf, int buflen,
|
2018-11-22 17:26:39 +08:00
|
|
|
u8 expected_type, unsigned long timeout)
|
2017-01-09 23:55:16 +08:00
|
|
|
{
|
2018-07-18 21:22:51 +08:00
|
|
|
long rcvtimeo = smc->clcsock->sk->sk_rcvtimeo;
|
2017-01-09 23:55:16 +08:00
|
|
|
struct sock *clc_sk = smc->clcsock->sk;
|
|
|
|
struct smc_clc_msg_hdr *clcm = buf;
|
|
|
|
struct msghdr msg = {NULL, 0};
|
|
|
|
int reason_code = 0;
|
2017-09-21 08:21:22 +08:00
|
|
|
struct kvec vec = {buf, buflen};
|
2020-07-08 23:05:15 +08:00
|
|
|
int len, datlen, recvlen;
|
|
|
|
bool check_trl = true;
|
2017-01-09 23:55:16 +08:00
|
|
|
int krflags;
|
|
|
|
|
|
|
|
/* peek the first few bytes to determine length of data to receive
|
|
|
|
* so we don't consume any subsequent CLC message or payload data
|
|
|
|
* in the TCP byte stream
|
|
|
|
*/
|
2017-09-21 08:21:22 +08:00
|
|
|
/*
|
|
|
|
* Caller must make sure that buflen is no less than
|
|
|
|
* sizeof(struct smc_clc_msg_hdr)
|
|
|
|
*/
|
2017-01-09 23:55:16 +08:00
|
|
|
krflags = MSG_PEEK | MSG_WAITALL;
|
2018-11-22 17:26:39 +08:00
|
|
|
clc_sk->sk_rcvtimeo = timeout;
|
2018-10-20 07:57:56 +08:00
|
|
|
iov_iter_kvec(&msg.msg_iter, READ, &vec, 1,
|
2017-09-21 08:21:22 +08:00
|
|
|
sizeof(struct smc_clc_msg_hdr));
|
|
|
|
len = sock_recvmsg(smc->clcsock, &msg, krflags);
|
2017-01-09 23:55:16 +08:00
|
|
|
if (signal_pending(current)) {
|
|
|
|
reason_code = -EINTR;
|
|
|
|
clc_sk->sk_err = EINTR;
|
|
|
|
smc->sk.sk_err = EINTR;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (clc_sk->sk_err) {
|
|
|
|
reason_code = -clc_sk->sk_err;
|
2018-11-22 17:26:37 +08:00
|
|
|
if (clc_sk->sk_err == EAGAIN &&
|
|
|
|
expected_type == SMC_CLC_DECLINE)
|
|
|
|
clc_sk->sk_err = 0; /* reset for fallback usage */
|
|
|
|
else
|
|
|
|
smc->sk.sk_err = clc_sk->sk_err;
|
2017-01-09 23:55:16 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (!len) { /* peer has performed orderly shutdown */
|
|
|
|
smc->sk.sk_err = ECONNRESET;
|
|
|
|
reason_code = -ECONNRESET;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (len < 0) {
|
2018-11-22 17:26:37 +08:00
|
|
|
if (len != -EAGAIN || expected_type != SMC_CLC_DECLINE)
|
|
|
|
smc->sk.sk_err = -len;
|
2017-01-09 23:55:16 +08:00
|
|
|
reason_code = len;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
datlen = ntohs(clcm->length);
|
|
|
|
if ((len < sizeof(struct smc_clc_msg_hdr)) ||
|
2020-09-11 00:48:21 +08:00
|
|
|
(clcm->version < SMC_V1) ||
|
2017-01-09 23:55:16 +08:00
|
|
|
((clcm->type != SMC_CLC_DECLINE) &&
|
|
|
|
(clcm->type != expected_type))) {
|
|
|
|
smc->sk.sk_err = EPROTO;
|
|
|
|
reason_code = -EPROTO;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2020-07-08 23:05:15 +08:00
|
|
|
if (clcm->type == SMC_CLC_PROPOSAL && clcm->path == SMC_TYPE_N)
|
|
|
|
reason_code = SMC_CLC_DECL_VERSMISMAT; /* just V2 offered */
|
|
|
|
|
2017-01-09 23:55:16 +08:00
|
|
|
/* receive the complete CLC message */
|
|
|
|
memset(&msg, 0, sizeof(struct msghdr));
|
2020-07-08 23:05:15 +08:00
|
|
|
if (datlen > buflen) {
|
|
|
|
check_trl = false;
|
|
|
|
recvlen = buflen;
|
|
|
|
} else {
|
|
|
|
recvlen = datlen;
|
|
|
|
}
|
|
|
|
iov_iter_kvec(&msg.msg_iter, READ, &vec, 1, recvlen);
|
2017-01-09 23:55:16 +08:00
|
|
|
krflags = MSG_WAITALL;
|
2017-09-21 08:21:22 +08:00
|
|
|
len = sock_recvmsg(smc->clcsock, &msg, krflags);
|
2020-07-08 23:05:15 +08:00
|
|
|
if (len < recvlen || !smc_clc_msg_hdr_valid(clcm, check_trl)) {
|
2017-01-09 23:55:16 +08:00
|
|
|
smc->sk.sk_err = EPROTO;
|
|
|
|
reason_code = -EPROTO;
|
|
|
|
goto out;
|
|
|
|
}
|
2020-07-08 23:05:15 +08:00
|
|
|
datlen -= len;
|
|
|
|
while (datlen) {
|
|
|
|
u8 tmp[SMC_CLC_RECV_BUF_LEN];
|
|
|
|
|
|
|
|
vec.iov_base = &tmp;
|
|
|
|
vec.iov_len = SMC_CLC_RECV_BUF_LEN;
|
|
|
|
/* receive remaining proposal message */
|
|
|
|
recvlen = datlen > SMC_CLC_RECV_BUF_LEN ?
|
|
|
|
SMC_CLC_RECV_BUF_LEN : datlen;
|
|
|
|
iov_iter_kvec(&msg.msg_iter, READ, &vec, 1, recvlen);
|
|
|
|
len = sock_recvmsg(smc->clcsock, &msg, krflags);
|
|
|
|
datlen -= len;
|
|
|
|
}
|
2017-01-09 23:55:17 +08:00
|
|
|
if (clcm->type == SMC_CLC_DECLINE) {
|
2018-07-25 22:35:32 +08:00
|
|
|
struct smc_clc_msg_decline *dclc;
|
|
|
|
|
|
|
|
dclc = (struct smc_clc_msg_decline *)clcm;
|
|
|
|
reason_code = SMC_CLC_DECL_PEERDECL;
|
|
|
|
smc->peer_diagnosis = ntohl(dclc->peer_diagnosis);
|
2017-09-21 15:16:32 +08:00
|
|
|
if (((struct smc_clc_msg_decline *)buf)->hdr.flag) {
|
2018-05-15 23:05:03 +08:00
|
|
|
smc->conn.lgr->sync_err = 1;
|
2020-02-17 23:24:54 +08:00
|
|
|
smc_lgr_terminate_sched(smc->conn.lgr);
|
2017-09-21 15:16:32 +08:00
|
|
|
}
|
2017-01-09 23:55:17 +08:00
|
|
|
}
|
|
|
|
|
2017-01-09 23:55:16 +08:00
|
|
|
out:
|
2018-11-22 17:26:39 +08:00
|
|
|
clc_sk->sk_rcvtimeo = rcvtimeo;
|
2017-01-09 23:55:16 +08:00
|
|
|
return reason_code;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* send CLC DECLINE message across internal TCP socket */
|
2017-09-21 15:16:32 +08:00
|
|
|
int smc_clc_send_decline(struct smc_sock *smc, u32 peer_diag_info)
|
2017-01-09 23:55:16 +08:00
|
|
|
{
|
|
|
|
struct smc_clc_msg_decline dclc;
|
|
|
|
struct msghdr msg;
|
|
|
|
struct kvec vec;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
memset(&dclc, 0, sizeof(dclc));
|
|
|
|
memcpy(dclc.hdr.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER));
|
|
|
|
dclc.hdr.type = SMC_CLC_DECLINE;
|
|
|
|
dclc.hdr.length = htons(sizeof(struct smc_clc_msg_decline));
|
2020-09-11 00:48:21 +08:00
|
|
|
dclc.hdr.version = SMC_V1;
|
2017-09-21 15:16:32 +08:00
|
|
|
dclc.hdr.flag = (peer_diag_info == SMC_CLC_DECL_SYNCERR) ? 1 : 0;
|
2020-02-26 05:41:22 +08:00
|
|
|
if ((!smc->conn.lgr || !smc->conn.lgr->is_smcd) &&
|
|
|
|
smc_ib_is_valid_local_systemid())
|
2020-02-14 15:59:00 +08:00
|
|
|
memcpy(dclc.id_for_peer, local_systemid,
|
|
|
|
sizeof(local_systemid));
|
2017-01-09 23:55:16 +08:00
|
|
|
dclc.peer_diagnosis = htonl(peer_diag_info);
|
|
|
|
memcpy(dclc.trl.eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER));
|
|
|
|
|
|
|
|
memset(&msg, 0, sizeof(msg));
|
|
|
|
vec.iov_base = &dclc;
|
|
|
|
vec.iov_len = sizeof(struct smc_clc_msg_decline);
|
|
|
|
len = kernel_sendmsg(smc->clcsock, &msg, &vec, 1,
|
|
|
|
sizeof(struct smc_clc_msg_decline));
|
2019-01-31 01:51:00 +08:00
|
|
|
if (len < 0 || len < sizeof(struct smc_clc_msg_decline))
|
2018-11-22 17:26:36 +08:00
|
|
|
len = -EPROTO;
|
|
|
|
return len > 0 ? 0 : len;
|
2017-01-09 23:55:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* send CLC PROPOSAL message across internal TCP socket */
|
2018-06-29 01:05:09 +08:00
|
|
|
int smc_clc_send_proposal(struct smc_sock *smc, int smc_type,
|
2019-04-12 18:57:26 +08:00
|
|
|
struct smc_init_info *ini)
|
2017-01-09 23:55:16 +08:00
|
|
|
{
|
2020-09-11 00:48:22 +08:00
|
|
|
struct smc_clc_msg_proposal_prefix *pclc_prfx;
|
|
|
|
struct smc_clc_msg_proposal *pclc_base;
|
|
|
|
struct smc_clc_msg_proposal_area *pclc;
|
|
|
|
struct smc_clc_ipv6_prefix *ipv6_prfx;
|
|
|
|
struct smc_clc_msg_smcd *pclc_smcd;
|
|
|
|
struct smc_clc_msg_trail *trl;
|
2018-03-16 22:06:40 +08:00
|
|
|
int len, i, plen, rc;
|
2017-01-09 23:55:16 +08:00
|
|
|
int reason_code = 0;
|
2018-06-29 01:05:09 +08:00
|
|
|
struct kvec vec[5];
|
2017-01-09 23:55:16 +08:00
|
|
|
struct msghdr msg;
|
|
|
|
|
2020-09-11 00:48:22 +08:00
|
|
|
pclc = kzalloc(sizeof(*pclc), GFP_KERNEL);
|
|
|
|
if (!pclc)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
pclc_base = &pclc->pclc_base;
|
|
|
|
pclc_smcd = &pclc->pclc_smcd;
|
|
|
|
pclc_prfx = &pclc->pclc_prfx;
|
|
|
|
ipv6_prfx = pclc->pclc_prfx_ipv6;
|
|
|
|
trl = &pclc->pclc_trl;
|
|
|
|
|
2018-03-16 22:06:39 +08:00
|
|
|
/* retrieve ip prefixes for CLC proposal msg */
|
2020-09-11 00:48:22 +08:00
|
|
|
rc = smc_clc_prfx_set(smc->clcsock, pclc_prfx, ipv6_prfx);
|
|
|
|
if (rc) {
|
|
|
|
kfree(pclc);
|
2018-03-16 22:06:39 +08:00
|
|
|
return SMC_CLC_DECL_CNFERR; /* configuration error */
|
2020-09-11 00:48:22 +08:00
|
|
|
}
|
2018-03-16 22:06:39 +08:00
|
|
|
|
2017-01-09 23:55:16 +08:00
|
|
|
/* send SMC Proposal CLC message */
|
2020-09-11 00:48:22 +08:00
|
|
|
plen = sizeof(*pclc_base) + sizeof(*pclc_prfx) +
|
|
|
|
(pclc_prfx->ipv6_prefixes_cnt * sizeof(ipv6_prfx[0])) +
|
|
|
|
sizeof(*trl);
|
|
|
|
memcpy(pclc_base->hdr.eyecatcher, SMC_EYECATCHER,
|
|
|
|
sizeof(SMC_EYECATCHER));
|
|
|
|
pclc_base->hdr.type = SMC_CLC_PROPOSAL;
|
|
|
|
pclc_base->hdr.version = SMC_V1; /* SMC version */
|
|
|
|
pclc_base->hdr.path = smc_type;
|
2018-06-29 01:05:09 +08:00
|
|
|
if (smc_type == SMC_TYPE_R || smc_type == SMC_TYPE_B) {
|
|
|
|
/* add SMC-R specifics */
|
2020-09-11 00:48:22 +08:00
|
|
|
memcpy(pclc_base->lcl.id_for_peer, local_systemid,
|
2018-06-29 01:05:09 +08:00
|
|
|
sizeof(local_systemid));
|
2020-09-11 00:48:22 +08:00
|
|
|
memcpy(pclc_base->lcl.gid, ini->ib_gid, SMC_GID_SIZE);
|
|
|
|
memcpy(pclc_base->lcl.mac, &ini->ib_dev->mac[ini->ib_port - 1],
|
2019-04-12 18:57:26 +08:00
|
|
|
ETH_ALEN);
|
2020-09-11 00:48:22 +08:00
|
|
|
pclc_base->iparea_offset = htons(0);
|
2018-06-29 01:05:09 +08:00
|
|
|
}
|
|
|
|
if (smc_type == SMC_TYPE_D || smc_type == SMC_TYPE_B) {
|
|
|
|
/* add SMC-D specifics */
|
2020-09-11 00:48:22 +08:00
|
|
|
plen += sizeof(*pclc_smcd);
|
|
|
|
pclc_base->iparea_offset = htons(sizeof(*pclc_smcd));
|
|
|
|
pclc_smcd->gid = ini->ism_dev->local_gid;
|
2018-06-29 01:05:09 +08:00
|
|
|
}
|
2020-09-11 00:48:22 +08:00
|
|
|
pclc_base->hdr.length = htons(plen);
|
2017-01-09 23:55:16 +08:00
|
|
|
|
2020-09-11 00:48:22 +08:00
|
|
|
memcpy(trl->eyecatcher, SMC_EYECATCHER, sizeof(SMC_EYECATCHER));
|
2017-01-09 23:55:16 +08:00
|
|
|
memset(&msg, 0, sizeof(msg));
|
2018-03-16 22:06:40 +08:00
|
|
|
i = 0;
|
2020-09-11 00:48:22 +08:00
|
|
|
vec[i].iov_base = pclc_base;
|
|
|
|
vec[i++].iov_len = sizeof(*pclc_base);
|
2018-06-29 01:05:09 +08:00
|
|
|
if (smc_type == SMC_TYPE_D || smc_type == SMC_TYPE_B) {
|
2020-09-11 00:48:22 +08:00
|
|
|
vec[i].iov_base = pclc_smcd;
|
|
|
|
vec[i++].iov_len = sizeof(*pclc_smcd);
|
2018-06-29 01:05:09 +08:00
|
|
|
}
|
2020-09-11 00:48:22 +08:00
|
|
|
vec[i].iov_base = pclc_prfx;
|
|
|
|
vec[i++].iov_len = sizeof(*pclc_prfx);
|
|
|
|
if (pclc_prfx->ipv6_prefixes_cnt > 0) {
|
|
|
|
vec[i].iov_base = ipv6_prfx;
|
|
|
|
vec[i++].iov_len = pclc_prfx->ipv6_prefixes_cnt *
|
2018-03-16 22:06:40 +08:00
|
|
|
sizeof(ipv6_prfx[0]);
|
|
|
|
}
|
2020-09-11 00:48:22 +08:00
|
|
|
vec[i].iov_base = trl;
|
|
|
|
vec[i++].iov_len = sizeof(*trl);
|
2017-01-09 23:55:16 +08:00
|
|
|
/* due to the few bytes needed for clc-handshake this cannot block */
|
2018-03-16 22:06:40 +08:00
|
|
|
len = kernel_sendmsg(smc->clcsock, &msg, vec, i, plen);
|
2018-09-18 21:46:38 +08:00
|
|
|
if (len < 0) {
|
|
|
|
smc->sk.sk_err = smc->clcsock->sk->sk_err;
|
|
|
|
reason_code = -smc->sk.sk_err;
|
2020-09-11 00:48:22 +08:00
|
|
|
} else if (len < ntohs(pclc_base->hdr.length)) {
|
2018-09-18 21:46:38 +08:00
|
|
|
reason_code = -ENETUNREACH;
|
|
|
|
smc->sk.sk_err = -reason_code;
|
2017-01-09 23:55:16 +08:00
|
|
|
}
|
|
|
|
|
2020-09-11 00:48:22 +08:00
|
|
|
kfree(pclc);
|
2017-01-09 23:55:16 +08:00
|
|
|
return reason_code;
|
|
|
|
}
|
|
|
|
|
2020-09-11 00:48:23 +08:00
|
|
|
/* build and send CLC CONFIRM / ACCEPT message */
|
|
|
|
static int smc_clc_send_confirm_accept(struct smc_sock *smc,
|
|
|
|
struct smc_clc_msg_accept_confirm *clc,
|
|
|
|
int first_contact)
|
2017-01-09 23:55:16 +08:00
|
|
|
{
|
2017-01-09 23:55:17 +08:00
|
|
|
struct smc_connection *conn = &smc->conn;
|
2017-01-09 23:55:16 +08:00
|
|
|
struct msghdr msg;
|
|
|
|
struct kvec vec;
|
|
|
|
|
|
|
|
/* send SMC Confirm CLC msg */
|
2020-09-11 00:48:23 +08:00
|
|
|
clc->hdr.version = SMC_V1; /* SMC version */
|
|
|
|
if (first_contact)
|
|
|
|
clc->hdr.flag = 1;
|
2020-09-11 00:48:21 +08:00
|
|
|
if (conn->lgr->is_smcd) {
|
2018-06-29 01:05:09 +08:00
|
|
|
/* SMC-D specific settings */
|
2020-09-11 00:48:23 +08:00
|
|
|
memcpy(clc->hdr.eyecatcher, SMCD_EYECATCHER,
|
2018-06-29 01:05:09 +08:00
|
|
|
sizeof(SMCD_EYECATCHER));
|
2020-09-11 00:48:23 +08:00
|
|
|
clc->hdr.path = SMC_TYPE_D;
|
|
|
|
clc->hdr.length = htons(SMCD_CLC_ACCEPT_CONFIRM_LEN);
|
|
|
|
clc->d0.gid = conn->lgr->smcd->local_gid;
|
|
|
|
clc->d0.token = conn->rmb_desc->token;
|
|
|
|
clc->d0.dmbe_size = conn->rmbe_size_short;
|
|
|
|
clc->d0.dmbe_idx = 0;
|
|
|
|
memcpy(&clc->d0.linkid, conn->lgr->id, SMC_LGR_ID_SIZE);
|
|
|
|
memcpy(clc->d0.smcd_trl.eyecatcher, SMCD_EYECATCHER,
|
2018-06-29 01:05:09 +08:00
|
|
|
sizeof(SMCD_EYECATCHER));
|
|
|
|
} else {
|
2020-09-11 00:48:23 +08:00
|
|
|
struct smc_link *link = conn->lnk;
|
|
|
|
|
2018-06-29 01:05:09 +08:00
|
|
|
/* SMC-R specific settings */
|
2020-04-29 23:10:40 +08:00
|
|
|
link = conn->lnk;
|
2020-09-11 00:48:23 +08:00
|
|
|
memcpy(clc->hdr.eyecatcher, SMC_EYECATCHER,
|
2018-06-29 01:05:09 +08:00
|
|
|
sizeof(SMC_EYECATCHER));
|
2020-09-11 00:48:23 +08:00
|
|
|
clc->hdr.path = SMC_TYPE_R;
|
|
|
|
clc->hdr.length = htons(SMCR_CLC_ACCEPT_CONFIRM_LEN);
|
|
|
|
memcpy(clc->r0.lcl.id_for_peer, local_systemid,
|
2018-06-29 01:05:09 +08:00
|
|
|
sizeof(local_systemid));
|
2020-09-11 00:48:23 +08:00
|
|
|
memcpy(&clc->r0.lcl.gid, link->gid, SMC_GID_SIZE);
|
|
|
|
memcpy(&clc->r0.lcl.mac, &link->smcibdev->mac[link->ibport - 1],
|
2018-06-29 01:05:09 +08:00
|
|
|
ETH_ALEN);
|
2020-09-11 00:48:23 +08:00
|
|
|
hton24(clc->r0.qpn, link->roce_qp->qp_num);
|
|
|
|
clc->r0.rmb_rkey =
|
2020-04-29 23:10:40 +08:00
|
|
|
htonl(conn->rmb_desc->mr_rx[link->link_idx]->rkey);
|
2020-09-11 00:48:23 +08:00
|
|
|
clc->r0.rmbe_idx = 1; /* for now: 1 RMB = 1 RMBE */
|
|
|
|
clc->r0.rmbe_alert_token = htonl(conn->alert_token_local);
|
|
|
|
switch (clc->hdr.type) {
|
|
|
|
case SMC_CLC_ACCEPT:
|
|
|
|
clc->r0.qp_mtu = link->path_mtu;
|
|
|
|
break;
|
|
|
|
case SMC_CLC_CONFIRM:
|
|
|
|
clc->r0.qp_mtu = min(link->path_mtu, link->peer_mtu);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
clc->r0.rmbe_size = conn->rmbe_size_short;
|
|
|
|
clc->r0.rmb_dma_addr = cpu_to_be64((u64)sg_dma_address
|
2020-04-29 23:10:40 +08:00
|
|
|
(conn->rmb_desc->sgt[link->link_idx].sgl));
|
2020-09-11 00:48:23 +08:00
|
|
|
hton24(clc->r0.psn, link->psn_initial);
|
|
|
|
memcpy(clc->r0.smcr_trl.eyecatcher, SMC_EYECATCHER,
|
2018-06-29 01:05:09 +08:00
|
|
|
sizeof(SMC_EYECATCHER));
|
|
|
|
}
|
2017-01-09 23:55:16 +08:00
|
|
|
|
|
|
|
memset(&msg, 0, sizeof(msg));
|
2020-09-11 00:48:23 +08:00
|
|
|
vec.iov_base = clc;
|
|
|
|
vec.iov_len = ntohs(clc->hdr.length);
|
|
|
|
return kernel_sendmsg(smc->clcsock, &msg, &vec, 1,
|
|
|
|
ntohs(clc->hdr.length));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* send CLC CONFIRM message across internal TCP socket */
|
|
|
|
int smc_clc_send_confirm(struct smc_sock *smc)
|
|
|
|
{
|
|
|
|
struct smc_clc_msg_accept_confirm cclc;
|
|
|
|
int reason_code = 0;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
/* send SMC Confirm CLC msg */
|
|
|
|
memset(&cclc, 0, sizeof(cclc));
|
|
|
|
cclc.hdr.type = SMC_CLC_CONFIRM;
|
|
|
|
len = smc_clc_send_confirm_accept(smc, &cclc, 0);
|
2018-06-29 01:05:09 +08:00
|
|
|
if (len < ntohs(cclc.hdr.length)) {
|
2017-01-09 23:55:16 +08:00
|
|
|
if (len >= 0) {
|
|
|
|
reason_code = -ENETUNREACH;
|
|
|
|
smc->sk.sk_err = -reason_code;
|
|
|
|
} else {
|
|
|
|
smc->sk.sk_err = smc->clcsock->sk->sk_err;
|
|
|
|
reason_code = -smc->sk.sk_err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return reason_code;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* send CLC ACCEPT message across internal TCP socket */
|
2020-09-11 00:48:21 +08:00
|
|
|
int smc_clc_send_accept(struct smc_sock *new_smc, bool srv_first_contact)
|
2017-01-09 23:55:16 +08:00
|
|
|
{
|
|
|
|
struct smc_clc_msg_accept_confirm aclc;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
memset(&aclc, 0, sizeof(aclc));
|
|
|
|
aclc.hdr.type = SMC_CLC_ACCEPT;
|
2020-09-11 00:48:23 +08:00
|
|
|
len = smc_clc_send_confirm_accept(new_smc, &aclc, srv_first_contact);
|
2018-11-22 17:26:36 +08:00
|
|
|
if (len < ntohs(aclc.hdr.length))
|
|
|
|
len = len >= 0 ? -EPROTO : -new_smc->clcsock->sk->sk_err;
|
2017-01-09 23:55:16 +08:00
|
|
|
|
2018-11-22 17:26:36 +08:00
|
|
|
return len > 0 ? 0 : len;
|
2017-01-09 23:55:16 +08:00
|
|
|
}
|