convert MPTCP to use YAML spec
Subsystems (3)
cover convert MPTCP to use YAML spec
this series converts most of the MPTCP netlink interface (plus uAPI bits) to use sources generated by a YAML spec file. Patch 2/5 and 5/5 have been individually verified with kselftests.
POC:
$ sudo ./tools/net/ynl/cli.py --spec \
Quoted 2 lines
Documentation/netlink/specs/mptcp.yaml--doadd_addr\
--json '{"addr": {"addr4": 16909061, "family": 2, "flags": 4, "id": 10, "port": 0}}'
$ ip -j mptcp endpoint show id 10
[{"address":"1.2.3.5","id":10,"backup":true}]Davide Caratti (5):
tools: ynl: add uns-admin-perm to genetlink legacy
mptcp: convert netlink from small_ops to ops
Documentation: netlink: add a YAML spec for mptcp
mptcp: uapi: use header file generated from YAML spec
net: mptcp: use policy generated by YAML spec
Documentation/netlink/genetlink-legacy.yaml | 2 +- Documentation/netlink/specs/mptcp.yaml | 397 ++++++++++++++++++++ include/uapi/linux/mptcp.h | 174 +-------- include/uapi/linux/mptcp_pm.h | 149 ++++++++ net/mptcp/Makefile | 3 +- net/mptcp/mptcp_pm_gen.c | 179 +++++++++ net/mptcp/mptcp_pm_gen.h | 58 +++ net/mptcp/pm_netlink.c | 134 ++----- net/mptcp/pm_userspace.c | 13 +- net/mptcp/protocol.h | 4 +- 10 files changed, 836 insertions(+), 277 deletions(-) create mode 100644 Documentation/netlink/specs/mptcp.yaml create mode 100644 include/uapi/linux/mptcp_pm.h create mode 100644 net/mptcp/mptcp_pm_gen.c create mode 100644 net/mptcp/mptcp_pm_gen.h
Signature · 1 line
2.40.1
PATCH 1/5 tools: ynl: add uns-admin-perm to genetlink legacy
this flag maps to GENL_UNS_ADMIN_PERM and will be used by future specs.
--- Documentation/netlink/genetlink-legacy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/netlink/genetlink-legacy.yaml +1 -1
@@ -316,7 +316,7 @@ properties: description: Command flags. type: array items: - enum: [ admin-perm ] + enum: [ admin-perm, uns-admin-perm ] dont-validate: description: Kernel attribute validation flags. type: array
Signature · 1 line
2.40.1
PATCH 3/5 Documentation: netlink: add a YAML spec for mptcp
In reply to Davide Caratti--- Documentation/netlink/specs/mptcp.yaml | 397 +++++++++++++++++++++++++ 1 file changed, 397 insertions(+) create mode 100644 Documentation/netlink/specs/mptcp.yaml
Documentation/netlink/specs/mptcp.yaml new file +397 -0
@@ -0,0 +1,397 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) + +name: mptcp_pm +protocol: genetlink-legacy +doc: Multipath TCP. + +c-family-name: mptcp_pm_name +c-version-name: mptcp_pm_ver +max-by-define: true +kernel-policy: per-op + +definitions: + - + type: enum + name: event-type + enum-name: mptcp_event_type + name-prefix: mptcp_event_ + entries: + - + name: unspec + - + name: created + value: 1 + doc: + token, family, saddr4 | saddr6, daddr4 | daddr6, sport, dport + A new MPTCP connection has been created. It is the good time to + allocate memory and send ADD_ADDR if needed. Depending on the + traffic-patterns it can take a long time until the + MPTCP_EVENT_ESTABLISHED is sent. + - + name: established + value: 2 + doc: + token, family, saddr4 | saddr6, daddr4 | daddr6, sport, dport + A MPTCP connection is established (can start new subflows). + - + name: closed + value: 3 + doc: + token + A MPTCP connection has stopped. + - + name: announced + value: 6 + doc: + token, rem_id, family, daddr4 | daddr6 [, dport] + A new address has been announced by the peer. + - + name: removed + value: 7 + doc: + token, rem_id + An address has been lost by the peer. + - + name: sub_established + value: 10 + doc: + token, family, loc_id, rem_id, saddr4 | saddr6, daddr4 | daddr6, sport, + dport, backup, if_idx [, error] + A new subflow has been established. 'error' should not be set. + - + name: sub_closed + value: 11 + doc: + token, family, loc_id, rem_id, saddr4 | saddr6, daddr4 | daddr6, sport, + dport, backup, if_idx [, error] + A subflow has been closed. An error (copy of sk_err) could be set if an + error has been detected for this subflow. + - + name: sub_priority + value: 13 + doc: + token, family, loc_id, rem_id, saddr4 | saddr6, daddr4 | daddr6, sport, + dport, backup, if_idx [, error] + The priority of a subflow has changed. 'error' should not be set. + - + name: listener_created + value: 15 + doc: + family, sport, saddr4 | saddr6 + A new PM listener is created. + - + name: listener_closed + value: 16 + doc: + family, sport, saddr4 | saddr6 + A PM listener is closed. + +attribute-sets: + - + name: address + name-prefix: mptcp_pm_addr_attr_ + attributes: + - + name: unspec + type: unused + value: 0 + - + name: family + type: u16 + - + name: id + type: u8 + - + name: addr4 + type: u32 + byte-order: big-endian + - + name: addr6 + type: binary + checks: + min-len: 16 + - + name: port + type: u16 + byte-order: big-endian + - + name: flags + type: u32 + - + name: if_idx + type: s32 + - + name: subflow-attribute + name-prefix: mptcp_subflow_attr_ + attributes: + - + name: unspec + type: unused + value: 0 + - + name: token_rem + type: u32 + - + name: token_loc + type: u32 + - + name: relwrite_seq + type: u32 + - + name: map_seq + type: u64 + - + name: map_sfseq + type: u32 + - + name: ssn_offset + type: u32 + - + name: map_datalen + type: u16 + - + name: flags + type: u32 + - + name: id_rem + type: u8 + - + name: id_loc + type: u8 + - + name: pad + type: pad + - + name: endpoint + name-prefix: mptcp_pm_endpoint_ + attributes: + - + name: addr + type: nest + nested-attributes: address + - + name: attr + name-prefix: mptcp_pm_attr_ + attributes: + - + name: unspec + type: unused + value: 0 + - + name: addr + type: nest + nested-attributes: address + - + name: rcv_add_addrs + type: u32 + - + name: subflows + type: u32 + - + name: token + type: u32 + - + name: loc_id + type: u8 + - + name: addr_remote + type: nest + nested-attributes: address + - + name: event_attr + enum-name: mptcp_event_attr + name-prefix: mptcp_attr_ + attributes: + - + name: UNSPEC + type: unused + value: 0 + - + name: token + type: u32 + - + name: family + type: u16 + - + name: loc_id + type: u8 + - + name: rem_id + type: u8 + - + name: saddr4 + type: u32 + byte-order: big-endian + - + name: saddr6 + type: binary + checks: + min-len: 16 + - + name: daddr4 + type: u32 + byte-order: big-endian + - + name: daddr6 + type: binary + checks: + min-len: 16 + - + name: sport + type: u16 + byte-order: big-endian + - + name: dport + type: u16 + byte-order: big-endian + - + name: backup + type: u8 + - + name: error + type: u8 + - + name: flags + type: u16 + - + name: timeout + type: u32 + - + name: if_idx + type: u32 + - + name: reset_reason + type: u32 + - + name: reset_flags + type: u32 + - + name: server_side + type: u8 + +operations: + list: + - + name: unspec + doc: unused + value: 0 + - + name: add_addr + doc: Add endpoint + attribute-set: endpoint + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: &add_addr_attrs + request: + attributes: + - addr + - + name: del_addr + doc: Delete endpoint + attribute-set: endpoint + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: *add_addr_attrs + - + name: get_addr + doc: Get endpoint information + attribute-set: endpoint + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: &get_addr_attrs + request: + attributes: + - addr + reply: + attributes: + - addr + dump: + reply: + attributes: + - addr + - + name: flush_addrs + doc: flush addresses + attribute-set: endpoint + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: *add_addr_attrs + - + name: set_limits + doc: Set protocol limits + attribute-set: attr + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: &mptcp_limits + request: + attributes: + - rcv_add_addrs + - subflows + - + name: get_limits + doc: Get protocol limits + attribute-set: attr + dont-validate: [ strict ] + do: &mptcp_get_limits + request: + attributes: + - rcv_add_addrs + - subflows + reply: + attributes: + - rcv_add_addrs + - subflows + - + name: set_flags + doc: Change endpoint flags + attribute-set: attr + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: &mptcp_set_flags + request: + attributes: + - addr + - addr_remote + - token + - + name: announce + doc: announce new sf + attribute-set: attr + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: &announce_add + request: + attributes: + - token + - addr + - + name: remove + doc: announce removal + attribute-set: attr + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: + request: + attributes: + - token + - loc_id + - + name: subflow_create + doc: todo + attribute-set: attr + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: &sf_create + request: + attributes: + - addr_remote + - token + - addr + - + name: subflow_destroy + doc: todo + attribute-set: attr + dont-validate: [ strict ] + flags: [ uns-admin-perm ] + do: *sf_create +
Signature · 1 line
2.40.1
PATCH 2/5 mptcp: convert netlink from small_ops to ops
In reply to Davide Caratti- use a separate attribute set for add/del/get/flush address operation, binary compatible with the existing one, to store the endpoint address. MPTCP_PM_ENDPOINT_ADDR is added to the uAPI (with the same value as MPTCP_PM_ATTR_ADDR) for these operations.
- convert mptcp_pm_ops[] and add policy files accordingly.
this prepares MPTCP control plane to be described as YAML spec.
--- include/uapi/linux/mptcp.h | 8 ++ net/mptcp/pm_netlink.c | 204 ++++++++++++++++++++++++------------- net/mptcp/pm_userspace.c | 2 +- net/mptcp/protocol.h | 4 +- 4 files changed, 146 insertions(+), 72 deletions(-)
include/uapi/linux/mptcp.h +8 -0
@@ -65,6 +65,14 @@ enum {#define MPTCP_PM_ATTR_MAX (__MPTCP_PM_ATTR_MAX - 1) +enum { +MPTCP_PM_ENDPOINT_ADDR =1 , + + __MPTCP_PM_ENDPOINT_MAX +}; + +#define MPTCP_PM_ENDPOINT_MAX (__MPTCP_PM_ENDPOINT_MAX - 1) +enum {MPTCP_PM_ADDR_ATTR_UNSPEC ,
net/mptcp/pm_netlink.c +134 -70
306 lines not on this page · raw message
net/mptcp/pm_userspace.c +1 -1
@@ -172,7 +172,7 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info) goto announce_err; } - err =mptcp_pm_parse_entry (addr, info, true, &addr_val); + err =mptcp_pm_parse_entry (addr, info, mptcp_pm_add_addr_nl_policy, true, &addr_val);if (err <0 ) {GENL_SET_ERR_MSG (info,"error parsing local address" ); goto announce_err;
net/mptcp/protocol.h +3 -1
@@ -335,6 +335,8 @@ struct mptcp_sock {#define mptcp_for_each_subflow_safe (__msk, __subflow, __tmp) \ list_for_each_entry_safe(__subflow, __tmp, &((__msk)->conn_list), node) +extern const struct nla_policy mptcp_pm_add_addr_nl_policy[]; +static inline void msk_owned_by_me (const struct mptcp_sock *msk) {sock_owned_by_me ((const struct sock *)msk);
@@ -802,7 +804,7 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk);int mptcp_pm_parse_addr (struct nlattr *attr,struct genl_info *info,struct mptcp_addr_info *addr);int mptcp_pm_parse_entry (struct nlattr *attr,struct genl_info *info, -bool require_family, +const struct nla_policy *nlap,bool require_family,struct mptcp_pm_addr_entry *entry); bool mptcp_pm_addr_families_match(const struct sock *sk, const struct mptcp_addr_info *loc,
Signature · 1 line
2.40.1
PATCH 4/5 mptcp: uapi: use header file generated from YAML spec
In reply to Davide Carattigenerated with:
$ ./tools/net/ynl/ynl-gen-c.py --mode uapi \
Quoted 2 lines
--spec
Documentation/netlink/specs/mptcp.yaml\
--header -oinclude/uapi/linux/mptcp_pm.h
--- include/uapi/linux/mptcp.h | 182 ++-------------------------------- include/uapi/linux/mptcp_pm.h | 149 ++++++++++++++++++++++++++++ 2 files changed, 159 insertions(+), 172 deletions(-) create mode 100644 include/uapi/linux/mptcp_pm.h
include/uapi/linux/mptcp.h +10 -172
@@ -23,99 +23,24 @@#define MPTCP_SUBFLOW_FLAG_CONNECTED _BITUL(7)#define MPTCP_SUBFLOW_FLAG_MAPVALID _BITUL(8) -enum { -MPTCP_SUBFLOW_ATTR_UNSPEC , -MPTCP_SUBFLOW_ATTR_TOKEN_REM , -MPTCP_SUBFLOW_ATTR_TOKEN_LOC , -MPTCP_SUBFLOW_ATTR_RELWRITE_SEQ , -MPTCP_SUBFLOW_ATTR_MAP_SEQ , -MPTCP_SUBFLOW_ATTR_MAP_SFSEQ , -MPTCP_SUBFLOW_ATTR_SSN_OFFSET , -MPTCP_SUBFLOW_ATTR_MAP_DATALEN , -MPTCP_SUBFLOW_ATTR_FLAGS , -MPTCP_SUBFLOW_ATTR_ID_REM , -MPTCP_SUBFLOW_ATTR_ID_LOC , -MPTCP_SUBFLOW_ATTR_PAD , - __MPTCP_SUBFLOW_ATTR_MAX -}; - -#define MPTCP_SUBFLOW_ATTR_MAX (__MPTCP_SUBFLOW_ATTR_MAX - 1) - -/* netlink interface */ -#define MPTCP_PM_NAME "mptcp_pm"#define MPTCP_PM_CMD_GRP_NAME "mptcp_pm_cmds"#define MPTCP_PM_EV_GRP_NAME "mptcp_pm_events" -#define MPTCP_PM_VER 0x1 - -/* -* ATTR types defined for MPTCP -*/ -enum { -MPTCP_PM_ATTR_UNSPEC , - -MPTCP_PM_ATTR_ADDR ,/* nested address */ -MPTCP_PM_ATTR_RCV_ADD_ADDRS ,/* u32 */ -MPTCP_PM_ATTR_SUBFLOWS ,/* u32 */ -MPTCP_PM_ATTR_TOKEN ,/* u32 */ -MPTCP_PM_ATTR_LOC_ID ,/* u8 */ -MPTCP_PM_ATTR_ADDR_REMOTE ,/* nested address */ - - __MPTCP_PM_ATTR_MAX -}; - -#define MPTCP_PM_ATTR_MAX (__MPTCP_PM_ATTR_MAX - 1) - -enum { -MPTCP_PM_ENDPOINT_ADDR =1 , - - __MPTCP_PM_ENDPOINT_MAX -}; - -#define MPTCP_PM_ENDPOINT_MAX (__MPTCP_PM_ENDPOINT_MAX - 1) - -enum { -MPTCP_PM_ADDR_ATTR_UNSPEC , - -MPTCP_PM_ADDR_ATTR_FAMILY ,/* u16 */ -MPTCP_PM_ADDR_ATTR_ID ,/* u8 */ -MPTCP_PM_ADDR_ATTR_ADDR4 ,/* struct in_addr */ -MPTCP_PM_ADDR_ATTR_ADDR6 ,/* struct in6_addr */ -MPTCP_PM_ADDR_ATTR_PORT ,/* u16 */ -MPTCP_PM_ADDR_ATTR_FLAGS ,/* u32 */ -MPTCP_PM_ADDR_ATTR_IF_IDX ,/* s32 */ - - __MPTCP_PM_ADDR_ATTR_MAX -}; -#define MPTCP_PM_ADDR_ATTR_MAX (__MPTCP_PM_ADDR_ATTR_MAX - 1) +#include <linux/mptcp_pm.h> -#define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0) -#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1) -#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2) -#define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3) -#define MPTCP_PM_ADDR_FLAG_IMPLICIT (1 << 4) - -enum { -MPTCP_PM_CMD_UNSPEC , - -MPTCP_PM_CMD_ADD_ADDR , -MPTCP_PM_CMD_DEL_ADDR , -MPTCP_PM_CMD_GET_ADDR , -MPTCP_PM_CMD_FLUSH_ADDRS , -MPTCP_PM_CMD_SET_LIMITS , -MPTCP_PM_CMD_GET_LIMITS , -MPTCP_PM_CMD_SET_FLAGS , -MPTCP_PM_CMD_ANNOUNCE , -MPTCP_PM_CMD_REMOVE , -MPTCP_PM_CMD_SUBFLOW_CREATE , -MPTCP_PM_CMD_SUBFLOW_DESTROY , - - __MPTCP_PM_CMD_AFTER_LAST -}; +/* for backward compatibility */ +#define __MPTCP_PM_CMD_AFTER_LAST __MPTCP_PM_CMD_MAX +#define __MPTCP_ATTR_AFTER_LAST __MPTCP_ATTR_MAX#define MPTCP_INFO_FLAG_FALLBACK _BITUL(0)#define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED _BITUL(1) +#define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0) +#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1) +#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2) +#define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3) +#define MPTCP_PM_ADDR_FLAG_IMPLICIT (1 << 4) +struct mptcp_info {__u8 mptcpi_subflows;__u8 mptcpi_add_addr_signal;
@@ -138,93 +63,6 @@ struct mptcp_info {__u64 mptcpi_bytes_acked; }; -/* -* MPTCP_EVENT_CREATED: token, family, saddr4 | saddr6, daddr4 | daddr6, -* sport, dport -* A new MPTCP connection has been created. It is the good time to allocate -* memory and send ADD_ADDR if needed. Depending on the traffic-patterns -* it can take a long time until the MPTCP_EVENT_ESTABLISHED is sent. -* -* MPTCP_EVENT_ESTABLISHED: token, family, saddr4 | saddr6, daddr4 | daddr6, -* sport, dport -* A MPTCP connection is established (can start new subflows). -* -* MPTCP_EVENT_CLOSED: token -* A MPTCP connection has stopped. -* -* MPTCP_EVENT_ANNOUNCED: token, rem_id, family, daddr4 | daddr6 [, dport] -* A new address has been announced by the peer. -* -* MPTCP_EVENT_REMOVED: token, rem_id -* An address has been lost by the peer. -* -* MPTCP_EVENT_SUB_ESTABLISHED: token, family, loc_id, rem_id, -* saddr4 | saddr6, daddr4 | daddr6, sport, -* dport, backup, if_idx [, error] -* A new subflow has been established. 'error' should not be set. -* -* MPTCP_EVENT_SUB_CLOSED: token, family, loc_id, rem_id, saddr4 | saddr6, -* daddr4 | daddr6, sport, dport, backup, if_idx -* [, error] -* A subflow has been closed. An error (copy of sk_err) could be set if an -* error has been detected for this subflow. -* -* MPTCP_EVENT_SUB_PRIORITY: token, family, loc_id, rem_id, saddr4 | saddr6, -* daddr4 | daddr6, sport, dport, backup, if_idx -* [, error] -* The priority of a subflow has changed. 'error' should not be set. -* -* MPTCP_EVENT_LISTENER_CREATED: family, sport, saddr4 | saddr6 -* A new PM listener is created. -* -* MPTCP_EVENT_LISTENER_CLOSED: family, sport, saddr4 | saddr6 -* A PM listener is closed. -*/ -enum mptcp_event_type { -MPTCP_EVENT_UNSPEC =0 , -MPTCP_EVENT_CREATED =1 , -MPTCP_EVENT_ESTABLISHED =2 , -MPTCP_EVENT_CLOSED =3 , - -MPTCP_EVENT_ANNOUNCED =6 , -MPTCP_EVENT_REMOVED =7 , - -MPTCP_EVENT_SUB_ESTABLISHED =10 , -MPTCP_EVENT_SUB_CLOSED =11 , - -MPTCP_EVENT_SUB_PRIORITY =13 , - -MPTCP_EVENT_LISTENER_CREATED =15 , -MPTCP_EVENT_LISTENER_CLOSED =16 , -}; - -enum mptcp_event_attr { -MPTCP_ATTR_UNSPEC =0 , - -MPTCP_ATTR_TOKEN ,/* u32 */ -MPTCP_ATTR_FAMILY ,/* u16 */ -MPTCP_ATTR_LOC_ID ,/* u8 */ -MPTCP_ATTR_REM_ID ,/* u8 */ -MPTCP_ATTR_SADDR4 ,/* be32 */ -MPTCP_ATTR_SADDR6 ,/* struct in6_addr */ -MPTCP_ATTR_DADDR4 ,/* be32 */ -MPTCP_ATTR_DADDR6 ,/* struct in6_addr */ -MPTCP_ATTR_SPORT ,/* be16 */ -MPTCP_ATTR_DPORT ,/* be16 */ -MPTCP_ATTR_BACKUP ,/* u8 */ -MPTCP_ATTR_ERROR ,/* u8 */ -MPTCP_ATTR_FLAGS ,/* u16 */ -MPTCP_ATTR_TIMEOUT ,/* u32 */ -MPTCP_ATTR_IF_IDX ,/* s32 */ -MPTCP_ATTR_RESET_REASON ,/* u32 */ -MPTCP_ATTR_RESET_FLAGS ,/* u32 */ -MPTCP_ATTR_SERVER_SIDE ,/* u8 */ - - __MPTCP_ATTR_AFTER_LAST -}; - -#define MPTCP_ATTR_MAX (__MPTCP_ATTR_AFTER_LAST - 1) -/* MPTCP Reset reason codes, rfc8684 */ #define MPTCP_RST_EUNSPEC 0#define MPTCP_RST_EMPTCP 1
include/uapi/linux/mptcp_pm.h new file +149 -0
149 lines not on this page · raw message
Signature · 1 line
2.40.1
PATCH 5/5 net: mptcp: use policy generated by YAML spec
In reply to Davide Carattigenerated with:
$ ./tools/net/ynl/ynl-gen-c.py --mode kernel \
Quoted 2 lines
--spec
Documentation/netlink/specs/mptcp.yaml--source \
-onet/mptcp/mptcp_pm_gen.c
$ ./tools/net/ynl/ynl-gen-c.py --mode kernel \
Quoted 2 lines
--spec
Documentation/netlink/specs/mptcp.yaml--header \
-onet/mptcp/mptcp_pm_gen.h
--- net/mptcp/Makefile | 3 +- net/mptcp/mptcp_pm_gen.c | 179 +++++++++++++++++++++++++++++++++++++++ net/mptcp/mptcp_pm_gen.h | 58 +++++++++++++ net/mptcp/pm_netlink.c | 176 ++++---------------------------------- net/mptcp/pm_userspace.c | 13 +-- 5 files changed, 265 insertions(+), 164 deletions(-) create mode 100644 net/mptcp/mptcp_pm_gen.c create mode 100644 net/mptcp/mptcp_pm_gen.h
net/mptcp/Makefile +2 -1
@@ -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
net/mptcp/mptcp_pm_gen.c new file +179 -0
179 lines not on this page · raw message
net/mptcp/mptcp_pm_gen.h new file +58 -0
58 lines not on this page · raw message
net/mptcp/pm_netlink.c +18 -158
283 lines not on this page · raw message
net/mptcp/pm_userspace.c +8 -5
@@ -6,6 +6,7 @@#include "protocol.h" #include "mib.h" +#include "mptcp_pm_gen.h" void mptcp_free_local_addr_list (struct mptcp_sock *msk) {
@@ -145,7 +146,7 @@ int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk,return mptcp_userspace_pm_append_new_local_addr (msk, &new_entry); } -int mptcp_nl_cmd_announce (struct sk_buff *skb,struct genl_info *info) +int mptcp_pm_nl_announce_doit (struct sk_buff *skb,struct genl_info *info) {struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN ];struct nlattr *addr = info->attrs[MPTCP_PM_ATTR_ADDR ];
@@ -172,7 +173,7 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info) goto announce_err; } - err =mptcp_pm_parse_entry (addr, info, mptcp_pm_add_addr_nl_policy, true, &addr_val); + err =mptcp_pm_parse_entry (addr, info, mptcp_pm_address_nl_policy, true, &addr_val);if (err <0 ) {GENL_SET_ERR_MSG (info,"error parsing local address" ); goto announce_err;
@@ -208,7 +209,7 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info)return err; } -int mptcp_nl_cmd_remove (struct sk_buff *skb,struct genl_info *info) +int mptcp_pm_nl_remove_doit (struct sk_buff *skb,struct genl_info *info) {struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN ];struct nlattr *id = info->attrs[MPTCP_PM_ATTR_LOC_ID ];
@@ -270,7 +271,8 @@ int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info)return err; } -int mptcp_nl_cmd_sf_create (struct sk_buff *skb,struct genl_info *info) +int mptcp_pm_nl_subflow_create_doit (struct sk_buff *skb, +struct genl_info *info) {struct nlattr *raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE ];struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN ];
@@ -400,7 +402,8 @@ static struct sock *mptcp_nl_find_ssk(struct mptcp_sock *msk,return NULL ; } -int mptcp_nl_cmd_sf_destroy (struct sk_buff *skb,struct genl_info *info) +int mptcp_pm_nl_subflow_destroy_doit (struct sk_buff *skb, +struct genl_info *info) {struct nlattr *raddr = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE ];struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN ];
Signature · 1 line
2.40.1
Re: net: mptcp: use policy generated by YAML spec: Build Failure
Hi Davide,
Thank you for your modifications, that's great!
But sadly, our CI spotted some issues with it when trying to build it.
You can find more details there:
https://patchwork.kernel.org/project/mptcp/patch/01e81e72cbd1720e2bb210f9c32039620731933d.1689932012.git.dcaratti@redhat.com/
https://github.com/multipath-tcp/mptcp_net-next/actions/runs/5621160253
Status: failure
Initiator: MPTCPimporter
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/afb8624c61f4
Feel free to reply to this email if you cannot access logs, if you need some support to fix the error, if this doesn't seem to be caused by your modifications or if the error is a false positive one.
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)
Re: net: mptcp: use policy generated by YAML spec: Tests Results
In reply to Davide CarattiHi Davide,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join):
- Unstable: 1 failed test(s): selftest_simult_flows 🔴:
- Task: https://cirrus-ci.com/task/5957906802147328
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5957906802147328/summary/summary.txt
- KVM Validation: debug (only selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/4691269406949376
- Summary: https://api.cirrus-ci.com/v1/artifact/task/4691269406949376/summary/summary.txt
- KVM Validation: debug (except selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/6520856755568640
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6520856755568640/summary/summary.txt
- KVM Validation: normal (only selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5394956848726016
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5394956848726016/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/afb8624c61f4
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-debugFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)
Paolo Abeni
maintainerRe: [PATCH mptcp-next 2/5] mptcp: convert netlink from small_ops to ops
In reply to Davide CarattiQuoted 4 lines · Davide Caratti
- use a separate attribute set for add/del/get/flush address operation, binary compatible with the existing one, to store the endpoint address.
MPTCP_PM_ENDPOINT_ADDRis added to the uAPI (with the same value asMPTCP_PM_ATTR_ADDR) for these operations.
Perhaps describing with more details why the above is safe would help.
e.g. the current code abuses the MPTCP_PM_ATTR_ADDR with multiple semathic meaning, etc.
Think again about it, such change could be worthy a separate patch.
Quoted 37 lines
- convert mptcp_pm_ops[] and add policy files accordingly.
this prepares MPTCP control plane to be described as YAML spec.
Signed-off-by Davide Caratti <[email protected]>--- include/uapi/linux/mptcp.h | 8 ++ net/mptcp/pm_netlink.c | 204 ++++++++++++++++++++++++------------- net/mptcp/pm_userspace.c | 2 +- net/mptcp/protocol.h | 4 +- 4 files changed, 146 insertions(+), 72 deletions(-)include/uapi/linux/mptcp.h +8
-0@@ -65,6 +65,14 @@ enum {#define MPTCP_PM_ATTR_MAX (__MPTCP_PM_ATTR_MAX - 1) +enum { +MPTCP_PM_ENDPOINT_ADDR =1 , + + __MPTCP_PM_ENDPOINT_MAX +}; + +#define MPTCP_PM_ENDPOINT_MAX (__MPTCP_PM_ENDPOINT_MAX - 1) +enum {MPTCP_PM_ADDR_ATTR_UNSPEC ,net/mptcp/pm_netlink.c +0
-0
net/mptcp/pm_netlink.c struct pm_nl_pernet { · line 50
Quoted 4 lines
net/mptcp/pm_netlink.c +1
-0@@ -47,6 +47,53 @@ struct pm_nl_pernet {#define MPTCP_PM_ADDR_MAX 8#define ADD_ADDR_RETRANS_MAX 3 +const struct nla_policy mptcp_pm_add_addr_nl_policy[MPTCP_PM_ADDR_ATTR_IF_IDX +1 ] = {
It looks like that renaming this policy 'mptcp_pm_address_nl_policy' will reduce the delta in later patches, possibly making the series more readable.
Quoted 99 lines
net/mptcp/pm_netlink.c +48
-24+ [MPTCP_PM_ADDR_ATTR_FAMILY] = { .type = NLA_U16, }, + [MPTCP_PM_ADDR_ATTR_ADDR4] = { .type = NLA_U32, }, + [MPTCP_PM_ADDR_ATTR_ADDR6] = { .len = 16, }, + [MPTCP_PM_ADDR_ATTR_ID] = { .type = NLA_U8, }, + [MPTCP_PM_ADDR_ATTR_PORT] = { .type = NLA_U16, }, + [MPTCP_PM_ADDR_ATTR_IF_IDX] = { .type = NLA_S32, }, + [MPTCP_PM_ADDR_ATTR_FLAGS] = { .type = NLA_U32, }, +}; + +/* 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_add_addr_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 */ +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_add_addr_nl_policy), + [MPTCP_PM_ATTR_ADDR_REMOTE ] =NLA_POLICY_NESTED (mptcp_pm_add_addr_nl_policy), + [MPTCP_PM_ATTR_TOKEN ] = { .type =NLA_U32 , }, +}; + +/* MPTCP_PM_CMD_ANNOUNCE - do */ +static const struct nla_policy mptcp_pm_announce_nl_policy[MPTCP_PM_ATTR_TOKEN +1 ] = { + [MPTCP_PM_ATTR_TOKEN ] = { .type =NLA_U32 , }, + [MPTCP_PM_ATTR_ADDR ] =NLA_POLICY_NESTED (mptcp_pm_add_addr_nl_policy), +}; + +/* 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_REMOTE ] =NLA_POLICY_NESTED (mptcp_pm_add_addr_nl_policy), + [MPTCP_PM_ATTR_TOKEN ] = { .type =NLA_U32 , }, + [MPTCP_PM_ATTR_ADDR ] =NLA_POLICY_NESTED (mptcp_pm_add_addr_nl_policy), +}; +static struct pm_nl_pernet *pm_nl_get_pernet (const struct net *net) {return net_generic (net, pm_nl_pernet_id);@@ -1100,29 +1147,6 @@ static const struct genl_multicast_group mptcp_pm_mcgrps[] = { }, }; -static const struct nla_policy -mptcp_pm_addr_policy[MPTCP_PM_ADDR_ATTR_MAX +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 ] = -NLA_POLICY_EXACT_LEN (sizeof (struct in6_addr )), - [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 }, -}; - -static const struct nla_policy mptcp_pm_policy[MPTCP_PM_ATTR_MAX +1 ] = { - [MPTCP_PM_ATTR_ADDR ] = -NLA_POLICY_NESTED (mptcp_pm_addr_policy), - [MPTCP_PM_ATTR_RCV_ADD_ADDRS ] = { .type =NLA_U32 , }, - [MPTCP_PM_ATTR_SUBFLOWS ] = { .type =NLA_U32 , }, - [MPTCP_PM_ATTR_TOKEN ] = { .type =NLA_U32 , }, - [MPTCP_PM_ATTR_LOC_ID ] = { .type =NLA_U8 , }, - [MPTCP_PM_ATTR_ADDR_REMOTE ] = -NLA_POLICY_NESTED (mptcp_pm_addr_policy), -}; -void mptcp_pm_nl_subflow_chk_stale (const struct mptcp_sock *msk,struct sock *ssk) {struct mptcp_subflow_context *iter, *subflow =mptcp_subflow_ctx (ssk);@@ -1172,6 +1196,7 @@ static int mptcp_pm_family_to_addr(int family)static int mptcp_pm_parse_pm_addr_attr (struct nlattr *tb[],const struct nlattr *attr,struct genl_info *info, +const struct nla_policy *nla_policy,struct mptcp_addr_info *addr,bool require_family) {@@ -1184,7 +1209,7 @@ static int mptcp_pm_parse_pm_addr_attr(struct nlattr *tb[],/* no validation needed - was already done via nested policy */ err =nla_parse_nested_deprecated (tb,MPTCP_PM_ADDR_ATTR_MAX , attr, - mptcp_pm_addr_policy, info->extack); + nla_policy, info->extack);if (err)return err;@@ -1237,19 +1262,20 @@ int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info,memset (addr,0 ,sizeof (*addr));
net/mptcp/pm_netlink.c int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info, · line 1270
Quoted 10 lines
net/mptcp/pm_netlink.c +3
-3-return mptcp_pm_parse_pm_addr_attr (tb, attr, info, addr, true); +return mptcp_pm_parse_pm_addr_attr (tb, attr, info, mptcp_pm_add_addr_nl_policy, addr, true); }int mptcp_pm_parse_entry (struct nlattr *attr,struct genl_info *info, -bool require_family, -struct mptcp_pm_addr_entry *entry) +const struct nla_policy *nla_policy, +bool require_family,struct mptcp_pm_addr_entry *entry)
I *think* mptcp_pm_parse_entry() is always invoked with 'mptcp_pm_add_addr_nl_policy' as the policy argument. Can we just remove such arg?
If so even mptcp_pm_parse_pm_addr_attr() is always invoked with the same value for the policy arg, and we could remove even that argument.
The whole diff will be smaller and more readable IMHO.
Otherwise LGTM!
Cheers,
Paolo
Paolo Abeni
maintainerRe: [PATCH mptcp-next 3/5] Documentation: netlink: add a YAML spec for mptcp
In reply to Davide CarattiQuoted 26 lines · Davide Caratti
Signed-off-by Davide Caratti <[email protected]>--- Documentation/netlink/specs/mptcp.yaml | 397 +++++++++++++++++++++++++ 1 file changed, 397 insertions(+) create mode 100644 Documentation/netlink/specs/mptcp.yamlDocumentation/netlink/specs/mptcp.yaml new file +13
-0@@ -0,0 +1,397 @@ +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) + +name: mptcp_pm +protocol: genetlink-legacy +doc: Multipath TCP. + +c-family-name: mptcp_pm_name +c-version-name: mptcp_pm_ver +max-by-define: true +kernel-policy: per-op + +definitions: + -
Documentation/netlink/specs/mptcp.yaml line 23
Quoted 10 lines
Documentation/netlink/specs/mptcp.yaml new file +10
-0+ type: enum + name: event-type + enum-name: mptcp_event_type + name-prefix: mptcp_event_ + entries: + - + name: unspec + - + name: created + value: 1
Do we need the 'value' element here and in all the later entries? Why is not sufficient set it on 'unspec'? Is that due to the later 'holes' in the assigned values? Could it be sufficient set the first value after the "hole"? In this case only sub_priority -> '13', listener_created -> '15'.
[...]
Documentation/netlink/specs/mptcp.yaml line 97
Quoted 9 lines
Documentation/netlink/specs/mptcp.yaml new file +9
-0+attribute-sets: + - + name: address + name-prefix: mptcp_pm_addr_attr_ + attributes: + - + name: unspec + type: unused + value: 0
Which value get the 'unspec' entry by default? Can we avoid setting 'value' here ? A few other similar case below.
Cheers,
Paolo
Paolo Abeni
maintainerRe: [PATCH mptcp-next 5/5] net: mptcp: use policy generated by YAML spec
In reply to Davide Carattinet/mptcp/pm_netlink.c static int mptcp_nl_add_subflow_or_signal_addr(struct net *net) · line 1282
Quoted 6 lines · Davide Caratti
net/mptcp/pm_netlink.c +1
-1@@ -1325,14 +1279,14 @@ static int mptcp_nl_add_subflow_or_signal_addr(struct net *net)return 0 ; } -static int mptcp_nl_cmd_add_addr (struct sk_buff *skb,struct genl_info *info) +int mptcp_pm_nl_add_addr_doit (struct sk_buff *skb,struct genl_info *info)
What about moving the command conversion to _doit, _dumpit to a separate patch, earlier in the series? so that here lands only the strictly needed changes. Such patch could carry even the userspace_pm conversion.
Cheers,
Paolo