* [PATCH RFC mptcp-net-next 0/5] YAML template for MPTCP netlink API
@ 2023-04-06 17:32 ` Davide Caratti
0 siblings, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-04-06 17:31 UTC (permalink / raw)
To: mptcp
Related: #377
Notes:
- the attributes in the operation list is not really good, we probably
need to specify better what parameters are used in the .doit() function
(though the generated code is the same). Specifying 'remote_addr'
either in 'request' or in 'reply' would probably make patch 2/5 useless.
- I didn't add the multicast groups on purpose. ynl-c.py is not able to
generate the operation list for genetlink-legacy, so all this part
(including multicast groups) needs to be left unspecified in the
template.
Davide Caratti (5):
tools: ynl: add uns-admin-perm to genetlink legacy
tools: ynl: fix bug in case of multiple nested attributes of the same
type
Documentation: netlink: add a YAML spec for mptcp
mptcp: uapi: add header files generated from YAML spec
net/mptcp: use netlink policy generated from YAML spec
Documentation/netlink/genetlink-legacy.yaml | 2 +-
Documentation/netlink/specs/mptcp.yaml | 361 ++++++++++++++++++++
include/uapi/linux/mptcp.h | 167 +--------
include/uapi/linux/mptcp_pm.h | 145 ++++++++
net/mptcp/Makefile | 3 +-
net/mptcp/pm_netlink.c | 107 +-----
net/mptcp/pm_nl.c | 91 +++++
net/mptcp/pm_nl.h | 39 +++
net/mptcp/pm_userspace.c | 9 +-
net/mptcp/protocol.h | 6 +-
tools/net/ynl/ynl-gen-c.py | 3 +-
11 files changed, 665 insertions(+), 268 deletions(-)
create mode 100644 Documentation/netlink/specs/mptcp.yaml
create mode 100644 include/uapi/linux/mptcp_pm.h
create mode 100644 net/mptcp/pm_nl.c
create mode 100644 net/mptcp/pm_nl.h
--
2.39.2
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH RFC mptcp-net-next 1/5] tools: ynl: add uns-admin-perm to genetlink legacy
@ 2023-04-06 17:32 ` Davide Caratti
0 siblings, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-04-06 17:31 UTC (permalink / raw)
To: mptcp
this flag maps to GENL_UNS_ADMIN_PERM and will be used by future specs.
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
Documentation/netlink/genetlink-legacy.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml
index b33541a51d6b..6d075bfb712e 100644
--- a/Documentation/netlink/genetlink-legacy.yaml
+++ b/Documentation/netlink/genetlink-legacy.yaml
@@ -295,7 +295,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
--
2.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH RFC mptcp-net-next 2/5] tools: ynl: fix bug in case of multiple nested attributes of the same type
@ 2023-04-06 17:32 ` Davide Caratti
0 siblings, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-04-06 17:31 UTC (permalink / raw)
To: mptcp
when a policy contains multiple nested attributes of the same type, avoid
re-initializing .request and .reply members.
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
tools/net/ynl/ynl-gen-c.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index cc2f8c945340..ba55f217a006 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -812,7 +812,8 @@ class Family(SpecFamily):
inherit = set()
nested = spec['nested-attributes']
if nested not in self.root_sets:
- self.pure_nested_structs[nested] = Struct(self, nested, inherited=inherit)
+ if nested not in self.pure_nested_structs:
+ self.pure_nested_structs[nested] = Struct(self, nested, inherited=inherit)
if attr in rs_members['request']:
self.pure_nested_structs[nested].request = True
if attr in rs_members['reply']:
--
2.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH RFC mptcp-net-next 3/5] Documentation: netlink: add a YAML spec for mptcp
@ 2023-04-06 17:32 ` Davide Caratti
0 siblings, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-04-06 17:31 UTC (permalink / raw)
To: mptcp
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
Documentation/netlink/specs/mptcp.yaml | 361 +++++++++++++++++++++++++
1 file changed, 361 insertions(+)
create mode 100644 Documentation/netlink/specs/mptcp.yaml
diff --git a/Documentation/netlink/specs/mptcp.yaml b/Documentation/netlink/specs/mptcp.yaml
new file mode 100644
index 000000000000..910307b021ba
--- /dev/null
+++ b/Documentation/netlink/specs/mptcp.yaml
@@ -0,0 +1,361 @@
+# 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: global
+
+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: addr
+ 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: attr
+ name-prefix: mptcp_pm_attr_
+ attributes:
+ -
+ name: unspec
+ type: unused
+ value: 0
+ -
+ name: addr
+ type: nest
+ nested-attributes: addr
+ -
+ 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: addr
+ -
+ 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: attr
+ flags: [ uns-admin-perm ]
+
+ do:
+ request: &add_addr_attrs
+ attributes:
+ - addr
+ -
+ name: del_addr
+ doc: Delete endpoint
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ -
+ name: get_addr
+ doc: Get endpoint information
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ reply: *add_addr_attrs
+
+ dump:
+ reply: *add_addr_attrs
+ -
+ name: flush_addrs
+ doc: flush addresses
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ -
+ name: set_limits
+ doc: Set protocol limits
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: &mptcp_limits
+ attributes:
+ - rcv_add_addrs
+ - subflows
+ -
+ name: get_limits
+ doc: Get protocol limits
+ attribute-set: attr
+ do:
+ request: *mptcp_limits
+ reply: *mptcp_limits
+ -
+ name: set_flags
+ doc: Change endpoint flags
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ -
+ name: announce
+ doc: announce new sf
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ reply: *add_addr_attrs
+ -
+ name: remove
+ doc: announce removal
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ reply: *add_addr_attrs
+ -
+ name: subflow_create
+ doc: todo
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ reply: *add_addr_attrs
+ -
+ name: subflow_destroy
+ doc: todo
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ reply: *add_addr_attrs
+
--
2.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH RFC mptcp-net-next 4/5] mptcp: uapi: add header files generated from YAML spec
@ 2023-04-06 17:32 ` Davide Caratti
0 siblings, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-04-06 17:31 UTC (permalink / raw)
To: mptcp
$ ./tools/net/ynl/ynl-gen-c.py --mode uapi \
> --spec Documentation/netlink/specs/mptcp.yaml --header \
> -o include/uapi/linux/mptcp_pm.h
and remove these definitions from mptcp.h
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
include/uapi/linux/mptcp.h | 167 +---------------------------------
include/uapi/linux/mptcp_pm.h | 145 +++++++++++++++++++++++++++++
2 files changed, 149 insertions(+), 163 deletions(-)
create mode 100644 include/uapi/linux/mptcp_pm.h
diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h
index 32af2d278cb4..f919f43a178a 100644
--- a/include/uapi/linux/mptcp.h
+++ b/include/uapi/linux/mptcp.h
@@ -12,6 +12,10 @@
#include <linux/in.h> /* for sockaddr_in */
#include <linux/in6.h> /* for sockaddr_in6 */
#include <linux/socket.h> /* for sockaddr_storage and sa_family */
+#include <linux/mptcp_pm.h> /* for netlink interface */
+
+#define __MPTCP_PM_CMD_AFTER_LAST __MPTCP_PM_CMD_MAX
+#define __MPTCP_ATTR_AFTER_LAST __MPTCP_ATTR_MAX
#define MPTCP_SUBFLOW_FLAG_MCAP_REM _BITUL(0)
#define MPTCP_SUBFLOW_FLAG_MCAP_LOC _BITUL(1)
@@ -23,88 +27,12 @@
#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_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)
-
#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
-};
-
#define MPTCP_INFO_FLAG_FALLBACK _BITUL(0)
#define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED _BITUL(1)
@@ -125,93 +53,6 @@ struct mptcp_info {
__u8 mptcpi_csum_enabled;
};
-/*
- * 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
diff --git a/include/uapi/linux/mptcp_pm.h b/include/uapi/linux/mptcp_pm.h
new file mode 100644
index 000000000000..37cdae7a871b
--- /dev/null
+++ b/include/uapi/linux/mptcp_pm.h
@@ -0,0 +1,145 @@
+/* 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 uapi header */
+
+#ifndef _UAPI_LINUX_MPTCP_PM_H
+#define _UAPI_LINUX_MPTCP_PM_H
+
+#define MPTCP_PM_NAME "mptcp_pm"
+#define MPTCP_PM_VER 1
+
+/**
+ * enum mptcp_pm_event_type
+ * @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,
+ MPTCP_EVENT_CREATED,
+ MPTCP_EVENT_ESTABLISHED,
+ MPTCP_EVENT_CLOSED,
+ MPTCP_EVENT_ANNOUNCED = 6,
+ MPTCP_EVENT_REMOVED,
+ MPTCP_EVENT_SUB_ESTABLISHED = 10,
+ MPTCP_EVENT_SUB_CLOSED,
+ MPTCP_EVENT_SUB_PRIORITY = 13,
+ MPTCP_EVENT_LISTENER_CREATED = 15,
+ MPTCP_EVENT_LISTENER_CLOSED,
+};
+
+enum {
+ MPTCP_PM_ADDR_ATTR_UNSPEC,
+ MPTCP_PM_ADDR_ATTR_FAMILY,
+ MPTCP_PM_ADDR_ATTR_ID,
+ MPTCP_PM_ADDR_ATTR_ADDR4,
+ MPTCP_PM_ADDR_ATTR_ADDR6,
+ MPTCP_PM_ADDR_ATTR_PORT,
+ MPTCP_PM_ADDR_ATTR_FLAGS,
+ MPTCP_PM_ADDR_ATTR_IF_IDX,
+
+ __MPTCP_PM_ADDR_ATTR_MAX
+};
+#define MPTCP_PM_ADDR_ATTR_MAX (__MPTCP_PM_ADDR_ATTR_MAX - 1)
+
+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)
+
+enum {
+ MPTCP_PM_ATTR_UNSPEC,
+ MPTCP_PM_ATTR_ADDR,
+ MPTCP_PM_ATTR_RCV_ADD_ADDRS,
+ MPTCP_PM_ATTR_SUBFLOWS,
+ MPTCP_PM_ATTR_TOKEN,
+ MPTCP_PM_ATTR_LOC_ID,
+ MPTCP_PM_ATTR_ADDR_REMOTE,
+
+ __MPTCP_PM_ATTR_MAX
+};
+#define MPTCP_PM_ATTR_MAX (__MPTCP_PM_ATTR_MAX - 1)
+
+enum mptcp_event_attr {
+ MPTCP_ATTR_UNSPEC,
+ MPTCP_ATTR_TOKEN,
+ MPTCP_ATTR_FAMILY,
+ MPTCP_ATTR_LOC_ID,
+ MPTCP_ATTR_REM_ID,
+ MPTCP_ATTR_SADDR4,
+ MPTCP_ATTR_SADDR6,
+ MPTCP_ATTR_DADDR4,
+ MPTCP_ATTR_DADDR6,
+ MPTCP_ATTR_SPORT,
+ MPTCP_ATTR_DPORT,
+ MPTCP_ATTR_BACKUP,
+ MPTCP_ATTR_ERROR,
+ MPTCP_ATTR_FLAGS,
+ MPTCP_ATTR_TIMEOUT,
+ MPTCP_ATTR_IF_IDX,
+ MPTCP_ATTR_RESET_REASON,
+ MPTCP_ATTR_RESET_FLAGS,
+ MPTCP_ATTR_SERVER_SIDE,
+
+ __MPTCP_ATTR_MAX
+};
+#define MPTCP_ATTR_MAX (__MPTCP_ATTR_MAX - 1)
+
+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_MAX
+};
+#define MPTCP_PM_CMD_MAX (__MPTCP_PM_CMD_MAX - 1)
+
+#define MPTCP_PM_CMD_GRP_NAME "mptcp_pm_cmds"
+#define MPTCP_PM_EV_GRP_NAME "mptcp_pm_events"
+
+#endif /* _UAPI_LINUX_MPTCP_PM_H */
--
2.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH RFC mptcp-net-next 5/5] net/mptcp: use netlink policy generated from YAML spec
2023-04-06 17:32 ` Davide Caratti
@ 2023-04-06 17:32 ` Davide Caratti
-1 siblings, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-04-06 17:31 UTC (permalink / raw)
To: mptcp
$ ./tools/net/ynl/ynl-gen-c.py --mode kernel \
> --spec Documentation/netlink/specs/mptcp.yaml --header \
> -o net/mptcp/pm_nl.h
$ ./tools/net/ynl/ynl-gen-c.py --mode kernel \
> --spec Documentation/netlink/specs/mptcp.yaml --source \
> -o net/mptcp/pm_nl.c
and remove the old ones we had in pm_netlink.c/pm_userspace.c
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
net/mptcp/Makefile | 3 +-
net/mptcp/pm_netlink.c | 107 +++++----------------------------------
net/mptcp/pm_nl.c | 91 +++++++++++++++++++++++++++++++++
net/mptcp/pm_nl.h | 39 ++++++++++++++
net/mptcp/pm_userspace.c | 9 ++--
net/mptcp/protocol.h | 6 +--
6 files changed, 152 insertions(+), 103 deletions(-)
create mode 100644 net/mptcp/pm_nl.c
create mode 100644 net/mptcp/pm_nl.h
diff --git a/net/mptcp/Makefile b/net/mptcp/Makefile
index 84e531f86b82..dedd1bf8d052 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 \
+ pm_nl.o
obj-$(CONFIG_SYN_COOKIES) += syncookies.o
obj-$(CONFIG_INET_MPTCP_DIAG) += mptcp_diag.o
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index e8336b8bd30e..44cb7925aec1 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -1116,28 +1116,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)
{
@@ -1200,7 +1178,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);
+ mptcp_pm_addr_nl_policy, info->extack);
if (err)
return err;
@@ -1315,7 +1293,7 @@ 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)
{
struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
@@ -1507,7 +1485,7 @@ static int mptcp_nl_remove_id_zero_address(struct net *net,
return 0;
}
-static int mptcp_nl_cmd_del_addr(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_ATTR_ADDR];
struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
@@ -1624,7 +1602,7 @@ static void __reset_counters(struct pm_nl_pernet *pernet)
pernet->addrs = 0;
}
-static int mptcp_nl_cmd_flush_addrs(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);
@@ -1680,7 +1658,7 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb,
return -EMSGSIZE;
}
-static int mptcp_nl_cmd_get_addr(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_ATTR_ADDR];
struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
@@ -1730,8 +1708,8 @@ static int mptcp_nl_cmd_get_addr(struct sk_buff *skb, struct genl_info *info)
return ret;
}
-static int mptcp_nl_cmd_dump_addrs(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;
@@ -1788,8 +1766,7 @@ static int parse_limit(struct genl_info *info, int id, unsigned int *limit)
return 0;
}
-static int
-mptcp_nl_cmd_set_limits(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;
@@ -1814,8 +1791,7 @@ mptcp_nl_cmd_set_limits(struct sk_buff *skb, struct genl_info *info)
return ret;
}
-static int
-mptcp_nl_cmd_get_limits(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;
@@ -1889,7 +1865,7 @@ static int mptcp_nl_set_flags(struct net *net,
return ret;
}
-static int mptcp_nl_cmd_set_flags(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 addr = { .addr = { .family = AF_UNSPEC }, }, *entry;
struct mptcp_pm_addr_entry remote = { .addr = { .family = AF_UNSPEC }, };
@@ -2282,72 +2258,15 @@ void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
nlmsg_free(skb);
}
-static const struct genl_small_ops mptcp_pm_ops[] = {
- {
- .cmd = MPTCP_PM_CMD_ADD_ADDR,
- .doit = mptcp_nl_cmd_add_addr,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_DEL_ADDR,
- .doit = mptcp_nl_cmd_del_addr,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_FLUSH_ADDRS,
- .doit = mptcp_nl_cmd_flush_addrs,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_GET_ADDR,
- .doit = mptcp_nl_cmd_get_addr,
- .dumpit = mptcp_nl_cmd_dump_addrs,
- },
- {
- .cmd = MPTCP_PM_CMD_SET_LIMITS,
- .doit = mptcp_nl_cmd_set_limits,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_GET_LIMITS,
- .doit = mptcp_nl_cmd_get_limits,
- },
- {
- .cmd = MPTCP_PM_CMD_SET_FLAGS,
- .doit = mptcp_nl_cmd_set_flags,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_ANNOUNCE,
- .doit = mptcp_nl_cmd_announce,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_REMOVE,
- .doit = mptcp_nl_cmd_remove,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_SUBFLOW_CREATE,
- .doit = mptcp_nl_cmd_sf_create,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_SUBFLOW_DESTROY,
- .doit = mptcp_nl_cmd_sf_destroy,
- .flags = GENL_UNS_ADMIN_PERM,
- },
-};
-
static struct genl_family mptcp_genl_family __ro_after_init = {
.name = MPTCP_PM_NAME,
.version = MPTCP_PM_VER,
.maxattr = MPTCP_PM_ATTR_MAX,
- .policy = mptcp_pm_policy,
+ .policy = mptcp_pm_attr_nl_policy,
.netnsok = true,
.module = THIS_MODULE,
- .small_ops = mptcp_pm_ops,
- .n_small_ops = ARRAY_SIZE(mptcp_pm_ops),
+ .small_ops = mptcp_pm_nl_ops,
+ .n_small_ops = ARRAY_SIZE(mptcp_pm_nl_ops),
.resv_start_op = MPTCP_PM_CMD_SUBFLOW_DESTROY + 1,
.mcgrps = mptcp_pm_mcgrps,
.n_mcgrps = ARRAY_SIZE(mptcp_pm_mcgrps),
diff --git a/net/mptcp/pm_nl.c b/net/mptcp/pm_nl.c
new file mode 100644
index 000000000000..5de927aa8a1d
--- /dev/null
+++ b/net/mptcp/pm_nl.c
@@ -0,0 +1,91 @@
+// 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 <net/netlink.h>
+#include <net/genetlink.h>
+
+#include "pm_nl.h"
+
+#include <linux/mptcp_pm.h>
+
+/* Common nested types */
+const struct nla_policy mptcp_pm_addr_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, },
+};
+
+/* Global operation policy for mptcp_pm */
+const struct nla_policy mptcp_pm_attr_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = {
+ [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_addr_nl_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_nl_policy),
+};
+
+/* Ops table for mptcp_pm */
+const struct genl_small_ops mptcp_pm_nl_ops[11] = {
+ {
+ .cmd = MPTCP_PM_CMD_ADD_ADDR,
+ .doit = mptcp_pm_nl_add_addr_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_DEL_ADDR,
+ .doit = mptcp_pm_nl_del_addr_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_GET_ADDR,
+ .doit = mptcp_pm_nl_get_addr_doit,
+ .dumpit = mptcp_pm_nl_get_addr_dumpit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_FLUSH_ADDRS,
+ .doit = mptcp_pm_nl_flush_addrs_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_SET_LIMITS,
+ .doit = mptcp_pm_nl_set_limits_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_GET_LIMITS,
+ .doit = mptcp_pm_nl_get_limits_doit,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_SET_FLAGS,
+ .doit = mptcp_pm_nl_set_flags_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_ANNOUNCE,
+ .doit = mptcp_pm_nl_announce_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_REMOVE,
+ .doit = mptcp_pm_nl_remove_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_SUBFLOW_CREATE,
+ .doit = mptcp_pm_nl_subflow_create_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_SUBFLOW_DESTROY,
+ .doit = mptcp_pm_nl_subflow_destroy_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+};
diff --git a/net/mptcp/pm_nl.h b/net/mptcp/pm_nl.h
new file mode 100644
index 000000000000..26dd13f3244d
--- /dev/null
+++ b/net/mptcp/pm_nl.h
@@ -0,0 +1,39 @@
+/* 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 <net/netlink.h>
+#include <net/genetlink.h>
+
+#include <linux/mptcp_pm.h>
+
+/* Common nested types */
+extern const struct nla_policy mptcp_pm_addr_nl_policy[MPTCP_PM_ADDR_ATTR_IF_IDX + 1];
+
+/* Global operation policy for mptcp_pm */
+extern const struct nla_policy mptcp_pm_attr_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1];
+
+/* Ops table for mptcp_pm */
+extern const struct genl_small_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_userspace.c b/net/mptcp/pm_userspace.c
index 27a275805c06..8936d0f80884 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -122,7 +122,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];
@@ -184,7 +184,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];
@@ -246,7 +246,7 @@ 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];
@@ -361,7 +361,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];
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 5a35c77723e3..ca33d2808b61 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -13,6 +13,8 @@
#include <uapi/linux/mptcp.h>
#include <net/genetlink.h>
+#include "pm_nl.h" /* for netlink interface */
+
#define MPTCP_SUPPORTED_VERSION 1
/* MPTCP option bits */
@@ -849,10 +851,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_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info);
-int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info);
-int mptcp_nl_cmd_sf_create(struct sk_buff *skb, struct genl_info *info);
-int mptcp_nl_cmd_sf_destroy(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.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH RFC mptcp-net-next 0/5] YAML template for MPTCP netlink API
@ 2023-04-06 17:32 ` Davide Caratti
0 siblings, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-04-06 17:32 UTC (permalink / raw)
To: mptcp
Related: #377
Notes:
- the attributes in the operation list is not really good, we probably
need to specify better what parameters are used in the .doit() function
(though the generated code is the same). Specifying 'remote_addr'
either in 'request' or in 'reply' would probably make patch 2/5 useless.
- I didn't add the multicast groups on purpose. ynl-c.py is not able to
generate the operation list for genetlink-legacy, so all this part
(including multicast groups) needs to be left unspecified in the
template.
Davide Caratti (5):
tools: ynl: add uns-admin-perm to genetlink legacy
tools: ynl: fix bug in case of multiple nested attributes of the same
type
Documentation: netlink: add a YAML spec for mptcp
mptcp: uapi: add header files generated from YAML spec
net/mptcp: use netlink policy generated from YAML spec
Documentation/netlink/genetlink-legacy.yaml | 2 +-
Documentation/netlink/specs/mptcp.yaml | 361 ++++++++++++++++++++
include/uapi/linux/mptcp.h | 167 +--------
include/uapi/linux/mptcp_pm.h | 145 ++++++++
net/mptcp/Makefile | 3 +-
net/mptcp/pm_netlink.c | 107 +-----
net/mptcp/pm_nl.c | 91 +++++
net/mptcp/pm_nl.h | 39 +++
net/mptcp/pm_userspace.c | 9 +-
net/mptcp/protocol.h | 6 +-
tools/net/ynl/ynl-gen-c.py | 3 +-
11 files changed, 665 insertions(+), 268 deletions(-)
create mode 100644 Documentation/netlink/specs/mptcp.yaml
create mode 100644 include/uapi/linux/mptcp_pm.h
create mode 100644 net/mptcp/pm_nl.c
create mode 100644 net/mptcp/pm_nl.h
--
2.39.2
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH RFC mptcp-net-next 1/5] tools: ynl: add uns-admin-perm to genetlink legacy
@ 2023-04-06 17:32 ` Davide Caratti
0 siblings, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-04-06 17:32 UTC (permalink / raw)
To: mptcp
this flag maps to GENL_UNS_ADMIN_PERM and will be used by future specs.
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
Documentation/netlink/genetlink-legacy.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml
index b33541a51d6b..6d075bfb712e 100644
--- a/Documentation/netlink/genetlink-legacy.yaml
+++ b/Documentation/netlink/genetlink-legacy.yaml
@@ -295,7 +295,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
--
2.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH RFC mptcp-net-next 2/5] tools: ynl: fix bug in case of multiple nested attributes of the same type
@ 2023-04-06 17:32 ` Davide Caratti
0 siblings, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-04-06 17:32 UTC (permalink / raw)
To: mptcp
when a policy contains multiple nested attributes of the same type, avoid
re-initializing .request and .reply members.
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
tools/net/ynl/ynl-gen-c.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index cc2f8c945340..ba55f217a006 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -812,7 +812,8 @@ class Family(SpecFamily):
inherit = set()
nested = spec['nested-attributes']
if nested not in self.root_sets:
- self.pure_nested_structs[nested] = Struct(self, nested, inherited=inherit)
+ if nested not in self.pure_nested_structs:
+ self.pure_nested_structs[nested] = Struct(self, nested, inherited=inherit)
if attr in rs_members['request']:
self.pure_nested_structs[nested].request = True
if attr in rs_members['reply']:
--
2.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH RFC mptcp-net-next 3/5] Documentation: netlink: add a YAML spec for mptcp
@ 2023-04-06 17:32 ` Davide Caratti
0 siblings, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-04-06 17:32 UTC (permalink / raw)
To: mptcp
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
Documentation/netlink/specs/mptcp.yaml | 361 +++++++++++++++++++++++++
1 file changed, 361 insertions(+)
create mode 100644 Documentation/netlink/specs/mptcp.yaml
diff --git a/Documentation/netlink/specs/mptcp.yaml b/Documentation/netlink/specs/mptcp.yaml
new file mode 100644
index 000000000000..910307b021ba
--- /dev/null
+++ b/Documentation/netlink/specs/mptcp.yaml
@@ -0,0 +1,361 @@
+# 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: global
+
+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: addr
+ 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: attr
+ name-prefix: mptcp_pm_attr_
+ attributes:
+ -
+ name: unspec
+ type: unused
+ value: 0
+ -
+ name: addr
+ type: nest
+ nested-attributes: addr
+ -
+ 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: addr
+ -
+ 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: attr
+ flags: [ uns-admin-perm ]
+
+ do:
+ request: &add_addr_attrs
+ attributes:
+ - addr
+ -
+ name: del_addr
+ doc: Delete endpoint
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ -
+ name: get_addr
+ doc: Get endpoint information
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ reply: *add_addr_attrs
+
+ dump:
+ reply: *add_addr_attrs
+ -
+ name: flush_addrs
+ doc: flush addresses
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ -
+ name: set_limits
+ doc: Set protocol limits
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: &mptcp_limits
+ attributes:
+ - rcv_add_addrs
+ - subflows
+ -
+ name: get_limits
+ doc: Get protocol limits
+ attribute-set: attr
+ do:
+ request: *mptcp_limits
+ reply: *mptcp_limits
+ -
+ name: set_flags
+ doc: Change endpoint flags
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ -
+ name: announce
+ doc: announce new sf
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ reply: *add_addr_attrs
+ -
+ name: remove
+ doc: announce removal
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ reply: *add_addr_attrs
+ -
+ name: subflow_create
+ doc: todo
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ reply: *add_addr_attrs
+ -
+ name: subflow_destroy
+ doc: todo
+ attribute-set: attr
+ flags: [ uns-admin-perm ]
+ do:
+ request: *add_addr_attrs
+ reply: *add_addr_attrs
+
--
2.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH RFC mptcp-net-next 4/5] mptcp: uapi: add header files generated from YAML spec
@ 2023-04-06 17:32 ` Davide Caratti
0 siblings, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-04-06 17:32 UTC (permalink / raw)
To: mptcp
$ ./tools/net/ynl/ynl-gen-c.py --mode uapi \
> --spec Documentation/netlink/specs/mptcp.yaml --header \
> -o include/uapi/linux/mptcp_pm.h
and remove these definitions from mptcp.h
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
include/uapi/linux/mptcp.h | 167 +---------------------------------
include/uapi/linux/mptcp_pm.h | 145 +++++++++++++++++++++++++++++
2 files changed, 149 insertions(+), 163 deletions(-)
create mode 100644 include/uapi/linux/mptcp_pm.h
diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h
index 32af2d278cb4..f919f43a178a 100644
--- a/include/uapi/linux/mptcp.h
+++ b/include/uapi/linux/mptcp.h
@@ -12,6 +12,10 @@
#include <linux/in.h> /* for sockaddr_in */
#include <linux/in6.h> /* for sockaddr_in6 */
#include <linux/socket.h> /* for sockaddr_storage and sa_family */
+#include <linux/mptcp_pm.h> /* for netlink interface */
+
+#define __MPTCP_PM_CMD_AFTER_LAST __MPTCP_PM_CMD_MAX
+#define __MPTCP_ATTR_AFTER_LAST __MPTCP_ATTR_MAX
#define MPTCP_SUBFLOW_FLAG_MCAP_REM _BITUL(0)
#define MPTCP_SUBFLOW_FLAG_MCAP_LOC _BITUL(1)
@@ -23,88 +27,12 @@
#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_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)
-
#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
-};
-
#define MPTCP_INFO_FLAG_FALLBACK _BITUL(0)
#define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED _BITUL(1)
@@ -125,93 +53,6 @@ struct mptcp_info {
__u8 mptcpi_csum_enabled;
};
-/*
- * 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
diff --git a/include/uapi/linux/mptcp_pm.h b/include/uapi/linux/mptcp_pm.h
new file mode 100644
index 000000000000..37cdae7a871b
--- /dev/null
+++ b/include/uapi/linux/mptcp_pm.h
@@ -0,0 +1,145 @@
+/* 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 uapi header */
+
+#ifndef _UAPI_LINUX_MPTCP_PM_H
+#define _UAPI_LINUX_MPTCP_PM_H
+
+#define MPTCP_PM_NAME "mptcp_pm"
+#define MPTCP_PM_VER 1
+
+/**
+ * enum mptcp_pm_event_type
+ * @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,
+ MPTCP_EVENT_CREATED,
+ MPTCP_EVENT_ESTABLISHED,
+ MPTCP_EVENT_CLOSED,
+ MPTCP_EVENT_ANNOUNCED = 6,
+ MPTCP_EVENT_REMOVED,
+ MPTCP_EVENT_SUB_ESTABLISHED = 10,
+ MPTCP_EVENT_SUB_CLOSED,
+ MPTCP_EVENT_SUB_PRIORITY = 13,
+ MPTCP_EVENT_LISTENER_CREATED = 15,
+ MPTCP_EVENT_LISTENER_CLOSED,
+};
+
+enum {
+ MPTCP_PM_ADDR_ATTR_UNSPEC,
+ MPTCP_PM_ADDR_ATTR_FAMILY,
+ MPTCP_PM_ADDR_ATTR_ID,
+ MPTCP_PM_ADDR_ATTR_ADDR4,
+ MPTCP_PM_ADDR_ATTR_ADDR6,
+ MPTCP_PM_ADDR_ATTR_PORT,
+ MPTCP_PM_ADDR_ATTR_FLAGS,
+ MPTCP_PM_ADDR_ATTR_IF_IDX,
+
+ __MPTCP_PM_ADDR_ATTR_MAX
+};
+#define MPTCP_PM_ADDR_ATTR_MAX (__MPTCP_PM_ADDR_ATTR_MAX - 1)
+
+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)
+
+enum {
+ MPTCP_PM_ATTR_UNSPEC,
+ MPTCP_PM_ATTR_ADDR,
+ MPTCP_PM_ATTR_RCV_ADD_ADDRS,
+ MPTCP_PM_ATTR_SUBFLOWS,
+ MPTCP_PM_ATTR_TOKEN,
+ MPTCP_PM_ATTR_LOC_ID,
+ MPTCP_PM_ATTR_ADDR_REMOTE,
+
+ __MPTCP_PM_ATTR_MAX
+};
+#define MPTCP_PM_ATTR_MAX (__MPTCP_PM_ATTR_MAX - 1)
+
+enum mptcp_event_attr {
+ MPTCP_ATTR_UNSPEC,
+ MPTCP_ATTR_TOKEN,
+ MPTCP_ATTR_FAMILY,
+ MPTCP_ATTR_LOC_ID,
+ MPTCP_ATTR_REM_ID,
+ MPTCP_ATTR_SADDR4,
+ MPTCP_ATTR_SADDR6,
+ MPTCP_ATTR_DADDR4,
+ MPTCP_ATTR_DADDR6,
+ MPTCP_ATTR_SPORT,
+ MPTCP_ATTR_DPORT,
+ MPTCP_ATTR_BACKUP,
+ MPTCP_ATTR_ERROR,
+ MPTCP_ATTR_FLAGS,
+ MPTCP_ATTR_TIMEOUT,
+ MPTCP_ATTR_IF_IDX,
+ MPTCP_ATTR_RESET_REASON,
+ MPTCP_ATTR_RESET_FLAGS,
+ MPTCP_ATTR_SERVER_SIDE,
+
+ __MPTCP_ATTR_MAX
+};
+#define MPTCP_ATTR_MAX (__MPTCP_ATTR_MAX - 1)
+
+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_MAX
+};
+#define MPTCP_PM_CMD_MAX (__MPTCP_PM_CMD_MAX - 1)
+
+#define MPTCP_PM_CMD_GRP_NAME "mptcp_pm_cmds"
+#define MPTCP_PM_EV_GRP_NAME "mptcp_pm_events"
+
+#endif /* _UAPI_LINUX_MPTCP_PM_H */
--
2.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH RFC mptcp-net-next 5/5] net/mptcp: use netlink policy generated from YAML spec
@ 2023-04-06 17:32 ` Davide Caratti
0 siblings, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-04-06 17:32 UTC (permalink / raw)
To: mptcp
$ ./tools/net/ynl/ynl-gen-c.py --mode kernel \
> --spec Documentation/netlink/specs/mptcp.yaml --header \
> -o net/mptcp/pm_nl.h
$ ./tools/net/ynl/ynl-gen-c.py --mode kernel \
> --spec Documentation/netlink/specs/mptcp.yaml --source \
> -o net/mptcp/pm_nl.c
and remove the old ones we had in pm_netlink.c/pm_userspace.c
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
net/mptcp/Makefile | 3 +-
net/mptcp/pm_netlink.c | 107 +++++----------------------------------
net/mptcp/pm_nl.c | 91 +++++++++++++++++++++++++++++++++
net/mptcp/pm_nl.h | 39 ++++++++++++++
net/mptcp/pm_userspace.c | 9 ++--
net/mptcp/protocol.h | 6 +--
6 files changed, 152 insertions(+), 103 deletions(-)
create mode 100644 net/mptcp/pm_nl.c
create mode 100644 net/mptcp/pm_nl.h
diff --git a/net/mptcp/Makefile b/net/mptcp/Makefile
index 84e531f86b82..dedd1bf8d052 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 \
+ pm_nl.o
obj-$(CONFIG_SYN_COOKIES) += syncookies.o
obj-$(CONFIG_INET_MPTCP_DIAG) += mptcp_diag.o
diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c
index e8336b8bd30e..44cb7925aec1 100644
--- a/net/mptcp/pm_netlink.c
+++ b/net/mptcp/pm_netlink.c
@@ -1116,28 +1116,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)
{
@@ -1200,7 +1178,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);
+ mptcp_pm_addr_nl_policy, info->extack);
if (err)
return err;
@@ -1315,7 +1293,7 @@ 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)
{
struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR];
struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
@@ -1507,7 +1485,7 @@ static int mptcp_nl_remove_id_zero_address(struct net *net,
return 0;
}
-static int mptcp_nl_cmd_del_addr(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_ATTR_ADDR];
struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
@@ -1624,7 +1602,7 @@ static void __reset_counters(struct pm_nl_pernet *pernet)
pernet->addrs = 0;
}
-static int mptcp_nl_cmd_flush_addrs(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);
@@ -1680,7 +1658,7 @@ static int mptcp_nl_fill_addr(struct sk_buff *skb,
return -EMSGSIZE;
}
-static int mptcp_nl_cmd_get_addr(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_ATTR_ADDR];
struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
@@ -1730,8 +1708,8 @@ static int mptcp_nl_cmd_get_addr(struct sk_buff *skb, struct genl_info *info)
return ret;
}
-static int mptcp_nl_cmd_dump_addrs(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;
@@ -1788,8 +1766,7 @@ static int parse_limit(struct genl_info *info, int id, unsigned int *limit)
return 0;
}
-static int
-mptcp_nl_cmd_set_limits(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;
@@ -1814,8 +1791,7 @@ mptcp_nl_cmd_set_limits(struct sk_buff *skb, struct genl_info *info)
return ret;
}
-static int
-mptcp_nl_cmd_get_limits(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;
@@ -1889,7 +1865,7 @@ static int mptcp_nl_set_flags(struct net *net,
return ret;
}
-static int mptcp_nl_cmd_set_flags(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 addr = { .addr = { .family = AF_UNSPEC }, }, *entry;
struct mptcp_pm_addr_entry remote = { .addr = { .family = AF_UNSPEC }, };
@@ -2282,72 +2258,15 @@ void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk,
nlmsg_free(skb);
}
-static const struct genl_small_ops mptcp_pm_ops[] = {
- {
- .cmd = MPTCP_PM_CMD_ADD_ADDR,
- .doit = mptcp_nl_cmd_add_addr,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_DEL_ADDR,
- .doit = mptcp_nl_cmd_del_addr,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_FLUSH_ADDRS,
- .doit = mptcp_nl_cmd_flush_addrs,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_GET_ADDR,
- .doit = mptcp_nl_cmd_get_addr,
- .dumpit = mptcp_nl_cmd_dump_addrs,
- },
- {
- .cmd = MPTCP_PM_CMD_SET_LIMITS,
- .doit = mptcp_nl_cmd_set_limits,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_GET_LIMITS,
- .doit = mptcp_nl_cmd_get_limits,
- },
- {
- .cmd = MPTCP_PM_CMD_SET_FLAGS,
- .doit = mptcp_nl_cmd_set_flags,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_ANNOUNCE,
- .doit = mptcp_nl_cmd_announce,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_REMOVE,
- .doit = mptcp_nl_cmd_remove,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_SUBFLOW_CREATE,
- .doit = mptcp_nl_cmd_sf_create,
- .flags = GENL_UNS_ADMIN_PERM,
- },
- {
- .cmd = MPTCP_PM_CMD_SUBFLOW_DESTROY,
- .doit = mptcp_nl_cmd_sf_destroy,
- .flags = GENL_UNS_ADMIN_PERM,
- },
-};
-
static struct genl_family mptcp_genl_family __ro_after_init = {
.name = MPTCP_PM_NAME,
.version = MPTCP_PM_VER,
.maxattr = MPTCP_PM_ATTR_MAX,
- .policy = mptcp_pm_policy,
+ .policy = mptcp_pm_attr_nl_policy,
.netnsok = true,
.module = THIS_MODULE,
- .small_ops = mptcp_pm_ops,
- .n_small_ops = ARRAY_SIZE(mptcp_pm_ops),
+ .small_ops = mptcp_pm_nl_ops,
+ .n_small_ops = ARRAY_SIZE(mptcp_pm_nl_ops),
.resv_start_op = MPTCP_PM_CMD_SUBFLOW_DESTROY + 1,
.mcgrps = mptcp_pm_mcgrps,
.n_mcgrps = ARRAY_SIZE(mptcp_pm_mcgrps),
diff --git a/net/mptcp/pm_nl.c b/net/mptcp/pm_nl.c
new file mode 100644
index 000000000000..5de927aa8a1d
--- /dev/null
+++ b/net/mptcp/pm_nl.c
@@ -0,0 +1,91 @@
+// 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 <net/netlink.h>
+#include <net/genetlink.h>
+
+#include "pm_nl.h"
+
+#include <linux/mptcp_pm.h>
+
+/* Common nested types */
+const struct nla_policy mptcp_pm_addr_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, },
+};
+
+/* Global operation policy for mptcp_pm */
+const struct nla_policy mptcp_pm_attr_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = {
+ [MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_addr_nl_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_nl_policy),
+};
+
+/* Ops table for mptcp_pm */
+const struct genl_small_ops mptcp_pm_nl_ops[11] = {
+ {
+ .cmd = MPTCP_PM_CMD_ADD_ADDR,
+ .doit = mptcp_pm_nl_add_addr_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_DEL_ADDR,
+ .doit = mptcp_pm_nl_del_addr_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_GET_ADDR,
+ .doit = mptcp_pm_nl_get_addr_doit,
+ .dumpit = mptcp_pm_nl_get_addr_dumpit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_FLUSH_ADDRS,
+ .doit = mptcp_pm_nl_flush_addrs_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_SET_LIMITS,
+ .doit = mptcp_pm_nl_set_limits_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_GET_LIMITS,
+ .doit = mptcp_pm_nl_get_limits_doit,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_SET_FLAGS,
+ .doit = mptcp_pm_nl_set_flags_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_ANNOUNCE,
+ .doit = mptcp_pm_nl_announce_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_REMOVE,
+ .doit = mptcp_pm_nl_remove_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_SUBFLOW_CREATE,
+ .doit = mptcp_pm_nl_subflow_create_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+ {
+ .cmd = MPTCP_PM_CMD_SUBFLOW_DESTROY,
+ .doit = mptcp_pm_nl_subflow_destroy_doit,
+ .flags = GENL_UNS_ADMIN_PERM,
+ },
+};
diff --git a/net/mptcp/pm_nl.h b/net/mptcp/pm_nl.h
new file mode 100644
index 000000000000..26dd13f3244d
--- /dev/null
+++ b/net/mptcp/pm_nl.h
@@ -0,0 +1,39 @@
+/* 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 <net/netlink.h>
+#include <net/genetlink.h>
+
+#include <linux/mptcp_pm.h>
+
+/* Common nested types */
+extern const struct nla_policy mptcp_pm_addr_nl_policy[MPTCP_PM_ADDR_ATTR_IF_IDX + 1];
+
+/* Global operation policy for mptcp_pm */
+extern const struct nla_policy mptcp_pm_attr_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1];
+
+/* Ops table for mptcp_pm */
+extern const struct genl_small_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_userspace.c b/net/mptcp/pm_userspace.c
index 27a275805c06..8936d0f80884 100644
--- a/net/mptcp/pm_userspace.c
+++ b/net/mptcp/pm_userspace.c
@@ -122,7 +122,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];
@@ -184,7 +184,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];
@@ -246,7 +246,7 @@ 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];
@@ -361,7 +361,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];
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 5a35c77723e3..ca33d2808b61 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -13,6 +13,8 @@
#include <uapi/linux/mptcp.h>
#include <net/genetlink.h>
+#include "pm_nl.h" /* for netlink interface */
+
#define MPTCP_SUPPORTED_VERSION 1
/* MPTCP option bits */
@@ -849,10 +851,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_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info);
-int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info);
-int mptcp_nl_cmd_sf_create(struct sk_buff *skb, struct genl_info *info);
-int mptcp_nl_cmd_sf_destroy(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.39.2
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: net/mptcp: use netlink policy generated from YAML spec: Build Failure
@ 2023-04-06 18:32 ` MPTCP CI
0 siblings, 0 replies; 21+ messages in thread
From: MPTCP CI @ 2023-04-06 18:32 UTC (permalink / raw)
To: Davide Caratti; +Cc: mptcp
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/20230406173159.vjKk7zJ6cyrQl9c5RwemQMbWO6eJd8GHzW-3jvtoa88@z/
https://github.com/multipath-tcp/mptcp_net-next/actions/runs/4631535712
Status: failure
Initiator: MPTCPimporter
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/7d20481ccf26
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)
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: net/mptcp: use netlink policy generated from YAML spec: Tests Results
@ 2023-04-06 18:39 ` MPTCP CI
0 siblings, 0 replies; 21+ messages in thread
From: MPTCP CI @ 2023-04-06 18:39 UTC (permalink / raw)
To: Davide Caratti; +Cc: mptcp
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):
- Unstable: 3 failed test(s): packetdrill_add_addr packetdrill_syscalls selftest_userspace_pm 🔴:
- Task: https://cirrus-ci.com/task/5911521633501184
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5911521633501184/summary/summary.txt
- KVM Validation: normal (only selftest_mptcp_join):
- Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
- Task: https://cirrus-ci.com/task/5348571680079872
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5348571680079872/summary/summary.txt
- KVM Validation: debug (except selftest_mptcp_join):
- Unstable: 3 failed test(s): packetdrill_add_addr packetdrill_syscalls selftest_userspace_pm 🔴:
- Task: https://cirrus-ci.com/task/6474471586922496
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6474471586922496/summary/summary.txt
- KVM Validation: debug (only selftest_mptcp_join):
- Unstable: 1 failed test(s): selftest_mptcp_join 🔴:
- Task: https://cirrus-ci.com/task/4644884238303232
- Summary: https://api.cirrus-ci.com/v1/artifact/task/4644884238303232/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/7d20481ccf26
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-debug
For 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)
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH RFC mptcp-net-next 3/5] Documentation: netlink: add a YAML spec for mptcp
2023-04-06 17:32 ` Davide Caratti
(?)
@ 2023-04-07 7:56 ` Paolo Abeni
2023-04-07 9:52 ` Davide Caratti
-1 siblings, 1 reply; 21+ messages in thread
From: Paolo Abeni @ 2023-04-07 7:56 UTC (permalink / raw)
To: Davide Caratti, mptcp
On Thu, 2023-04-06 at 19:31 +0200, Davide Caratti wrote:
[...]
> +attribute-sets:
> + -
> + name: addr
> + name-prefix: mptcp_pm_addr_attr_
> + attributes:
> + -
> + name: unspec
> + type: unused
> + value: 0
This entry should not be needed, the tool should add it by default and
keep the first item with value == 1.
> + -
> + name: attr
> + name-prefix: mptcp_pm_attr_
> + attributes:
> + -
> + name: unspec
> + type: unused
> + value: 0
> + -
> + name: addr
> + type: nest
> + nested-attributes: addr
> + -
> + 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: addr
Is this the definition requiring patch 2/5 ?
Are there other attribute set requiring such change?
Thanks!
Paolo
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH RFC mptcp-net-next 2/5] tools: ynl: fix bug in case of multiple nested attributes of the same type
2023-04-06 17:32 ` Davide Caratti
(?)
@ 2023-04-07 8:00 ` Paolo Abeni
2023-04-07 8:53 ` Davide Caratti
2023-07-18 14:46 ` Davide Caratti
-1 siblings, 2 replies; 21+ messages in thread
From: Paolo Abeni @ 2023-04-07 8:00 UTC (permalink / raw)
To: Davide Caratti, mptcp
On Thu, 2023-04-06 at 19:31 +0200, Davide Caratti wrote:
> when a policy contains multiple nested attributes of the same type, avoid
> re-initializing .request and .reply members.
It's unclear to me why we need to avoid such re-init...
>
> Signed-off-by: Davide Caratti <dcaratti@redhat.com>
> ---
> tools/net/ynl/ynl-gen-c.py | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
> index cc2f8c945340..ba55f217a006 100755
> --- a/tools/net/ynl/ynl-gen-c.py
> +++ b/tools/net/ynl/ynl-gen-c.py
> @@ -812,7 +812,8 @@ class Family(SpecFamily):
> inherit = set()
> nested = spec['nested-attributes']
> if nested not in self.root_sets:
> - self.pure_nested_structs[nested] = Struct(self, nested, inherited=inherit)
> + if nested not in self.pure_nested_structs:
> + self.pure_nested_structs[nested] = Struct(self, nested, inherited=inherit)
... and is unclear to me how the above produces the effect described in
the commit message :)
Thanks!
Paolo
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH RFC mptcp-net-next 5/5] net/mptcp: use netlink policy generated from YAML spec
2023-04-06 17:32 ` Davide Caratti
(?)
@ 2023-04-07 8:03 ` Paolo Abeni
-1 siblings, 0 replies; 21+ messages in thread
From: Paolo Abeni @ 2023-04-07 8:03 UTC (permalink / raw)
To: Davide Caratti, mptcp
On Thu, 2023-04-06 at 19:31 +0200, Davide Caratti wrote:
> $ ./tools/net/ynl/ynl-gen-c.py --mode kernel \
> > --spec Documentation/netlink/specs/mptcp.yaml --header \
> > -o net/mptcp/pm_nl.h
> $ ./tools/net/ynl/ynl-gen-c.py --mode kernel \
> > --spec Documentation/netlink/specs/mptcp.yaml --source \
> > -o net/mptcp/pm_nl.c
perhaps:
pm_nl_autogen.{c,h}
or
pm_nl_spec.{c,h}
to avoid confusion vs pm_netlink ?
Thanks!
Paolo
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH RFC mptcp-net-next 2/5] tools: ynl: fix bug in case of multiple nested attributes of the same type
2023-04-07 8:00 ` Paolo Abeni
@ 2023-04-07 8:53 ` Davide Caratti
2023-07-18 14:46 ` Davide Caratti
1 sibling, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-04-07 8:53 UTC (permalink / raw)
To: Paolo Abeni; +Cc: mptcp
hi Paolo,
thanks a lot for looking at this!
On Fri, Apr 07, 2023 at 10:00:43AM +0200, Paolo Abeni wrote:
> On Thu, 2023-04-06 at 19:31 +0200, Davide Caratti wrote:
> > when a policy contains multiple nested attributes of the same type, avoid
> > re-initializing .request and .reply members.
>
> It's unclear to me why we need to avoid such re-init...
*disclaimer*: this will sound as a giant word pun, since "pm", "addr" and
"attr" are used in any combination in the current netlink API :)
That said:
"attr" has two nested attributes, "addr" and "remote_addr", of the same
type "addr". When ynl-gen-c.py parses "addr" (e.g. in the block
describing the "add_addr" operation), it sets
self.pure_nested_structs['addr'].Request
equal to True, because at least on operation needs it. Then, when it
parses "remote_addr", the call to
Struct(self, nested, inherited=inherit)
will reset the above variable to 'False'. As a consequence, when it comes
to print the nla_policy struct, the following code will run:
2127 if args.mode == "kernel":
2128 if args.header:
2129 for _, struct in sorted(parsed.pure_nested_structs.items()):
2130 if struct.request:
2131 cw.p('/* Common nested types */')
2132 break
2133 for attr_set, struct in sorted(parsed.pure_nested_structs.items()):
2134 if struct.request:
2135 print_req_policy_fwd(cw, struct)
2136 cw.nl()
since struct.request has become True and then resetted to False,
ynl-gen-c.py refuses to print the nla_policy of the nested attribute.
Like I mentioned in the cover letter, changing the yaml spec in a way that
at least one operation requires 'remote_addr' in the attribute-set will
make this issue disappear; anyway, I think that the current behavior of
ynl-gen-c.py is not intentional, that's why I did this fix attempt.
[...]
> > diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
> > index cc2f8c945340..ba55f217a006 100755
> > --- a/tools/net/ynl/ynl-gen-c.py
> > +++ b/tools/net/ynl/ynl-gen-c.py
> > @@ -812,7 +812,8 @@ class Family(SpecFamily):
> > inherit = set()
> > nested = spec['nested-attributes']
> > if nested not in self.root_sets:
> > - self.pure_nested_structs[nested] = Struct(self, nested, inherited=inherit)
> > + if nested not in self.pure_nested_structs:
> > + self.pure_nested_structs[nested] = Struct(self, nested, inherited=inherit)
>
> ... and is unclear to me how the above produces the effect described in
> the commit message :)
this hunk avoids re-initializing
self.pure_nested_structs['addr'].{request,reply}
when it has already been parsed once. If at least a nested attribute sets
'request' to True, then 'request' remains True also when other nested
attributes of the same type are found.
--
davide
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH RFC mptcp-net-next 3/5] Documentation: netlink: add a YAML spec for mptcp
2023-04-07 7:56 ` Paolo Abeni
@ 2023-04-07 9:52 ` Davide Caratti
0 siblings, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-04-07 9:52 UTC (permalink / raw)
To: Paolo Abeni; +Cc: mptcp
hello Paolo, thanks for looking at this!
On Fri, Apr 07, 2023 at 09:56:39AM +0200, Paolo Abeni wrote:
> On Thu, 2023-04-06 at 19:31 +0200, Davide Caratti wrote:
> [...]
> > +attribute-sets:
> > + -
> > + name: addr
> > + name-prefix: mptcp_pm_addr_attr_
> > + attributes:
> > + -
> > + name: unspec
> > + type: unused
> > + value: 0
>
> This entry should not be needed, the tool should add it by default and
> keep the first item with value == 1.
wouldn't this would break the uAPI? I mean, in the current one we have
MPTCP_PM_ADDR_ATTR_UNSPEC equal to zero. Removing the whole element would
make MPTCP_PM_ADDR_ATTR_UNSPEC disappear and potentially break the build
of userspace programs that use it. See below:
$ git diff
diff --git a/Documentation/netlink/specs/mptcp.yaml b/Documentation/netlink/specs/mptcp.yaml
index 910307b021ba..12974bf0cf10 100644
--- a/Documentation/netlink/specs/mptcp.yaml
+++ b/Documentation/netlink/specs/mptcp.yaml
@@ -91,10 +91,6 @@ attribute-sets:
name: addr
name-prefix: mptcp_pm_addr_attr_
attributes:
- -
- name: unspec
- type: unused
- value: 0
-
name: family
type: u16
$ ./tools/net/ynl/ynl-gen-c.py --mode uapi \
> --spec Documentation/netlink/specs/mptcp.yaml --header \
> | grep -B1 -A1 -i addr_attr_family
enum {
MPTCP_PM_ADDR_ATTR_FAMILY = 1,
MPTCP_PM_ADDR_ATTR_ID,
[...]
> > + -
> > + name: addr_remote
> > + type: nest
> > + nested-attributes: addr
>
> Is this the definition requiring patch 2/5 ?
yes! I replied to your comment to patch 2/5 (and hopefully didn't mess with the names ;) )
> Are there other attribute set requiring such change?
currently ynl-gen-c.py supports only a single attribute-set for
each list of operations - but the effect on the generated code is
not relevant AFAIU.
--
davide
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: net/mptcp: use netlink policy generated from YAML spec: Build Failure
@ 2023-04-07 9:58 ` MPTCP CI
0 siblings, 0 replies; 21+ messages in thread
From: MPTCP CI @ 2023-04-07 9:58 UTC (permalink / raw)
To: Davide Caratti; +Cc: mptcp
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/20230406173159.vjKk7zJ6cyrQl9c5RwemQMbWO6eJd8GHzW-3jvtoa88@z/
https://github.com/multipath-tcp/mptcp_net-next/actions/runs/4631535712
Status: cancelled
Initiator: MPTCPimporter
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/7d20481ccf26
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)
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH RFC mptcp-net-next 2/5] tools: ynl: fix bug in case of multiple nested attributes of the same type
2023-04-07 8:00 ` Paolo Abeni
2023-04-07 8:53 ` Davide Caratti
@ 2023-07-18 14:46 ` Davide Caratti
1 sibling, 0 replies; 21+ messages in thread
From: Davide Caratti @ 2023-07-18 14:46 UTC (permalink / raw)
To: Paolo Abeni; +Cc: mptcp
On Fri, Apr 7, 2023 at 10:00 AM Paolo Abeni <pabeni@redhat.com> wrote:
>
> On Thu, 2023-04-06 at 19:31 +0200, Davide Caratti wrote:
> > when a policy contains multiple nested attributes of the same type, avoid
> > re-initializing .request and .reply members.
>
> It's unclear to me why we need to avoid such re-init...
>
> >
> > Signed-off-by: Davide Caratti <dcaratti@redhat.com>
> > ---
> > tools/net/ynl/ynl-gen-c.py | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
> > index cc2f8c945340..ba55f217a006 100755
> > --- a/tools/net/ynl/ynl-gen-c.py
> > +++ b/tools/net/ynl/ynl-gen-c.py
> > @@ -812,7 +812,8 @@ class Family(SpecFamily):
> > inherit = set()
> > nested = spec['nested-attributes']
> > if nested not in self.root_sets:
> > - self.pure_nested_structs[nested] = Struct(self, nested, inherited=inherit)
> > + if nested not in self.pure_nested_structs:
> > + self.pure_nested_structs[nested] = Struct(self, nested, inherited=inherit)
>
> ... and is unclear to me how the above produces the effect described in
> the commit message :)
FTR: I'm removing this patch from the series as it's already in the
net-next tree [1]. Thanks!
[1] https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/commit/?id=67c65ce762adaf3515fe0585
--
davide
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2023-07-18 14:46 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06 17:31 [PATCH RFC mptcp-net-next 0/5] YAML template for MPTCP netlink API Davide Caratti
2023-04-06 17:32 ` Davide Caratti
2023-04-06 17:31 ` [PATCH RFC mptcp-net-next 1/5] tools: ynl: add uns-admin-perm to genetlink legacy Davide Caratti
2023-04-06 17:32 ` Davide Caratti
2023-04-06 17:31 ` [PATCH RFC mptcp-net-next 2/5] tools: ynl: fix bug in case of multiple nested attributes of the same type Davide Caratti
2023-04-06 17:32 ` Davide Caratti
2023-04-07 8:00 ` Paolo Abeni
2023-04-07 8:53 ` Davide Caratti
2023-07-18 14:46 ` Davide Caratti
2023-04-06 17:31 ` [PATCH RFC mptcp-net-next 3/5] Documentation: netlink: add a YAML spec for mptcp Davide Caratti
2023-04-06 17:32 ` Davide Caratti
2023-04-07 7:56 ` Paolo Abeni
2023-04-07 9:52 ` Davide Caratti
2023-04-06 17:31 ` [PATCH RFC mptcp-net-next 4/5] mptcp: uapi: add header files generated from YAML spec Davide Caratti
2023-04-06 17:32 ` Davide Caratti
2023-04-06 17:31 ` [PATCH RFC mptcp-net-next 5/5] net/mptcp: use netlink policy " Davide Caratti
2023-04-06 17:31 ` Davide Caratti
2023-04-06 17:32 ` Davide Caratti
2023-04-07 8:03 ` Paolo Abeni
2023-04-06 18:32 ` net/mptcp: use netlink policy generated from YAML spec: Build Failure MPTCP CI
2023-04-06 18:39 ` net/mptcp: use netlink policy generated from YAML spec: Tests Results MPTCP CI
2023-04-07 9:58 ` net/mptcp: use netlink policy generated from YAML spec: Build Failure MPTCP CI
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.