29 Apr, 2018

1 commit

  • [ Upstream commit ec518f21cb1a1b1f8a516499ea05c60299e04963 ]

    Before syzbot/KMSAN bites, add the missing policy for TIPC_NLA_NET_ADDR

    Fixes: 27c21416727a ("tipc: add net set to new netlink api")
    Signed-off-by: Eric Dumazet
    Cc: Jon Maloy
    Cc: Ying Xue
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Eric Dumazet
     

14 Apr, 2017

1 commit


28 Oct, 2016

4 commits

  • Now genl_register_family() is the only thing (other than the
    users themselves, perhaps, but I didn't find any doing that)
    writing to the family struct.

    In all families that I found, genl_register_family() is only
    called from __init functions (some indirectly, in which case
    I've add __init annotations to clarifly things), so all can
    actually be marked __ro_after_init.

    This protects the data structure from accidental corruption.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • Instead of providing macros/inline functions to initialize
    the families, make all users initialize them statically and
    get rid of the macros.

    This reduces the kernel code size by about 1.6k on x86-64
    (with allyesconfig).

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • Static family IDs have never really been used, the only
    use case was the workaround I introduced for those users
    that assumed their family ID was also their multicast
    group ID.

    Additionally, because static family IDs would never be
    reserved by the generic netlink code, using a relatively
    low ID would only work for built-in families that can be
    registered immediately after generic netlink is started,
    which is basically only the control family (apart from
    the workaround code, which I also had to add code for so
    it would reserve those IDs)

    Thus, anything other than GENL_ID_GENERATE is flawed and
    luckily not used except in the cases I mentioned. Move
    those workarounds into a few lines of code, and then get
    rid of GENL_ID_GENERATE entirely, making it more robust.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • This helper function allows family implementations to access
    their family's attrbuf. This gets rid of the attrbuf usage
    in families, and also adds locking validation, since it's not
    valid to use the attrbuf with parallel_ops or outside of the
    dumpit callback.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

27 Aug, 2016

2 commits

  • When using replicast a UDP bearer can have an arbitrary amount of
    remote ip addresses associated with it. This means we cannot simply
    add all remote ip addresses to an existing bearer data message as it
    might fill the message, leaving us with a truncated message that we
    can't safely resume. To handle this we introduce the new netlink
    command TIPC_NL_UDP_GET_REMOTEIP. This command is intended to be
    called when the bearer data message has the
    TIPC_NLA_UDP_MULTI_REMOTEIP flag set, indicating there are more than
    one remote ip (replicast).

    Signed-off-by: Richard Alpe
    Reviewed-by: Jon Maloy
    Signed-off-by: David S. Miller

    Richard Alpe
     
  • This patch introduces UDP replicast. A concept where we emulate
    multicast by sending multiple unicast messages to configured peers.

    The purpose of replicast is mainly to be able to use TIPC in cloud
    environments where IP multicast is disabled. Using replicas to unicast
    multicast messages is costly as we have to copy each skb and send the
    copies individually.

    Signed-off-by: Richard Alpe
    Reviewed-by: Jon Maloy
    Signed-off-by: David S. Miller

    Richard Alpe
     

19 Aug, 2016

1 commit

  • Add TIPC_NL_PEER_REMOVE netlink command. This command can remove
    an offline peer node from the internal data structures.

    This will be supported by the tipc user space tool in iproute2.

    Signed-off-by: Richard Alpe
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     

27 Jul, 2016

3 commits


08 Mar, 2016

1 commit


21 Nov, 2015

2 commits

  • We move the definition of struct tipc_link from link.h to link.c in
    order to minimize its exposure to the rest of the code.

    When needed, we define new functions to make it possible for external
    entities to access and set data in the link.

    Apart from the above, there are no functional changes.

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

    Jon Paul Maloy
     
  • In our effort to have less code and include dependencies between
    entities such as node, link and bearer, we try to narrow down
    the exposed interface towards the node as much as possible.

    In this commit, we move the definition of struct tipc_node, along
    with many of its associated function declarations, from node.h to
    node.c. We also move some function definitions from link.c and
    name_distr.c to node.c, since they access fields in struct tipc_node
    that should not be externally visible. The moved functions are renamed
    according to new location, and made static whenever possible.

    There are no functional changes in this commit.

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

    Jon Paul Maloy
     

10 Feb, 2015

1 commit

  • The new netlink API is no longer "v2" but rather the standard API and
    the legacy API is now "nl compat". We split them into separate
    start/stop and put them in different files in order to further
    distinguish them.

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Ying Xue
    Reviewed-by: Jon Maloy
    Signed-off-by: David S. Miller

    Richard Alpe
     

13 Jan, 2015

2 commits

  • Currently tipc module only allows users sitting on "init_net" namespace
    to configure it through netlink interface. But now almost each tipc
    component is able to be aware of net namespace, so it's time to open
    the permission for users residing in other namespaces, allowing them
    to configure their own tipc stack instance through netlink interface.

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

    Ying Xue
     
  • Involve namespace infrastructure, make the "tipc_net_id" global
    variable aware of per namespace, and rename it to "net_id". In
    order that the conversion can be successfully done, an instance
    of networking namespace must be passed to relevant functions,
    allowing them to access the "net_id" variable of per namespace.

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

    Ying Xue
     

22 Nov, 2014

14 commits

  • Add TIPC_NL_NAME_TABLE_GET command to the new tipc netlink API.

    This command supports dumping the name table of all nodes.

    Netlink logical layout of name table response message:
    -> name table
    -> publication
    -> type
    -> lower
    -> upper
    -> scope
    -> node
    -> ref
    -> key

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     
  • Add TIPC_NL_NET_SET command to the new tipc netlink API.

    This command can set the network id and network (tipc) address.

    Netlink logical layout of network set message:
    -> net
    [ -> id ]
    [ -> address ]

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     
  • Add TIPC_NL_NET_GET command to the new tipc netlink API.

    This command dumps the network id of the node.

    Netlink logical layout of returned network data:
    -> net
    -> id

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     
  • Add TIPC_NL_NODE_GET to the new tipc netlink API.

    This command can dump the address and node status of all nodes in the
    tipc cluster.

    Netlink logical layout of returned node/address data:
    -> node
    -> address
    -> up flag

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     
  • Add TIPC_NL_MEDIA_SET command to the new tipc netlink API.

    This command can set one or more link properties for a particular
    media.

    Netlink logical layout of bearer set message:
    -> media
    -> name
    -> link properties
    [ -> tolerance ]
    [ -> priority ]
    [ -> window ]

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     
  • Add TIPC_NL_MEDIA_GET command to the new tipc netlink API.

    This command supports dumping all information about all defined
    media as well as getting all information about a specific media.

    The information about a media includes name and link properties.

    Netlink logical layout of media get response message:
    -> media
    -> name
    -> link properties
    -> tolerance
    -> priority
    -> window

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     
  • Add TIPC_NL_LINK_RESET_STATS command to the new netlink API.

    This command resets the link statistics for a particular link.

    Netlink logical layout of link reset message:
    -> link
    -> name

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     
  • Add TIPC_NL_LINK_SET to the new tipc netlink API.

    This command can set one or more link properties for a particular
    link.

    Netlink logical layout of link set message:
    -> link
    -> name
    -> properties
    [ -> tolerance ]
    [ -> priority ]
    [ -> window ]

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     
  • Add TIPC_NL_LINK_GET command to the new tipc netlink API.

    This command supports dumping all information about all links
    (including the broadcast link) or getting all information about a
    specific link (not the broadcast link).

    The information about a link includes name, transmission info,
    properties and link statistics.

    As the tipc broadcast link is special we unfortunately have to treat
    it specially. It is a deliberate decision not to abstract the
    broadcast link on this (API) level.

    Netlink logical layout of link response message:
    -> port
    -> name
    -> MTU
    -> RX
    -> TX
    -> up flag
    -> active flag
    -> properties
    -> priority
    -> tolerance
    -> window
    -> statistics
    -> rx_info
    -> rx_fragments
    -> rx_fragmented
    -> rx_bundles
    -> rx_bundled
    -> tx_info
    -> tx_fragments
    -> tx_fragmented
    -> tx_bundles
    -> tx_bundled
    -> msg_prof_tot
    -> msg_len_cnt
    -> msg_len_tot
    -> msg_len_p0
    -> msg_len_p1
    -> msg_len_p2
    -> msg_len_p3
    -> msg_len_p4
    -> msg_len_p5
    -> msg_len_p6
    -> rx_states
    -> rx_probes
    -> rx_nacks
    -> rx_deferred
    -> tx_states
    -> tx_probes
    -> tx_nacks
    -> tx_acks
    -> retransmitted
    -> duplicates
    -> link_congs
    -> max_queue
    -> avg_queue

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     
  • Add TIPC_NL_PUBL_GET command to the new tipc netlink API.

    This command supports dumping of all publications for a specific
    socket.

    Netlink logical layout of request message:
    -> socket
    -> reference

    Netlink logical layout of response message:
    -> publication
    -> type
    -> lower
    -> upper

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     
  • Add TIPC_NL_SOCK_GET command to the new tipc netlink API.

    This command supports dumping of all available sockets with their
    associated connection or publication(s). It could be extended to reply
    with a single socket if the NLM_F_DUMP isn't set.

    The information about a socket includes reference, address, connection
    information / publication information.

    Netlink logical layout of response message:
    -> socket
    -> reference
    -> address
    [
    -> connection
    -> node
    -> socket
    [
    -> connected flag
    -> type
    -> instance
    ]
    ]
    [
    -> publication flag
    ]

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     
  • Add TIPC_NL_BEARER_SET command to the new tipc netlink API.

    This command can set one or more link properties for a particular
    bearer.

    Netlink logical layout of bearer set message:
    -> bearer
    -> name
    -> link properties
    [ -> tolerance ]
    [ -> priority ]
    [ -> window ]

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     
  • Add TIPC_NL_BEARER_GET command to the new tipc netlink API.

    This command supports dumping all data about all bearers or getting
    all information about a specific bearer.

    The information about a bearer includes name, link priorities and
    domain.

    Netlink logical layout of bearer get message:
    -> bearer
    -> name

    Netlink logical layout of returned bearer information:
    -> bearer
    -> name
    -> link properties
    -> priority
    -> tolerance
    -> window
    -> domain

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     
  • A new netlink API for tipc that can disable or enable a tipc bearer.

    The new API is separated from the old API because of a bug in the
    user space client (tipc-config). The problem is that older versions
    of tipc-config has a very low receive limit and adding commands to
    the legacy genl_opts struct causes the ctrl_getfamily() response
    message to grow, subsequently breaking the tool.

    The new API utilizes netlink policies for input validation. Where the
    top-level netlink attributes are tipc-logical entities, like bearer.
    The top level entities then contain nested attributes. In this case
    a name, nested link properties and a domain.

    Netlink commands implemented in this patch:
    TIPC_NL_BEARER_ENABLE
    TIPC_NL_BEARER_DISABLE

    Netlink logical layout of bearer enable message:
    -> bearer
    -> name
    [ -> domain ]
    [
    -> properties
    -> priority
    ]

    Netlink logical layout of bearer disable message:
    -> bearer
    -> name

    Signed-off-by: Richard Alpe
    Reviewed-by: Erik Hugne
    Reviewed-by: Jon Maloy
    Acked-by: Ying Xue
    Signed-off-by: David S. Miller

    Richard Alpe
     

25 Apr, 2014

1 commit

  • It is possible by passing a netlink socket to a more privileged
    executable and then to fool that executable into writing to the socket
    data that happens to be valid netlink message to do something that
    privileged executable did not intend to do.

    To keep this from happening replace bare capable and ns_capable calls
    with netlink_capable, netlink_net_calls and netlink_ns_capable calls.
    Which act the same as the previous calls except they verify that the
    opener of the socket had the desired permissions as well.

    Reported-by: Andy Lutomirski
    Signed-off-by: "Eric W. Biederman"
    Signed-off-by: David S. Miller

    Eric W. Biederman
     

22 Feb, 2014

1 commit

  • When tipc module is inserted, many tipc components are initialized
    one by one. During the initialization period, if one of them is
    failed, tipc_core_stop() will be called to stop all components
    whatever corresponding components are created or not. To avoid to
    release uncreated ones, relevant components have to add necessary
    enabled flags indicating whether they are created or not.

    But in the initialization stage, if one component is unsuccessfully
    created, we will just destroy successfully created components before
    the failed component instead of all components. All enabled flags
    defined in components, in turn, become redundant. Additionally it's
    also unnecessary to identify whether table.types is NULL in
    tipc_nametbl_stop() because name stable has been definitely created
    successfully when tipc_nametbl_stop() is called.

    Cc: Jon Maloy
    Cc: Erik Hugne
    Signed-off-by: Ying Xue
    Reviewed-by: Paul Gortmaker
    Signed-off-by: David S. Miller

    Ying Xue
     

20 Nov, 2013

1 commit

  • As suggested by David Miller, make genl_register_family_with_ops()
    a macro and pass only the array, evaluating ARRAY_SIZE() in the
    macro, this is a little safer.

    The openvswitch has some indirection, assing ops/n_ops directly in
    that code. This might ultimately just assign the pointers in the
    family initializations, saving the struct genl_family_and_ops and
    code (once mcast groups are handled differently.)

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

29 Mar, 2013

1 commit


11 Sep, 2012

1 commit

  • It is a frequent mistake to confuse the netlink port identifier with a
    process identifier. Try to reduce this confusion by renaming fields
    that hold port identifiers portid instead of pid.

    I have carefully avoided changing the structures exported to
    userspace to avoid changing the userspace API.

    I have successfully built an allyesconfig kernel with this change.

    Signed-off-by: "Eric W. Biederman"
    Acked-by: Stephen Hemminger
    Signed-off-by: David S. Miller

    Eric W. Biederman
     

14 Jul, 2012

1 commit

  • All messages should go directly to the kernel log. The TIPC
    specific error, warning, info and debug trace macro's are
    removed and all references replaced with pr_err, pr_warn,
    pr_info and pr_debug.

    Commonly used sub-strings are explicitly declared as a const
    char to reduce .text size.

    Note that this means the debug messages (changed to pr_debug),
    are now enabled through dynamic debugging, instead of a TIPC
    specific Kconfig option (TIPC_DEBUG). The latter will be
    phased out completely

    Signed-off-by: Erik Hugne
    Signed-off-by: Jon Maloy
    [PG: use pr_fmt as suggested by Joe Perches ]
    Signed-off-by: Paul Gortmaker

    Erik Hugne
     

13 Jul, 2009

1 commit

  • This makes generic netlink network namespace aware. No
    generic netlink families except for the controller family
    are made namespace aware, they need to be checked one by
    one and then set the family->netnsok member to true.

    A new function genlmsg_multicast_netns() is introduced to
    allow sending a multicast message in a given namespace,
    for example when it applies to an object that lives in
    that namespace, a new function genlmsg_multicast_allns()
    to send a message to all network namespaces (for objects
    that do not have an associated netns).

    The function genlmsg_multicast() is changed to multicast
    the message in just init_net, which is currently correct
    for all generic netlink families since they only work in
    init_net right now. Some will later want to work in all
    net namespaces because they do not care about the netns
    at all -- those will have to be converted to use one of
    the new functions genlmsg_multicast_allns() or
    genlmsg_multicast_netns() whenever they are made netns
    aware in some way.

    After this patch families can easily decide whether or
    not they should be available in all net namespaces. Many
    genl families us it for objects not related to networking
    and should therefore be available in all namespaces, but
    that will have to be done on a per family basis.

    Note that this doesn't touch on the checkpoint/restart
    problem where network namespaces could be used, genl
    families and multicast groups are numbered globally and
    I see no easy way of changing that, especially since it
    must be possible to multicast to all network namespaces
    for those families that do not care about netns.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

22 May, 2009

1 commit