convert write_threads, write_version and write_ports to netlink commands
Subsystems (5)
v9 cover convert write_threads, write_version and write_ports to netlink commands
Introduce write_threads, write_version and write_ports netlink commands similar to the ones available through the procfs.
Changes since v8:
- introduce scope parameter to write_thread command
- add the capability to specity multiple threads in write_thread for future usage
- fix comments
Changes since v7:
- add gracetime and leasetime to threads-{set,get} command
- rely on nla_nest_start instead of nla_nest_start_noflag
Changes since v6:
- add the capability to pass sockaddr from userspace through listener-set command
- rebase on top of nfsd-next
Changes since v5:
- for write_ports and write_version commands, userspace is expected to provide a NFS listeners/supported versions list it want to enable (all the other ports/versions will be disabled).
- fix comments
- rebase on top of nfsd-next
Changes since v4:
- rebase on top of nfsd-next tree
Changes since v3:
- drop write_maxconn and write_maxblksize for the moment
- add write_version and write_ports commands
Changes since v2:
- use u32 to store nthreads in nfsd_nl_threads_set_doit
- rename server-attr in control-plane in nfsd.yaml specs
Changes since v1:
- remove write_v4_end_grace command
- add write_maxblksize and write_maxconn netlink commands
This patch can be tested with user-space tool reported below:
https://patchwork.kernel.org/project/linux-nfs/cover/[email protected]/
Jeff Layton (3):
NFSD: move nfsd_mutex handling into nfsd_svc callers
NFSD: allow callers to pass in scope string to nfsd_svc
SUNRPC: add a new svc_find_listener helper
Lorenzo Bianconi (4):
NFSD: convert write_threads to netlink command
NFSD: add write_version to netlink command
SUNRPC: introduce svc_xprt_create_from_sa utility routine
NFSD: add listener-{set,get} netlink command
Documentation/netlink/specs/nfsd.yaml | 110 ++++++ fs/nfsd/netlink.c | 66 ++++ fs/nfsd/netlink.h | 10 + fs/nfsd/netns.h | 1 + fs/nfsd/nfsctl.c | 517 +++++++++++++++++++++++++- fs/nfsd/nfsd.h | 2 +- fs/nfsd/nfssvc.c | 11 +- include/linux/sunrpc/svc_xprt.h | 5 + include/uapi/linux/nfsd_netlink.h | 47 +++ net/sunrpc/svc_xprt.c | 167 ++++++--- 10 files changed, 870 insertions(+), 66 deletions(-)
Signature · 1 line
2.44.0
PATCH v9 1/7 NFSD: move nfsd_mutex handling into nfsd_svc callers
From: Jeff Layton <[email protected]>
Currently nfsd_svc holds the nfsd_mutex over the whole function. For some of the later netlink patches though, we want to do some other things to the server before starting it. Move the mutex handling into the callers.
--- fs/nfsd/nfsctl.c | 2 ++ fs/nfsd/nfssvc.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-)
fs/nfsd/nfsctl.c +2 -0
@@ -404,7 +404,9 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)if (newthreads <0 )return -EINVAL ;trace_nfsd_ctl_threads (net, newthreads); +mutex_lock (&nfsd_mutex); rv =nfsd_svc (newthreads, net, file->f_cred); +mutex_unlock (&nfsd_mutex);if (rv <0 )return rv; }else
fs/nfsd/nfssvc.c +2 -2
@@ -775,7 +775,8 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred)struct nfsd_net *nn =net_generic (net, nfsd_net_id);struct svc_serv *serv; -mutex_lock (&nfsd_mutex); +lockdep_assert_held (&nfsd_mutex); +dprintk ("nfsd: creating service\n" ); nrservs =max (nrservs,0 );
@@ -804,7 +805,6 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred)if (serv->sv_nrthreads ==0 )nfsd_destroy_serv (net); out: -mutex_unlock (&nfsd_mutex);return error; }
Signature · 1 line
2.44.0
PATCH v9 2/7 NFSD: allow callers to pass in scope string to nfsd_svc
In reply to Lorenzo BianconiFrom: Jeff Layton <[email protected]>
Currently admins set this by using unshare to create a new uts namespace, and then resetting the hostname. With the new netlink interface we can just pass this in directly. Prepare nfsd_svc for this change.
--- fs/nfsd/nfsctl.c | 2 +- fs/nfsd/nfsd.h | 2 +- fs/nfsd/nfssvc.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
fs/nfsd/nfsctl.c +1 -1
@@ -405,7 +405,7 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size)return -EINVAL ;trace_nfsd_ctl_threads (net, newthreads);mutex_lock (&nfsd_mutex); - rv =nfsd_svc (newthreads, net, file->f_cred); + rv =nfsd_svc (newthreads, net, file->f_cred,NULL );mutex_unlock (&nfsd_mutex);if (rv <0 )return rv;
fs/nfsd/nfsd.h +1 -1
@@ -103,7 +103,7 @@ bool nfssvc_encode_voidres(struct svc_rqst *rqstp,/* * Function prototypes. */ -int nfsd_svc (int nrservs,struct net *net,const struct cred *cred); +int nfsd_svc (int nrservs,struct net *net,const struct cred *cred,const char *scope);int nfsd_dispatch (struct svc_rqst *rqstp);int nfsd_nrthreads (struct net *);
fs/nfsd/nfssvc.c +2 -2
@@ -769,7 +769,7 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net)* this is the first time nrservs is nonzero. */ int -nfsd_svc (int nrservs,struct net *net,const struct cred *cred) +nfsd_svc (int nrservs,struct net *net,const struct cred *cred,const char *scope) {int error;struct nfsd_net *nn =net_generic (net, nfsd_net_id);
@@ -786,7 +786,7 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred)if (nrservs ==0 && nn->nfsd_serv ==NULL ) goto out; -strscpy (nn->nfsd_name,utsname ()->nodename, +strscpy (nn->nfsd_name, scope ? scope :utsname ()->nodename,sizeof (nn->nfsd_name)); error =nfsd_create_serv (net);
Signature · 1 line
2.44.0
PATCH v9 3/7 NFSD: convert write_threads to netlink command
In reply to Lorenzo BianconiIntroduce write_threads netlink command similar to the one available through the procfs.
--- Documentation/netlink/specs/nfsd.yaml | 39 +++++++ fs/nfsd/netlink.c | 20 ++++ fs/nfsd/netlink.h | 2 + fs/nfsd/nfsctl.c | 143 ++++++++++++++++++++++++++ include/uapi/linux/nfsd_netlink.h | 12 +++ 5 files changed, 216 insertions(+)
Documentation/netlink/specs/nfsd.yaml +39 -0
@@ -62,6 +62,22 @@ attribute-sets: name: compound-ops type: u32 multi-attr: true + - + name: server + attributes: + - + name: threads + type: u32 + multi-attr: true + - + name: gracetime + type: u32 + - + name: leasetime + type: u32 + - + name: scope + type: string operations: list:
@@ -87,3 +103,26 @@ operations: - sport - dport - compound-ops + - + name: threads-set + doc: set the number of running threads + attribute-set: server + flags: [ admin-perm ] + do: + request: + attributes: + - threads + - gracetime + - leasetime + - scope + - + name: threads-get + doc: get the number of running threads + attribute-set: server + do: + reply: + attributes: + - threads + - gracetime + - leasetime + - scope
fs/nfsd/netlink.c +20 -0
@@ -10,6 +10,14 @@#include <uapi/linux/nfsd_netlink.h> +/* NFSD_CMD_THREADS_SET - do */ +static const struct nla_policy nfsd_threads_set_nl_policy[NFSD_A_SERVER_SCOPE +1 ] = { + [NFSD_A_SERVER_THREADS ] = { .type =NLA_U32 , }, + [NFSD_A_SERVER_GRACETIME ] = { .type =NLA_U32 , }, + [NFSD_A_SERVER_LEASETIME ] = { .type =NLA_U32 , }, + [NFSD_A_SERVER_SCOPE ] = { .type =NLA_NUL_STRING , }, +}; +/* Ops table for nfsd */ static const struct genl_split_ops nfsd_nl_ops[] = { {
@@ -19,6 +27,18 @@ static const struct genl_split_ops nfsd_nl_ops[] = { .done = nfsd_nl_rpc_status_get_done, .flags = GENL_CMD_CAP_DUMP, }, + { + .cmd = NFSD_CMD_THREADS_SET, + .doit = nfsd_nl_threads_set_doit, + .policy = nfsd_threads_set_nl_policy, + .maxattr = NFSD_A_SERVER_SCOPE, + .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, + }, + { + .cmd = NFSD_CMD_THREADS_GET, + .doit = nfsd_nl_threads_get_doit, + .flags = GENL_CMD_CAP_DO, + }, }; struct genl_family nfsd_nl_family __ro_after_init = {
fs/nfsd/netlink.h +2 -0
@@ -16,6 +16,8 @@ int nfsd_nl_rpc_status_get_done(struct netlink_callback *cb);int nfsd_nl_rpc_status_get_dumpit (struct sk_buff *skb,struct netlink_callback *cb); +int nfsd_nl_threads_set_doit (struct sk_buff *skb,struct genl_info *info); +int nfsd_nl_threads_get_doit (struct sk_buff *skb,struct genl_info *info);extern struct genl_family nfsd_nl_family;
fs/nfsd/nfsctl.c +143 -0
155 lines not on this page · raw message
include/uapi/linux/nfsd_netlink.h +12 -0
@@ -29,8 +29,20 @@ enum {NFSD_A_RPC_STATUS_MAX = (__NFSD_A_RPC_STATUS_MAX -1 ) }; +enum { +NFSD_A_SERVER_THREADS =1 , +NFSD_A_SERVER_GRACETIME , +NFSD_A_SERVER_LEASETIME , +NFSD_A_SERVER_SCOPE , + + __NFSD_A_SERVER_MAX, +NFSD_A_SERVER_MAX = (__NFSD_A_SERVER_MAX -1 ) +}; +enum {NFSD_CMD_RPC_STATUS_GET =1 , +NFSD_CMD_THREADS_SET , +NFSD_CMD_THREADS_GET , __NFSD_CMD_MAX,NFSD_CMD_MAX = (__NFSD_CMD_MAX -1 )
Signature · 1 line
2.44.0
PATCH v9 4/7 NFSD: add write_version to netlink command
In reply to Lorenzo BianconiIntroduce write_version netlink command through a "declarative" interface. This patch introduces a change in behavior since for version-set userspace is expected to provide a NFS major/minor version list it wants to enable while all the other ones will be disabled. (procfs write_version command implements imperative interface where the admin writes +3/-3 to enable/disable a single version.
--- Documentation/netlink/specs/nfsd.yaml | 37 +++++++ fs/nfsd/netlink.c | 24 +++++ fs/nfsd/netlink.h | 5 + fs/nfsd/netns.h | 1 + fs/nfsd/nfsctl.c | 150 ++++++++++++++++++++++++++ fs/nfsd/nfssvc.c | 3 +- include/uapi/linux/nfsd_netlink.h | 18 ++++ 7 files changed, 236 insertions(+), 2 deletions(-)
Documentation/netlink/specs/nfsd.yaml +37 -0
@@ -78,6 +78,26 @@ attribute-sets: - name: scope type: string + - + name: version + attributes: + - + name: major + type: u32 + - + name: minor + type: u32 + - + name: enabled + type: flag + - + name: server-proto + attributes: + - + name: version + type: nest + nested-attributes: version + multi-attr: true operations: list:
@@ -126,3 +146,20 @@ operations: - gracetime - leasetime - scope + - + name: version-set + doc: set nfs enabled versions + attribute-set: server-proto + flags: [ admin-perm ] + do: + request: + attributes: + - version + - + name: version-get + doc: get nfs enabled versions + attribute-set: server-proto + do: + reply: + attributes: + - version
fs/nfsd/netlink.c +24 -0
@@ -10,6 +10,13 @@#include <uapi/linux/nfsd_netlink.h> +/* Common nested types */ +const struct nla_policy nfsd_version_nl_policy[NFSD_A_VERSION_ENABLED +1 ] = { + [NFSD_A_VERSION_MAJOR ] = { .type =NLA_U32 , }, + [NFSD_A_VERSION_MINOR ] = { .type =NLA_U32 , }, + [NFSD_A_VERSION_ENABLED ] = { .type =NLA_FLAG , }, +}; +/* NFSD_CMD_THREADS_SET - do */ static const struct nla_policy nfsd_threads_set_nl_policy[NFSD_A_SERVER_SCOPE +1 ] = { [NFSD_A_SERVER_THREADS ] = { .type =NLA_U32 , },
@@ -18,6 +25,11 @@ static const struct nla_policy nfsd_threads_set_nl_policy[NFSD_A_SERVER_SCOPE + [NFSD_A_SERVER_SCOPE] = { .type = NLA_NUL_STRING, }, }; +/* NFSD_CMD_VERSION_SET - do */ +static const struct nla_policy nfsd_version_set_nl_policy[NFSD_A_SERVER_PROTO_VERSION +1 ] = { + [NFSD_A_SERVER_PROTO_VERSION ] =NLA_POLICY_NESTED (nfsd_version_nl_policy), +}; +/* Ops table for nfsd */ static const struct genl_split_ops nfsd_nl_ops[] = { {
@@ -39,6 +51,18 @@ static const struct genl_split_ops nfsd_nl_ops[] = { .doit = nfsd_nl_threads_get_doit, .flags = GENL_CMD_CAP_DO, }, + { + .cmd = NFSD_CMD_VERSION_SET, + .doit = nfsd_nl_version_set_doit, + .policy = nfsd_version_set_nl_policy, + .maxattr = NFSD_A_SERVER_PROTO_VERSION, + .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, + }, + { + .cmd = NFSD_CMD_VERSION_GET, + .doit = nfsd_nl_version_get_doit, + .flags = GENL_CMD_CAP_DO, + }, }; struct genl_family nfsd_nl_family __ro_after_init = {
fs/nfsd/netlink.h +5 -0
@@ -11,6 +11,9 @@#include <uapi/linux/nfsd_netlink.h> +/* Common nested types */ +extern const struct nla_policy nfsd_version_nl_policy[NFSD_A_VERSION_ENABLED +1 ]; +int nfsd_nl_rpc_status_get_start (struct netlink_callback *cb);int nfsd_nl_rpc_status_get_done (struct netlink_callback *cb);
@@ -18,6 +21,8 @@ int nfsd_nl_rpc_status_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);int nfsd_nl_threads_set_doit (struct sk_buff *skb,struct genl_info *info);int nfsd_nl_threads_get_doit (struct sk_buff *skb,struct genl_info *info); +int nfsd_nl_version_set_doit (struct sk_buff *skb,struct genl_info *info); +int nfsd_nl_version_get_doit (struct sk_buff *skb,struct genl_info *info);extern struct genl_family nfsd_nl_family;
fs/nfsd/netns.h +1 -0
@@ -218,6 +218,7 @@ struct nfsd_net {/* Simple check to find out if a given net was properly initialized */ #define nfsd_netns_ready (nn) ((nn)->sessionid_hashtbl) +extern bool nfsd_support_version (int vers);extern void nfsd_netns_free_versions (struct nfsd_net *nn);extern unsigned int nfsd_net_id;
fs/nfsd/nfsctl.c +150 -0
156 lines not on this page · raw message
fs/nfsd/nfssvc.c +1 -2
@@ -133,8 +133,7 @@ struct svc_program nfsd_program = { .pg_rpcbind_set = nfsd_rpcbind_set, }; -static bool -nfsd_support_version (int vers) +bool nfsd_support_version (int vers) {if (vers >=NFSD_MINVERS && vers <NFSD_NRVERS )return nfsd_version[vers] !=NULL ;
include/uapi/linux/nfsd_netlink.h +18 -0
@@ -39,10 +39,28 @@ enum {NFSD_A_SERVER_MAX = (__NFSD_A_SERVER_MAX -1 ) }; +enum { +NFSD_A_VERSION_MAJOR =1 , +NFSD_A_VERSION_MINOR , +NFSD_A_VERSION_ENABLED , + + __NFSD_A_VERSION_MAX, +NFSD_A_VERSION_MAX = (__NFSD_A_VERSION_MAX -1 ) +}; + +enum { +NFSD_A_SERVER_PROTO_VERSION =1 , + + __NFSD_A_SERVER_PROTO_MAX, +NFSD_A_SERVER_PROTO_MAX = (__NFSD_A_SERVER_PROTO_MAX -1 ) +}; +enum {NFSD_CMD_RPC_STATUS_GET =1 ,NFSD_CMD_THREADS_SET ,NFSD_CMD_THREADS_GET , +NFSD_CMD_VERSION_SET , +NFSD_CMD_VERSION_GET , __NFSD_CMD_MAX,NFSD_CMD_MAX = (__NFSD_CMD_MAX -1 )
Signature · 1 line
2.44.0
PATCH v9 5/7 SUNRPC: introduce svc_xprt_create_from_sa utility routine
In reply to Lorenzo BianconiAdd svc_xprt_create_from_sa utility routine and refactor svc_xprt_create() codebase in order to introduce the capability to create a svc port from socket address.
--- include/linux/sunrpc/svc_xprt.h | 3 + net/sunrpc/svc_xprt.c | 133 ++++++++++++++++++-------------- 2 files changed, 78 insertions(+), 58 deletions(-)
include/linux/sunrpc/svc_xprt.h +3 -0
@@ -135,6 +135,9 @@ int svc_reg_xprt_class(struct svc_xprt_class *);void svc_unreg_xprt_class (struct svc_xprt_class *);void svc_xprt_init (struct net *,struct svc_xprt_class *,struct svc_xprt *,struct svc_serv *); +int svc_xprt_create_from_sa (struct svc_serv *serv,const char *xprt_name, +struct net *net,struct sockaddr *sap, +int flags,const struct cred *cred); int svc_xprt_create(struct svc_serv *serv, const char *xprt_name, struct net *net, const int family, const unsigned short port, int flags,
net/sunrpc/svc_xprt.c +75 -58
172 lines not on this page · raw message
Signature · 1 line
2.44.0
PATCH v9 6/7 SUNRPC: add a new svc_find_listener helper
In reply to Lorenzo BianconiFrom: Jeff Layton <[email protected]>
svc_find_listener will return the transport instance pointer for the endpoint accepting connections/peer traffic from the specified transport class, and matching sockaddr.
--- include/linux/sunrpc/svc_xprt.h | 2 ++ net/sunrpc/svc_xprt.c | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
include/linux/sunrpc/svc_xprt.h +2 -0
@@ -150,6 +150,8 @@ void svc_xprt_copy_addrs(struct svc_rqst *rqstp, struct svc_xprt *xprt);void svc_xprt_close (struct svc_xprt *xprt);int svc_port_is_privileged (struct sockaddr *sin);int svc_print_xprts (char *buf,int maxlen); +struct svc_xprt *svc_find_listener (struct svc_serv *serv,const char *xcl_name, +struct net *net,const struct sockaddr *sa);struct svc_xprt *svc_find_xprt (struct svc_serv *serv,const char *xcl_name,struct net *net,const sa_family_t af,const unsigned short port);
net/sunrpc/svc_xprt.c +34 -0
@@ -1276,6 +1276,40 @@ static struct svc_deferred_req *svc_deferred_dequeue(struct svc_xprt *xprt)return dr; } +/** +* svc_find_listener - find an RPC transport instance +* @serv: pointer to svc_serv to search +* @xcl_name: C string containing transport's class name +* @net: owner net pointer +* @sa: sockaddr containing address +* +* Return the transport instance pointer for the endpoint accepting +* connections/peer traffic from the specified transport class, +* and matching sockaddr. +*/ +struct svc_xprt *svc_find_listener (struct svc_serv *serv,const char *xcl_name, +struct net *net,const struct sockaddr *sa) +{ +struct svc_xprt *xprt; +struct svc_xprt *found =NULL ; + +spin_lock_bh (&serv->sv_lock); +list_for_each_entry (xprt, &serv->sv_permsocks, xpt_list) { +if (xprt->xpt_net != net) +continue ; +if (strcmp (xprt->xpt_class->xcl_name, xcl_name)) +continue ; +if (!rpc_cmp_addr_port (sa, (struct sockaddr *)&xprt->xpt_local)) +continue ; + found = xprt; +svc_xprt_get (xprt); +break ; + } +spin_unlock_bh (&serv->sv_lock); +return found; +} +EXPORT_SYMBOL_GPL (svc_find_listener); +/** * svc_find_xprt - find an RPC transport instance * @serv: pointer to svc_serv to search
Signature · 1 line
2.44.0
PATCH v9 7/7 NFSD: add listener-{set,get} netlink command
In reply to Lorenzo BianconiIntroduce write_ports netlink command. For listener-set, userspace is expected to provide a NFS listeners list it wants enabled. All other sockets will be closed.
--- Documentation/netlink/specs/nfsd.yaml | 34 ++++ fs/nfsd/netlink.c | 22 +++ fs/nfsd/netlink.h | 3 + fs/nfsd/nfsctl.c | 220 ++++++++++++++++++++++++++ include/uapi/linux/nfsd_netlink.h | 17 ++ 5 files changed, 296 insertions(+)
Documentation/netlink/specs/nfsd.yaml +34 -0
@@ -98,6 +98,23 @@ attribute-sets: type: nest nested-attributes: version multi-attr: true + - + name: sock + attributes: + - + name: addr + type: binary + - + name: transport-name + type: string + - + name: server-sock + attributes: + - + name: addr + type: nest + nested-attributes: sock + multi-attr: true operations: list:
@@ -163,3 +180,20 @@ operations: reply: attributes: - version + - + name: listener-set + doc: set nfs running sockets + attribute-set: server-sock + flags: [ admin-perm ] + do: + request: + attributes: + - addr + - + name: listener-get + doc: get nfs running listeners + attribute-set: server-sock + do: + reply: + attributes: + - addr
fs/nfsd/netlink.c +22 -0
@@ -11,6 +11,11 @@#include <uapi/linux/nfsd_netlink.h> /* Common nested types */ +const struct nla_policy nfsd_sock_nl_policy[NFSD_A_SOCK_TRANSPORT_NAME +1 ] = { + [NFSD_A_SOCK_ADDR ] = { .type =NLA_BINARY , }, + [NFSD_A_SOCK_TRANSPORT_NAME ] = { .type =NLA_NUL_STRING , }, +}; +const struct nla_policy nfsd_version_nl_policy[NFSD_A_VERSION_ENABLED +1 ] = { [NFSD_A_VERSION_MAJOR ] = { .type =NLA_U32 , }, [NFSD_A_VERSION_MINOR ] = { .type =NLA_U32 , },
@@ -30,6 +35,11 @@ static const struct nla_policy nfsd_version_set_nl_policy[NFSD_A_SERVER_PROTO_VE [NFSD_A_SERVER_PROTO_VERSION] = NLA_POLICY_NESTED(nfsd_version_nl_policy), }; +/* NFSD_CMD_LISTENER_SET - do */ +static const struct nla_policy nfsd_listener_set_nl_policy[NFSD_A_SERVER_SOCK_ADDR +1 ] = { + [NFSD_A_SERVER_SOCK_ADDR ] =NLA_POLICY_NESTED (nfsd_sock_nl_policy), +}; +/* Ops table for nfsd */ static const struct genl_split_ops nfsd_nl_ops[] = { {
@@ -63,6 +73,18 @@ static const struct genl_split_ops nfsd_nl_ops[] = { .doit = nfsd_nl_version_get_doit, .flags = GENL_CMD_CAP_DO, }, + { + .cmd = NFSD_CMD_LISTENER_SET, + .doit = nfsd_nl_listener_set_doit, + .policy = nfsd_listener_set_nl_policy, + .maxattr = NFSD_A_SERVER_SOCK_ADDR, + .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, + }, + { + .cmd = NFSD_CMD_LISTENER_GET, + .doit = nfsd_nl_listener_get_doit, + .flags = GENL_CMD_CAP_DO, + }, }; struct genl_family nfsd_nl_family __ro_after_init = {
fs/nfsd/netlink.h +3 -0
@@ -12,6 +12,7 @@#include <uapi/linux/nfsd_netlink.h> /* Common nested types */ +extern const struct nla_policy nfsd_sock_nl_policy[NFSD_A_SOCK_TRANSPORT_NAME +1 ];extern const struct nla_policy nfsd_version_nl_policy[NFSD_A_VERSION_ENABLED +1 ];int nfsd_nl_rpc_status_get_start (struct netlink_callback *cb);
@@ -23,6 +24,8 @@ int nfsd_nl_threads_set_doit(struct sk_buff *skb, struct genl_info *info);int nfsd_nl_threads_get_doit (struct sk_buff *skb,struct genl_info *info);int nfsd_nl_version_set_doit (struct sk_buff *skb,struct genl_info *info);int nfsd_nl_version_get_doit (struct sk_buff *skb,struct genl_info *info); +int nfsd_nl_listener_set_doit (struct sk_buff *skb,struct genl_info *info); +int nfsd_nl_listener_get_doit (struct sk_buff *skb,struct genl_info *info);extern struct genl_family nfsd_nl_family;
fs/nfsd/nfsctl.c +220 -0
226 lines not on this page · raw message
include/uapi/linux/nfsd_netlink.h +17 -0
@@ -55,12 +55,29 @@ enum {NFSD_A_SERVER_PROTO_MAX = (__NFSD_A_SERVER_PROTO_MAX -1 ) }; +enum { +NFSD_A_SOCK_ADDR =1 , +NFSD_A_SOCK_TRANSPORT_NAME , + + __NFSD_A_SOCK_MAX, +NFSD_A_SOCK_MAX = (__NFSD_A_SOCK_MAX -1 ) +}; + +enum { +NFSD_A_SERVER_SOCK_ADDR =1 , + + __NFSD_A_SERVER_SOCK_MAX, +NFSD_A_SERVER_SOCK_MAX = (__NFSD_A_SERVER_SOCK_MAX -1 ) +}; +enum {NFSD_CMD_RPC_STATUS_GET =1 ,NFSD_CMD_THREADS_SET ,NFSD_CMD_THREADS_GET ,NFSD_CMD_VERSION_SET ,NFSD_CMD_VERSION_GET , +NFSD_CMD_LISTENER_SET , +NFSD_CMD_LISTENER_GET , __NFSD_CMD_MAX,NFSD_CMD_MAX = (__NFSD_CMD_MAX -1 )
Signature · 1 line
2.44.0
Chuck Lever
AppliedQuoted 47 lines · Lorenzo Bianconi
Introduce
write_threads,write_versionandwrite_portsnetlink commands similar to the ones available through the procfs.Changes since v8:
- introduce scope parameter towrite_threadcommand
- add the capability to specity multiple threads inwrite_threadfor future usage
- fix comments
Changes since v7:
- add gracetime and leasetime to threads-{set,get} command
- rely onnla_nest_startinstead ofnla_nest_start_noflag
Changes since v6:
- add the capability to pass sockaddr from userspace through listener-set command
- rebase on top of nfsd-next
Changes since v5:
- forwrite_portsandwrite_versioncommands, userspace is expected to provide a NFS listeners/supported versions list it want to enable (all the other ports/versions will be disabled).
- fix comments
- rebase on top of nfsd-next
Changes since v4:
- rebase on top of nfsd-next tree
Changes since v3:
- dropwrite_maxconnandwrite_maxblksizefor the moment
- addwrite_versionandwrite_portscommands
Changes since v2:
- use u32 to store nthreads innfsd_nl_threads_set_doit
- rename server-attr in control-plane innfsd.yamlspecs
Changes since v1:
- removewrite_v4_end_gracecommand
- addwrite_maxblksizeandwrite_maxconnnetlink commandsThis patch can be tested with user-space tool reported below:
https://patchwork.kernel.org/project/linux-nfs/cover/[email protected]/Jeff Layton (3):
NFSD: movenfsd_mutexhandling intonfsd_svccallers
NFSD: allow callers to pass in scope string tonfsd_svc
SUNRPC: add a newsvc_find_listenerhelperLorenzo Bianconi (4):
NFSD: convertwrite_threadsto netlink command
NFSD: addwrite_versionto netlink command
SUNRPC: introducesvc_xprt_create_from_sautility routine
NFSD: add listener-{set,get} netlink command
Quoted 15 lines
Documentation/netlink/specs/nfsd.yaml | 110 ++++++ fs/nfsd/netlink.c | 66 ++++ fs/nfsd/netlink.h | 10 + fs/nfsd/netns.h | 1 + fs/nfsd/nfsctl.c | 517 +++++++++++++++++++++++++- fs/nfsd/nfsd.h | 2 +- fs/nfsd/nfssvc.c | 11 +- include/linux/sunrpc/svc_xprt.h | 5 + include/uapi/linux/nfsd_netlink.h | 47 +++ net/sunrpc/svc_xprt.c | 167 ++++++--- 10 files changed, 870 insertions(+), 66 deletions(-)Signature · 1 line
2.44.0
Applied to nfsd-next (for v6.10) with many thanks!
Signature · 1 line
Chuck Lever