1. 23 3月, 2009 1 次提交
  2. 04 3月, 2009 1 次提交
    • P
      netlink: invert error code in netlink_set_err() · 4843b93c
      Pablo Neira Ayuso 提交于
      The callers of netlink_set_err() currently pass a negative value
      as parameter for the error code. However, sk->sk_err wants a
      positive error value. Without this patch, skb_recv_datagram() called
      by netlink_recvmsg() may return a positive value to report an error.
      
      Another choice to fix this is to change callers to pass a positive
      error value, but this seems a bit inconsistent and error prone
      to me. Indeed, the callers of netlink_set_err() assumed that the
      (usual) negative value for error codes was fine before this patch :).
      
      This patch also includes some documentation in docbook format
      for netlink_set_err() to avoid this sort of confusion.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      4843b93c
  3. 27 2月, 2009 1 次提交
  4. 25 2月, 2009 1 次提交
    • P
      netlink: change nlmsg_notify() return value logic · 1ce85fe4
      Pablo Neira Ayuso 提交于
      This patch changes the return value of nlmsg_notify() as follows:
      
      If NETLINK_BROADCAST_ERROR is set by any of the listeners and
      an error in the delivery happened, return the broadcast error;
      else if there are no listeners apart from the socket that
      requested a change with the echo flag, return the result of the
      unicast notification. Thus, with this patch, the unicast
      notification is handled in the same way of a broadcast listener
      that has set the NETLINK_BROADCAST_ERROR socket flag.
      
      This patch is useful in case that the caller of nlmsg_notify()
      wants to know the result of the delivery of a netlink notification
      (including the broadcast delivery) and take any action in case
      that the delivery failed. For example, ctnetlink can drop packets
      if the event delivery failed to provide reliable logging and
      state-synchronization at the cost of dropping packets.
      
      This patch also modifies the rtnetlink code to ignore the return
      value of rtnl_notify() in all callers. The function rtnl_notify()
      (before this patch) returned the error of the unicast notification
      which makes rtnl_set_sk_err() reports errors to all listeners. This
      is not of any help since the origin of the change (the socket that
      requested the echoing) notices the ENOBUFS error if the notification
      fails and should resync itself.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Acked-by: NPatrick McHardy <kaber@trash.net>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1ce85fe4
  5. 20 2月, 2009 1 次提交
    • P
      netlink: add NETLINK_BROADCAST_ERROR socket option · be0c22a4
      Pablo Neira Ayuso 提交于
      This patch adds NETLINK_BROADCAST_ERROR which is a netlink
      socket option that the listener can set to make netlink_broadcast()
      return errors in the delivery to the caller. This option is useful
      if the caller of netlink_broadcast() do something with the result
      of the message delivery, like in ctnetlink where it drops a network
      packet if the event delivery failed, this is used to enable reliable
      logging and state-synchronization. If this socket option is not set,
      netlink_broadcast() only reports ESRCH errors and silently ignore
      ENOBUFS errors, which is what most netlink_broadcast() callers
      should do.
      
      This socket option is based on a suggestion from Patrick McHardy.
      Patrick McHardy can exchange this patch for a beer from me ;).
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Acked-by: NPatrick McHardy <kaber@trash.net>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      be0c22a4
  6. 06 2月, 2009 1 次提交
    • P
      netlink: change return-value logic of netlink_broadcast() · ff491a73
      Pablo Neira Ayuso 提交于
      Currently, netlink_broadcast() reports errors to the caller if no
      messages at all were delivered:
      
      1) If, at least, one message has been delivered correctly, returns 0.
      2) Otherwise, if no messages at all were delivered due to skb_clone()
         failure, return -ENOBUFS.
      3) Otherwise, if there are no listeners, return -ESRCH.
      
      With this patch, the caller knows if the delivery of any of the
      messages to the listeners have failed:
      
      1) If it fails to deliver any message (for whatever reason), return
         -ENOBUFS.
      2) Otherwise, if all messages were delivered OK, returns 0.
      3) Otherwise, if no listeners, return -ESRCH.
      
      In the current ctnetlink code and in Netfilter in general, we can add
      reliable logging and connection tracking event delivery by dropping the
      packets whose events were not successfully delivered over Netlink. Of
      course, this option would be settable via /proc as this approach reduces
      performance (in terms of filtered connections per seconds by a stateful
      firewall) but providing reliable logging and event delivery (for
      conntrackd) in return.
      
      This patch also changes some clients of netlink_broadcast() that
      may report ENOBUFS errors via printk. This error handling is not
      of any help. Instead, the userspace daemons that are listening to
      those netlink messages should resync themselves with the kernel-side
      if they hit ENOBUFS.
      
      BTW, netlink_broadcast() clients include those that call
      cn_netlink_send(), nlmsg_multicast() and genlmsg_multicast() since they
      internally call netlink_broadcast() and return its error value.
      Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ff491a73
  7. 25 11月, 2008 1 次提交
  8. 24 11月, 2008 2 次提交
  9. 17 10月, 2008 1 次提交
  10. 14 10月, 2008 1 次提交
  11. 26 7月, 2008 1 次提交
  12. 02 7月, 2008 1 次提交
  13. 06 6月, 2008 1 次提交
  14. 28 4月, 2008 1 次提交
  15. 19 4月, 2008 1 次提交
  16. 26 3月, 2008 3 次提交
  17. 22 3月, 2008 1 次提交
  18. 01 3月, 2008 2 次提交
  19. 02 2月, 2008 1 次提交
  20. 01 2月, 2008 1 次提交
    • P
      [NETNS]: Fix race between put_net() and netlink_kernel_create(). · 23fe1866
      Pavel Emelyanov 提交于
      The comment about "race free view of the set of network
      namespaces" was a bit hasty. Look (there even can be only
      one CPU, as discovered by Alexey Dobriyan and Denis Lunev):
      
      put_net()
        if (atomic_dec_and_test(&net->refcnt))
          /* true */
            __put_net(net);
              queue_work(...);
      
      /*
       * note: the net now has refcnt 0, but still in
       * the global list of net namespaces
       */
      
      == re-schedule ==
      
      register_pernet_subsys(&some_ops);
        register_pernet_operations(&some_ops);
          (*some_ops)->init(net);
            /*
             * we call netlink_kernel_create() here
             * in some places
             */
            netlink_kernel_create();
               sk_alloc();
                  get_net(net); /* refcnt = 1 */
               /*
                * now we drop the net refcount not to
                * block the net namespace exit in the
                * future (or this can be done on the
                * error path)
                */
               put_net(sk->sk_net);
                   if (atomic_dec_and_test(&...))
                         /*
                          * true. BOOOM! The net is
                          * scheduled for release twice
                          */
      
      When thinking on this problem, I decided, that getting and
      putting the net in init callback is wrong. If some init
      callback needs to have a refcount-less reference on the struct
      net, _it_ has to be careful himself, rather than relying on
      the infrastructure to handle this correctly.
      
      In case of netlink_kernel_create(), the problem is that the
      sk_alloc() gets the given namespace, but passing the info
      that we don't want to get it inside this call is too heavy.
      
      Instead, I propose to crate the socket inside an init_net
      namespace and then re-attach it to the desired one right
      after the socket is created.
      
      After doing this, we also have to be careful on error paths
      not to drop the reference on the namespace, we didn't get
      the one on.
      Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
      Acked-by: NDenis Lunev <den@openvz.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      23fe1866
  21. 29 1月, 2008 8 次提交
  22. 13 11月, 2007 1 次提交
  23. 07 11月, 2007 1 次提交
  24. 01 11月, 2007 1 次提交
  25. 27 10月, 2007 1 次提交
    • E
      [NET]: Marking struct pernet_operations __net_initdata was inappropriate · 2b008b0a
      Eric W. Biederman 提交于
      It is not safe to to place struct pernet_operations in a special section.
      We need struct pernet_operations to last until we call unregister_pernet_subsys.
      Which doesn't happen until module unload.
      
      So marking struct pernet_operations is a disaster for modules in two ways.
      - We discard it before we call the exit method it points to.
      - Because I keep struct pernet_operations on a linked list discarding
        it for compiled in code removes elements in the middle of a linked
        list and does horrible things for linked insert.
      
      So this looks safe assuming __exit_refok is not discarded
      for modules.
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2b008b0a
  26. 24 10月, 2007 1 次提交
  27. 16 10月, 2007 1 次提交
  28. 11 10月, 2007 2 次提交
    • D
      [NET]: make netlink user -> kernel interface synchronious · cd40b7d3
      Denis V. Lunev 提交于
      This patch make processing netlink user -> kernel messages synchronious.
      This change was inspired by the talk with Alexey Kuznetsov about current
      netlink messages processing. He says that he was badly wrong when introduced 
      asynchronious user -> kernel communication.
      
      The call netlink_unicast is the only path to send message to the kernel
      netlink socket. But, unfortunately, it is also used to send data to the
      user.
      
      Before this change the user message has been attached to the socket queue
      and sk->sk_data_ready was called. The process has been blocked until all
      pending messages were processed. The bad thing is that this processing
      may occur in the arbitrary process context.
      
      This patch changes nlk->data_ready callback to get 1 skb and force packet
      processing right in the netlink_unicast.
      
      Kernel -> user path in netlink_unicast remains untouched.
      
      EINTR processing for in netlink_run_queue was changed. It forces rtnl_lock
      drop, but the process remains in the cycle until the message will be fully
      processed. So, there is no need to use this kludges now.
      Signed-off-by: NDenis V. Lunev <den@openvz.org>
      Acked-by: NAlexey Kuznetsov <kuznet@ms2.inr.ac.ru>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      cd40b7d3
    • D
      [NET]: unify netlink kernel socket recognition · aed81560
      Denis V. Lunev 提交于
      There are currently two ways to determine whether the netlink socket is a
      kernel one or a user one. This patch creates a single inline call for
      this purpose and unifies all the calls in the af_netlink.c
      
      No similar calls are found outside af_netlink.c.
      Signed-off-by: NDenis V. Lunev <den@openvz.org>
      Acked-by: NAlexey Kuznetsov <kuznet@ms2.inr.ac.ru>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      aed81560