Re: [PATCH net-next 11/15] mptcp: pm: add id parameter for get_addr
From: Simon Horman
Date: Fri Jan 17 2025 - 05:43:48 EST
On Thu, Jan 16, 2025 at 05:51:33PM +0100, Matthieu Baerts (NGI0) wrote:
> From: Geliang Tang <tanggeliang@xxxxxxxxxx>
>
> The address id is parsed both in mptcp_pm_nl_get_addr() and
> mptcp_userspace_pm_get_addr(), this makes the code somewhat repetitive.
>
> So this patch adds a new parameter 'id' for all get_addr() interfaces.
> The address id is only parsed in mptcp_pm_nl_get_addr_doit(), then pass
> it to both mptcp_pm_nl_get_addr() and mptcp_userspace_pm_get_addr().
>
> Signed-off-by: Geliang Tang <tanggeliang@xxxxxxxxxx>
> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@xxxxxxxxxx>
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@xxxxxxxxxx>
...
> diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
> index 853b1ea8680ae753fcb882d8b8f4486519798503..392f91dd21b4ce07efb5f44c701f2261afcdc37e 100644
> --- a/net/mptcp/pm_netlink.c
> +++ b/net/mptcp/pm_netlink.c
> @@ -1773,23 +1773,15 @@ int mptcp_nl_fill_addr(struct sk_buff *skb,
> return -EMSGSIZE;
> }
>
> -int mptcp_pm_nl_get_addr(struct genl_info *info)
> +int mptcp_pm_nl_get_addr(u8 id, struct genl_info *info)
> {
> struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
> - struct mptcp_pm_addr_entry addr, *entry;
> + struct mptcp_pm_addr_entry *entry;
> struct sk_buff *msg;
> struct nlattr *attr;
> void *reply;
> int ret;
>
> - if (GENL_REQ_ATTR_CHECK(info, MPTCP_PM_ENDPOINT_ADDR))
> - return -EINVAL;
> -
> - attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR];
> - ret = mptcp_pm_parse_entry(attr, info, false, &addr);
> - if (ret < 0)
> - return ret;
> -
Hi Matthieu and Geliang,
This hunk removes the initialisation of attr...
> msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
> if (!msg)
> return -ENOMEM;
> @@ -1803,7 +1795,7 @@ int mptcp_pm_nl_get_addr(struct genl_info *info)
> }
>
> rcu_read_lock();
> - entry = __lookup_addr_by_id(pernet, addr.addr.id);
> + entry = __lookup_addr_by_id(pernet, id);
> if (!entry) {
> NL_SET_ERR_MSG_ATTR(info->extack, attr, "address not found");
... but attr is still used here.
Flagged by clang-19 W=1 builds and Smatch.
> ret = -EINVAL;
...