netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
  • * Re: [PATCH] Improve behaviour of Netlink Sockets
           [not found]       ` <412F1269.8090303@eurodev.net>
           [not found]         ` <20040827172736.543dbd54.davem@redhat.com>
    @ 2004-09-18 10:25         ` Herbert Xu
      2004-09-19  4:36           ` Pablo Neira
      1 sibling, 1 reply; 96+ messages in thread
    From: Herbert Xu @ 2004-09-18 10:25 UTC (permalink / raw)
      To: Pablo Neira; +Cc: davem, linux-net, netdev, kaber
    
    Pablo Neira <pablo@eurodev.net> wrote:
    > 
    > thanks, I fixed, I shouldn't type at 5 a.m. If any other problem, please 
    > let me know.
    
    Sorry I should've reviewed this patch sooner.  It finally caught my
    attention as I went to update the 2.4 IPsec backport.
    
    Firstly there is a sock leak there.  The following patch fixes it.
    The white space damage is not mine :)
    
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
    
    Secondly, I'm dubious about the patch as a whole.  For instance, what
    exactly is the wake_up_process() bit trying to do? Surely that process
    would've been woken up multiple times already if its queue is full.  If
    it can't empty the queue fast enough, what is this extra wake up going
    to achieve?
    
    And what is it going to do with thread groups?
    
    Cheers,
    -- 
    Visit Openswan at http://www.openswan.org/
    Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
    Home Page: http://gondor.apana.org.au/~herbert/
    PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
    --
    ===== net/netlink/af_netlink.c 1.52 vs edited =====
    --- 1.52/net/netlink/af_netlink.c	2004-08-28 10:11:04 +10:00
    +++ 2.6/net/netlink/af_netlink.c	2004-09-18 20:09:20 +10:00
    @@ -630,7 +630,8 @@
     
     			if (!nlwork)
     				return -1;
    -		
    +
    +			sock_hold(sk);
     			INIT_WORK(&nlwork->work, netlink_wq_handler, nlwork);
     			nlwork->sk = sk;
     			nlwork->len = skb->len;
    @@ -683,14 +684,13 @@
     			netlink_overrun(sk);
     			/* Clone failed. Notify ALL listeners. */
     			failure = 1;
    -			sock_put(sk);
     		} else if (netlink_broadcast_deliver(sk, skb2)) {
     			netlink_overrun(sk);
    -			sock_put(sk);
     		} else {
     			delivered = 1;
     			skb2 = NULL;
     		}
    +		sock_put(sk);
     	}
     
     	netlink_unlock_table();
    --
    ===== net/netlink/af_netlink.c 1.15 vs edited =====
    --- 1.15/net/netlink/af_netlink.c	2004-08-31 10:04:34 +10:00
    +++ 2.4/net/netlink/af_netlink.c	2004-09-18 20:25:29 +10:00
    @@ -549,7 +549,8 @@
     		
     			if  (!nlwork) 
     				return -EAGAIN;
    -		
    +
    +			sock_hold(sk);
     			INIT_TQUEUE(&nlwork->work, netlink_tq_handler, nlwork);
     			nlwork->sk = sk;
     			nlwork->len = skb->len;
    @@ -601,12 +602,11 @@
     			netlink_overrun(sk);
     			/* Clone failed. Notify ALL listeners. */
     			failure = 1;
    -			sock_put(sk);
     		} else if (netlink_broadcast_deliver(sk, skb2)) {
     			netlink_overrun(sk);
    -			sock_put(sk);
     		} else
     			skb2 = NULL;
    +		sock_put(sk);
     	}
     
     	netlink_unlock_table();
    
    ^ permalink raw reply	[flat|nested] 96+ messages in thread
  • [parent not found: <E1C90Da-0001V7-00@gondolin.me.apana.org.au>]
  • * Re: [PATCH] Improve behaviour of Netlink Sockets
    @ 2004-09-29  9:53 James Chapman
      2004-09-29  9:59 ` Herbert Xu
      0 siblings, 1 reply; 96+ messages in thread
    From: James Chapman @ 2004-09-29  9:53 UTC (permalink / raw)
      To: hadi, herbert; +Cc: pablo, davem, netdev
    
    Re: async netlink messages
    
    Is it possible to deliver async messages to userspace using a polling
    mechanism to help solve the overrun problem?
    
    - Have the kernel keep a list of async messages sent towards each
      socket rather than trying to deliver each message to the app
      immediately.  Have the kernel send a netlink event message (say,
      NETLINK_EVENT_WAKEUP) to the app when this queue first goes
      non-empty. No new NETLINK_EVENT_WAKEUP messages are sent until the
      event queue goes empty again.
    
    - On receipt of NETLINK_EVENT_WAKEUP, a process issues a netlink
      GET (or DUMP?) on its netlink socket to read its queued events.
    
    - If the socket event queue overruns, discard new events and flag the
      event queue as having lost messages. When the userspace app reads
      the event queue, it will discover that messages have been lost and
      can then re-read state from the kernel.
    
    - Use a setsockopt on the netlink socket to have the socket configured
      in this polled-event mode.
    
    Just a thought.
    
    /james
    
    
    -----Original Message-----
    From: Herbert Xu [mailto:herbert@gondor.apana.org.au]
    Sent: 28 September 2004 04:59
    To: hadi@cyberus.ca
    Cc: pablo@eurodev.net,  davem@davemloft.net, netdev@oss.sgi.com
    Subject: Re: [PATCH] Improve behaviour of Netlink Sockets
    
    On Mon, Sep 27, 2004 at 11:45:25PM -0400, jamal wrote:
    >
    > > Now that we know where the events are coming from and what they are,
    > > we can decide on the solution.  In this particular case, there is
    > > nothing you can do on the sending side.  Stopping people from operating
    > > on networking objects just because some netlink listener can't keep up
    > > isn't going to work.  So congestion control is out of the question.
    >
    > fixing the NLM_GOODSIZE issue is a very good first step.
    
    Well I'm afraid that it doesn't help in your interface address example
    because rtmsg_ifa() already allocates a buffer of (approximately) the
    right size.  That is, it doesn't use NLM_GOODSIZE at all.
    
    > Adding congestion control would be harder but not out of question.
    
    But the question is who are you going to throttle? If you throttle
    the source of the messages then you're going to stop people from adding
    or deleting IP addresses which can't be right.
    
    If you move the netlink sender into a different execution context and
    throttle that then that's just extending the receive queue length by
    stealth.
    
    So I'm afraid I don't see how congestion control could be applied in
    *this* particular context.
    
    > > So just bite the bullet and reread the system state by issuing dump
    > > operations.
    >
    > We may as well choose to document it as being this mostly because of the
    > issue i described above. We shouldnt give up so easily though ;->
    
    Well IMHO this is not giving up at all.
    
    Think of it another way.  Monitoring routes is like maintaining a
    program.  Normally you just fix the bugs as they come.  But if the
    bug reports are coming in so fast that you can't keep up, perhaps
    it's time to throw it away and rewrite it from scratch :)
    --
    Visit Openswan at http://www.openswan.org/
    Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
    Home Page: http://gondor.apana.org.au/~herbert/
    PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
    
    
    
    
    
    
    ----- End forwarded message -----
    
    ^ permalink raw reply	[flat|nested] 96+ messages in thread
    * Re: [PATCH] Improve behaviour of Netlink Sockets
    @ 2004-09-30  9:50 James Chapman
      0 siblings, 0 replies; 96+ messages in thread
    From: James Chapman @ 2004-09-30  9:50 UTC (permalink / raw)
      To: herbert; +Cc: hadi, pablo, davem, netdev
    
    > On Wed, Sep 29, 2004 at 10:53:43AM +0100, James Chapman wrote:
    > >
    > > - Have the kernel keep a list of async messages sent towards each
    > >   socket rather than trying to deliver each message to the app
    > >   immediately.  Have the kernel send a netlink event message (say,
    > >   NETLINK_EVENT_WAKEUP) to the app when this queue first goes
    > >   non-empty. No new NETLINK_EVENT_WAKEUP messages are sent until the
    > >   event queue goes empty again.
    > >
    > > - On receipt of NETLINK_EVENT_WAKEUP, a process issues a netlink
    > >   GET (or DUMP?) on its netlink socket to read its queued events.
    > >
    > > - If the socket event queue overruns, discard new events and flag the
    > >   event queue as having lost messages. When the userspace app reads
    > >   the event queue, it will discover that messages have been lost and
    > >   can then re-read state from the kernel.
    > >
    > > - Use a setsockopt on the netlink socket to have the socket configured
    > >   in this polled-event mode.
    >
    > That's basically how it works now.
    
    Looks like I was proposing something similar to Jamal's intermediate
    queue. With the above scheme, there would be no need for userspace to
    periodically poll for events since that would be kicked off by the
    wakeup message. Also, while events are held in the kernel, they
    wouldn't be charged to the netlink socket -- instead they'd be limited
    by a system-wide count, sharing the event resource across all netlink
    sockets.
    
    /james
    
    ^ permalink raw reply	[flat|nested] 96+ messages in thread

    end of thread, other threads:[~2004-09-30  9:50 UTC | newest]
    
    Thread overview: 96+ messages (download: mbox.gz follow: Atom feed
    -- links below jump to the message on this page --
         [not found] <412DF807.2040703@eurodev.net>
         [not found] ` <20040826141407.38b56729.davem@redhat.com>
         [not found]   ` <412EB40A.6010100@eurodev.net>
         [not found]     ` <20040826214710.5e322f1a.davem@redhat.com>
         [not found]       ` <412F1269.8090303@eurodev.net>
         [not found]         ` <20040827172736.543dbd54.davem@redhat.com>
    2004-08-30  0:37           ` [PATCH] Improve behaviour of Netlink Sockets Pablo Neira
    2004-08-31  0:20             ` David S. Miller
    2004-08-31 16:37               ` Pablo Neira
    2004-08-31 20:16                 ` David S. Miller
    2004-09-18 10:25         ` Herbert Xu
    2004-09-19  4:36           ` Pablo Neira
    2004-09-19  5:18             ` Pablo Neira
    2004-09-19  7:58             ` Herbert Xu
    2004-09-19 12:02               ` Herbert Xu
    2004-09-19 12:07                 ` Herbert Xu
    2004-09-19 20:50                   ` Pablo Neira
    2004-09-19 21:53                     ` Herbert Xu
    2004-09-19 22:49                       ` Pablo Neira
    2004-09-19 23:44                         ` Herbert Xu
    2004-09-20  0:31                           ` Pablo Neira
    2004-09-20  1:00                             ` Herbert Xu
    2004-09-19 20:50                 ` Pablo Neira
    2004-09-19 21:59                   ` Herbert Xu
    2004-09-19 22:39                     ` jamal
    2004-09-19 22:55                       ` Pablo Neira
    2004-09-19 23:04                         ` jamal
    2004-09-19 23:10                           ` Herbert Xu
    2004-09-19 23:17                       ` Herbert Xu
    2004-09-20  2:39                         ` jamal
    2004-09-20  2:58                           ` Herbert Xu
    2004-09-20 12:34                             ` jamal
    2004-09-20 18:14                               ` Pablo Neira
    2004-09-20 21:59                                 ` Herbert Xu
    2004-09-21 11:47                                   ` jamal
    2004-09-21 12:09                                     ` Herbert Xu
    2004-09-22  0:05                                 ` Herbert Xu
    2004-09-22  0:24                                   ` Pablo Neira
    2004-09-22  2:48                                   ` Pablo Neira
    2004-09-22  2:50                                     ` David S. Miller
    2004-09-22  2:53                                     ` jamal
    2004-09-22  3:46                                       ` Herbert Xu
    2004-09-22 11:35                                         ` jamal
    2004-09-23 12:05                                           ` Herbert Xu
    2004-09-24  2:56                                             ` jamal
    2004-09-24  3:20                                               ` Herbert Xu
    2004-09-27 12:41                                                 ` jamal
    2004-09-22  4:52                                     ` Herbert Xu
    2004-09-22 12:08                                       ` jamal
    2004-09-22 17:52                                         ` David S. Miller
    2004-09-23 15:40                                           ` Pablo Neira
    2004-09-23 19:16                                             ` David S. Miller
    2004-09-24  3:28                                               ` Herbert Xu
    2004-09-24  5:39                                                 ` David S. Miller
    2004-09-24  6:26                                                   ` Herbert Xu
    2004-09-24 17:58                                                     ` David S. Miller
    2004-09-24 22:06                                                       ` Herbert Xu
    2004-09-24 22:28                                                         ` Herbert Xu
    2004-09-27 12:59                                                         ` jamal
    2004-09-27 12:53                                                 ` jamal
    2004-09-23 12:07                                         ` Herbert Xu
    2004-09-24  1:19                                           ` Pablo Neira
    2004-09-24  3:04                                           ` jamal
    2004-09-24  3:24                                             ` Herbert Xu
    2004-09-27 12:46                                               ` jamal
    2004-09-27 21:36                                                 ` Herbert Xu
    2004-09-28  2:43                                                   ` jamal
    2004-09-28  2:46                                                     ` Herbert Xu
    2004-09-28  3:06                                                       ` jamal
    2004-09-28  3:23                                                         ` Herbert Xu
    2004-09-28  3:45                                                           ` jamal
    2004-09-28  3:59                                                             ` Herbert Xu
    2004-09-28 10:36                                                               ` jamal
    2004-09-28 11:11                                                                 ` Herbert Xu
    2004-09-28 12:16                                                                   ` Herbert Xu
    2004-09-28 12:39                                                                     ` On DaveMs congestion control algorithm WAS(Re: " jamal
    2004-09-28 18:24                                                                       ` David S. Miller
    2004-09-29  2:23                                                                         ` jamal
    2004-09-28 12:32                                                                   ` jamal
    2004-09-29  0:13                                                                     ` Herbert Xu
    2004-09-29  2:52                                                                       ` jamal
    2004-09-29  3:27                                                                         ` Herbert Xu
    2004-09-29  4:02                                                                           ` David S. Miller
    2004-09-29 10:50                                                                           ` jamal
    2004-09-29 11:42                                                                             ` Herbert Xu
    2004-09-29 13:55                                                                               ` jamal
    2004-09-28 21:07                                                                 ` Pablo Neira
    2004-09-28 23:19                                                                   ` Herbert Xu
    2004-09-28 23:20                                                                     ` David S. Miller
    2004-09-29  2:28                                                                   ` jamal
    2004-09-29  2:30                                                                     ` Herbert Xu
    2004-09-29  2:59                                                                       ` jamal
    2004-09-22  2:57                                   ` jamal
    2004-09-22  3:39                                     ` Herbert Xu
    2004-09-19 20:47               ` Pablo Neira
    2004-09-19 21:20                 ` Herbert Xu
    2004-09-19 22:14                   ` Pablo Neira
    2004-09-19 23:31                     ` Herbert Xu
         [not found] ` <E1C90Da-0001V7-00@gondolin.me.apana.org.au>
    2004-09-19 12:00   ` Herbert Xu
    2004-09-29  9:53 James Chapman
    2004-09-29  9:59 ` Herbert Xu
      -- strict thread matches above, loose matches on Subject: below --
    2004-09-30  9:50 James Chapman
    

    This is a public inbox, see mirroring instructions
    for how to clone and mirror all data and code used for this inbox;
    as well as URLs for NNTP newsgroup(s).