1. 04 6月, 2019 1 次提交
    • J
      tipc: fix modprobe tipc failed after switch order of device registration · ca75a9fc
      Junwei Hu 提交于
      commit 526f5b851a96566803ee4bee60d0a34df56c77f8 upstream.
      
      Error message printed:
      modprobe: ERROR: could not insert 'tipc': Address family not
      supported by protocol.
      when modprobe tipc after the following patch: switch order of
      device registration, commit 7e27e8d6130c
      ("tipc: switch order of device registration to fix a crash")
      
      Because sock_create_kern(net, AF_TIPC, ...) called by
      tipc_topsrv_create_listener() in the initialization process
      of tipc_init_net(), so tipc_socket_init() must be execute before that.
      Meanwhile, tipc_net_id need to be initialized when sock_create()
      called, and tipc_socket_init() is no need to be called for each namespace.
      
      I add a variable tipc_topsrv_net_ops, and split the
      register_pernet_subsys() of tipc into two parts, and split
      tipc_socket_init() with initialization of pernet params.
      
      By the way, I fixed resources rollback error when tipc_bcast_init()
      failed in tipc_init_net().
      
      Fixes: 7e27e8d6130c ("tipc: switch order of device registration to fix a crash")
      Signed-off-by: NJunwei Hu <hujunwei4@huawei.com>
      Reported-by: NWang Wang <wangwang2@huawei.com>
      Reported-by: syzbot+1e8114b61079bfe9cbc5@syzkaller.appspotmail.com
      Reviewed-by: NKang Zhou <zhoukang7@huawei.com>
      Reviewed-by: NSuanming Mou <mousuanming@huawei.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ca75a9fc
  2. 01 4月, 2018 1 次提交
    • J
      tipc: replace name table service range array with rb tree · 218527fe
      Jon Maloy 提交于
      The current design of the binding table has an unnecessary memory
      consuming and complex data structure. It aggregates the service range
      items into an array, which is expanded by a factor two every time it
      becomes too small to hold a new item. Furthermore, the arrays never
      shrink when the number of ranges diminishes.
      
      We now replace this array with an RB tree that is holding the range
      items as tree nodes, each range directly holding a list of bindings.
      
      This, along with a few name changes, improves both readability and
      volume of the code, as well as reducing memory consumption and hopefully
      improving cache hit rate.
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      218527fe
  3. 17 2月, 2018 8 次提交
    • J
      tipc: rename tipc_server to tipc_topsrv · 026321c6
      Jon Maloy 提交于
      We rename struct tipc_server to struct tipc_topsrv. This reflect its now
      specialized role as topology server. Accoringly, we change or add function
      prefixes to make it clearer which functionality those belong to.
      
      There are no functional changes in this commit.
      Acked-by: NYing.Xue <ying.xue@windriver.com>
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      026321c6
    • J
      tipc: make struct tipc_server private for server.c · 5c45ab24
      Jon Maloy 提交于
      In order to narrow the interface and dependencies between the topology
      server and the subscription/binding table functionality we move struct
      tipc_server inside the file server.c. This requires some code
      adaptations in other files, but those are mostly minor.
      
      The most important change is that we have to move the start/stop
      functions for the topology server to server.c, where they logically
      belong anyway.
      Acked-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      5c45ab24
    • J
      tipc: some prefix changes · da0a75e8
      Jon Maloy 提交于
      Since we now have removed struct tipc_subscriber from the code, and
      only struct tipc_subscription remains, there is no longer need for long
      and awkward prefixes to distinguish between their pertaining functions.
      
      We now change all tipc_subscrp_* prefixes to tipc_sub_*. This is
      a purely cosmetic change.
      Acked-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      da0a75e8
    • J
      tipc: collapse subscription creation functions · 242e82cc
      Jon Maloy 提交于
      After the previous changes it becomes logical to collapse the two-level
      creation of subscription instances into one. We do that here.
      
      We also rename the creation and deletion functions for more consistency.
      Acked-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      242e82cc
    • J
      tipc: simplify endianness handling in topology subscriber · 8985ecc7
      Jon Maloy 提交于
      Because of the requirement for total distribution transparency, users
      send subscriptions and receive topology events in their own host format.
      It is up to the topology server to determine this format and do the
      correct conversions to and from its own host format when needed.
      
      Until now, this has been handled in a rather non-transparent way inside
      the topology server and subscriber code, leading to unnecessary
      complexity when creating subscriptions and issuing events.
      
      We now improve this situation by adding two new macros, tipc_sub_read()
      and tipc_evt_write(). Both those functions calculate the need for
      conversion internally before performing their respective operations.
      Hence, all handling of such conversions become transparent to the rest
      of the code.
      Acked-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8985ecc7
    • J
      tipc: simplify interaction between subscription and topology connection · 414574a0
      Jon Maloy 提交于
      The message transmission and reception in the topology server is more
      generic than is currently necessary. By basing the funtionality on the
      fact that we only send items of type struct tipc_event and always
      receive items of struct tipc_subcr we can make several simplifications,
      and also get rid of some unnecessary dynamic memory allocations.
      Acked-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      414574a0
    • J
      tipc: eliminate struct tipc_subscriber · df79d040
      Jon Maloy 提交于
      It is unnecessary to keep two structures, struct tipc_conn and struct
      tipc_subscriber, with a one-to-one relationship and still with different
      life cycles. The fact that the two often run in different contexts, and
      still may access each other via direct pointers constitutes an additional
      hazard, something we have experienced at several occasions, and still
      see happening.
      
      We have identified at least two remaining problems that are easier to
      fix if we simplify the topology server data structure somewhat.
      
      - When there is a race between a subscription up/down event and a
        timeout event, it is fully possible that the former might be delivered
        after the latter, leading to confusion for the receiver.
      
      - The function tipc_subcrp_timeout() is executing in interrupt context,
        while the following call chain is at least theoretically possible:
        tipc_subscrp_timeout()
          tipc_subscrp_send_event()
            tipc_conn_sendmsg()
              conn_put()
                tipc_conn_kref_release()
                  sock_release(sock)
      
      I.e., we end up calling a function that might try to sleep in
      interrupt context. To eliminate this, we need to ensure that the
      tipc_conn structure and the socket, as well as the subscription
      instances, only are deleted in work queue context, i.e., after the
      timeout event really has been sent out.
      
      We now remove this unnecessary complexity, by merging data and
      functionality of the subscriber structure into struct tipc_conn
      and the associated file server.c. We thereafter add a spinlock and
      a new 'inactive' state to the subscription structure. Using those,
      both problems described above can be easily solved.
      Acked-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      df79d040
    • J
      tipc: remove unnecessary function pointers · c901d26d
      Jon Maloy 提交于
      Interaction between the functionality in server.c and subscr.c is
      done via function pointers installed in struct server. This makes
      the code harder to follow, and doesn't serve any obvious purpose.
      
      Here, we replace the function pointers with direct function calls.
      Acked-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c901d26d
  4. 10 1月, 2018 1 次提交
    • J
      tipc: improve groupcast scope handling · 232d07b7
      Jon Maloy 提交于
      When a member joins a group, it also indicates a binding scope. This
      makes it possible to create both node local groups, invisible to other
      nodes, as well as cluster global groups, visible everywhere.
      
      In order to avoid that different members end up having permanently
      differing views of group size and memberhip, we must inhibit locally
      and globally bound members from joining the same group.
      
      We do this by using the binding scope as an additional separator between
      groups. I.e., a member must ignore all membership events from sockets
      using a different scope than itself, and all lookups for message
      destinations must require an exact match between the message's lookup
      scope and the potential target's binding scope.
      
      Apart from making it possible to create local groups using the same
      identity on different nodes, a side effect of this is that it now also
      becomes possible to create a cluster global group with the same identity
      across the same nodes, without interfering with the local groups.
      Acked-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      232d07b7
  5. 29 3月, 2017 1 次提交
    • Y
      tipc: adjust the policy of holding subscription kref · 7efea60d
      Ying Xue 提交于
      When a new subscription object is inserted into name_seq->subscriptions
      list, it's under name_seq->lock protection; when a subscription is
      deleted from the list, it's also under the same lock protection;
      similarly, when accessing a subscription by going through subscriptions
      list, the entire process is also protected by the name_seq->lock.
      
      Therefore, if subscription refcount is increased before it's inserted
      into subscriptions list, and its refcount is decreased after it's
      deleted from the list, it will be unnecessary to hold refcount at all
      before accessing subscription object which is obtained by going through
      subscriptions list under name_seq->lock protection.
      Signed-off-by: NYing Xue <ying.xue@windriver.com>
      Reviewed-by: NJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7efea60d
  6. 25 1月, 2017 1 次提交
  7. 06 2月, 2016 2 次提交
  8. 05 5月, 2015 1 次提交
    • Y
      tipc: rename functions defined in subscr.c · 57f1d186
      Ying Xue 提交于
      When a topology server accepts a connection request from its client,
      it allocates a connection instance and a tipc_subscriber structure
      object. The former is used to communicate with client, and the latter
      is often treated as a subscriber which manages all subscription events
      requested from a same client. When a topology server receives a request
      of subscribing name services from a client through the connection, it
      creates a tipc_subscription structure instance which is seen as a
      subscription recording what name services are subscribed. In order to
      manage all subscriptions from a same client, topology server links
      them into the subscrp_list of the subscriber. So subscriber and
      subscription completely represents different meanings respectively,
      but function names associated with them make us so confused that we
      are unable to easily tell which function is against subscriber and
      which is to subscription. So we want to eliminate the confusion by
      renaming them.
      Signed-off-by: NYing Xue <ying.xue@windriver.com>
      Reviewed-by: NJon Maloy <jon.maloy@ericson.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      57f1d186
  9. 13 1月, 2015 4 次提交
  10. 18 6月, 2013 2 次提交
    • P
      tipc: cosmetic realignment of function arguments · ae8509c4
      Paul Gortmaker 提交于
      No runtime code changes here.  Just a realign of the function
      arguments to start where the 1st one was, and fit as many args
      as can be put in an 80 char line.
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ae8509c4
    • Y
      tipc: convert topology server to use new server facility · 13a2e898
      Ying Xue 提交于
      As the new TIPC server infrastructure has been introduced, we can
      now convert the TIPC topology server to it.  We get two benefits
      from doing this:
      
      1) It simplifies the topology server locking policy.  In the
      original locking policy, we placed one spin lock pointer in the
      tipc_subscriber structure to reuse the lock of the subscriber's
      server port, controlling access to members of tipc_subscriber
      instance.  That is, we only used one lock to ensure both
      tipc_port and tipc_subscriber members were safely accessed.
      
      Now we introduce another spin lock for tipc_subscriber structure
      only protecting themselves, to get a finer granularity locking
      policy.  Moreover, the change will allow us to make the topology
      server code more readable and maintainable.
      
      2) It fixes a bug where sent subscription events may be lost when
      the topology port is congested.  Using the new service, the
      topology server now queues sent events into an outgoing buffer,
      and then wakes up a sender process which has been blocked in
      workqueue context.  The process will keep picking events from the
      buffer and send them to their respective subscribers, using the
      kernel socket interface, until the buffer is empty. Even if the
      socket is congested during transmission there is no risk that
      events may be dropped, since the sender process may block when
      needed.
      
      Some minor reordering of initialization is done, since we now
      have a scenario where the topology server must be started after
      socket initialization has taken place, as the former depends
      on the latter.  And overall, we see a simplification of the
      TIPC subscriber code in making this changeover.
      Signed-off-by: NYing Xue <ying.xue@windriver.com>
      Signed-off-by: NJon Maloy <jon.maloy@ericsson.com>
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      13a2e898
  11. 01 5月, 2012 1 次提交
    • P
      tipc: compress out gratuitous extra carriage returns · 617d3c7a
      Paul Gortmaker 提交于
      Some of the comment blocks are floating in limbo between two
      functions, or between blocks of code.  Delete the extra line
      feeds between any comment and its associated following block
      of code, to be consistent with the majority of the rest of
      the kernel.  Also delete trailing newlines at EOF and fix
      a couple trivial typos in existing comments.
      
      This is a 100% cosmetic change with no runtime impact.  We get
      rid of over 500 lines of non-code, and being blank line deletes,
      they won't even show up as noise in git blame.
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      617d3c7a
  12. 30 12月, 2011 1 次提交
  13. 18 9月, 2011 1 次提交
  14. 21 10月, 2010 1 次提交
    • N
      Revert d88dca79 · db5a753b
      Neil Horman 提交于
      TIPC needs to have its endianess issues fixed.  Unfortunately, the format of a
      subscriber message is passed in directly from user space, so requiring this
      message to be in network byte order breaks user space ABI.  Revert this change
      until such time as we can determine how to do this in a backwards compatible
      manner.
      Signed-off-by: NNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      db5a753b
  15. 09 3月, 2010 1 次提交
    • N
      tipc: fix endianness on tipc subscriber messages · d88dca79
      Neil Horman 提交于
      Remove htohl implementation from tipc
      
      I was working on forward porting the downstream commits for TIPC and ran accross this one:
      http://tipc.cslab.ericsson.net/cgi-bin/gitweb.cgi?p=people/allan/tipc.git;a=commitdiff;h=894279b9437b63cbb02405ad5b8e033b51e4e31e
      
      I was going to just take it, when I looked closer and noted what it was doing.
      This is basically a routine to byte swap fields of data in sent/received packets
      for tipc, dependent upon the receivers guessed endianness of the peer when a
      connection is established.  Asside from just seeming silly to me, it appears to
      violate the latest RFC draft for tipc:
      http://tipc.sourceforge.net/doc/draft-spec-tipc-02.txt
      Which, according to section 4.2 and 4.3.3, requires that all fields of all
      commands be sent in network byte order.  So instead of just taking this patch,
      instead I'm removing the htohl function and replacing the calls with calls to
      ntohl in the rx path and htonl in the send path.
      
      As part of this fix, I'm also changing the subscr_cancel function, which
      searches the list of subscribers, using a memcmp of the entire subscriber list,
      for the entry to tear down.  unfortunately it memcmps the entire tipc_subscr
      structure which has several bits that are private to the local side, so nothing
      will ever match.  section 5.2 of the draft spec indicates the <type,upper,lower>
      tuple should uniquely identify a subscriber, so convert subscr_cancel to just
      match on those fields (properly endian swapped).
      
      I've tested this using the tipc test suite, and its passed without issue.
      Signed-off-by: NNeil Horman <nhorman@tuxdriver.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d88dca79
  16. 20 5月, 2008 4 次提交
  17. 11 2月, 2007 1 次提交
  18. 18 1月, 2006 1 次提交
  19. 13 1月, 2006 3 次提交