21 May, 2019

1 commit

  • 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: Junwei Hu
    Reported-by: Wang Wang
    Reported-by: syzbot+1e8114b61079bfe9cbc5@syzkaller.appspotmail.com
    Reviewed-by: Kang Zhou
    Reviewed-by: Suanming Mou
    Signed-off-by: David S. Miller

    Junwei Hu
     

01 Apr, 2018

1 commit

  • 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: Jon Maloy
    Signed-off-by: David S. Miller

    Jon Maloy
     

17 Feb, 2018

8 commits

  • 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: Ying.Xue
    Signed-off-by: Jon Maloy
    Signed-off-by: David S. Miller

    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: Ying Xue
    Signed-off-by: Jon Maloy
    Signed-off-by: David S. Miller

    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: Ying Xue
    Signed-off-by: Jon Maloy
    Signed-off-by: David S. Miller

    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: Ying Xue
    Signed-off-by: Jon Maloy
    Signed-off-by: David S. Miller

    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: Ying Xue
    Signed-off-by: Jon Maloy
    Signed-off-by: David S. Miller

    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: Ying Xue
    Signed-off-by: Jon Maloy
    Signed-off-by: David S. Miller

    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: Ying Xue
    Signed-off-by: Jon Maloy
    Signed-off-by: David S. Miller

    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: Ying Xue
    Signed-off-by: Jon Maloy
    Signed-off-by: David S. Miller

    Jon Maloy
     

10 Jan, 2018

1 commit

  • 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: Ying Xue
    Signed-off-by: Jon Maloy
    Signed-off-by: David S. Miller

    Jon Maloy
     

29 Mar, 2017

1 commit

  • 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: Ying Xue
    Reviewed-by: Jon Maloy
    Signed-off-by: David S. Miller

    Ying Xue
     

25 Jan, 2017

1 commit

  • Until now, the subscribers keep track of the subscriptions using
    reference count at subscriber level. At subscription cancel or
    subscriber delete, we delete the subscription only if the timer
    was pending for the subscription. This approach is incorrect as:
    1. del_timer() is not SMP safe, if on CPU0 the check for pending
    timer returns true but CPU1 might schedule the timer callback
    thereby deleting the subscription. Thus when CPU0 is scheduled,
    it deletes an invalid subscription.
    2. We export tipc_subscrp_report_overlap(), which accesses the
    subscription pointer multiple times. Meanwhile the subscription
    timer can expire thereby freeing the subscription and we might
    continue to access the subscription pointer leading to memory
    violations.

    In this commit, we introduce subscription refcount to avoid deleting
    an invalid subscription.

    Reported-and-Tested-by: John Thompson
    Acked-by: Ying Xue
    Acked-by: Jon Maloy
    Signed-off-by: Parthasarathy Bhuvaragan
    Signed-off-by: David S. Miller

    Parthasarathy Bhuvaragan
     

06 Feb, 2016

2 commits

  • Until now, struct tipc_subscriber has duplicate fields for
    type, upper and lower (as member of struct tipc_name_seq) at:
    1. as member seq in struct tipc_subscription
    2. as member seq in struct tipc_subscr, which is contained
    in struct tipc_event
    The former structure contains the type, upper and lower
    values in network byte order and the later contains the
    intact copy of the request.
    The struct tipc_subscription contains a field swap to
    determine if request needs network byte order conversion.
    Thus by using swap, we can convert the request when
    required instead of duplicating it.

    In this commit,
    1. we remove the references to these elements as members of
    struct tipc_subscription and replace them with elements
    from struct tipc_subscr.
    2. provide new functions to convert the user request into
    network byte order.

    Acked-by: Ying Xue
    Reviewed-by: Jon Maloy
    Signed-off-by: Parthasarathy Bhuvaragan
    Signed-off-by: David S. Miller

    Parthasarathy Bhuvaragan
     
  • Until now, struct tipc_subscription has duplicate timeout and filter
    attributes present:
    1. directly as members of struct tipc_subscription
    2. in struct tipc_subscr, which is contained in struct tipc_event

    In this commit, we remove the references to these elements as
    members of struct tipc_subscription and replace them with elements
    from struct tipc_subscr.

    Acked-by: Ying Xue
    Reviewed-by: Jon Maloy
    Signed-off-by: Parthasarathy Bhuvaragan
    Signed-off-by: David S. Miller

    Parthasarathy Bhuvaragan
     

05 May, 2015

1 commit

  • 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: Ying Xue
    Reviewed-by: Jon Maloy
    Signed-off-by: David S. Miller

    Ying Xue
     

