[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201125163034.7a4c526e@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Date: Wed, 25 Nov 2020 16:30:34 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Karsten Graul <kgraul@...ux.ibm.com>
Cc: David Miller <davem@...emloft.net>,
Heiko Carstens <hca@...ux.ibm.com>,
Stefan Raspl <raspl@...ux.ibm.com>, netdev@...r.kernel.org,
linux-s390@...r.kernel.org
Subject: Re: [PATCH net-next v5 10/14] net/smc: Introduce SMCR get linkgroup
command
On Tue, 24 Nov 2020 18:50:43 +0100 Karsten Graul wrote:
> +static int smc_nl_fill_lgr(struct smc_link_group *lgr,
> + struct sk_buff *skb,
> + struct netlink_callback *cb)
> +{
> + char smc_target[SMC_MAX_PNETID_LEN + 1];
> + struct nlattr *attrs;
> +
> + attrs = nla_nest_start_noflag(skb, SMC_GEN_LGR_SMCR);
> + if (!attrs)
> + goto errout;
> +
> + if (nla_put_u32(skb, SMC_NLA_LGR_R_ID, *((u32 *)&lgr->id)) < 0)
> + goto errattr;
> + if (nla_put_u32(skb, SMC_NLA_LGR_R_CONNS_NUM, lgr->conns_num) < 0)
> + goto errattr;
> + if (nla_put_u8(skb, SMC_NLA_LGR_R_ROLE, lgr->role) < 0)
> + goto errattr;
> + if (nla_put_u8(skb, SMC_NLA_LGR_R_TYPE, lgr->type) < 0)
> + goto errattr;
> + if (nla_put_u8(skb, SMC_NLA_LGR_R_VLAN_ID, lgr->vlan_id) < 0)
> + goto errattr;
> + memset(smc_target, 0, sizeof(smc_target));
unnecessary
> + snprintf(smc_target, sizeof(smc_target), "%s", lgr->pnet_id);
> + if (nla_put_string(skb, SMC_NLA_LGR_R_PNETID, smc_target) < 0)
> + goto errattr;
> +
> + nla_nest_end(skb, attrs);
> + return 0;
> +errattr:
> + nla_nest_cancel(skb, attrs);
> +errout:
> + return -EMSGSIZE;
> +}
> +
> +static int smc_nl_handle_lgr(struct smc_link_group *lgr,
> + struct sk_buff *skb,
> + struct netlink_callback *cb)
> +{
> + int rc = 0;
unnecessary init
> + void *nlh;
> +
> + nlh = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
> + &smc_gen_nl_family, NLM_F_MULTI,
> + SMC_NETLINK_GET_LGR_SMCR);
> + if (!nlh)
> + return -EMSGSIZE;
> + rc = smc_nl_fill_lgr(lgr, skb, cb);
> + if (rc < 0)
> + goto errout;
> +
> + genlmsg_end(skb, nlh);
> + return rc;
smc_nl_fill_lgr() never return positive values (why would it?)
so:
if (rc)
...
...
return 0;
> +errout:
> + genlmsg_cancel(skb, nlh);
> + return rc;
> +}
> static const struct nla_policy smc_gen_nl_policy[SMC_GEN_MAX + 1] = {
> [SMC_GEN_UNSPEC] = { .type = NLA_UNSPEC, },
> [SMC_GEN_SYS_INFO] = { .type = NLA_NESTED, },
> + [SMC_GEN_LGR_SMCR] = { .type = NLA_NESTED, },
not an input attr
Powered by blists - more mailing lists