LCOV - code coverage report
Current view: top level - include/linux/sunrpc - clnt.h (source / functions) Hit Total Coverage
Test: Real Lines: 0 4 0.0 %
Date: 2020-10-17 15:46:16 Functions: 0 0 -
Legend: Neither, QEMU, Real, Both Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: GPL-2.0 */
       2                 :            : /*
       3                 :            :  *  linux/include/linux/sunrpc/clnt.h
       4                 :            :  *
       5                 :            :  *  Declarations for the high-level RPC client interface
       6                 :            :  *
       7                 :            :  *  Copyright (C) 1995, 1996, Olaf Kirch <okir@monad.swb.de>
       8                 :            :  */
       9                 :            : 
      10                 :            : #ifndef _LINUX_SUNRPC_CLNT_H
      11                 :            : #define _LINUX_SUNRPC_CLNT_H
      12                 :            : 
      13                 :            : #include <linux/types.h>
      14                 :            : #include <linux/socket.h>
      15                 :            : #include <linux/in.h>
      16                 :            : #include <linux/in6.h>
      17                 :            : 
      18                 :            : #include <linux/sunrpc/msg_prot.h>
      19                 :            : #include <linux/sunrpc/sched.h>
      20                 :            : #include <linux/sunrpc/xprt.h>
      21                 :            : #include <linux/sunrpc/auth.h>
      22                 :            : #include <linux/sunrpc/stats.h>
      23                 :            : #include <linux/sunrpc/xdr.h>
      24                 :            : #include <linux/sunrpc/timer.h>
      25                 :            : #include <linux/sunrpc/rpc_pipe_fs.h>
      26                 :            : #include <asm/signal.h>
      27                 :            : #include <linux/path.h>
      28                 :            : #include <net/ipv6.h>
      29                 :            : #include <linux/sunrpc/xprtmultipath.h>
      30                 :            : 
      31                 :            : struct rpc_inode;
      32                 :            : 
      33                 :            : /*
      34                 :            :  * The high-level client handle
      35                 :            :  */
      36                 :            : struct rpc_clnt {
      37                 :            :         atomic_t                cl_count;       /* Number of references */
      38                 :            :         unsigned int            cl_clid;        /* client id */
      39                 :            :         struct list_head        cl_clients;     /* Global list of clients */
      40                 :            :         struct list_head        cl_tasks;       /* List of tasks */
      41                 :            :         spinlock_t              cl_lock;        /* spinlock */
      42                 :            :         struct rpc_xprt __rcu * cl_xprt;        /* transport */
      43                 :            :         const struct rpc_procinfo *cl_procinfo; /* procedure info */
      44                 :            :         u32                     cl_prog,        /* RPC program number */
      45                 :            :                                 cl_vers,        /* RPC version number */
      46                 :            :                                 cl_maxproc;     /* max procedure number */
      47                 :            : 
      48                 :            :         struct rpc_auth *       cl_auth;        /* authenticator */
      49                 :            :         struct rpc_stat *       cl_stats;       /* per-program statistics */
      50                 :            :         struct rpc_iostats *    cl_metrics;     /* per-client statistics */
      51                 :            : 
      52                 :            :         unsigned int            cl_softrtry : 1,/* soft timeouts */
      53                 :            :                                 cl_softerr  : 1,/* Timeouts return errors */
      54                 :            :                                 cl_discrtry : 1,/* disconnect before retry */
      55                 :            :                                 cl_noretranstimeo: 1,/* No retransmit timeouts */
      56                 :            :                                 cl_autobind : 1,/* use getport() */
      57                 :            :                                 cl_chatty   : 1;/* be verbose */
      58                 :            : 
      59                 :            :         struct rpc_rtt *        cl_rtt;         /* RTO estimator data */
      60                 :            :         const struct rpc_timeout *cl_timeout;   /* Timeout strategy */
      61                 :            : 
      62                 :            :         atomic_t                cl_swapper;     /* swapfile count */
      63                 :            :         int                     cl_nodelen;     /* nodename length */
      64                 :            :         char                    cl_nodename[UNX_MAXNODENAME+1];
      65                 :            :         struct rpc_pipe_dir_head cl_pipedir_objects;
      66                 :            :         struct rpc_clnt *       cl_parent;      /* Points to parent of clones */
      67                 :            :         struct rpc_rtt          cl_rtt_default;
      68                 :            :         struct rpc_timeout      cl_timeout_default;
      69                 :            :         const struct rpc_program *cl_program;
      70                 :            :         const char *            cl_principal;   /* use for machine cred */
      71                 :            : #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
      72                 :            :         struct dentry           *cl_debugfs;    /* debugfs directory */
      73                 :            : #endif
      74                 :            :         struct rpc_xprt_iter    cl_xpi;
      75                 :            :         const struct cred       *cl_cred;
      76                 :            : };
      77                 :            : 
      78                 :            : /*
      79                 :            :  * General RPC program info
      80                 :            :  */
      81                 :            : #define RPC_MAXVERSION          4
      82                 :            : struct rpc_program {
      83                 :            :         const char *            name;           /* protocol name */
      84                 :            :         u32                     number;         /* program number */
      85                 :            :         unsigned int            nrvers;         /* number of versions */
      86                 :            :         const struct rpc_version **     version;        /* version array */
      87                 :            :         struct rpc_stat *       stats;          /* statistics */
      88                 :            :         const char *            pipe_dir_name;  /* path to rpc_pipefs dir */
      89                 :            : };
      90                 :            : 
      91                 :            : struct rpc_version {
      92                 :            :         u32                     number;         /* version number */
      93                 :            :         unsigned int            nrprocs;        /* number of procs */
      94                 :            :         const struct rpc_procinfo *procs;       /* procedure array */
      95                 :            :         unsigned int            *counts;        /* call counts */
      96                 :            : };
      97                 :            : 
      98                 :            : /*
      99                 :            :  * Procedure information
     100                 :            :  */
     101                 :            : struct rpc_procinfo {
     102                 :            :         u32                     p_proc;         /* RPC procedure number */
     103                 :            :         kxdreproc_t             p_encode;       /* XDR encode function */
     104                 :            :         kxdrdproc_t             p_decode;       /* XDR decode function */
     105                 :            :         unsigned int            p_arglen;       /* argument hdr length (u32) */
     106                 :            :         unsigned int            p_replen;       /* reply hdr length (u32) */
     107                 :            :         unsigned int            p_timer;        /* Which RTT timer to use */
     108                 :            :         u32                     p_statidx;      /* Which procedure to account */
     109                 :            :         const char *            p_name;         /* name of procedure */
     110                 :            : };
     111                 :            : 
     112                 :            : #ifdef __KERNEL__
     113                 :            : 
     114                 :            : struct rpc_create_args {
     115                 :            :         struct net              *net;
     116                 :            :         int                     protocol;
     117                 :            :         struct sockaddr         *address;
     118                 :            :         size_t                  addrsize;
     119                 :            :         struct sockaddr         *saddress;
     120                 :            :         const struct rpc_timeout *timeout;
     121                 :            :         const char              *servername;
     122                 :            :         const char              *nodename;
     123                 :            :         const struct rpc_program *program;
     124                 :            :         u32                     prognumber;     /* overrides program->number */
     125                 :            :         u32                     version;
     126                 :            :         rpc_authflavor_t        authflavor;
     127                 :            :         u32                     nconnect;
     128                 :            :         unsigned long           flags;
     129                 :            :         char                    *client_name;
     130                 :            :         struct svc_xprt         *bc_xprt;       /* NFSv4.1 backchannel */
     131                 :            :         const struct cred       *cred;
     132                 :            : };
     133                 :            : 
     134                 :            : struct rpc_add_xprt_test {
     135                 :            :         void (*add_xprt_test)(struct rpc_clnt *clnt,
     136                 :            :                 struct rpc_xprt *xprt,
     137                 :            :                 void *calldata);
     138                 :            :         void *data;
     139                 :            : };
     140                 :            : 
     141                 :            : /* Values for "flags" field */
     142                 :            : #define RPC_CLNT_CREATE_HARDRTRY        (1UL << 0)
     143                 :            : #define RPC_CLNT_CREATE_AUTOBIND        (1UL << 2)
     144                 :            : #define RPC_CLNT_CREATE_NONPRIVPORT     (1UL << 3)
     145                 :            : #define RPC_CLNT_CREATE_NOPING          (1UL << 4)
     146                 :            : #define RPC_CLNT_CREATE_DISCRTRY        (1UL << 5)
     147                 :            : #define RPC_CLNT_CREATE_QUIET           (1UL << 6)
     148                 :            : #define RPC_CLNT_CREATE_INFINITE_SLOTS  (1UL << 7)
     149                 :            : #define RPC_CLNT_CREATE_NO_IDLE_TIMEOUT (1UL << 8)
     150                 :            : #define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT      (1UL << 9)
     151                 :            : #define RPC_CLNT_CREATE_SOFTERR         (1UL << 10)
     152                 :            : 
     153                 :            : struct rpc_clnt *rpc_create(struct rpc_create_args *args);
     154                 :            : struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
     155                 :            :                                 const struct rpc_program *, u32);
     156                 :            : struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
     157                 :            : struct rpc_clnt *rpc_clone_client_set_auth(struct rpc_clnt *,
     158                 :            :                                 rpc_authflavor_t);
     159                 :            : int             rpc_switch_client_transport(struct rpc_clnt *,
     160                 :            :                                 struct xprt_create *,
     161                 :            :                                 const struct rpc_timeout *);
     162                 :            : 
     163                 :            : void            rpc_shutdown_client(struct rpc_clnt *);
     164                 :            : void            rpc_release_client(struct rpc_clnt *);
     165                 :            : void            rpc_task_release_transport(struct rpc_task *);
     166                 :            : void            rpc_task_release_client(struct rpc_task *);
     167                 :            : struct rpc_xprt *rpc_task_get_xprt(struct rpc_clnt *clnt,
     168                 :            :                 struct rpc_xprt *xprt);
     169                 :            : 
     170                 :            : int             rpcb_create_local(struct net *);
     171                 :            : void            rpcb_put_local(struct net *);
     172                 :            : int             rpcb_register(struct net *, u32, u32, int, unsigned short);
     173                 :            : int             rpcb_v4_register(struct net *net, const u32 program,
     174                 :            :                                  const u32 version,
     175                 :            :                                  const struct sockaddr *address,
     176                 :            :                                  const char *netid);
     177                 :            : void            rpcb_getport_async(struct rpc_task *);
     178                 :            : 
     179                 :            : void rpc_prepare_reply_pages(struct rpc_rqst *req, struct page **pages,
     180                 :            :                              unsigned int base, unsigned int len,
     181                 :            :                              unsigned int hdrsize);
     182                 :            : void            rpc_call_start(struct rpc_task *);
     183                 :            : int             rpc_call_async(struct rpc_clnt *clnt,
     184                 :            :                                const struct rpc_message *msg, int flags,
     185                 :            :                                const struct rpc_call_ops *tk_ops,
     186                 :            :                                void *calldata);
     187                 :            : int             rpc_call_sync(struct rpc_clnt *clnt,
     188                 :            :                               const struct rpc_message *msg, int flags);
     189                 :            : struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred,
     190                 :            :                                int flags);
     191                 :            : int             rpc_restart_call_prepare(struct rpc_task *);
     192                 :            : int             rpc_restart_call(struct rpc_task *);
     193                 :            : void            rpc_setbufsize(struct rpc_clnt *, unsigned int, unsigned int);
     194                 :            : struct net *    rpc_net_ns(struct rpc_clnt *);
     195                 :            : size_t          rpc_max_payload(struct rpc_clnt *);
     196                 :            : size_t          rpc_max_bc_payload(struct rpc_clnt *);
     197                 :            : unsigned int    rpc_num_bc_slots(struct rpc_clnt *);
     198                 :            : void            rpc_force_rebind(struct rpc_clnt *);
     199                 :            : size_t          rpc_peeraddr(struct rpc_clnt *, struct sockaddr *, size_t);
     200                 :            : const char      *rpc_peeraddr2str(struct rpc_clnt *, enum rpc_display_format_t);
     201                 :            : int             rpc_localaddr(struct rpc_clnt *, struct sockaddr *, size_t);
     202                 :            : 
     203                 :            : int             rpc_clnt_iterate_for_each_xprt(struct rpc_clnt *clnt,
     204                 :            :                         int (*fn)(struct rpc_clnt *, struct rpc_xprt *, void *),
     205                 :            :                         void *data);
     206                 :            : 
     207                 :            : int             rpc_clnt_test_and_add_xprt(struct rpc_clnt *clnt,
     208                 :            :                         struct rpc_xprt_switch *xps,
     209                 :            :                         struct rpc_xprt *xprt,
     210                 :            :                         void *dummy);
     211                 :            : int             rpc_clnt_add_xprt(struct rpc_clnt *, struct xprt_create *,
     212                 :            :                         int (*setup)(struct rpc_clnt *,
     213                 :            :                                 struct rpc_xprt_switch *,
     214                 :            :                                 struct rpc_xprt *,
     215                 :            :                                 void *),
     216                 :            :                         void *data);
     217                 :            : void            rpc_set_connect_timeout(struct rpc_clnt *clnt,
     218                 :            :                         unsigned long connect_timeout,
     219                 :            :                         unsigned long reconnect_timeout);
     220                 :            : 
     221                 :            : int             rpc_clnt_setup_test_and_add_xprt(struct rpc_clnt *,
     222                 :            :                         struct rpc_xprt_switch *,
     223                 :            :                         struct rpc_xprt *,
     224                 :            :                         void *);
     225                 :            : 
     226                 :            : const char *rpc_proc_name(const struct rpc_task *task);
     227                 :            : 
     228                 :            : void rpc_clnt_xprt_switch_put(struct rpc_clnt *);
     229                 :            : void rpc_clnt_xprt_switch_add_xprt(struct rpc_clnt *, struct rpc_xprt *);
     230                 :            : bool rpc_clnt_xprt_switch_has_addr(struct rpc_clnt *clnt,
     231                 :            :                         const struct sockaddr *sap);
     232                 :            : void rpc_cleanup_clids(void);
     233                 :            : 
     234                 :            : static inline int rpc_reply_expected(struct rpc_task *task)
     235                 :            : {
     236                 :          0 :         return (task->tk_msg.rpc_proc != NULL) &&
     237                 :          0 :                 (task->tk_msg.rpc_proc->p_decode != NULL);
     238                 :            : }
     239                 :            : 
     240                 :            : static inline void rpc_task_close_connection(struct rpc_task *task)
     241                 :            : {
     242                 :          0 :         if (task->tk_xprt)
     243                 :          0 :                 xprt_force_disconnect(task->tk_xprt);
     244                 :            : }
     245                 :            : #endif /* __KERNEL__ */
     246                 :            : #endif /* _LINUX_SUNRPC_CLNT_H */
    

Generated by: LCOV version 1.14