Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: ermenson.sec@gmail.com
Cc: alibuda@linux.alibaba.com, dust.li@linux.alibaba.com,
	sidraya@linux.ibm.com, mjambigi@linux.ibm.com,
	tonylu@linux.alibaba.com, guwen@linux.alibaba.com,
	davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
	pabeni@redhat.com, willemb@google.com, horms@kernel.org,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-s390@vger.kernel.org
Subject: Re: [PATCH net-next v2 3/4] net/smc: set a new link's peer gid and mac at creation
Date: Fri, 04 Dec 2026 15:41:54 +0000	[thread overview]
Message-ID: <179639891424.3146.6361540241954783090@kernel.org> (raw)
In-Reply-To: <20261203153514.1440337-4-ermenson.sec@gmail.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message never says why the change is needed, and it
  hides a hard dependency.
- [Low] "No reader changes behaviour" is not accurate for user-visible
  output.
- [Low] Both the commit message and the new comment in smcr_link_init()
  say the add-link callers overwrite peer_gid/peer_mac in…
- [Low] The new comment in smcr_link_init() says "peer_qpn, peer_psn and
  peer_mtu come from the peer's CLC CONFIRM".

--

net/smc: set a new link's peer gid and mac at creation

This patch makes smcr_link_init() copy peer_gid and peer_mac from
smc_init_info into the new link when the link is created. Before, both
stayed zero until smc_link_save_peer_info() ran after the CLC accept or
confirm. The add-link paths pass a zeroed smc_init_info and fill both
fields from the ADD_LINK message.

> smcr_link_init() leaves lnk->peer_gid and lnk->peer_mac zero. They are
> filled only once the peer's CLC accept or confirm has been processed, by
> smc_link_save_peer_info(), which copies them out of smc_init_info. Both
> values are already in smc_init_info when the link is created, so set them
> there. This changes when the fields become valid, not what they hold.

[Severity: Low]
The message explains why the change is harmless. Could it also say why
the change is needed?

As far as I can tell, the reason is the next patch in the series,
"net/smc: drop smc_server_lgr_pending across the CLC CONFIRM wait". That
patch adds smcr_lgr_pending_match(), which reads peer_gid and peer_mac of
links still in SMC_LNK_ACTIVATING:

    if (!memcmp(lnk->peer_gid, ini->peer_gid, SMC_GID_SIZE) &&
        (ini->smcr_version == SMC_V2 ||
         !memcmp(lnk->peer_mac, ini->peer_mac, ETH_ALEN)))

These fields are only non-zero at that point because of this patch.
Neither commit message mentions the dependency.

smc_link_save_peer_info() in af_smc.c still does the same copy:

    memcpy(link->peer_gid, ini->peer_gid, SMC_GID_SIZE);
    memcpy(link->peer_mac, ini->peer_mac, sizeof(link->peer_mac));

So the patch writes the same values a second time rather than moving the
first write. Read on its own, the patch looks like a no-op cleanup that
could be dropped. If it were dropped, the next patch would still build,
but smcr_lgr_pending_match() would compare zeros against ini->peer_gid
and never match.

Would it make sense to state this dependency in the commit message?

> No reader changes behaviour: the QP is programmed from the gid only after
> the peer info is saved, smcr_lgr_match() looks at active links, and the
> netlink and diag paths display the field.

[Severity: Low]
Is "No reader changes behaviour" accurate for what user space sees?

smc_nl_handle_lgr() dumps every link that passes smc_link_usable().
smc_link_usable() rejects only SMC_LNK_UNUSED and SMC_LNK_INACTIVE, so
SMC_LNK_ACTIVATING links are dumped too:

net/smc/smc_core.c:smc_nl_handle_lgr() {
    ...
		if (!smc_link_usable(&lgr->lnk[i]))
			continue;
		if (smc_nl_fill_lgr_link(lgr, &lgr->lnk[i], skb, cb))
    ...
}

smc_nl_fill_lgr_link() puts link->peer_gid into SMC_NLA_LINK_PEER_GID.
__smc_diag_dump() in smc_diag.c exports it as well.

On the server, smc_lgr_create() adds the link group to smc_lgr_list right
after smcr_link_init(). The link then stays ACTIVATING for the whole CLC
CONFIRM wait, which can last up to CLC_WAIT_TIME.

Netlink and diag dumps taken during that window used to show an all-zero
peer GID. They now show the GID from the proposal. This includes
handshakes that later time out and get cleared.

The value is the same one smc_link_save_peer_info() stores later, so this
looks harmless. Could the message describe this change rather than call
it a non-change?

