v2 fixes for "mptcp: convert Netlink code to use YAML spec"
Subsystems (3)
cover v2 fixes for "mptcp: convert Netlink code to use YAML spec"
v2 changes:
- de-uglify YAML spef file, replacing '_' with '-' and avoiding unnecessary assignments in enums (Jakub Kicinski)
- keep validating addr6 with NLA_POLICY_EXACT_LEN() (Jakub Kicinski)
- Don't leave MPTCP_EVENT_UNSPEC undocumented (Simon Horman)
patch 1/5 will cause a small context mismatch in "net: mptcp: use policy generated by YAML spec"
Davide Caratti (5):
Squash-to: "net: mptcp: convert netlink from small_ops to ops"
Squash-to: "Documentation: netlink: add a YAML spec for mptcp"
Squash-to: "uapi: mptcp: use header file generated from YAML spec" Squash to: "net: mptcp: use policy generated by YAML spec"
tools: ynl-gen: add support for exact-len validation
Signature · 1 line
2.41.0
PATCH 1/5 Squash-to: "net: mptcp: convert netlink from small_ops to ops"
--- net/mptcp/pm_netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/pm_netlink.c +1 -1
@@ -53,7 +53,7 @@ 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_ADDR6] = NLA_POLICY_EXACT_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, },
Signature · 1 line
2.41.0
PATCH 2/5 Squash-to: "Documentation: netlink: add a YAML spec for mptcp"
In reply to Davide Caratti--- Documentation/netlink/specs/mptcp.yaml | 127 ++++++++++++------------- 1 file changed, 62 insertions(+), 65 deletions(-)
Documentation/netlink/specs/mptcp.yaml +62 -65
@@ -4,8 +4,8 @@ name: mptcp_pm protocol: genetlink-legacy doc: Multipath TCP. -c-family-name: mptcp_pm_name -c-version-name: mptcp_pm_ver +c-family-name: mptcp-pm-name +c-version-name: mptcp-pm-ver max-by-define: true kernel-policy: per-op
@@ -13,12 +13,12 @@ definitions: - type: enum name: event-type - enum-name: mptcp_event_type - name-prefix: mptcp_event_ + enum-name: mptcp-event-type + name-prefix: mptcp-event- entries: - name: unspec - value: 0 + doc: unused event - name: created doc:
@@ -45,41 +45,38 @@ definitions: 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 + 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 + name: sub-closed 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 + 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 + name: listener-created value: 15 doc: family, sport, saddr4 | saddr6 A new PM listener is created. - - name: listener_closed - value: 16 + name: listener-closed doc: family, sport, saddr4 | saddr6 A PM listener is closed.
@@ -87,7 +84,7 @@ definitions: attribute-sets: - name: address - name-prefix: mptcp_pm_addr_attr_ + name-prefix: mptcp-pm-addr-attr- attributes: - name: unspec
@@ -107,7 +104,7 @@ attribute-sets: name: addr6 type: binary checks: - min-len: 16 + exact-len: 16 - name: port type: u16
@@ -116,52 +113,52 @@ attribute-sets: name: flags type: u32 - - name: if_idx + name: if-idx type: s32 - name: subflow-attribute - name-prefix: mptcp_subflow_attr_ + name-prefix: mptcp-subflow-attr- attributes: - name: unspec type: unused value: 0 - - name: token_rem + name: token-rem type: u32 - - name: token_loc + name: token-loc type: u32 - - name: relwrite_seq + name: relwrite-seq type: u32 - - name: map_seq + name: map-seq type: u64 - - name: map_sfseq + name: map-sfseq type: u32 - - name: ssn_offset + name: ssn-offset type: u32 - - name: map_datalen + name: map-datalen type: u16 - name: flags type: u32 - - name: id_rem + name: id-rem type: u8 - - name: id_loc + name: id-loc type: u8 - name: pad type: pad - name: endpoint - name-prefix: mptcp_pm_endpoint_ + name-prefix: mptcp-pm-endpoint- attributes: - name: addr
@@ -169,7 +166,7 @@ attribute-sets: nested-attributes: address - name: attr - name-prefix: mptcp_pm_attr_ + name-prefix: mptcp-pm-attr- attributes: - name: unspec
@@ -180,7 +177,7 @@ attribute-sets: type: nest nested-attributes: address - - name: rcv_add_addrs + name: rcv-add-addrs type: u32 - name: subflows
@@ -189,19 +186,19 @@ attribute-sets: name: token type: u32 - - name: loc_id + name: loc-id type: u8 - - name: addr_remote + name: addr-remote type: nest nested-attributes: address - - name: event_attr - enum-name: mptcp_event_attr - name-prefix: mptcp_attr_ + name: event-attr + enum-name: mptcp-event-attr + name-prefix: mptcp-attr- attributes: - - name: UNSPEC + name: unspec type: unused value: 0 -
@@ -211,10 +208,10 @@ attribute-sets: name: family type: u16 - - name: loc_id + name: loc-id type: u8 - - name: rem_id + name: rem-id type: u8 - name: saddr4
@@ -258,13 +255,13 @@ attribute-sets: name: if_idx type: u32 - - name: reset_reason + name: reset-reason type: u32 - - name: reset_flags + name: reset-flags type: u32 - - name: server_side + name: server-side type: u8 operations:
@@ -274,29 +271,29 @@ operations: doc: unused value: 0 - - name: add_addr + name: add-addr doc: Add endpoint attribute-set: endpoint dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: &add_addr_attrs + do: &add-addr-attrs request: attributes: - addr - - name: del_addr + name: del-addr doc: Delete endpoint attribute-set: endpoint dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: *add_addr_attrs + do: *add-addr-attrs - - name: get_addr + name: get-addr doc: Get endpoint information attribute-set: endpoint dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: &get_addr_attrs + do: &get-addr-attrs request: attributes: - addr
@@ -308,56 +305,56 @@ operations: attributes: - addr - - name: flush_addrs + name: flush-addrs doc: flush addresses attribute-set: endpoint dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: *add_addr_attrs + do: *add-addr-attrs - - name: set_limits + name: set-limits doc: Set protocol limits attribute-set: attr dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: &mptcp_limits + do: &mptcp-limits request: attributes: - - rcv_add_addrs + - rcv-add-addrs - subflows - - name: get_limits + name: get-limits doc: Get protocol limits attribute-set: attr dont-validate: [ strict ] - do: &mptcp_get_limits + do: &mptcp-get-limits request: attributes: - - rcv_add_addrs + - rcv-add-addrs - subflows reply: attributes: - - rcv_add_addrs + - rcv-add-addrs - subflows - - name: set_flags + name: set-flags doc: Change endpoint flags attribute-set: attr dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: &mptcp_set_flags + do: &mptcp-set-flags request: attributes: - addr - token - - addr_remote + - addr-remote - name: announce doc: announce new sf attribute-set: attr dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: &announce_add + do: &announce-add request: attributes: - addr
@@ -372,23 +369,23 @@ operations: request: attributes: - token - - loc_id + - loc-id - - name: subflow_create + name: subflow-create doc: todo attribute-set: attr dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: &sf_create + do: &sf-create request: attributes: - addr - token - - addr_remote + - addr-remote - - name: subflow_destroy + name: subflow-destroy doc: todo attribute-set: attr dont-validate: [ strict ] flags: [ uns-admin-perm ] - do: *sf_create + do: *sf-create
Signature · 1 line
2.41.0
PATCH 3/5 Squash-to: "uapi: mptcp: use header file generated from YAML spec"
In reply to Davide Caratti--- include/uapi/linux/mptcp_pm.h | 1 + 1 file changed, 1 insertion(+)
include/uapi/linux/mptcp_pm.h +1 -0
@@ -11,6 +11,7 @@/** * enum mptcp_event_type +* @MPTCP_EVENT_UNSPEC: unused event * @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
Signature · 1 line
2.41.0
PATCH 4/5 Squash to: "net: mptcp: use policy generated by YAML spec"
In reply to Davide Carattias per Jakub's review, a newer YAML spec is going to validate addr6 with NLA_POLICY_EXACT_LEN(16)
--- net/mptcp/mptcp_pm_gen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mptcp/mptcp_pm_gen.c +1 -1
@@ -15,7 +15,7 @@ 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_ADDR6] = NLA_POLICY_EXACT_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, },
Signature · 1 line
2.41.0
PATCH 5/5 tools: ynl-gen: add support for exact-len validation
In reply to Davide Carattiadd support for 'exact-len' validation on netlink attributes.
--- Documentation/netlink/genetlink-c.yaml | 3 +++ Documentation/netlink/genetlink-legacy.yaml | 3 +++ Documentation/netlink/genetlink.yaml | 3 +++ Documentation/netlink/netlink-raw.yaml | 3 +++ tools/net/ynl/ynl-gen-c.py | 28 +++++++++++++-------- 5 files changed, 29 insertions(+), 11 deletions(-)
Documentation/netlink/genetlink-c.yaml +3 -0
@@ -194,6 +194,9 @@ properties: max-len: description: Max length for a string or a binary attribute. $ref: '#/$defs/len-or-define' + exact-len: + description: Exact length for a string or a binary attribute. + $ref: '#/$defs/len-or-define' sub-type: *attr-type display-hint: &display-hint description: |
Documentation/netlink/genetlink-legacy.yaml +3 -0
@@ -233,6 +233,9 @@ properties: max-len: description: Max length for a string or a binary attribute. $ref: '#/$defs/len-or-define' + exact-len: + description: Exact length for a string or a binary attribute. + $ref: '#/$defs/len-or-define' sub-type: *attr-type display-hint: *display-hint # Start genetlink-c
Documentation/netlink/genetlink.yaml +3 -0
@@ -167,6 +167,9 @@ properties: max-len: description: Max length for a string or a binary attribute. $ref: '#/$defs/len-or-define' + exact-len: + description: Exact length for a string or a binary attribute. + $ref: '#/$defs/len-or-define' sub-type: *attr-type display-hint: &display-hint description: |
Documentation/netlink/netlink-raw.yaml +3 -0
@@ -240,6 +240,9 @@ properties: max-len: description: Max length for a string or a binary attribute. $ref: '#/$defs/len-or-define' + exact-len: + description: Exact length for a string or a binary attribute. + $ref: '#/$defs/len-or-define' sub-type: *attr-type display-hint: *display-hint # Start genetlink-c
tools/net/ynl/ynl-gen-c.py +17 -11
@@ -355,10 +355,13 @@ class TypeString(Type): return f'.type = YNL_PT_NUL_STR, ' def _attr_policy(self, policy): - mem = '{ .type = ' + policy - if 'max-len' in self.checks: - mem += ', .len = ' + str(self.checks['max-len']) - mem += ', }' + if 'exact-len' in self.checks: + mem = 'NLA_POLICY_EXACT_LEN(' + str(self.checks['exact-len']) + ')' + else: + mem = '{ .type = ' + policy + if 'max-len' in self.checks: + mem += ', .len = ' + str(self.checks['max-len']) + mem += ', }' return mem def attr_policy(self, cw):
@@ -404,14 +407,17 @@ class TypeBinary(Type): return f'.type = YNL_PT_BINARY,' def _attr_policy(self, policy): - mem = '{ ' - if len(self.checks) == 1 and 'min-len' in self.checks: - mem += '.len = ' + str(self.checks['min-len']) - elif len(self.checks) == 0: - mem += '.type = NLA_BINARY' + if 'exact-len' in self.checks: + mem = 'NLA_POLICY_EXACT_LEN(' + str(self.checks['exact-len']) + ')' else: - raise Exception('One or more of binary type checks not implemented, yet') - mem += ', }' + mem = '{ ' + if len(self.checks) == 1 and 'min-len' in self.checks: + mem += '.len = ' + str(self.checks['min-len']) + elif len(self.checks) == 0: + mem += '.type = NLA_BINARY' + else: + raise Exception('One or more of binary type checks not implemented, yet') + mem += ', }' return mem def attr_put(self, ri, var):
Signature · 1 line
2.41.0
Re: tools: ynl-gen: add support for exact-len validation: Tests Results
Hi 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):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5917958434717696
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5917958434717696/summary/summary.txt
- KVM Validation: normal (only selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5309085919215616
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5309085919215616/summary/summary.txt
- KVM Validation: debug (except selftest_mptcp_join):
- Script error! ❓:
- Task: https://cirrus-ci.com/task/5109073318772736
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5109073318772736/summary/summary.txt
- KVM Validation: debug (only selftest_mptcp_join):
- Script error! ❓:
- Task: https://cirrus-ci.com/task/5027610942504960
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5027610942504960/summary/summary.txt
Initiator: Matthieu Baerts
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/da604a436c74
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)
Re: tools: ynl-gen: add support for exact-len validation: 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):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5917958434717696
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5917958434717696/summary/summary.txt
- KVM Validation: normal (only selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5309085919215616
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5309085919215616/summary/summary.txt
- KVM Validation: debug (except selftest_mptcp_join):
- Success! ✅:
- Task: https://cirrus-ci.com/task/5378729350791168
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5378729350791168/summary/summary.txt
- KVM Validation: debug (only selftest_mptcp_join):
- Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
- Task: https://cirrus-ci.com/task/5962237232283648
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5962237232283648/summary/summary.txt
Initiator: Matthieu Baerts
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/da604a436c74
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)
Matthieu Baerts
maintainerHi Davide, Paolo,
Quoted 8 lines · Davide Caratti
v2 changes:
- de-uglify YAML spef file, replacing '_' with '-' and avoiding unnecessary assignments in enums (Jakub Kicinski)
- keep validating addr6 withNLA_POLICY_EXACT_LEN()(Jakub Kicinski)
- Don't leaveMPTCP_EVENT_UNSPECundocumented (Simon Horman)patch 1/5 will cause a small context mismatch in "net: mptcp: use policy generated by YAML spec"
Thank you for the new version.
This version looks good to me, but do you mind checking with Paolo if it is also OK for him because he gave his Acked-by on the previous version.
When that will be done, I will apply the different patches and send them to netdev. I can re-use your v2 changelog in the cover-letter. Or do you want me to write something else?
One last thing: can I apply your last patch ("tools: ynl-gen: add support for exact-len validation") between these two?
- "tools: ynl: add uns-admin-perm to genetlink legacy"
- "net: mptcp: convert netlink from small_ops to ops"
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
hello Matthieu, thanks for looking at this!
Quoted 3 lines · Matthieu Baerts
Hi Davide, Paolo,
[...]
Quoted 3 lines
When that will be done, I will apply the different patches and send them to netdev. I can re-use your v2 changelog in the cover-letter. Or do you want me to write something else?
Ok for me,
Quoted 5 lines
One last thing: can I apply your last patch ("tools: ynl-gen: add support for exact-len validation") between these two?
- "tools: ynl: add uns-admin-perm to genetlink legacy"
- "net: mptcp: convert netlink fromsmall_opsto ops"
that's ok also. Let's hope it won't conflict with [1] at the next sync :) But if it does, let me know and I'll try another squash-to.
[1] https://lore.kernel.org/netdev/[email protected]/
thanks!
Signature · 1 line
davide
Matthieu Baerts
maintainerHi Davide, Paolo,
Quoted 9 lines · Matthieu Baerts
Hi Davide, Paolo,
Quoted 6 lines · Davide Caratti
v2 changes:
- de-uglify YAML spef file, replacing '_' with '-' and avoiding unnecessary assignments in enums (Jakub Kicinski)
- keep validating addr6 withNLA_POLICY_EXACT_LEN()(Jakub Kicinski)
- Don't leaveMPTCP_EVENT_UNSPECundocumented (Simon Horman)
Quoted 7 lines
Quoted 2 lines
patch 1/5 will cause a small context mismatch in "net: mptcp: use policy generated by YAML spec"
Thank you for the new version.
This version looks good to me, but do you mind checking with Paolo if it is also OK for him because he gave his Acked-by on the previous version.
I hope that's OK: I just applied them in our tree. I will still wait for Paolo's ACK before sending the v2 upstream
- 22e720cbc227: "squashed" patch 1/5 in "net: mptcp: convert netlink from small_ops to ops"
- a1d16bbc8e6b: "squashed" patch 2/5 in "Documentation: netlink: add a YAML spec for mptcp"
- 77fef1f8df04: "squashed" patch 3/5 in "uapi: mptcp: use header file generated from YAML spec"
- dc863cd3742e: conflict in t/net-mptcp-use-policy-generated-by-YAML-spec
- e258da3fda0d: "squashed" patch 4/5 in "net: mptcp: use policy generated by YAML spec"
- 3c523c3a147b: tools: ynl-gen: add support for exact-len validation
- Results: e5c88dc2d209..65682b5b41eb (export)
I had to resolved conflicts with patch 5/5 as you predicted. It was not difficult but please double-check I did that correctly :)
I also checked that I could re-generate the files, and they would still look the same.
Tests are now in progress:
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20231021T134222
Cheers,
Matt