All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Staubach <staubach@redhat.com>
To: Peter Staubach <staubach@redhat.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>,
	Janne Karhunen <janne.karhunen@gmail.com>,
	linux-nfs@vger.kernel.org
Subject: Re: [patch] fix statd -n
Date: Fri, 18 Apr 2008 16:23:50 -0400	[thread overview]
Message-ID: <48090356.9020703@redhat.com> (raw)
In-Reply-To: <480902CA.1070805@redhat.com>

Peter Staubach wrote:
> J. Bruce Fields wrote:
>> On Thu, Apr 17, 2008 at 12:38:43PM -0400, Janne Karhunen wrote:
>>  
>>> Apparently lockd does not expect statd to be used with -n
>>> switch: statd is expected to bind loopback, always. Attached
>>> patches show one (IPv4 specific) way of fixing it. Comments?
>>>     
>>
>> Maybe statd really should always bind to the loopback interface?  Is
>> there any reason not to?
>>
>>   
>
> I think that statd needs to be reachable from clients
> and/or servers when the state changes on the other end.
>
> This "-n" option really assumes that the system is single-homed
> though, doesn't it?  Binding to one particular interface will
> make it so that statd will not be reachable via any of the other
> interfaces on the system.
>
> Perhaps statd should always bind to the loopback interface
> if it doesn't bind to INADDR_ANY?
>

Sorry, not very clear.  Perhaps statd should bind to the loopback
interface in addition to any other interfaces if it doesn't bind
to INADDR_ANY.

    Thanx...

       ps

