Commit fb1c535b authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'mptcp-convert-netlink-code-to-use-yaml-spec'

Mat Martineau says:

====================
mptcp: convert Netlink code to use YAML spec

This series from Davide converts most of the MPTCP Netlink interface
(plus uAPI bits) to use sources generated by YNL using a YAML spec file.

This new YAML file is useful to validate the API and to generate a good
documentation page.

Patch 1 modifies YNL spec to support "uns-admin-perm" for genetlink
legacy.

Patch 2 adds support for validating exact length of netlink attrs.

Patch 3 converts Netlink structures from small_ops to ops to prepare the
switch to YAML.

Patch 4 adds the Netlink YAML spec for MPTCP.

Patch 5 adds and uses a new header file generated from the new YAML
spec.

Patch 6 renames some handlers to match the ones generated from the YAML
spec.

Patch 7 adds and uses Netlink policies automatically generated from the
YAML spec.
====================

Link: https://lore.kernel.org/r/20231023-send-net-next-20231023-1-v2-0-16b1f701f900@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 6d25d1dc aab4d856
......@@ -199,6 +199,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: |
......
......@@ -242,6 +242,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
......@@ -337,7 +340,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
......
......@@ -172,6 +172,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: |
......
......@@ -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
......
# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
name: mptcp_pm
protocol: genetlink-legacy
doc: Multipath TCP.
c-family-name: mptcp-pm-name
c-version-name: mptcp-pm-ver
max-by-define: true
kernel-policy: per-op
definitions:
-
type: enum
name: event-type
enum-name: mptcp-event-type
name-prefix: mptcp-event-
entries:
-
name: unspec
doc: unused event
-
name: created
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
doc:
token, family, saddr4 | saddr6, daddr4 | daddr6, sport, dport
A MPTCP connection is established (can start new subflows).
-
name: closed
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
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
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
doc:
family, sport, saddr4 | saddr6
A PM listener is closed.
attribute-sets:
-
name: address
name-prefix: mptcp-pm-addr-attr-
attributes:
-
name: unspec
type: unused
value: 0
-
name: family
type: u16
-
name: id
type: u8
-
name: addr4
type: u32
byte-order: big-endian
-
name: addr6
type: binary
checks:
exact-len: 16
-
name: port
type: u16
byte-order: big-endian
-
name: flags
type: u32
-
name: if-idx
type: s32
-
name: subflow-attribute
name-prefix: mptcp-subflow-attr-
attributes:
-
name: unspec
type: unused
value: 0
-
name: token-rem
type: u32
-
name: token-loc
type: u32
-
name: relwrite-seq
type: u32
-
name: map-seq
type: u64
-
name: map-sfseq
type: u32
-
name: ssn-offset
type: u32
-
name: map-datalen
type: u16
-
name: flags
type: u32
-
name: id-rem
type: u8
-
name: id-loc
type: u8
-
name: pad
type: pad
-
name: endpoint
name-prefix: mptcp-pm-endpoint-
attributes:
-
name: addr
type: nest
nested-attributes: address
-
name: attr
name-prefix: mptcp-pm-attr-
attributes:
-
name: unspec
type: unused
value: 0
-
name: addr
type: nest
nested-attributes: address
-
name: rcv-add-addrs
type: u32
-
name: subflows
type: u32
-
name: token
type: u32
-
name: loc-id
type: u8
-
name: addr-remote
type: nest
nested-attributes: address
-
name: event-attr
enum-name: mptcp-event-attr
name-prefix: mptcp-attr-
attributes:
-
name: unspec
type: unused
value: 0
-
name: token
type: u32
-
name: family
type: u16
-
name: loc-id
type: u8
-
name: rem-id
type: u8
-
name: saddr4
type: u32
byte-order: big-endian
-
name: saddr6
type: binary
checks:
min-len: 16
-
name: daddr4
type: u32
byte-order: big-endian
-
name: daddr6
type: binary
checks:
min-len: 16
-
name: sport
type: u16
byte-order: big-endian
-
name: dport
type: u16
byte-order: big-endian
-
name: backup
type: u8
-
name: error
type: u8
-
name: flags
type: u16
-
name: timeout
type: u32
-
name: if_idx
type: u32
-
name: reset-reason
type: u32
-
name: reset-flags
type: u32
-
name: server-side
type: u8
operations:
list:
-
name: unspec
doc: unused
value: 0
-
name: add-addr
doc: Add endpoint
attribute-set: endpoint
dont-validate: [ strict ]
flags: [ uns-admin-perm ]
do: &add-addr-attrs
request:
attributes:
- addr
-
name: del-addr
doc: Delete endpoint
attribute-set: endpoint
dont-validate: [ strict ]
flags: [ uns-admin-perm ]
do: *add-addr-attrs
-
name: get-addr
doc: Get endpoint information
attribute-set: endpoint
dont-validate: [ strict ]
flags: [ uns-admin-perm ]
do: &get-addr-attrs
request:
attributes:
- addr
reply:
attributes:
- addr
dump:
reply:
attributes:
- addr
-
name: flush-addrs
doc: flush addresses
attribute-set: endpoint
dont-validate: [ strict ]
flags: [ uns-admin-perm ]
do: *add-addr-attrs
-
name: set-limits
doc: Set protocol limits
attribute-set: attr
dont-validate: [ strict ]
flags: [ uns-admin-perm ]
do: &mptcp-limits
request:
attributes:
- rcv-add-addrs
- subflows
-
name: get-limits
doc: Get protocol limits
attribute-set: attr
dont-validate: [ strict ]
do: &mptcp-get-limits
request:
attributes:
- rcv-add-addrs
- subflows
reply:
attributes:
- rcv-add-addrs
- subflows
-
name: set-flags
doc: Change endpoint flags
attribute-set: attr
dont-validate: [ strict ]
flags: [ uns-admin-perm ]
do: &mptcp-set-flags
request:
attributes:
- addr
- token
- addr-remote
-
name: announce
doc: announce new sf
attribute-set: attr
dont-validate: [ strict ]
flags: [ uns-admin-perm ]
do: &announce-add
request:
attributes:
- addr
- token
-
name: remove
doc: announce removal
attribute-set: attr
dont-validate: [ strict ]
flags: [ uns-admin-perm ]
do:
request:
attributes:
- token
- loc-id
-
name: subflow-create
doc: todo
attribute-set: attr
dont-validate: [ strict ]
flags: [ uns-admin-perm ]
do: &sf-create
request:
attributes:
- addr
- token
- addr-remote
-
name: subflow-destroy
doc: todo
attribute-set: attr
dont-validate: [ strict ]
flags: [ uns-admin-perm ]
do: *sf-create
......@@ -14960,10 +14960,11 @@ W: https://github.com/multipath-tcp/mptcp_net-next/wiki
B: https://github.com/multipath-tcp/mptcp_net-next/issues
T: git https://github.com/multipath-tcp/mptcp_net-next.git export-net
T: git https://github.com/multipath-tcp/mptcp_net-next.git export
F: Documentation/netlink/specs/mptcp.yaml
F: Documentation/networking/mptcp-sysctl.rst
F: include/net/mptcp.h
F: include/trace/events/mptcp.h
F: include/uapi/linux/mptcp.h
F: include/uapi/linux/mptcp*.h
F: net/mptcp/
F: tools/testing/selftests/bpf/*/*mptcp*.c
F: tools/testing/selftests/net/mptcp/
......
......@@ -23,91 +23,24 @@
#define MPTCP_SUBFLOW_FLAG_CONNECTED _BITUL(7)
#define MPTCP_SUBFLOW_FLAG_MAPVALID _BITUL(8)
enum {
MPTCP_SUBFLOW_ATTR_UNSPEC,
MPTCP_SUBFLOW_ATTR_TOKEN_REM,
MPTCP_SUBFLOW_ATTR_TOKEN_LOC,
MPTCP_SUBFLOW_ATTR_RELWRITE_SEQ,
MPTCP_SUBFLOW_ATTR_MAP_SEQ,
MPTCP_SUBFLOW_ATTR_MAP_SFSEQ,
MPTCP_SUBFLOW_ATTR_SSN_OFFSET,
MPTCP_SUBFLOW_ATTR_MAP_DATALEN,
MPTCP_SUBFLOW_ATTR_FLAGS,
MPTCP_SUBFLOW_ATTR_ID_REM,
MPTCP_SUBFLOW_ATTR_ID_LOC,
MPTCP_SUBFLOW_ATTR_PAD,
__MPTCP_SUBFLOW_ATTR_MAX
};
#define MPTCP_SUBFLOW_ATTR_MAX (__MPTCP_SUBFLOW_ATTR_MAX - 1)
/* netlink interface */
#define MPTCP_PM_NAME "mptcp_pm"
#define MPTCP_PM_CMD_GRP_NAME "mptcp_pm_cmds"
#define MPTCP_PM_EV_GRP_NAME "mptcp_pm_events"
#define MPTCP_PM_VER 0x1
/*
* ATTR types defined for MPTCP
*/
enum {
MPTCP_PM_ATTR_UNSPEC,
MPTCP_PM_ATTR_ADDR, /* nested address */
MPTCP_PM_ATTR_RCV_ADD_ADDRS, /* u32 */
MPTCP_PM_ATTR_SUBFLOWS, /* u32 */
MPTCP_PM_ATTR_TOKEN, /* u32 */
MPTCP_PM_ATTR_LOC_ID, /* u8 */
MPTCP_PM_ATTR_ADDR_REMOTE, /* nested address */
__MPTCP_PM_ATTR_MAX
};
#define MPTCP_PM_ATTR_MAX (__MPTCP_PM_ATTR_MAX - 1)
enum {
MPTCP_PM_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,
#include <linux/mptcp_pm.h>
MPTCP_PM_CMD_ADD_ADDR,
MPTCP_PM_CMD_DEL_ADDR,
MPTCP_PM_CMD_GET_ADDR,
MPTCP_PM_CMD_FLUSH_ADDRS,
MPTCP_PM_CMD_SET_LIMITS,
MPTCP_PM_CMD_GET_LIMITS,
MPTCP_PM_CMD_SET_FLAGS,
MPTCP_PM_CMD_ANNOUNCE,
MPTCP_PM_CMD_REMOVE,
MPTCP_PM_CMD_SUBFLOW_CREATE,
MPTCP_PM_CMD_SUBFLOW_DESTROY,
__MPTCP_PM_CMD_AFTER_LAST
};
/* for backward compatibility */
#define __MPTCP_PM_CMD_AFTER_LAST __MPTCP_PM_CMD_MAX
#define __MPTCP_ATTR_AFTER_LAST __MPTCP_ATTR_MAX
#define MPTCP_INFO_FLAG_FALLBACK _BITUL(0)
#define MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED _BITUL(1)
#define MPTCP_PM_ADDR_FLAG_SIGNAL (1 << 0)
#define MPTCP_PM_ADDR_FLAG_SUBFLOW (1 << 1)
#define MPTCP_PM_ADDR_FLAG_BACKUP (1 << 2)
#define MPTCP_PM_ADDR_FLAG_FULLMESH (1 << 3)
#define MPTCP_PM_ADDR_FLAG_IMPLICIT (1 << 4)
struct mptcp_info {
__u8 mptcpi_subflows;
__u8 mptcpi_add_addr_signal;
......@@ -130,93 +63,6 @@ struct mptcp_info {
__u64 mptcpi_bytes_acked;
};
/*
* MPTCP_EVENT_CREATED: token, family, saddr4 | saddr6, daddr4 | daddr6,
* sport, dport
* A new MPTCP connection has been created. It is the good time to allocate
* memory and send ADD_ADDR if needed. Depending on the traffic-patterns
* it can take a long time until the MPTCP_EVENT_ESTABLISHED is sent.
*
* MPTCP_EVENT_ESTABLISHED: token, family, saddr4 | saddr6, daddr4 | daddr6,
* sport, dport
* A MPTCP connection is established (can start new subflows).
*
* MPTCP_EVENT_CLOSED: token
* A MPTCP connection has stopped.
*
* MPTCP_EVENT_ANNOUNCED: token, rem_id, family, daddr4 | daddr6 [, dport]
* A new address has been announced by the peer.
*
* MPTCP_EVENT_REMOVED: token, rem_id
* An address has been lost by the peer.
*
* MPTCP_EVENT_SUB_ESTABLISHED: token, family, loc_id, rem_id,
* saddr4 | saddr6, daddr4 | daddr6, sport,
* dport, backup, if_idx [, error]
* A new subflow has been established. 'error' should not be set.
*
* MPTCP_EVENT_SUB_CLOSED: token, family, loc_id, rem_id, saddr4 | saddr6,
* daddr4 | daddr6, sport, dport, backup, if_idx
* [, error]
* A subflow has been closed. An error (copy of sk_err) could be set if an
* error has been detected for this subflow.
*
* MPTCP_EVENT_SUB_PRIORITY: token, family, loc_id, rem_id, saddr4 | saddr6,
* daddr4 | daddr6, sport, dport, backup, if_idx
* [, error]
* The priority of a subflow has changed. 'error' should not be set.
*
* MPTCP_EVENT_LISTENER_CREATED: family, sport, saddr4 | saddr6
* A new PM listener is created.
*
* MPTCP_EVENT_LISTENER_CLOSED: family, sport, saddr4 | saddr6
* A PM listener is closed.
*/
enum mptcp_event_type {
MPTCP_EVENT_UNSPEC = 0,
MPTCP_EVENT_CREATED = 1,
MPTCP_EVENT_ESTABLISHED = 2,
MPTCP_EVENT_CLOSED = 3,
MPTCP_EVENT_ANNOUNCED = 6,
MPTCP_EVENT_REMOVED = 7,
MPTCP_EVENT_SUB_ESTABLISHED = 10,
MPTCP_EVENT_SUB_CLOSED = 11,
MPTCP_EVENT_SUB_PRIORITY = 13,
MPTCP_EVENT_LISTENER_CREATED = 15,
MPTCP_EVENT_LISTENER_CLOSED = 16,
};
enum mptcp_event_attr {
MPTCP_ATTR_UNSPEC = 0,
MPTCP_ATTR_TOKEN, /* u32 */
MPTCP_ATTR_FAMILY, /* u16 */
MPTCP_ATTR_LOC_ID, /* u8 */
MPTCP_ATTR_REM_ID, /* u8 */
MPTCP_ATTR_SADDR4, /* be32 */
MPTCP_ATTR_SADDR6, /* struct in6_addr */
MPTCP_ATTR_DADDR4, /* be32 */
MPTCP_ATTR_DADDR6, /* struct in6_addr */
MPTCP_ATTR_SPORT, /* be16 */
MPTCP_ATTR_DPORT, /* be16 */
MPTCP_ATTR_BACKUP, /* u8 */
MPTCP_ATTR_ERROR, /* u8 */
MPTCP_ATTR_FLAGS, /* u16 */
MPTCP_ATTR_TIMEOUT, /* u32 */
MPTCP_ATTR_IF_IDX, /* s32 */
MPTCP_ATTR_RESET_REASON,/* u32 */
MPTCP_ATTR_RESET_FLAGS, /* u32 */
MPTCP_ATTR_SERVER_SIDE, /* u8 */
__MPTCP_ATTR_AFTER_LAST
};
#define MPTCP_ATTR_MAX (__MPTCP_ATTR_AFTER_LAST - 1)
/* MPTCP Reset reason codes, rfc8684 */
#define MPTCP_RST_EUNSPEC 0
#define MPTCP_RST_EMPTCP 1
......
/* 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_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
* 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_ENDPOINT_ADDR = 1,
__MPTCP_PM_ENDPOINT_MAX
};
#define MPTCP_PM_ENDPOINT_MAX (__MPTCP_PM_ENDPOINT_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)
#endif /* _UAPI_LINUX_MPTCP_PM_H */
......@@ -2,7 +2,8 @@
obj-$(CONFIG_MPTCP) += mptcp.o
mptcp-y := protocol.o subflow.o options.o token.o crypto.o ctrl.o pm.o diag.o \
mib.o pm_netlink.o sockopt.o pm_userspace.o fastopen.o sched.o
mib.o pm_netlink.o sockopt.o pm_userspace.o fastopen.o sched.o \
mptcp_pm_gen.o
obj-$(CONFIG_SYN_COOKIES) += syncookies.o
obj-$(CONFIG_INET_MPTCP_DIAG) += mptcp_diag.o
......
// 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 "mptcp_pm_gen.h"
#include <uapi/linux/mptcp_pm.h>
/* Common nested types */
const struct nla_policy mptcp_pm_address_nl_policy[MPTCP_PM_ADDR_ATTR_IF_IDX + 1] = {
[MPTCP_PM_ADDR_ATTR_FAMILY] = { .type = NLA_U16, },
[MPTCP_PM_ADDR_ATTR_ID] = { .type = NLA_U8, },
[MPTCP_PM_ADDR_ATTR_ADDR4] = { .type = NLA_U32, },
[MPTCP_PM_ADDR_ATTR_ADDR6] = 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, },
};
/* MPTCP_PM_CMD_ADD_ADDR - do */
const struct nla_policy mptcp_pm_add_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = {
[MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy),
};
/* MPTCP_PM_CMD_DEL_ADDR - do */
const struct nla_policy mptcp_pm_del_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = {
[MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy),
};
/* MPTCP_PM_CMD_GET_ADDR - do */
const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = {
[MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy),
};
/* MPTCP_PM_CMD_FLUSH_ADDRS - do */
const struct nla_policy mptcp_pm_flush_addrs_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1] = {
[MPTCP_PM_ENDPOINT_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy),
};
/* MPTCP_PM_CMD_SET_LIMITS - do */
const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1] = {
[MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, },
[MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, },
};
/* MPTCP_PM_CMD_GET_LIMITS - do */
const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1] = {
[MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, },
[MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, },
};
/* MPTCP_PM_CMD_SET_FLAGS - do */
const struct nla_policy mptcp_pm_set_flags_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = {
[MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy),
[MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, },
[MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy),
};
/* MPTCP_PM_CMD_ANNOUNCE - do */
const struct nla_policy mptcp_pm_announce_nl_policy[MPTCP_PM_ATTR_TOKEN + 1] = {
[MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy),
[MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, },
};
/* MPTCP_PM_CMD_REMOVE - do */
const struct nla_policy mptcp_pm_remove_nl_policy[MPTCP_PM_ATTR_LOC_ID + 1] = {
[MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, },
[MPTCP_PM_ATTR_LOC_ID] = { .type = NLA_U8, },
};
/* MPTCP_PM_CMD_SUBFLOW_CREATE - do */
const struct nla_policy mptcp_pm_subflow_create_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = {
[MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy),
[MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, },
[MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy),
};
/* MPTCP_PM_CMD_SUBFLOW_DESTROY - do */
const struct nla_policy mptcp_pm_subflow_destroy_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1] = {
[MPTCP_PM_ATTR_ADDR] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy),
[MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, },
[MPTCP_PM_ATTR_ADDR_REMOTE] = NLA_POLICY_NESTED(mptcp_pm_address_nl_policy),
};
/* Ops table for mptcp_pm */
const struct genl_ops mptcp_pm_nl_ops[11] = {
{
.cmd = MPTCP_PM_CMD_ADD_ADDR,
.validate = GENL_DONT_VALIDATE_STRICT,
.doit = mptcp_pm_nl_add_addr_doit,
.policy = mptcp_pm_add_addr_nl_policy,
.maxattr = MPTCP_PM_ENDPOINT_ADDR,
.flags = GENL_UNS_ADMIN_PERM,
},
{
.cmd = MPTCP_PM_CMD_DEL_ADDR,
.validate = GENL_DONT_VALIDATE_STRICT,
.doit = mptcp_pm_nl_del_addr_doit,
.policy = mptcp_pm_del_addr_nl_policy,
.maxattr = MPTCP_PM_ENDPOINT_ADDR,
.flags = GENL_UNS_ADMIN_PERM,
},
{
.cmd = MPTCP_PM_CMD_GET_ADDR,
.validate = GENL_DONT_VALIDATE_STRICT,
.doit = mptcp_pm_nl_get_addr_doit,
.dumpit = mptcp_pm_nl_get_addr_dumpit,
.policy = mptcp_pm_get_addr_nl_policy,
.maxattr = MPTCP_PM_ENDPOINT_ADDR,
.flags = GENL_UNS_ADMIN_PERM,
},
{
.cmd = MPTCP_PM_CMD_FLUSH_ADDRS,
.validate = GENL_DONT_VALIDATE_STRICT,
.doit = mptcp_pm_nl_flush_addrs_doit,
.policy = mptcp_pm_flush_addrs_nl_policy,
.maxattr = MPTCP_PM_ENDPOINT_ADDR,
.flags = GENL_UNS_ADMIN_PERM,
},
{
.cmd = MPTCP_PM_CMD_SET_LIMITS,
.validate = GENL_DONT_VALIDATE_STRICT,
.doit = mptcp_pm_nl_set_limits_doit,
.policy = mptcp_pm_set_limits_nl_policy,
.maxattr = MPTCP_PM_ATTR_SUBFLOWS,
.flags = GENL_UNS_ADMIN_PERM,
},
{
.cmd = MPTCP_PM_CMD_GET_LIMITS,
.validate = GENL_DONT_VALIDATE_STRICT,
.doit = mptcp_pm_nl_get_limits_doit,
.policy = mptcp_pm_get_limits_nl_policy,
.maxattr = MPTCP_PM_ATTR_SUBFLOWS,
},
{
.cmd = MPTCP_PM_CMD_SET_FLAGS,
.validate = GENL_DONT_VALIDATE_STRICT,
.doit = mptcp_pm_nl_set_flags_doit,
.policy = mptcp_pm_set_flags_nl_policy,
.maxattr = MPTCP_PM_ATTR_ADDR_REMOTE,
.flags = GENL_UNS_ADMIN_PERM,
},
{
.cmd = MPTCP_PM_CMD_ANNOUNCE,
.validate = GENL_DONT_VALIDATE_STRICT,
.doit = mptcp_pm_nl_announce_doit,
.policy = mptcp_pm_announce_nl_policy,
.maxattr = MPTCP_PM_ATTR_TOKEN,
.flags = GENL_UNS_ADMIN_PERM,
},
{
.cmd = MPTCP_PM_CMD_REMOVE,
.validate = GENL_DONT_VALIDATE_STRICT,
.doit = mptcp_pm_nl_remove_doit,
.policy = mptcp_pm_remove_nl_policy,
.maxattr = MPTCP_PM_ATTR_LOC_ID,
.flags = GENL_UNS_ADMIN_PERM,
},
{
.cmd = MPTCP_PM_CMD_SUBFLOW_CREATE,
.validate = GENL_DONT_VALIDATE_STRICT,
.doit = mptcp_pm_nl_subflow_create_doit,
.policy = mptcp_pm_subflow_create_nl_policy,
.maxattr = MPTCP_PM_ATTR_ADDR_REMOTE,
.flags = GENL_UNS_ADMIN_PERM,
},
{
.cmd = MPTCP_PM_CMD_SUBFLOW_DESTROY,
.validate = GENL_DONT_VALIDATE_STRICT,
.doit = mptcp_pm_nl_subflow_destroy_doit,
.policy = mptcp_pm_subflow_destroy_nl_policy,
.maxattr = MPTCP_PM_ATTR_ADDR_REMOTE,
.flags = GENL_UNS_ADMIN_PERM,
},
};
/* 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 <uapi/linux/mptcp_pm.h>
/* Common nested types */
extern const struct nla_policy mptcp_pm_address_nl_policy[MPTCP_PM_ADDR_ATTR_IF_IDX + 1];
extern const struct nla_policy mptcp_pm_add_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1];
extern const struct nla_policy mptcp_pm_del_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1];
extern const struct nla_policy mptcp_pm_get_addr_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1];
extern const struct nla_policy mptcp_pm_flush_addrs_nl_policy[MPTCP_PM_ENDPOINT_ADDR + 1];
extern const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1];
extern const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLOWS + 1];
extern const struct nla_policy mptcp_pm_set_flags_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1];
extern const struct nla_policy mptcp_pm_announce_nl_policy[MPTCP_PM_ATTR_TOKEN + 1];
extern const struct nla_policy mptcp_pm_remove_nl_policy[MPTCP_PM_ATTR_LOC_ID + 1];
extern const struct nla_policy mptcp_pm_subflow_create_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1];
extern const struct nla_policy mptcp_pm_subflow_destroy_nl_policy[MPTCP_PM_ATTR_ADDR_REMOTE + 1];
/* Ops table for mptcp_pm */
extern const struct genl_ops mptcp_pm_nl_ops[11];
int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info);
int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info);
int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info);
int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info);
int mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, struct genl_info *info);
int mptcp_pm_nl_get_limits_doit(struct sk_buff *skb, struct genl_info *info);
int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info);
int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info);
int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info);
int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb,
struct genl_info *info);
int mptcp_pm_nl_subflow_destroy_doit(struct sk_buff *skb,
struct genl_info *info);
#endif /* _LINUX_MPTCP_PM_GEN_H */
......@@ -1104,29 +1104,6 @@ static const struct genl_multicast_group mptcp_pm_mcgrps[] = {
},
};
static const struct nla_policy
mptcp_pm_addr_policy[MPTCP_PM_ADDR_ATTR_MAX + 1] = {
[MPTCP_PM_ADDR_ATTR_FAMILY] = { .type = NLA_U16, },
[MPTCP_PM_ADDR_ATTR_ID] = { .type = NLA_U8, },
[MPTCP_PM_ADDR_ATTR_ADDR4] = { .type = NLA_U32, },
[MPTCP_PM_ADDR_ATTR_ADDR6] =
NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)),
[MPTCP_PM_ADDR_ATTR_PORT] = { .type = NLA_U16 },
[MPTCP_PM_ADDR_ATTR_FLAGS] = { .type = NLA_U32 },
[MPTCP_PM_ADDR_ATTR_IF_IDX] = { .type = NLA_S32 },
};
static const struct nla_policy mptcp_pm_policy[MPTCP_PM_ATTR_MAX + 1] = {
[MPTCP_PM_ATTR_ADDR] =
NLA_POLICY_NESTED(mptcp_pm_addr_policy),
[MPTCP_PM_ATTR_RCV_ADD_ADDRS] = { .type = NLA_U32, },
[MPTCP_PM_ATTR_SUBFLOWS] = { .type = NLA_U32, },
[MPTCP_PM_ATTR_TOKEN] = { .type = NLA_U32, },
[MPTCP_PM_ATTR_LOC_ID] = { .type = NLA_U8, },
[MPTCP_PM_ATTR_ADDR_REMOTE] =
NLA_POLICY_NESTED(mptcp_pm_addr_policy),
};
void mptcp_pm_nl_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk)
{
struct mptcp_subflow_context *iter, *subflow = mptcp_subflow_ctx(ssk);
......@@ -1188,7 +1165,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_address_nl_policy, info->extack);
if (err)
return err;
......@@ -1303,9 +1280,9 @@ 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 nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR];
struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
struct mptcp_pm_addr_entry addr, *entry;
int ret;
......@@ -1484,9 +1461,9 @@ 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 nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR];
struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
struct mptcp_pm_addr_entry addr, *entry;
unsigned int addr_max;
......@@ -1619,7 +1596,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);
......@@ -1675,9 +1652,9 @@ 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 nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR];
struct pm_nl_pernet *pernet = genl_info_pm_nl(info);
struct mptcp_pm_addr_entry addr, *entry;
struct sk_buff *msg;
......@@ -1725,8 +1702,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;
......@@ -1783,8 +1760,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;
......@@ -1809,8 +1785,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;
......@@ -1919,7 +1894,7 @@ int mptcp_pm_nl_set_flags(struct net *net, struct mptcp_pm_addr_entry *addr, u8
return 0;
}
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 remote = { .addr = { .family = AF_UNSPEC }, };
struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, };
......@@ -2283,72 +2258,13 @@ 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,
.netnsok = true,
.module = THIS_MODULE,
.small_ops = mptcp_pm_ops,
.n_small_ops = ARRAY_SIZE(mptcp_pm_ops),
.ops = mptcp_pm_nl_ops,
.n_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),
......
......@@ -145,7 +145,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];
......@@ -208,7 +208,7 @@ int mptcp_nl_cmd_announce(struct sk_buff *skb, struct genl_info *info)
return err;
}
int mptcp_nl_cmd_remove(struct sk_buff *skb, struct genl_info *info)
int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info)
{
struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN];
struct nlattr *id = info->attrs[MPTCP_PM_ATTR_LOC_ID];
......@@ -270,7 +270,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];
......@@ -394,7 +394,7 @@ 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];
......
......@@ -13,6 +13,8 @@
#include <uapi/linux/mptcp.h>
#include <net/genetlink.h>
#include "mptcp_pm_gen.h"
#define MPTCP_SUPPORTED_VERSION 1
/* MPTCP option bits */
......@@ -877,10 +879,6 @@ void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk,
struct list_head *rm_list);
void mptcp_free_local_addr_list(struct mptcp_sock *msk);
int mptcp_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);
......
......@@ -410,10 +410,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.get_limit('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.get_limit('max-len'))
mem += ', }'
return mem
def attr_policy(self, cw):
......@@ -459,14 +462,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.get_limit('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.get_limit('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):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment