diff options
author | Ying Xue <ying.xue@windriver.com> | 2015-01-09 02:27:10 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-01-12 16:24:33 -0500 |
commit | 347475395434abb2b61bf59c2952470f37072567 (patch) | |
tree | 71a5f63547edecee31f557d0bacbf993b953a099 /net/tipc/addr.h | |
parent | 4ac1c8d0ee9faf3a4be185cc4db1381fa0d81280 (diff) |
tipc: make tipc node address support net namespace
If net namespace is supported in tipc, each namespace will be treated
as a separate tipc node. Therefore, every namespace must own its
private tipc node address. This means the "tipc_own_addr" global
variable of node address must be moved to tipc_net structure to
satisfy the requirement. It's turned out that users also can assign
node address for every namespace.
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Tested-by: Tero Aho <Tero.Aho@coriant.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/addr.h')
-rw-r--r-- | net/tipc/addr.h | 44 |
1 files changed, 6 insertions, 38 deletions
diff --git a/net/tipc/addr.h b/net/tipc/addr.h index 4e364c4f1359..c700c2d28e09 100644 --- a/net/tipc/addr.h +++ b/net/tipc/addr.h | |||
@@ -39,12 +39,12 @@ | |||
39 | 39 | ||
40 | #include <linux/types.h> | 40 | #include <linux/types.h> |
41 | #include <linux/tipc.h> | 41 | #include <linux/tipc.h> |
42 | #include <net/net_namespace.h> | ||
43 | #include <net/netns/generic.h> | ||
42 | 44 | ||
43 | #define TIPC_ZONE_MASK 0xff000000u | 45 | #define TIPC_ZONE_MASK 0xff000000u |
44 | #define TIPC_CLUSTER_MASK 0xfffff000u | 46 | #define TIPC_CLUSTER_MASK 0xfffff000u |
45 | 47 | ||
46 | extern u32 tipc_own_addr __read_mostly; | ||
47 | |||
48 | static inline u32 tipc_zone_mask(u32 addr) | 48 | static inline u32 tipc_zone_mask(u32 addr) |
49 | { | 49 | { |
50 | return addr & TIPC_ZONE_MASK; | 50 | return addr & TIPC_ZONE_MASK; |
@@ -55,42 +55,10 @@ static inline u32 tipc_cluster_mask(u32 addr) | |||
55 | return addr & TIPC_CLUSTER_MASK; | 55 | return addr & TIPC_CLUSTER_MASK; |
56 | } | 56 | } |
57 | 57 | ||
58 | static inline int in_own_cluster_exact(u32 addr) | 58 | int in_own_cluster(struct net *net, u32 addr); |
59 | { | 59 | int in_own_cluster_exact(struct net *net, u32 addr); |
60 | return !((addr ^ tipc_own_addr) >> 12); | 60 | int in_own_node(struct net *net, u32 addr); |
61 | } | 61 | u32 addr_domain(struct net *net, u32 sc); |
62 | |||
63 | /** | ||
64 | * in_own_node - test for node inclusion; <0.0.0> always matches | ||
65 | */ | ||
66 | static inline int in_own_node(u32 addr) | ||
67 | { | ||
68 | return (addr == tipc_own_addr) || !addr; | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * in_own_cluster - test for cluster inclusion; <0.0.0> always matches | ||
73 | */ | ||
74 | static inline int in_own_cluster(u32 addr) | ||
75 | { | ||
76 | return in_own_cluster_exact(addr) || !addr; | ||
77 | } | ||
78 | |||
79 | /** | ||
80 | * addr_domain - convert 2-bit scope value to equivalent message lookup domain | ||
81 | * | ||
82 | * Needed when address of a named message must be looked up a second time | ||
83 | * after a network hop. | ||
84 | */ | ||
85 | static inline u32 addr_domain(u32 sc) | ||
86 | { | ||
87 | if (likely(sc == TIPC_NODE_SCOPE)) | ||
88 | return tipc_own_addr; | ||
89 | if (sc == TIPC_CLUSTER_SCOPE) | ||
90 | return tipc_cluster_mask(tipc_own_addr); | ||
91 | return tipc_zone_mask(tipc_own_addr); | ||
92 | } | ||
93 | |||
94 | int tipc_addr_domain_valid(u32); | 62 | int tipc_addr_domain_valid(u32); |
95 | int tipc_addr_node_valid(u32 addr); | 63 | int tipc_addr_node_valid(u32 addr); |
96 | int tipc_in_scope(u32 domain, u32 addr); | 64 | int tipc_in_scope(u32 domain, u32 addr); |