>    Thanx...
>
>       ps
>
>> From a quick look at the current nfs-utils code: it looks like the -n
>> option only affects the operation of the sm-notify program that's called
>> on boot to notify peer statd's?  I'm a little confused.  (What version
>> of nfs-utils are you working from?)
>>
>> --b.
>>
>>  
>>> -- 
>>> // Janne
>>>     
>>
>>  
>>> --- rmtcall.c.org    2008-04-14 10:53:30.000000000 -0400
>>> +++ rmtcall.c    2008-04-14 13:01:27.000000000 -0400
>>> @@ -37,6 +37,7 @@
>>>  #include <netdb.h>
>>>  #include <string.h>
>>>  #include <unistd.h>
>>> +#include <errno.h>
>>>  #ifdef HAVE_IFADDRS_H
>>>  #include <ifaddrs.h>
>>>  #endif /* HAVE_IFADDRS_H */
>>> @@ -54,6 +55,34 @@
>>>  
>>>  static unsigned long    xid = 0;    /* RPC XID counter */
>>>  static int        sockfd = -1;    /* notify socket */
>>> +static int              ifset = 0;
>>> +
>>> +/*
>>> + * Notify lockd of non-standard binding + */
>>> +inline void
>>> +nlm_nsm_set(unsigned int addr)
>>> +{
>>> +        ssize_t sz = 0;
>>> +        char buf[20];
>>> +        int fd;
>>> +
>>> +        if ( ifset )
>>> +                return ;
>>> +
>>> +        sprintf (buf,"%u",addr);
>>> +
>>> +        fd = open ("/proc/sys/fs/nfs/nlm_nsm_interface", O_RDWR);
>>> +        if (fd > 0) {
>>> +                sz = write (fd,buf,strlen((char*)buf));
>>> +                if ( sz == -1 )
>>> +                        note(N_CRIT, "statd: write: %s\n", 
>>> strerror(errno));
>>> +                close (fd);
>>> +        } else
>>> +                note(N_CRIT, "statd: -n was specified with with no 
>>> kernel support?\n");
>>> +
>>> +        ifset = 1;
>>> +}
>>>  
>>>  /*
>>>   * Initialize callback socket
>>> @@ -85,6 +114,7 @@ statd_get_socket(int port)
>>>          struct hostent *hp = gethostbyname(MY_NAME);
>>>          if (hp)
>>>              sin.sin_addr = *(struct in_addr *) hp->h_addr;
>>> +        nlm_nsm_set ((unsigned int)sin.sin_addr.s_addr);
>>>      }
>>>      if (port != 0) {
>>>          sin.sin_port = htons(port);
>>>     
>>
>>  
>>> diff -Naurp lockd.org/svc4proc.c lockd/svc4proc.c
>>> --- lockd.org/svc4proc.c    2008-04-14 10:58:29.000000000 -0400
>>> +++ lockd/svc4proc.c    2008-04-14 12:19:04.000000000 -0400
>>> @@ -21,6 +21,8 @@
>>>  
>>>  #define NLMDBG_FACILITY        NLMDBG_CLIENT
>>>  
>>> +extern unsigned int nlm_nsm_interface;
>>> +
>>>  /*
>>>   * Obtain client and file from arguments
>>>   */
>>> @@ -430,8 +432,9 @@ nlm4svc_proc_sm_notify(struct svc_rqst *
>>>      memcpy(&saddr, svc_addr_in(rqstp), sizeof(saddr));
>>>  
>>>      dprintk("lockd: SM_NOTIFY     called\n");
>>> -    if (saddr.sin_addr.s_addr != htonl(INADDR_LOOPBACK)
>>> -     || ntohs(saddr.sin_port) >= 1024) {
>>> +    if (((saddr.sin_addr.s_addr != htonl(INADDR_LOOPBACK))
>>> +     && (nlm_nsm_interface && (saddr.sin_addr.s_addr != 
>>> htonl(nlm_nsm_interface))))
>>> +     || (ntohs(saddr.sin_port) >= 1024)) {
>>>          char buf[RPC_MAX_ADDRBUFLEN];
>>>          printk(KERN_WARNING "lockd: rejected NSM callback from %s\n",
>>>                  svc_print_addr(rqstp, buf, sizeof(buf)));
>>> diff -Naurp lockd.org/svc.c lockd/svc.c
>>> --- lockd.org/svc.c    2008-04-14 10:58:29.000000000 -0400
>>> +++ lockd/svc.c    2008-04-14 12:19:04.000000000 -0400
>>> @@ -64,6 +64,7 @@ static unsigned long        nlm_grace_period;
>>>  static unsigned long        nlm_timeout = LOCKD_DFLT_TIMEO;
>>>  static int            nlm_udpport, nlm_tcpport;
>>>  int                nsm_use_hostnames = 0;
>>> +unsigned int            nlm_nsm_interface = 0;
>>>  
>>>  /*
>>>   * Constants needed for the sysctl interface.
>>> @@ -425,6 +426,14 @@ static ctl_table nlm_sysctls[] = {
>>>          .mode        = 0644,
>>>          .proc_handler    = &proc_dointvec,
>>>      },
>>> +        {
>>> +                .ctl_name       = CTL_UNNUMBERED,
>>> +                .procname       = "nlm_nsm_interface",
>>> +                .data           = &nlm_nsm_interface,
>>> +                .maxlen         = sizeof(int),
>>> +                .mode           = 0644,
>>> +                .proc_handler   = &proc_dointvec,
>>> +        },
>>>      { .ctl_name = 0 }
>>>  };
>>>  
>>> diff -Naurp lockd.org/svcproc.c lockd/svcproc.c
>>> --- lockd.org/svcproc.c    2008-04-14 10:58:29.000000000 -0400
>>> +++ lockd/svcproc.c    2008-04-14 12:19:04.000000000 -0400
>>> @@ -21,6 +21,8 @@
>>>  
>>>  #define NLMDBG_FACILITY        NLMDBG_CLIENT
>>>  
>>> +extern unsigned int nlm_nsm_interface;
>>> +
>>>  #ifdef CONFIG_LOCKD_V4
>>>  static __be32
>>>  cast_to_nlm(__be32 status, u32 vers)
>>> @@ -462,8 +464,9 @@ nlmsvc_proc_sm_notify(struct svc_rqst *r
>>>      memcpy(&saddr, svc_addr_in(rqstp), sizeof(saddr));
>>>  
>>>      dprintk("lockd: SM_NOTIFY     called\n");
>>> -    if (saddr.sin_addr.s_addr != htonl(INADDR_LOOPBACK)
>>> -     || ntohs(saddr.sin_port) >= 1024) {
>>> +    if (((saddr.sin_addr.s_addr != htonl(INADDR_LOOPBACK))
>>> +     && (nlm_nsm_interface && (saddr.sin_addr.s_addr != 
>>> htonl(nlm_nsm_interface))))
>>> +     || (ntohs(saddr.sin_port) >= 1024)) {
>>>          char buf[RPC_MAX_ADDRBUFLEN];
>>>          printk(KERN_WARNING "lockd: rejected NSM callback from %s\n",
>>>                  svc_print_addr(rqstp, buf, sizeof(buf)));
>>>     
>>
>> -- 
>> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>   
>
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


  reply	other threads:[~2008-04-18 20:23 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-17 16:38 [patch] fix statd -n Janne Karhunen
     [not found] ` <24c1515f0804170938s23fe3ea3pfe77355ed01d8bbf-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-18 17:36   ` J. Bruce Fields
2008-04-18 18:11     ` Janne Karhunen
     [not found]       ` <24c1515f0804181111x465d7083o4b78e1ba36b51cb-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-18 18:25         ` J. Bruce Fields
2008-04-18 18:31           ` Janne Karhunen
     [not found]             ` <24c1515f0804181131i238a50a7v85ef80299ec2216f-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-18 18:34               ` J. Bruce Fields
2008-04-18 18:55                 ` Janne Karhunen
2008-04-18 19:46                 ` Janne Karhunen
2008-04-18 20:22         ` Peter Staubach
2008-04-18 20:39           ` Janne Karhunen
2008-04-18 18:20     ` Wendy Cheng
2008-04-18 20:21     ` Peter Staubach
2008-04-18 20:23       ` Peter Staubach [this message]
2008-04-18 20:32         ` J. Bruce Fields
2008-04-18 20:46           ` Janne Karhunen
     [not found]             ` <24c1515f0804181346g5867fa1fqfbbcd13af25027cb-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-21  0:02               ` J. Bruce Fields
2008-04-21  0:49                 ` Janne Karhunen
     [not found]                   ` <24c1515f0804201749x47bee916y9970fe1102bfb5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-21  2:11                     ` J. Bruce Fields
2008-04-21 11:01                       ` Jeff Layton
     [not found]                         ` <20080421070107.454cfad2-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-04-21 13:39                           ` J. Bruce Fields
2008-04-21 14:10                             ` Jeff Layton
     [not found]                               ` <20080421101003.4e9d85a6-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2008-04-21 17:32                                 ` J. Bruce Fields
2008-04-21 17:55                                   ` Jeff Layton
2008-04-21 18:28                                   ` Wendy Cheng
2008-04-21 15:01                       ` Chuck Lever
2008-04-21 15:40                         ` Janne Karhunen
2008-04-21 14:46                 ` Janne Karhunen
     [not found]                   ` <24c1515f0804210746t2d392b8ct6575f09dc7254b07-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-21 16:59                     ` J. Bruce Fields
2008-04-21 17:25                       ` Janne Karhunen
2008-04-28 20:52                 ` Janne Karhunen
     [not found]                   ` <24c1515f0804281352u2d04ac89i820dc6807dde39f1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-04-29 14:45                     ` Wendy Cheng
2008-04-29 16:16                       ` J. Bruce Fields
2008-05-01 12:57                         ` Janne Karhunen
     [not found]                           ` <24c1515f0805010557o5daf72f7hc3db5bf85354898e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-05-01 13:28                             ` Janne Karhunen
     [not found]                               ` <24c1515f0805010628k6b57598btb27116c719b99fad-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-05-01 13:50                                 ` Wendy Cheng
2008-05-01 13:58                                   ` Janne Karhunen
2008-05-02 15:21                                 ` Wendy Cheng
2008-05-02 15:24                                   ` Wendy Cheng
2008-05-02 21:13                                   ` Janne Karhunen
     [not found]                                     ` <24c1515f0805021413u450d8bbcr806a90c327b287a1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-05-02 21:15                                       ` Janne Karhunen
2008-05-02 22:33                                       ` Wendy Cheng
2008-05-02 22:54                                         ` Janne Karhunen
     [not found]                                           ` <24c1515f0805021554u483c471bm61cf3a6d8d434b45-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-05-03 15:29                                             ` Wendy Cheng
2008-05-03 17:31                                               ` Janne Karhunen
2008-05-03  0:24                                         ` Janne Karhunen
     [not found]                                           ` <24c1515f0805021724q7dfe5294r702a9c8ffde01129-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-05-05 14:45                                             ` J. Bruce Fields
2008-05-05 14:59                                               ` Wendy Cheng
2008-05-05 15:01                                                 ` Janne Karhunen
     [not found]                                                   ` <24c1515f0805050801m66cce68k94073914ba26511e-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-05-05 15:21                                                     ` Wendy Cheng
2008-05-05 15:23                                                       ` Janne Karhunen
     [not found]                                                         ` <24c1515f0805050823s14f4caf7s3a4ff06a70c220be-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-05-05 15:25                                                           ` J. Bruce Fields
2008-05-05 15:28                                                             ` Janne Karhunen
     [not found]                                                               ` <24c1515f0805050828o3aa5b33aod2a6e4e0b5b6c9dc-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-05-05 15:58                                                                 ` J. Bruce Fields
2008-05-05 16:42                                                                   ` Janne Karhunen
     [not found]                                                                     ` <24c1515f0805050942h26a0aaefi471216482fbabef5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2008-05-05 17:02                                                                       ` J. Bruce Fields
2008-05-05 17:10                                                                         ` Janne Karhunen
2008-05-05 16:00                                                                 ` Wendy Cheng
2008-05-05 16:14                                                                   ` Janne Karhunen
2008-05-05 15:25                                                           ` Janne Karhunen

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=48090356.9020703@redhat.com \
    --to=staubach@redhat.com \
    --cc=bfields@fieldses.org \
    --cc=janne.karhunen@gmail.com \
    --cc=linux-nfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.