Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp359853rdg; Tue, 10 Oct 2023 12:23:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmoqDuTMZ1VzKw/sEu5yZhsXJ3Ht4yShVSrmUHzlyh+UWlv4kqJ+u0mQnZ8+ldfNl8L1/V X-Received: by 2002:a05:6a20:f3a2:b0:154:9943:7320 with SMTP id qr34-20020a056a20f3a200b0015499437320mr15296884pzb.28.1696965801106; Tue, 10 Oct 2023 12:23:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696965801; cv=none; d=google.com; s=arc-20160816; b=Go4INla4O/dVcFe6fuiwStWWoCGKxSD5fogTEfsprQrLSi4jWuIII3mScY176aCGgB hNX2kuvHUjLNTZMBASE/xHUzJ/y7Tqfu/68HaiaJf3CrIZo3Xhg4XstPXsE2peuzllus g8KdnqUooGPWERTctaRb1HgIZoYiVHVY+GpfgsxdJBlEo/11/oZSaLA0baDAA5Xf9C2K lfg9o2RNf4F+PedusK4p/uVZFOSeKQxX21x3JlHAWVPfLxElDxeQyTxePNTdCtgAHf+K kTihuFR11Wt5BkP+mllLfJgRJs+WJuQoAhy06IvaIlWv6OXX5gL16GvVQjeHCH2bicNh hRDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=9dSpnidx07T9fqYRSdBACSFWG5mGxjyf52N8EwvQ+lk=; fh=CMthp1ao86x1aG9RPV72P83kOX00N/q60qpwDQNh1po=; b=0R5s5fW7+Xukgro/kGiCCWNSgYTywo7KVOopJgOcnBI7OHTYmbrP6e0Lh6czt8gD1+ 7wQjy/7Mxd4aJg+9FKa+2AL7Uj6ZyWn/DIpe904ARwGJcPuAIueuZJHW9RK+JjPvtNoi 3j92toPGXVXRqGJMjgo47bKDlso6FetLFFVFYGxpIAUp5obftYJdCfogCaFINaP2k8Ma 3oAZb2qEmsQRdJtboOsJW3SMpfGcKw6gsiTdZeqtbRPNH5ejbJceDVQmGjGVgirKBYkt f2QCAQOpOeXZaeWZD19rZkO5IzrIvwne8hWhjOacExivHlzcRpNQpseJsbei5Jrn3gwa Ukuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VxiPP7eU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id x63-20020a638642000000b0058934e7216dsi12451584pgd.751.2023.10.10.12.23.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 12:23:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VxiPP7eU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E852481C5270; Tue, 10 Oct 2023 12:23:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234352AbjJJTWi (ORCPT + 99 others); Tue, 10 Oct 2023 15:22:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234284AbjJJTWV (ORCPT ); Tue, 10 Oct 2023 15:22:21 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 066E3C4 for ; Tue, 10 Oct 2023 12:22:17 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F263C4339A; Tue, 10 Oct 2023 19:22:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696965737; bh=WzRXUUwS9m1a0U8d7UAQjJP9E67JgFPV0KFH7ZPXq5c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VxiPP7eUSPv1h6qEzguisBtJlqqqbNuI41pr20qDt02VcVcDvCHtsEftJZOYIVFYb 5tvFhJvE5usVnQ9xeX/WaiizKkYA5oRbcsFkAWzNZO5WHFglKlbqBCG7KpiGJyXVLo SuqUb4zzvoKqsTLDU5HlDRHW+NlSsiVGXwcob6mrjz+RTo5pN4rQBfHjOwt83UM8Qz MrNovBK7V1DCZnB2XAl5Hov0nQS8euhA6W+/7LoyAKXrping5ZriuDkuSfUyItYsI5 szYSOYtUxao+3amtpq/1lOsdKs0UlmPA/XP3LiUWLsD+g4VIHpjYc9qti9It63Y4qp vNAJOT2sCZUeA== From: Matthieu Baerts Date: Tue, 10 Oct 2023 21:21:47 +0200 Subject: [PATCH net-next 6/6] net: mptcp: use policy generated by YAML spec MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-6-18dd117e8f50@kernel.org> References: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-0-18dd117e8f50@kernel.org> In-Reply-To: <20231010-upstream-net-next-20231006-mptcp-ynl-v1-0-18dd117e8f50@kernel.org> To: mptcp@lists.linux.dev, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Mat Martineau Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Davide Caratti , Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=20691; i=matttbe@kernel.org; h=from:subject:message-id; bh=Q4zkiSxZDxxWhjFQgvV08qM+2CwZMM5SYj3P+JEtxlk=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBlJaRVv4s2thphzXvxPLZCIFde5yz40b1aBE5hH beFS77ctzKJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZSWkVQAKCRD2t4JPQmmg cybMD/0cRyOOyfwGHtnoEv+R4G9f+cWQ+8p/Vh5P6ARtQ4bETVjp1hV+ENVKG005K7d9uJi/+jU mfEe7BVkUbpUaVCXmJpFIdY6QcFnvmGEeqQF0/+1TDYuksNuxKQXIJzfCUMI9eHxtwrzlyt5DZx YdeLfmtsrv6uQ4tyd6NVti8EbTJnDOyfAWSaSH6xnZc5rWUcqdmg7uKiB2zNpNw4nnXl0o1KvZn 7EsD1+94Y8ahqFpmmnXrLOQpQiKoYZmq5VckFGDnogzuKTOo2caOvoPhaRqIf75qXaOVpf8c6D6 ews1P+C5mkboXqojxuYIoxdBRV/+UXxI5gtJtPt31CB/vNgK4OpiWqwXrpDuSrVGYL3tfISWSO8 +pgApABDAboonX68WRlimhMTjSL8J2HlepQTQP+LIAdjl51tPsbZdQFrGtJ5lnKvrBOQV9sjT4K AmxECaXjOSXgPfhh60aOejNIO3TcUXbKMQYNRObcsr6IgOODCf8wJXxPXmHCilZFOGrKlHoigTb TEcW5+Bii2jfXlJx2KJrJHGijQO3fl6uTYtrdhB4+/TnAO2nXi7hyyadIeGIqQ6FpwgLLxNhrJd 4GvranketaG37NBDx/nPbCVQS6WIvqnKABspWVqKYfQqxZpFSzDeFMbra4MGZrmLZX04fM89WYD RZRIU+Lj56ZaHBw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 10 Oct 2023 12:23:16 -0700 (PDT) X-Spam-Level: ** From: Davide Caratti generated with: $ ./tools/net/ynl/ynl-gen-c.py --mode kernel \ > --spec Documentation/netlink/specs/mptcp.yaml --source \ > -o net/mptcp/mptcp_pm_gen.c $ ./tools/net/ynl/ynl-gen-c.py --mode kernel \ > --spec Documentation/netlink/specs/mptcp.yaml --header \ > -o net/mptcp/mptcp_pm_gen.h Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/340 Acked-by: Paolo Abeni Signed-off-by: Davide Caratti Signed-off-by: Matthieu Baerts --- net/mptcp/Makefile | 3 +- net/mptcp/mptcp_pm_gen.c | 179 +++++++++++++++++++++++++++++++++++++++++++++++ net/mptcp/mptcp_pm_gen.h | 58 +++++++++++++++ net/mptcp/pm_netlink.c | 165 +++---------------------------------------- net/mptcp/protocol.h | 6 +- 5 files changed, 250 insertions(+), 161 deletions(-) diff --git a/net/mptcp/Makefile b/net/mptcp/Makefile index 84e531f86b82..bcf1dbf3a432 100644 --- a/net/mptcp/Makefile +++ b/net/mptcp/Makefile @@ -2,7 +2,8 @@ obj-$(CONFIG_MPTCP) += mptcp.o mptcp-y := protocol.o subflow.o options.o token.o crypto.o ctrl.o pm.o diag.o \ - mib.o pm_netlink.o sockopt.o pm_userspace.o fastopen.o sched.o + mib.o pm_netlink.o sockopt.o pm_userspace.o fastopen.o sched.o \ + mptcp_pm_gen.o obj-$(CONFIG_SYN_COOKIES) += syncookies.o obj-$(CONFIG_INET_MPTCP_DIAG) += mptcp_diag.o diff --git a/net/mptcp/mptcp_pm_gen.c b/net/mptcp/mptcp_pm_gen.c new file mode 100644 index 000000000000..673b5167af6b --- /dev/null +++ b/net/mptcp/mptcp_pm_gen.c @@ -0,0 +1,179 @@ +// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/mptcp.yaml */ +/* YNL-GEN kernel source */ + +#include +#include + +#include "mptcp_pm_gen.h" + +#include + +/* Common nested types */ +const struct nla_policy mptcp_pm_address_nl_policy[MPTCP_PM_ADDR_ATTR_IF_IDX + 1] = { + [MPTCP_PM_ADDR_ATTR_FAMILY] = { .type = NLA_U16, }, + [MPTCP_PM_ADDR_ATTR_ID] = { .type = NLA_U8, }, + [MPTCP_PM_ADDR_ATTR_ADDR4] = { .type = NLA_U32, }, + [MPTCP_PM_ADDR_ATTR_ADDR6] = { .len = 16, }, + [MPTCP_PM_ADDR_ATTR_PORT] = { .type = NLA_U16, }, + [MPTCP_PM_ADDR_ATTR_FLAGS] = { .type = NLA_U32, }, + [MPTCP_PM_ADDR_ATTR_IF_IDX] = { .type = NLA_S32, }, +}; + +/* MPTCP_PM_CMD_ADD_ADDR - do */ +const struct nla_policy mptcp_pm_add_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = { + [MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_DEL_ADDR - do */ +const struct nla_policy mptcp_pm_del_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = { + [MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_GET_ADDR - do */ +const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = { + [MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_FLUSH_ADDRS - do */ +const struct nla_policy mptcp_pm_flush_addrs_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = { + [MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_SET_LIMITS - do */ +const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1] = { + [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, }, +}; + +/* MPTCP_PM_CMD_GET_LIMITS - do */ +const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1] = { + [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, }, +}; + +/* MPTCP_PM_CMD_SET_FLAGS - do */ +const struct nla_policy mptcp_pm_set_flags_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = { + [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_ANNOUNCE - do */ +const struct nla_policy mptcp_pm_announce_nl_policy[MPTCP_PM_ATTR_TOKEN + 1] = { + [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, +}; + +/* MPTCP_PM_CMD_REMOVE - do */ +const struct nla_policy mptcp_pm_remove_nl_policy[MPTCP_PM_ATTR_LOC_ID + 1] = { + [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_LOC_ID] = { .type = NLA_U8, }, +}; + +/* MPTCP_PM_CMD_SUBFLOW_CREATE - do */ +const struct nla_policy mptcp_pm_subflow_create_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = { + [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* MPTCP_PM_CMD_SUBFLOW_DESTROY - do */ +const struct nla_policy mptcp_pm_subflow_destroy_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = { + [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), + [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, + [MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), +}; + +/* Ops table for mptcp_pm */ +const struct genl_ops mptcp_pm_nl_ops[11] = { + { + .cmd = MPTCP_PM_CMD_ADD_ADDR, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_add_addr_doit, + .policy = mptcp_pm_add_addr_nl_policy, + .maxattr = MPTCP_PM_ENDPOINT_ADDR, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_DEL_ADDR, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_del_addr_doit, + .policy = mptcp_pm_del_addr_nl_policy, + .maxattr = MPTCP_PM_ENDPOINT_ADDR, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_GET_ADDR, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_get_addr_doit, + .dumpit = mptcp_pm_nl_get_addr_dumpit, + .policy = mptcp_pm_get_addr_nl_policy, + .maxattr = MPTCP_PM_ENDPOINT_ADDR, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_FLUSH_ADDRS, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_flush_addrs_doit, + .policy = mptcp_pm_flush_addrs_nl_policy, + .maxattr = MPTCP_PM_ENDPOINT_ADDR, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_SET_LIMITS, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_set_limits_doit, + .policy = mptcp_pm_set_limits_nl_policy, + .maxattr = MPTCP_PM_ATTR_SUBFLOWS, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_GET_LIMITS, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_get_limits_doit, + .policy = mptcp_pm_get_limits_nl_policy, + .maxattr = MPTCP_PM_ATTR_SUBFLOWS, + }, + { + .cmd = MPTCP_PM_CMD_SET_FLAGS, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_set_flags_doit, + .policy = mptcp_pm_set_flags_nl_policy, + .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_ANNOUNCE, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_announce_doit, + .policy = mptcp_pm_announce_nl_policy, + .maxattr = MPTCP_PM_ATTR_TOKEN, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_REMOVE, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_remove_doit, + .policy = mptcp_pm_remove_nl_policy, + .maxattr = MPTCP_PM_ATTR_LOC_ID, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_SUBFLOW_CREATE, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_subflow_create_doit, + .policy = mptcp_pm_subflow_create_nl_policy, + .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, + .flags = GENL_UNS_ADMIN_PERM, + }, + { + .cmd = MPTCP_PM_CMD_SUBFLOW_DESTROY, + .validate = GENL_DONT_VALIDATE_STRICT, + .doit = mptcp_pm_nl_subflow_destroy_doit, + .policy = mptcp_pm_subflow_destroy_nl_policy, + .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, + .flags = GENL_UNS_ADMIN_PERM, + }, +}; diff --git a/net/mptcp/mptcp_pm_gen.h b/net/mptcp/mptcp_pm_gen.h new file mode 100644 index 000000000000..10579d184587 --- /dev/null +++ b/net/mptcp/mptcp_pm_gen.h @@ -0,0 +1,58 @@ +/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ +/* Do not edit directly, auto-generated from: */ +/* Documentation/netlink/specs/mptcp.yaml */ +/* YNL-GEN kernel header */ + +#ifndef _LINUX_MPTCP_PM_GEN_H +#define _LINUX_MPTCP_PM_GEN_H + +#include +#include + +#include + +/* Common nested types */ +extern const struct nla_policy mptcp_pm_address_nl_policy[MPTCP_PM_ADDR_ATTR_IF_IDX + 1]; + +extern const struct nla_policy mptcp_pm_add_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1]; + +extern const struct nla_policy mptcp_pm_del_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1]; + +extern const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1]; + +extern const struct nla_policy mptcp_pm_flush_addrs_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1]; + +extern const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1]; + +extern const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1]; + +extern const struct nla_policy mptcp_pm_set_flags_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1]; + +extern const struct nla_policy mptcp_pm_announce_nl_policy[MPTCP_PM_ATTR_TOKEN + 1]; + +extern const struct nla_policy mptcp_pm_remove_nl_policy[MPTCP_PM_ATTR_LOC_ID + 1]; + +extern const struct nla_policy mptcp_pm_subflow_create_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1]; + +extern const struct nla_policy mptcp_pm_subflow_destroy_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1]; + +/* Ops table for mptcp_pm */ +extern const struct genl_ops mptcp_pm_nl_ops[11]; + +int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *skb, + struct netlink_callback *cb); +int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_get_limits_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info); +int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, + struct genl_info *info); +int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, + struct genl_info *info); + +#endif /* _LINUX_MPTCP_PM_GEN_H */ diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index dc3ed337eb1f..1529ec358815 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -48,60 +48,6 @@ struct pm_nl_pernet { #define MPTCP_PM_ADDR_MAX 8 #define ADD_ADDR_RETRANS_MAX 3 -static -const struct nla_policy mptcp_pm_address_nl_policy[MPTCP_PM_ADDR_ATTR_IF_IDX + 1] = { - [MPTCP_PM_ADDR_ATTR_FAMILY] = { .type = NLA_U16, }, - [MPTCP_PM_ADDR_ATTR_ID] = { .type = NLA_U8, }, - [MPTCP_PM_ADDR_ATTR_ADDR4] = { .type = NLA_U32, }, - [MPTCP_PM_ADDR_ATTR_ADDR6] = { .len = 16, }, - [MPTCP_PM_ADDR_ATTR_PORT] = { .type = NLA_U16, }, - [MPTCP_PM_ADDR_ATTR_FLAGS] = { .type = NLA_U32, }, - [MPTCP_PM_ADDR_ATTR_IF_IDX] = { .type = NLA_S32, }, -}; - -/* MPTCP_PM_CMD_ADD_ADDR / DEL / GET / FLUSH - do */ -static -const struct nla_policy mptcp_pm_endpoint_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = { - [MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), -}; - -/* MPTCP_PM_CMD_SET_LIMITS - do */ -static -const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1] = { - [MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, }, - [MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, }, -}; - -/* MPTCP_PM_CMD_SET_FLAGS - do */ -static -const struct nla_policy mptcp_pm_set_flags_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = { - [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), - [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, - [MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), -}; - -/* MPTCP_PM_CMD_ANNOUNCE - do */ -static -const struct nla_policy mptcp_pm_announce_nl_policy[MPTCP_PM_ATTR_TOKEN + 1] = { - [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), - [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, -}; - -/* MPTCP_PM_CMD_REMOVE - do */ -static -const struct nla_policy mptcp_pm_remove_nl_policy[MPTCP_PM_ATTR_LOC_ID + 1] = { - [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, - [MPTCP_PM_ATTR_LOC_ID] = { .type = NLA_U8, }, -}; - -/* MPTCP_PM_CMD_SUBFLOW_CREATE / DESTROY - do */ -static -const struct nla_policy mptcp_pm_subflow_create_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = { - [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), - [MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, }, - [MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy), -}; - static struct pm_nl_pernet *pm_nl_get_pernet(const struct net *net) { return net_generic(net, pm_nl_pernet_id); @@ -1334,7 +1280,7 @@ static int mptcp_nl_add_subflow_or_signal_addr(struct net *net) return 0; } -static int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); @@ -1515,7 +1461,7 @@ static int mptcp_nl_remove_id_zero_address(struct net *net, return 0; } -static int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); @@ -1650,7 +1596,7 @@ static void __reset_counters(struct pm_nl_pernet *pernet) pernet->addrs = 0; } -static int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info) { struct pm_nl_pernet *pernet = genl_info_pm_nl(info); LIST_HEAD(free_list); @@ -1706,7 +1652,7 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb, return -EMSGSIZE; } -static int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); @@ -1756,8 +1702,8 @@ static int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info return ret; } -static int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, - struct netlink_callback *cb) +int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, + struct netlink_callback *cb) { struct net *net = sock_net(msg->sk); struct mptcp_pm_addr_entry *entry; @@ -1814,8 +1760,7 @@ static int parse_limit(struct genl_info *info, int id, unsigned int *limit) return 0; } -static int -mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, struct genl_info *info) { struct pm_nl_pernet *pernet = genl_info_pm_nl(info); unsigned int rcv_addrs, subflows; @@ -1840,8 +1785,7 @@ mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, struct genl_info *info) return ret; } -static int -mptcp_pm_nl_get_limits_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_get_limits_doit(struct sk_buff *skb, struct genl_info *info) { struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct sk_buff *msg; @@ -1950,7 +1894,7 @@ int mptcp_pm_nl_set_flags(struct net *net, struct mptcp_pm_addr_entry *addr, u8 return 0; } -static int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) +int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) { struct mptcp_pm_addr_entry remote = { .addr = { .family = AF_UNSPEC }, }; struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, }; @@ -2314,97 +2258,6 @@ void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, nlmsg_free(skb); } -static const struct genl_ops mptcp_pm_nl_ops[] = { - { - .cmd = MPTCP_PM_CMD_ADD_ADDR, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_add_addr_doit, - .policy = mptcp_pm_endpoint_nl_policy, - .maxattr = MPTCP_PM_ENDPOINT_ADDR, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_DEL_ADDR, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_del_addr_doit, - .policy = mptcp_pm_endpoint_nl_policy, - .maxattr = MPTCP_PM_ENDPOINT_ADDR, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_GET_ADDR, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_get_addr_doit, - .dumpit = mptcp_pm_nl_get_addr_dumpit, - .policy = mptcp_pm_endpoint_nl_policy, - .maxattr = MPTCP_PM_ENDPOINT_ADDR, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_FLUSH_ADDRS, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_flush_addrs_doit, - .policy = mptcp_pm_endpoint_nl_policy, - .maxattr = MPTCP_PM_ENDPOINT_ADDR, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_SET_LIMITS, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_set_limits_doit, - .policy = mptcp_pm_set_limits_nl_policy, - .maxattr = MPTCP_PM_ATTR_SUBFLOWS, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_GET_LIMITS, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_get_limits_doit, - .policy = mptcp_pm_set_limits_nl_policy, - .maxattr = MPTCP_PM_ATTR_SUBFLOWS, - }, - { - .cmd = MPTCP_PM_CMD_SET_FLAGS, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_set_flags_doit, - .policy = mptcp_pm_set_flags_nl_policy, - .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_ANNOUNCE, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_announce_doit, - .policy = mptcp_pm_announce_nl_policy, - .maxattr = MPTCP_PM_ATTR_TOKEN, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_REMOVE, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_remove_doit, - .policy = mptcp_pm_remove_nl_policy, - .maxattr = MPTCP_PM_ATTR_LOC_ID, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_SUBFLOW_CREATE, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_subflow_create_doit, - .policy = mptcp_pm_subflow_create_nl_policy, - .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, - .flags = GENL_UNS_ADMIN_PERM, - }, - { - .cmd = MPTCP_PM_CMD_SUBFLOW_DESTROY, - .validate = GENL_DONT_VALIDATE_STRICT, - .doit = mptcp_pm_nl_subflow_destroy_doit, - .policy = mptcp_pm_subflow_create_nl_policy, - .maxattr = MPTCP_PM_ATTR_ADDR_REMOTE, - .flags = GENL_UNS_ADMIN_PERM, - }, -}; - static struct genl_family mptcp_genl_family __ro_after_init = { .name = MPTCP_PM_NAME, .version = MPTCP_PM_VER, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 4d6e40416f84..c4c05afdc48c 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -13,6 +13,8 @@ #include #include +#include "mptcp_pm_gen.h" + #define MPTCP_SUPPORTED_VERSION 1 /* MPTCP option bits */ @@ -877,10 +879,6 @@ void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, struct list_head *rm_list); void mptcp_free_local_addr_list(struct mptcp_sock *msk); -int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info); -int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info); -int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info); -int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb, struct genl_info *info); void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, const struct sock *ssk, gfp_t gfp); -- 2.40.1