mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roberto Nibali <ratz@drugphish.ch>
To: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: linux-kernel@vger.kernel.org
Subject: Re: NFS (vfs-related) syscall logging
Date: Wed, 19 Jun 2002 01:35:04 +0200	[thread overview]
Message-ID: <3D0FC3A8.7030101@drugphish.ch> (raw)
In-Reply-To: <200206171913.53561.trond.myklebust@fys.uio.no>

Hello,

> 'ethereal' *is* a damned intelligent parser that understands RPC/NFS/... ;-)
                     ^^^^^^
                       :)

Yes, it does, but it is a pain to get for example nfsd_unlink or 
nfsd_create_v3 calls and filter out the UID, GID and pathname. And 
fiddling around with nfs.data is quite a pain too. Plus (t)ethereal 
opens yet another code path in the TCP/IP stack via skb_clone() to add 
it to the ptype_all list while running. I'd like to do things where they 
should be done ;).

> You should be able to use its read filtering capabilities to cherry-pick 
> exactly the information that interests you.

I tried for a while but I found it easier to extend the current NFS code 
  with my needs, especially after you gave me the hint below!

> If you are going to insist on logging using printks, you might as well just 
> use the existing RPC debugging code. Just rewrite your printks to the format
> 
> dfprintk(BITMASK, format,...)
> 
> The value of BITMASK can be whatever you want, although the masks between 
> 0x0001 and 0x0200 are already used by the existing nfsd debugging code (see 
> include/linux/nfsd/debug.h).
> 
> Then just 'echo BITMASK >/proc/sys/sunrpc/nfsd_debug' in order to begin 
> logging.

Thank you very much for this valuable hint. Since I'm using a recursive 
function in my patch to print the pathname along with the according 
syscall it turned out to be stupid to use dfprintk for the first part of 
the output and then trying to patch together the rest. What I did was 
following (basic chunk of code responsible for a syscall):

+ 
if (nfsd_debug & NFSDDBG_SYSREAD){
+ 
	printk(KERN_INFO "NFSLOG UID=%d GID=%d FILE=",
+ 
		rqstp->rq_cred.cr_uid,
+ 
		rqstp->rq_cred.cr_gid);
+ 
	print_dirname(fhp->fh_dentry);
+ 
	printk(" OP=%s IP=%d.%d.%d.%d\n",
+ 
		__FUNCTION__,
+ 
		NIPQUAD(rqstp->rq_addr.sin_addr.s_addr));

I enhanced the debug.h with 5 new bitmasks (no more left now) and use 
them like that, despite the fact that dfprintk would add the NFSDDBG_ 
part. print_dirname now can be kept simple:

+static void print_dirname(struct dentry *getdentry) {
+ 
if ((getdentry != NULL) && !IS_ROOT(getdentry)){
+ 
	print_dirname(getdentry->d_parent);
+ 
}
+ 
if (!IS_ROOT(getdentry)) {
+ 
	printk("/%s", getdentry->d_name.name);
+ 
}
+}

Now another interesting thing I found was that the fname in nfsd_unlink 
is not always passed up correctly. I haven't tracked it down to the 
exact byte but you can reproduce it like follows:

1. mount a NFS export
2. create a deeply nested directory tree with let's say 30 Bytes as a
    pathname
3. now do a: echo "test" > test && rm -f ./test
4. watch the output of fname in unlink via a well placed printk().
5. fname must have length 4 and the tree must have a certain length too,
    I haven't found that one out yet

fname is already passed over in a wrong way at ../fs/nfsd/nfs3proc.c in 
nfsd3_proc_remove(). In my case with a printk("fname=%s", fname) I get
fname=test^A for nfsd_unlink and fname=test for nfsd_create_v3. Could 
you have a look into that one, please?

Best regards,
Roberto Nibali, ratz
-- 
echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq'|dc


      reply	other threads:[~2002-06-18 23:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-14 21:21 Roberto Nibali
2002-06-16 20:44 ` Trond Myklebust
2002-06-17 16:39   ` Roberto Nibali
2002-06-17 17:13     ` Trond Myklebust
2002-06-18 23:35       ` Roberto Nibali [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3D0FC3A8.7030101@drugphish.ch \
    --to=ratz@drugphish.ch \
    --cc=linux-kernel@vger.kernel.org \
    --cc=trond.myklebust@fys.uio.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®