]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
selftests: mptcp: add the port argument for set_flags
authorGeliang Tang <geliang.tang@suse.com>
Sat, 5 Feb 2022 00:03:30 +0000 (16:03 -0800)
committerJakub Kicinski <kuba@kernel.org>
Sat, 5 Feb 2022 04:30:23 +0000 (20:30 -0800)
This patch added the port argument for setting the address flags in
pm_nl_ctl.

Usage:

    pm_nl_ctl set 10.0.2.1 flags backup port 10100

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/mptcp/pm_nl_ctl.c

index 152b84e44d69d79d1c7cea5eabc03b4915a3c692..2a57462764d062d4e7112fc3e20dcd96342e1c9e 100644 (file)
@@ -28,7 +28,7 @@ static void syntax(char *argv[])
        fprintf(stderr, "\tadd [flags signal|subflow|backup|fullmesh] [id <nr>] [dev <name>] <ip>\n");
        fprintf(stderr, "\tdel <id> [<ip>]\n");
        fprintf(stderr, "\tget <id>\n");
-       fprintf(stderr, "\tset <ip> [flags backup|nobackup|fullmesh|nofullmesh]\n");
+       fprintf(stderr, "\tset <ip> [flags backup|nobackup|fullmesh|nofullmesh] [port <nr>]\n");
        fprintf(stderr, "\tflush\n");
        fprintf(stderr, "\tdump\n");
        fprintf(stderr, "\tlimits [<rcv addr max> <subflow max>]\n");
@@ -721,6 +721,18 @@ int set_flags(int fd, int pm_family, int argc, char *argv[])
                        rta->rta_len = RTA_LENGTH(4);
                        memcpy(RTA_DATA(rta), &flags, 4);
                        off += NLMSG_ALIGN(rta->rta_len);
+               } else if (!strcmp(argv[arg], "port")) {
+                       u_int16_t port;
+
+                       if (++arg >= argc)
+                               error(1, 0, " missing port value");
+
+                       port = atoi(argv[arg]);
+                       rta = (void *)(data + off);
+                       rta->rta_type = MPTCP_PM_ADDR_ATTR_PORT;
+                       rta->rta_len = RTA_LENGTH(2);
+                       memcpy(RTA_DATA(rta), &port, 2);
+                       off += NLMSG_ALIGN(rta->rta_len);
                } else {
                        error(1, 0, "unknown keyword %s", argv[arg]);
                }