tipc: simplify include dependencies

When we try to add new inline functions in the code, we sometimes
run into circular include dependencies.

The main problem is that the file core.h, which really should be at
the root of the dependency chain, instead is a leaf. I.e., core.h
includes a number of header files that themselves should be allowed
to include core.h. In reality this is unnecessary, because core.h does
not need to know the full signature of any of the structs it refers to,
only their type declaration.

In this commit, we remove all dependencies from core.h towards any
other tipc header file.

As a consequence of this change, we can now move the function
tipc_own_addr(net) from addr.c to addr.h, and make it inline.

There are no functional changes in this commit.

Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jon Paul Maloy 2015-05-14 10:46:13 -04:00 committed by David S. Miller
parent 75b44b018e
commit a6bf70f792
8 changed files with 22 additions and 17 deletions

View file

@ -38,13 +38,6 @@
#include "addr.h" #include "addr.h"
#include "core.h" #include "core.h"
u32 tipc_own_addr(struct net *net)
{
struct tipc_net *tn = net_generic(net, tipc_net_id);
return tn->own_addr;
}
/** /**
* in_own_cluster - test for cluster inclusion; <0.0.0> always matches * in_own_cluster - test for cluster inclusion; <0.0.0> always matches
*/ */

View file

@ -41,10 +41,18 @@
#include <linux/tipc.h> #include <linux/tipc.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <net/netns/generic.h> #include <net/netns/generic.h>
#include "core.h"
#define TIPC_ZONE_MASK 0xff000000u #define TIPC_ZONE_MASK 0xff000000u
#define TIPC_CLUSTER_MASK 0xfffff000u #define TIPC_CLUSTER_MASK 0xfffff000u
static inline u32 tipc_own_addr(struct net *net)
{
struct tipc_net *tn = net_generic(net, tipc_net_id);
return tn->own_addr;
}
static inline u32 tipc_zone_mask(u32 addr) static inline u32 tipc_zone_mask(u32 addr)
{ {
return addr & TIPC_ZONE_MASK; return addr & TIPC_ZONE_MASK;

View file

@ -38,9 +38,9 @@
#define _TIPC_BEARER_H #define _TIPC_BEARER_H
#include "netlink.h" #include "netlink.h"
#include "core.h"
#include <net/genetlink.h> #include <net/genetlink.h>
#define MAX_BEARERS 2
#define MAX_MEDIA 3 #define MAX_MEDIA 3
#define MAX_NODES 4096 #define MAX_NODES 4096
#define WSIZE 32 #define WSIZE 32

View file

@ -60,16 +60,19 @@
#include <net/netns/generic.h> #include <net/netns/generic.h>
#include <linux/rhashtable.h> #include <linux/rhashtable.h>
#include "node.h" struct tipc_node;
#include "bearer.h" struct tipc_bearer;
#include "bcast.h" struct tipc_bcbearer;
#include "netlink.h" struct tipc_bclink;
#include "link.h" struct tipc_link;
#include "node.h" struct tipc_name_table;
#include "msg.h" struct tipc_server;
#define TIPC_MOD_VER "2.0.0" #define TIPC_MOD_VER "2.0.0"
#define NODE_HTABLE_SIZE 512
#define MAX_BEARERS 3
extern int tipc_net_id __read_mostly; extern int tipc_net_id __read_mostly;
extern int sysctl_tipc_rmem[3] __read_mostly; extern int sysctl_tipc_rmem[3] __read_mostly;
extern int sysctl_tipc_named_timeout __read_mostly; extern int sysctl_tipc_named_timeout __read_mostly;

View file

@ -40,6 +40,7 @@
#include "subscr.h" #include "subscr.h"
#include "socket.h" #include "socket.h"
#include "node.h" #include "node.h"
#include "bcast.h"
static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = { static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = {
[TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC }, [TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC },

View file

@ -39,6 +39,7 @@
#include "node.h" #include "node.h"
#include "name_distr.h" #include "name_distr.h"
#include "socket.h" #include "socket.h"
#include "bcast.h"
static void node_lost_contact(struct tipc_node *n_ptr); static void node_lost_contact(struct tipc_node *n_ptr);
static void node_established_contact(struct tipc_node *n_ptr); static void node_established_contact(struct tipc_node *n_ptr);

View file

@ -45,8 +45,6 @@
/* Out-of-range value for node signature */ /* Out-of-range value for node signature */
#define INVALID_NODE_SIG 0x10000 #define INVALID_NODE_SIG 0x10000
#define NODE_HTABLE_SIZE 512
/* Flags used to take different actions according to flag type /* Flags used to take different actions according to flag type
* TIPC_WAIT_PEER_LINKS_DOWN: wait to see that peer's links are down * TIPC_WAIT_PEER_LINKS_DOWN: wait to see that peer's links are down
* TIPC_WAIT_OWN_LINKS_DOWN: wait until peer node is declared down * TIPC_WAIT_OWN_LINKS_DOWN: wait until peer node is declared down

View file

@ -41,6 +41,7 @@
#include "link.h" #include "link.h"
#include "name_distr.h" #include "name_distr.h"
#include "socket.h" #include "socket.h"
#include "bcast.h"
#define SS_LISTENING -1 /* socket is listening */ #define SS_LISTENING -1 /* socket is listening */
#define SS_READY -2 /* socket is connectionless */ #define SS_READY -2 /* socket is connectionless */