13 Jan, 2015

4 commits

  • TIPC establishes one subscriber server which allows users to subscribe
    their interesting name service status. After tipc supports namespace,
    one dedicated tipc stack instance is created for each namespace, and
    each instance can be deemed as one independent TIPC node. As a result,
    subscriber server must be built for each namespace.

    Signed-off-by: Ying Xue
    Tested-by: Tero Aho
    Reviewed-by: Jon Maloy
    Signed-off-by: David S. Miller

    Ying Xue
     
  • TIPC name table is used to store the mapping relationship between
    TIPC service name and socket port ID. When tipc supports namespace,
    it allows users to publish service names only owned by a certain
    namespace. Therefore, every namespace must have its private name
    table to prevent service names published to one namespace from being
    contaminated by other service names in another namespace. Therefore,
    The name table global variable (ie, nametbl) and its lock must be
    moved to tipc_net structure, and a parameter of namespace must be
    added for necessary functions so that they can obtain name table
    variable defined in tipc_net structure.

    Signed-off-by: Ying Xue
    Tested-by: Tero Aho
    Reviewed-by: Jon Maloy
    Signed-off-by: David S. Miller

    Ying Xue
     
  • Only the works of initializing and shutting down tipc module are done
    in core.h and core.c files, so all stuffs which are not closely
    associated with the two tasks should be moved to appropriate places.

    Signed-off-by: Ying Xue
    Tested-by: Tero Aho
    Reviewed-by: Jon Maloy
    Signed-off-by: David S. Miller

    Ying Xue
     
  • Not only some wrapper function like k_term_timer() is empty, but also
    some others including k_start_timer() and k_cancel_timer() don't return
    back any value to its caller, what's more, there is no any component
    in the kernel world to do such thing. Therefore, these timer interfaces
    defined in tipc module should be purged.

    Signed-off-by: Ying Xue
    Tested-by: Tero Aho
    Reviewed-by: Jon Maloy
    Signed-off-by: David S. Miller

    Ying Xue
     

18 Jun, 2013

2 commits

  • 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: Paul Gortmaker
    Signed-off-by: David S. Miller

    Paul Gortmaker
     
  • 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: Ying Xue
    Signed-off-by: Jon Maloy
    Signed-off-by: Paul Gortmaker
    Signed-off-by: David S. Miller

    Ying Xue
     

01 May, 2012

1 commit

  • 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: Paul Gortmaker

    Paul Gortmaker
     

30 Dec, 2011

1 commit


18 Sep, 2011

1 commit


21 Oct, 2010

1 commit

  • 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: Neil Horman
    Signed-off-by: David S. Miller

    Neil Horman
     

09 Mar, 2010

1 commit

  • 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
    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: Neil Horman
    Signed-off-by: David S. Miller

    Neil Horman
     

20 May, 2008

4 commits

  • This patch contains a set of cosmetic changes to TIPC's network
    topology service subsystem, including:

    - updates to comments (including copyright dates)
    - re-ordering structure fields to group them more logically
    - removal of optional debugging code that is no longer required
    - minor changes to whitespace to conform to Linux coding conventions

    Signed-off-by: Allan Stephens
    Signed-off-by: David S. Miller

    Allan Stephens
     
  • This patch modifies TIPC's network topology service so that it
    only requires a single reference table entry per subscriber
    connection, rather than two. This is achieved by letting the
    reference to the server port communicating with the subscriber
    act as the reference to the subscriber object itself. (Since
    the subscriber cannot exist without its port, and vice versa,
    this dual role for the reference is perfectly natural.) This
    consolidation reduces the size of the reference table by 50%
    in the default configuration.

    Signed-off-by: Allan Stephens
    Signed-off-by: David S. Miller

    Allan Stephens
     
  • This patch enables TIPC's topology server code to do customized
    endianness conversions on a per-subscription basis. (This
    capability is needed to support the upcoming consolidation of
    subscriber and subscription object references.)

    Signed-off-by: Allan Stephens
    Signed-off-by: David S. Miller

    Allan Stephens
     
  • This patch enables TIPC's topology server code to do customized
    overlap detection handling on a per-subscription basis. (This
    capability is needed to support the upcoming introduction of
    multi-cluster TIPC networks.)

    Signed-off-by: Allan Stephens
    Signed-off-by: David S. Miller

    Allan Stephens
     

11 Feb, 2007

1 commit


18 Jan, 2006

1 commit


13 Jan, 2006

3 commits