The message also leaves out two other readers: the link selection loop in
smc_connect_rdma() and smc_llc_find_asym_link(). Neither seems to change
in practice:

- The smc_connect_rdma() loop also needs peer_qpn to match, and peer_qpn
  is still 0.
- smc_llc_find_asym_link() never sees two links during a first contact.

> diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
> index 34fd8f3e7939f..61d4d4b559caf 100644
> --- a/net/smc/smc_core.c
> +++ b/net/smc/smc_core.c
> @@ -824,6 +824,15 @@ int smcr_link_init(struct smc_link_group *lgr, struct smc_link *lnk,
>  		lnk->wr_rx_sge_cnt = 1;
>  		lnk->wr_rx_buflen = SMC_WR_BUF_SIZE;
>  	}
> +	/* peer_qpn, peer_psn and peer_mtu come from the peer's CLC CONFIRM and
> +	 * are filled later by smc_link_save_peer_info(). The gid and the mac are

[Severity: Low]
Does this hold on the client side? Only the server takes these values
from the CLC CONFIRM, in smc_listen_rdma_finish():

    smc_link_save_peer_info(link, cclc, ini);

On the client, smc_connect_rdma() passes the server's CLC ACCEPT:

    if (ini->first_contact_local)
        smc_link_save_peer_info(link, aclc, ini);

So for client first links, peer_qpn, peer_psn and peer_mtu come from the
ACCEPT. The commit message gets this right ("the peer's CLC accept or
confirm").

At the end of the series, the comment still names only CLC CONFIRM for
these fields. The same comment says the gid and mac come "from the
proposal on the server and from the accept on the client", so the comment
contradicts itself.

> +	 * already in ini here, and smc_link_save_peer_info() copies them from the
> +	 * same fields, so this changes when they become valid and not what they
> +	 * hold. The add-link callers pass a zeroed ini and overwrite both in
> +	 * smc_llc_save_add_link_info() straight after.
> +	 */

[Severity: Low]
Is "straight after" accurate for the server add-link path? It holds for
the client, where smc_llc_cli_add_link() calls
smc_llc_save_add_link_info() right after smcr_link_init().

In smc_llc_srv_add_link(), several steps run between the two calls,
including a blocking wait for the peer:

smc_llc_srv_add_link()
    smcr_link_init()
    smcr_buf_map_lgr()
    smc_llc_send_add_link()
    smc_llc_wait(..., SMC_LLC_WAIT_TIME, SMC_LLC_ADD_LINK)
    ...
    smc_llc_save_add_link_info(link_new, add_llc);

The -ETIMEDOUT and -ENOLINK exits after smc_llc_wait() skip
smc_llc_save_add_link_info() entirely.

Later in the series, "net/smc: drop smc_server_lgr_pending across the CLC
CONFIRM wait" changes the comment to say "afterwards". This commit
message still says "straight after".

Could the comment be fixed in this patch rather than in a later one, and
the commit message updated to match?

The comment also reads like a changelog ("this changes when they become
valid and not what they hold"), and it still does at the end of the
series. It describes the patch rather than the code, which will read
oddly once merged.

Could it describe the code's behaviour instead?

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203153514.1440337-1-ermenson.sec%40gmail.com

  reply	other threads:[~2026-12-04 15:41 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 15:35 [PATCH net-next v2 0/4] net/smc: stop a silent peer stalling every server handshake Ermenson Junior
2026-12-03 15:35 ` [PATCH net-next v2 1/4] net/smc: bound the SMC-Rv1 add-link rkey exchange Ermenson Junior
2026-12-04 15:41   ` netdev-bot+sashiko
2026-12-03 15:35 ` [PATCH net-next v2 2/4] net/smc: check the ADD_LINK_CONT send result in the server " Ermenson Junior
2026-12-04 15:41   ` netdev-bot+sashiko
2026-12-03 15:35 ` [PATCH net-next v2 3/4] net/smc: set a new link's peer gid and mac at creation Ermenson Junior
2026-12-04 15:41   ` netdev-bot+sashiko [this message]
2026-12-03 15:35 ` [PATCH net-next v2 4/4] net/smc: drop smc_server_lgr_pending across the CLC CONFIRM wait Ermenson Junior
2026-12-04 15:41   ` netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179639891424.3146.6361540241954783090@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=alibuda@linux.alibaba.com \
    --cc=davem@davemloft.net \
    --cc=dust.li@linux.alibaba.com \
    --cc=edumazet@kernel.org \
    --cc=ermenson.sec@gmail.com \
    --cc=guwen@linux.alibaba.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjambigi@linux.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sidraya@linux.ibm.com \
    --cc=tonylu@linux.alibaba.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox