tipc: Add routines for safe checking of node's network address
Introduces routines that test whether a given network address is equal to a node's own network address or if it lies within the node's own network cluster, and which work properly regardless of whether the node is using the default network address <0.0.0> or a non-zero network address that is assigned later on. In essence, these routines ensure that address <0.0.0> is treated as an alias for "this node", regardless of which network address the node is actually using. Old users of the pre-existing more strict match in_own_cluster() have been accordingly redirected to what is now called in_own_cluster_exact() --- which does not extend matching to <0,0,0>. Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
This commit is contained in:

committed by
Paul Gortmaker

parent
fd6eced8a4
commit
336ebf5bf5
@@ -50,11 +50,29 @@ static inline u32 tipc_cluster_mask(u32 addr)
|
||||
return addr & TIPC_CLUSTER_MASK;
|
||||
}
|
||||
|
||||
static inline int in_own_cluster(u32 addr)
|
||||
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
|
||||
*
|
||||
|
Reference in New Issue
Block a user