Skip to content

Commit

Permalink
Merge branch 'tipc-namespaces'
Browse files Browse the repository at this point in the history
Ying Xue says:

====================
tipc: make tipc support namespace

This patchset aims to add net namespace support for TIPC stack.

Currently TIPC module declares the following global resources:
- TIPC network idenfication number
- TIPC node table
- TIPC bearer list table
- TIPC broadcast link
- TIPC socket reference table
- TIPC name service table
- TIPC node address
- TIPC service subscriber server
- TIPC random value
- TIPC netlink

In order that TIPC is aware of namespace, above each resource must be
allocated, initialized and destroyed inside per namespace. Therefore,
the major works of this patchset are to isolate these global resources
and make them private for each namespace. However, before these changes
come true, some necessary preparation works must be first done: convert
socket reference table with generic rhashtable, cleanup core.c and
core.h files, remove unnecessary wrapper functions for kernel timer
interfaces and so on.

It should be noted that commit ##1 ("tipc: fix bug in broadcast
retransmit code") was already submitted to 'net' tree, so please see
below link:

http://patchwork.ozlabs.org/patch/426717/

Since it is prerequisite for the rest of the series to apply, I
prepend them to the series.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jan 12, 2015
2 parents 45e8183 + d49e204 commit d9fbfb9
Show file tree
Hide file tree
Showing 32 changed files with 1,503 additions and 1,277 deletions.
45 changes: 44 additions & 1 deletion net/tipc/addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,51 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#include "core.h"
#include <linux/kernel.h>
#include "addr.h"
#include "core.h"

/**
* in_own_cluster - test for cluster inclusion; <0.0.0> always matches
*/
int in_own_cluster(struct net *net, u32 addr)
{
return in_own_cluster_exact(net, addr) || !addr;
}

int in_own_cluster_exact(struct net *net, u32 addr)
{
struct tipc_net *tn = net_generic(net, tipc_net_id);

return !((addr ^ tn->own_addr) >> 12);
}

/**
* in_own_node - test for node inclusion; <0.0.0> always matches
*/
int in_own_node(struct net *net, u32 addr)
{
struct tipc_net *tn = net_generic(net, tipc_net_id);

return (addr == tn->own_addr) || !addr;
}

/**
* addr_domain - convert 2-bit scope value to equivalent message lookup domain
*
* Needed when address of a named message must be looked up a second time
* after a network hop.
*/
u32 addr_domain(struct net *net, u32 sc)
{
struct tipc_net *tn = net_generic(net, tipc_net_id);

if (likely(sc == TIPC_NODE_SCOPE))
return tn->own_addr;
if (sc == TIPC_CLUSTER_SCOPE)
return tipc_cluster_mask(tn->own_addr);
return tipc_zone_mask(tn->own_addr);
}

/**
* tipc_addr_domain_valid - validates a network domain address
Expand Down
45 changes: 8 additions & 37 deletions net/tipc/addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
#ifndef _TIPC_ADDR_H
#define _TIPC_ADDR_H

#include "core.h"
#include <linux/types.h>
#include <linux/tipc.h>
#include <net/net_namespace.h>
#include <net/netns/generic.h>

#define TIPC_ZONE_MASK 0xff000000u
#define TIPC_CLUSTER_MASK 0xfffff000u
Expand All @@ -52,42 +55,10 @@ static inline u32 tipc_cluster_mask(u32 addr)
return addr & TIPC_CLUSTER_MASK;
}

static inline int in_own_cluster_exact(u32 addr)
{
return !((addr ^ tipc_own_addr) >> 12);
}

/**
* in_own_node - test for node inclusion; <0.0.0> always matches
*/
static inline int in_own_node(u32 addr)
{
return (addr == tipc_own_addr) || !addr;
}

/**
* in_own_cluster - test for cluster inclusion; <0.0.0> always matches
*/
static inline int in_own_cluster(u32 addr)
{
return in_own_cluster_exact(addr) || !addr;
}

/**
* addr_domain - convert 2-bit scope value to equivalent message lookup domain
*
* Needed when address of a named message must be looked up a second time
* after a network hop.
*/
static inline u32 addr_domain(u32 sc)
{
if (likely(sc == TIPC_NODE_SCOPE))
return tipc_own_addr;
if (sc == TIPC_CLUSTER_SCOPE)
return tipc_cluster_mask(tipc_own_addr);
return tipc_zone_mask(tipc_own_addr);
}

int in_own_cluster(struct net *net, u32 addr);
int in_own_cluster_exact(struct net *net, u32 addr);
int in_own_node(struct net *net, u32 addr);
u32 addr_domain(struct net *net, u32 sc);
int tipc_addr_domain_valid(u32);
int tipc_addr_node_valid(u32 addr);
int tipc_in_scope(u32 domain, u32 addr);
Expand Down
Loading

0 comments on commit d9fbfb9

Please sign in to comment.