Skip to content

Commit a6bf70f

Browse files
Jon Paul Maloydavem330
authored andcommitted
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>
1 parent 75b44b0 commit a6bf70f

8 files changed

Lines changed: 22 additions & 17 deletions

File tree

‎net/tipc/addr.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@
3838
#include "addr.h"
3939
#include "core.h"
4040

41-
u32 tipc_own_addr(struct net *net)
42-
{
43-
struct tipc_net *tn = net_generic(net, tipc_net_id);
44-
45-
return tn->own_addr;
46-
}
47-
4841
/**
4942
* in_own_cluster - test for cluster inclusion; <0.0.0> always matches
5043
*/

‎net/tipc/addr.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,18 @@
4141
#include <linux/tipc.h>
4242
#include <net/net_namespace.h>
4343
#include <net/netns/generic.h>
44+
#include "core.h"
4445

4546
#define TIPC_ZONE_MASK 0xff000000u
4647
#define TIPC_CLUSTER_MASK 0xfffff000u
4748

49+
static inline u32 tipc_own_addr(struct net *net)
50+
{
51+
struct tipc_net *tn = net_generic(net, tipc_net_id);
52+
53+
return tn->own_addr;
54+
}
55+
4856
static inline u32 tipc_zone_mask(u32 addr)
4957
{
5058
return addr & TIPC_ZONE_MASK;

‎net/tipc/bearer.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
#define _TIPC_BEARER_H
3939

4040
#include "netlink.h"
41+
#include "core.h"
4142
#include <net/genetlink.h>
4243

43-
#define MAX_BEARERS 2
4444
#define MAX_MEDIA 3
4545
#define MAX_NODES 4096
4646
#define WSIZE 32

‎net/tipc/core.h‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,19 @@
6060
#include <net/netns/generic.h>
6161
#include <linux/rhashtable.h>
6262

63-
#include "node.h"
64-
#include "bearer.h"
65-
#include "bcast.h"
66-
#include "netlink.h"
67-
#include "link.h"
68-
#include "node.h"
69-
#include "msg.h"
63+
struct tipc_node;
64+
struct tipc_bearer;
65+
struct tipc_bcbearer;
66+
struct tipc_bclink;
67+
struct tipc_link;
68+
struct tipc_name_table;
69+
struct tipc_server;
7070

7171
#define TIPC_MOD_VER "2.0.0"
7272

73+
#define NODE_HTABLE_SIZE 512
74+
#define MAX_BEARERS 3
75+
7376
extern int tipc_net_id __read_mostly;
7477
extern int sysctl_tipc_rmem[3] __read_mostly;
7578
extern int sysctl_tipc_named_timeout __read_mostly;

‎net/tipc/net.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "subscr.h"
4141
#include "socket.h"
4242
#include "node.h"
43+
#include "bcast.h"
4344

4445
static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = {
4546
[TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC },

‎net/tipc/node.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "node.h"
4040
#include "name_distr.h"
4141
#include "socket.h"
42+
#include "bcast.h"
4243

4344
static void node_lost_contact(struct tipc_node *n_ptr);
4445
static void node_established_contact(struct tipc_node *n_ptr);

‎net/tipc/node.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
/* Out-of-range value for node signature */
4646
#define INVALID_NODE_SIG 0x10000
4747

48-
#define NODE_HTABLE_SIZE 512
49-
5048
/* Flags used to take different actions according to flag type
5149
* TIPC_WAIT_PEER_LINKS_DOWN: wait to see that peer's links are down
5250
* TIPC_WAIT_OWN_LINKS_DOWN: wait until peer node is declared down

‎net/tipc/socket.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include "link.h"
4242
#include "name_distr.h"
4343
#include "socket.h"
44+
#include "bcast.h"
4445

4546
#define SS_LISTENING -1 /* socket is listening */
4647
#define SS_READY -2 /* socket is connectionless */

0 commit comments

Comments
 (0)