Skip to content

Commit 5fd9fd6

Browse files
Jon Paul Maloydavem330
authored andcommitted
tipc: create broadcast transmission link at namespace init
The broadcast transmission link is currently instantiated when the network subsystem is started, i.e., on order from user space via netlink. This forces the broadcast transmission code to do unnecessary tests for the existence of the transmission link, as well in single mode node as in network mode. In this commit, we do instead create the link during initialization of the name space, and remove it when it is stopped. The fact that the transmission link now has a guaranteed longer life cycle than any of its potential clients paves the way for further code simplifcations and optimizations. Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Reviewed-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0043550 commit 5fd9fd6

4 files changed

Lines changed: 24 additions & 7 deletions

File tree

‎net/tipc/bcast.c‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ struct tipc_bc_base {
106106
struct tipc_node *retransmit_to;
107107
};
108108

109+
static struct tipc_bc_base *tipc_bc_base(struct net *net)
110+
{
111+
return tipc_net(net)->bcbase;
112+
}
113+
109114
/**
110115
* tipc_nmap_equal - test for equality of node maps
111116
*/
@@ -1041,22 +1046,28 @@ int tipc_bcast_init(struct net *net)
10411046
bcl->bearer_id = MAX_BEARERS;
10421047
rcu_assign_pointer(tn->bearer_list[MAX_BEARERS], &bcbearer->bearer);
10431048
bcl->pmsg = (struct tipc_msg *)&bcl->proto_msg;
1044-
msg_set_prevnode(bcl->pmsg, tn->own_addr);
1049+
10451050
strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME);
10461051
tn->bcbearer = bcbearer;
10471052
tn->bcbase = bclink;
10481053
tn->bcl = bcl;
10491054
return 0;
10501055
}
10511056

1057+
void tipc_bcast_reinit(struct net *net)
1058+
{
1059+
struct tipc_bc_base *b = tipc_bc_base(net);
1060+
1061+
msg_set_prevnode(b->link.pmsg, tipc_own_addr(net));
1062+
}
1063+
10521064
void tipc_bcast_stop(struct net *net)
10531065
{
10541066
struct tipc_net *tn = net_generic(net, tipc_net_id);
10551067

10561068
tipc_bclink_lock(net);
10571069
tipc_link_purge_queues(tn->bcl);
10581070
tipc_bclink_unlock(net);
1059-
10601071
RCU_INIT_POINTER(tn->bearer_list[BCBEARER], NULL);
10611072
synchronize_net();
10621073
kfree(tn->bcbearer);

‎net/tipc/bcast.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct tipc_node_map;
4747
extern const char tipc_bclink_name[];
4848

4949
int tipc_bcast_init(struct net *net);
50+
void tipc_bcast_reinit(struct net *net);
5051
void tipc_bcast_stop(struct net *net);
5152
void tipc_bclink_add_node(struct net *net, u32 addr);
5253
void tipc_bclink_remove_node(struct net *net, u32 addr);

‎net/tipc/core.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "bearer.h"
4343
#include "net.h"
4444
#include "socket.h"
45+
#include "bcast.h"
4546

4647
#include <linux/module.h>
4748

@@ -71,8 +72,15 @@ static int __net_init tipc_init_net(struct net *net)
7172
err = tipc_topsrv_start(net);
7273
if (err)
7374
goto out_subscr;
75+
76+
err = tipc_bcast_init(net);
77+
if (err)
78+
goto out_bclink;
79+
7480
return 0;
7581

82+
out_bclink:
83+
tipc_bcast_stop(net);
7684
out_subscr:
7785
tipc_nametbl_stop(net);
7886
out_nametbl:
@@ -85,6 +93,7 @@ static void __net_exit tipc_exit_net(struct net *net)
8593
{
8694
tipc_topsrv_stop(net);
8795
tipc_net_stop(net);
96+
tipc_bcast_stop(net);
8897
tipc_nametbl_stop(net);
8998
tipc_sk_rht_destroy(net);
9099
}

‎net/tipc/net.c‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,11 @@ int tipc_net_start(struct net *net, u32 addr)
112112
{
113113
struct tipc_net *tn = net_generic(net, tipc_net_id);
114114
char addr_string[16];
115-
int res;
116115

117116
tn->own_addr = addr;
118117
tipc_named_reinit(net);
119118
tipc_sk_reinit(net);
120-
res = tipc_bcast_init(net);
121-
if (res)
122-
return res;
119+
tipc_bcast_reinit(net);
123120

124121
tipc_nametbl_publish(net, TIPC_CFG_SRV, tn->own_addr, tn->own_addr,
125122
TIPC_ZONE_SCOPE, 0, tn->own_addr);
@@ -142,7 +139,6 @@ void tipc_net_stop(struct net *net)
142139
tn->own_addr);
143140
rtnl_lock();
144141
tipc_bearer_stop(net);
145-
tipc_bcast_stop(net);
146142
tipc_node_stop(net);
147143
rtnl_unlock();
148144

0 commit comments

Comments
 (0)