]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests: mptcp: pm: use simpler send/recv forms
authorMatthieu Baerts (NGI0) <matttbe@kernel.org>
Fri, 8 May 2026 15:40:53 +0000 (17:40 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 12 May 2026 01:01:37 +0000 (18:01 -0700)
Instead of sendto() and recvfrom() which the NL address that was already
provided before.

Just simpler and easier to read without the to/from variants.

While at it, fix a checkpatch warning by removing multiple assignments.

Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20260508-net-next-mptcp-pm-inc-limits-v1-8-c84e3fdf9b6a@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/mptcp/pm_nl_ctl.c

index 99eecccbf0c8764bff203549535fe243bb2664d2..78180da1efcc53a5d19cb7d6da47638a3e9612c5 100644 (file)
@@ -217,8 +217,6 @@ static int capture_events(int fd, int event_group)
 /* do a netlink command and, if max > 0, fetch the reply ; nh's size >1024B */
 static int do_nl_req(int fd, struct nlmsghdr *nh, int len, int max)
 {
-       struct sockaddr_nl nladdr = { .nl_family = AF_NETLINK };
-       socklen_t addr_len;
        void *data = nh;
        int rem, ret;
        int err = 0;
@@ -230,15 +228,15 @@ static int do_nl_req(int fd, struct nlmsghdr *nh, int len, int max)
        }
 
        nh->nlmsg_len = len;
-       ret = sendto(fd, data, len, 0, (void *)&nladdr, sizeof(nladdr));
+       ret = send(fd, data, len, 0);
        if (ret != len)
                error(1, errno, "send netlink: %uB != %uB\n", ret, len);
 
-       addr_len = sizeof(nladdr);
-       rem = ret = recvfrom(fd, data, max, 0, (void *)&nladdr, &addr_len);
+       ret = recv(fd, data, max, 0);
        if (ret < 0)
                error(1, errno, "recv netlink: %uB\n", ret);
 
+       rem = ret;
        /* Beware: the NLMSG_NEXT macro updates the 'rem' argument */
        for (; NLMSG_OK(nh, rem); nh = NLMSG_NEXT(nh, rem)) {
                if (nh->nlmsg_type == NLMSG_DONE)