[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d77ffb6e-28e6-4666-ae73-33bb64a44318@linux.alibaba.com>
Date: Mon, 3 Jun 2024 22:43:14 +0800
From: "D. Wythe" <alibuda@...ux.alibaba.com>
To: Ratheesh Kannoth <rkannoth@...vell.com>
Cc: kgraul@...ux.ibm.com, wenjia@...ux.ibm.com, jaka@...ux.ibm.com,
wintera@...ux.ibm.com, guwen@...ux.alibaba.com, kuba@...nel.org,
davem@...emloft.net, netdev@...r.kernel.org, linux-s390@...r.kernel.org,
linux-rdma@...r.kernel.org, tonylu@...ux.alibaba.com, pabeni@...hat.com,
edumazet@...gle.com
Subject: Re: [PATCH net-next v5 3/3] net/smc: Introduce IPPROTO_SMC
On 6/3/24 11:49 AM, Ratheesh Kannoth wrote:
> On 2024-05-30 at 15:00:40, D. Wythe (alibuda@...ux.alibaba.com) wrote:
>> From: "D. Wythe" <alibuda@...ux.alibaba.com>
>>
>> +
>> +int __init smc_inet_init(void)
>> +{
>> + int rc;
>> +
>> + rc = proto_register(&smc_inet_prot, 1);
>> + if (rc) {
>> + pr_err("%s: proto_register smc_inet_prot fails with %d\n", __func__, rc);
>> + return rc;
>> + }
>> + /* no return value */
>> + inet_register_protosw(&smc_inet_protosw);
>> +
>> +#if IS_ENABLED(CONFIG_IPV6)
>> + rc = proto_register(&smc_inet6_prot, 1);
>> + if (rc) {
>> + pr_err("%s: proto_register smc_inet6_prot fails with %d\n", __func__, rc);
>> + goto out_inet6_prot;
>> + }
>> + rc = inet6_register_protosw(&smc_inet6_protosw);
>> + if (rc) {
>> + pr_err("%s: inet6_register_protosw smc_inet6_protosw fails with %d\n",
>> + __func__, rc);
>> + goto out_inet6_protosw;
>> + }
>> +#endif /* CONFIG_IPV6 */
>> +
>> + return rc;
>> +#if IS_ENABLED(CONFIG_IPV6)
> Can you combine this #if with above one ? Any way you need this only in case of ipv6.
> Error handling with #if is an hindrance to a good readability.
Hi Ratheesh,
Thanks for your advice. Totally agreed with that.
I'll give it a fix in next version.
Best wishes,
D. Wythe
>> +out_inet6_protosw:
>> + proto_unregister(&smc_inet6_prot);
>> +out_inet6_prot:
>> + inet_unregister_protosw(&smc_inet_protosw);
>> + proto_unregister(&smc_inet_prot);
>> + return rc;
>> +#endif /* CONFIG_IPV6 */
>> +}
>> +
>> +void smc_inet_exit(void)
>> +{
>> +#if IS_ENABLED(CONFIG_IPV6)
>> + inet6_unregister_protosw(&smc_inet6_protosw);
>> + proto_unregister(&smc_inet6_prot);
>> +#endif /* CONFIG_IPV6 */
>> + inet_unregister_protosw(&smc_inet_protosw);
>> + proto_unregister(&smc_inet_prot);
>> +}
>> diff --git a/net/smc/smc_inet.h b/net/smc/smc_inet.h
>> new file mode 100644
>> index 00000000..a489c8a
>> --- /dev/null
>> +++ b/net/smc/smc_inet.h
>> @@ -0,0 +1,22 @@
>> +/* SPDX-License-Identifier: GPL-2.0 */
>> +/*
>> + * Shared Memory Communications over RDMA (SMC-R) and RoCE
>> + *
>> + * Definitions for the IPPROTO_SMC (socket related)
>> +
>> + * Copyright IBM Corp. 2016
>> + * Copyright (c) 2024, Alibaba Inc.
>> + *
>> + * Author: D. Wythe <alibuda@...ux.alibaba.com>
>> + */
>> +#ifndef __INET_SMC
>> +#define __INET_SMC
>> +
>> +/* Initialize protocol registration on IPPROTO_SMC,
>> + * @return 0 on success
>> + */
>> +int smc_inet_init(void);
>> +
>> +void smc_inet_exit(void);
>> +
>> +#endif /* __INET_SMC */
>> --
>> 1.8.3.1
>>
Powered by blists - more mailing lists