Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 82484
b: refs/heads/master
c: dc9a16e
h: refs/heads/master
v: v3
  • Loading branch information
Tom Tucker authored and J. Bruce Fields committed Feb 1, 2008
1 parent d2933ae commit c4e3f3a
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 260c1d1298f6703d38fdccd3dd5a310766327340
refs/heads/master: dc9a16e49dbba3dd042e6aec5d9a7929e099a89b
1 change: 1 addition & 0 deletions trunk/include/linux/sunrpc/svc_xprt.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ void svc_xprt_copy_addrs(struct svc_rqst *rqstp, struct svc_xprt *xprt);
void svc_close_xprt(struct svc_xprt *xprt);
void svc_delete_xprt(struct svc_xprt *xprt);
int svc_port_is_privileged(struct sockaddr *sin);
int svc_print_xprts(char *buf, int maxlen);

static inline void svc_xprt_get(struct svc_xprt *xprt)
{
Expand Down
28 changes: 28 additions & 0 deletions trunk/net/sunrpc/svc_xprt.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,34 @@ void svc_unreg_xprt_class(struct svc_xprt_class *xcl)
}
EXPORT_SYMBOL_GPL(svc_unreg_xprt_class);

/*
* Format the transport list for printing
*/
int svc_print_xprts(char *buf, int maxlen)
{
struct list_head *le;
char tmpstr[80];
int len = 0;
buf[0] = '\0';

spin_lock(&svc_xprt_class_lock);
list_for_each(le, &svc_xprt_class_list) {
int slen;
struct svc_xprt_class *xcl =
list_entry(le, struct svc_xprt_class, xcl_list);

sprintf(tmpstr, "%s %d\n", xcl->xcl_name, xcl->xcl_max_payload);
slen = strlen(tmpstr);
if (len + slen > maxlen)
break;
len += slen;
strcat(buf, tmpstr);
}
spin_unlock(&svc_xprt_class_lock);

return len;
}

static void svc_xprt_free(struct kref *kref)
{
struct svc_xprt *xprt =
Expand Down
31 changes: 31 additions & 0 deletions trunk/net/sunrpc/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/sunrpc/types.h>
#include <linux/sunrpc/sched.h>
#include <linux/sunrpc/stats.h>
#include <linux/sunrpc/svc_xprt.h>

/*
* Declare the debug flags here
Expand Down Expand Up @@ -55,6 +56,30 @@ rpc_unregister_sysctl(void)
}
}

static int proc_do_xprt(ctl_table *table, int write, struct file *file,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
char tmpbuf[256];
int len;
if ((*ppos && !write) || !*lenp) {
*lenp = 0;
return 0;
}
if (write)
return -EINVAL;
else {
len = svc_print_xprts(tmpbuf, sizeof(tmpbuf));
if (!access_ok(VERIFY_WRITE, buffer, len))
return -EFAULT;

if (__copy_to_user(buffer, tmpbuf, len))
return -EFAULT;
}
*lenp -= len;
*ppos += len;
return 0;
}

static int
proc_dodebug(ctl_table *table, int write, struct file *file,
void __user *buffer, size_t *lenp, loff_t *ppos)
Expand Down Expand Up @@ -147,6 +172,12 @@ static ctl_table debug_table[] = {
.mode = 0644,
.proc_handler = &proc_dodebug
},
{
.procname = "transports",
.maxlen = 256,
.mode = 0444,
.proc_handler = &proc_do_xprt,
},
{ .ctl_name = 0 }
};

Expand Down

0 comments on commit c4e3f3a

Please sign in to comment.