diff options
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/bcast.c | 28 | ||||
-rw-r--r-- | net/tipc/bcast.h | 2 | ||||
-rw-r--r-- | net/tipc/config.c | 6 | ||||
-rw-r--r-- | net/tipc/net.c | 9 | ||||
-rw-r--r-- | net/tipc/net.h | 2 |
5 files changed, 32 insertions, 15 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 9eceaa72f21b..ef8cff4ad743 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
@@ -100,12 +100,9 @@ struct tipc_bclink { | |||
100 | struct tipc_node *retransmit_to; | 100 | struct tipc_node *retransmit_to; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | static struct tipc_bcbearer bcast_bearer; | 103 | static struct tipc_bcbearer *bcbearer; |
104 | static struct tipc_bclink bcast_link; | 104 | static struct tipc_bclink *bclink; |
105 | 105 | static struct tipc_link *bcl; | |
106 | static struct tipc_bcbearer *bcbearer = &bcast_bearer; | ||
107 | static struct tipc_bclink *bclink = &bcast_link; | ||
108 | static struct tipc_link *bcl = &bcast_link.link; | ||
109 | 106 | ||
110 | const char tipc_bclink_name[] = "broadcast-link"; | 107 | const char tipc_bclink_name[] = "broadcast-link"; |
111 | 108 | ||
@@ -788,8 +785,19 @@ int tipc_bclink_set_queue_limits(u32 limit) | |||
788 | return 0; | 785 | return 0; |
789 | } | 786 | } |
790 | 787 | ||
791 | void tipc_bclink_init(void) | 788 | int tipc_bclink_init(void) |
792 | { | 789 | { |
790 | bcbearer = kzalloc(sizeof(*bcbearer), GFP_ATOMIC); | ||
791 | if (!bcbearer) | ||
792 | return -ENOMEM; | ||
793 | |||
794 | bclink = kzalloc(sizeof(*bclink), GFP_ATOMIC); | ||
795 | if (!bclink) { | ||
796 | kfree(bcbearer); | ||
797 | return -ENOMEM; | ||
798 | } | ||
799 | |||
800 | bcl = &bclink->link; | ||
793 | bcbearer->bearer.media = &bcbearer->media; | 801 | bcbearer->bearer.media = &bcbearer->media; |
794 | bcbearer->media.send_msg = tipc_bcbearer_send; | 802 | bcbearer->media.send_msg = tipc_bcbearer_send; |
795 | sprintf(bcbearer->media.name, "tipc-broadcast"); | 803 | sprintf(bcbearer->media.name, "tipc-broadcast"); |
@@ -805,6 +813,7 @@ void tipc_bclink_init(void) | |||
805 | rcu_assign_pointer(bearer_list[MAX_BEARERS], &bcbearer->bearer); | 813 | rcu_assign_pointer(bearer_list[MAX_BEARERS], &bcbearer->bearer); |
806 | bcl->state = WORKING_WORKING; | 814 | bcl->state = WORKING_WORKING; |
807 | strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME); | 815 | strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME); |
816 | return 0; | ||
808 | } | 817 | } |
809 | 818 | ||
810 | void tipc_bclink_stop(void) | 819 | void tipc_bclink_stop(void) |
@@ -814,8 +823,9 @@ void tipc_bclink_stop(void) | |||
814 | tipc_bclink_unlock(); | 823 | tipc_bclink_unlock(); |
815 | 824 | ||
816 | RCU_INIT_POINTER(bearer_list[BCBEARER], NULL); | 825 | RCU_INIT_POINTER(bearer_list[BCBEARER], NULL); |
817 | memset(bclink, 0, sizeof(*bclink)); | 826 | synchronize_net(); |
818 | memset(bcbearer, 0, sizeof(*bcbearer)); | 827 | kfree(bcbearer); |
828 | kfree(bclink); | ||
819 | } | 829 | } |
820 | 830 | ||
821 | /** | 831 | /** |
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h index 7c1ef1b3d7b3..ea162c7b30ee 100644 --- a/net/tipc/bcast.h +++ b/net/tipc/bcast.h | |||
@@ -81,7 +81,7 @@ static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, | |||
81 | void tipc_port_list_add(struct tipc_port_list *pl_ptr, u32 port); | 81 | void tipc_port_list_add(struct tipc_port_list *pl_ptr, u32 port); |
82 | void tipc_port_list_free(struct tipc_port_list *pl_ptr); | 82 | void tipc_port_list_free(struct tipc_port_list *pl_ptr); |
83 | 83 | ||
84 | void tipc_bclink_init(void); | 84 | int tipc_bclink_init(void); |
85 | void tipc_bclink_stop(void); | 85 | void tipc_bclink_stop(void); |
86 | void tipc_bclink_add_node(u32 addr); | 86 | void tipc_bclink_add_node(u32 addr); |
87 | void tipc_bclink_remove_node(u32 addr); | 87 | void tipc_bclink_remove_node(u32 addr); |
diff --git a/net/tipc/config.c b/net/tipc/config.c index 251f5a2028e4..2b42403ad33a 100644 --- a/net/tipc/config.c +++ b/net/tipc/config.c | |||
@@ -177,8 +177,10 @@ static struct sk_buff *cfg_set_own_addr(void) | |||
177 | if (tipc_own_addr) | 177 | if (tipc_own_addr) |
178 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED | 178 | return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED |
179 | " (cannot change node address once assigned)"); | 179 | " (cannot change node address once assigned)"); |
180 | tipc_net_start(addr); | 180 | if (!tipc_net_start(addr)) |
181 | return tipc_cfg_reply_none(); | 181 | return tipc_cfg_reply_none(); |
182 | |||
183 | return tipc_cfg_reply_error_string("cannot change to network mode"); | ||
182 | } | 184 | } |
183 | 185 | ||
184 | static struct sk_buff *cfg_set_max_ports(void) | 186 | static struct sk_buff *cfg_set_max_ports(void) |
diff --git a/net/tipc/net.c b/net/tipc/net.c index 75bb39025d53..f8fc95d58c0d 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
@@ -164,20 +164,25 @@ void tipc_net_route_msg(struct sk_buff *buf) | |||
164 | tipc_link_xmit(buf, dnode, msg_link_selector(msg)); | 164 | tipc_link_xmit(buf, dnode, msg_link_selector(msg)); |
165 | } | 165 | } |
166 | 166 | ||
167 | void tipc_net_start(u32 addr) | 167 | int tipc_net_start(u32 addr) |
168 | { | 168 | { |
169 | char addr_string[16]; | 169 | char addr_string[16]; |
170 | int res; | ||
170 | 171 | ||
171 | tipc_own_addr = addr; | 172 | tipc_own_addr = addr; |
172 | tipc_named_reinit(); | 173 | tipc_named_reinit(); |
173 | tipc_port_reinit(); | 174 | tipc_port_reinit(); |
174 | tipc_bclink_init(); | 175 | res = tipc_bclink_init(); |
176 | if (res) | ||
177 | return res; | ||
178 | |||
175 | tipc_nametbl_publish(TIPC_CFG_SRV, tipc_own_addr, tipc_own_addr, | 179 | tipc_nametbl_publish(TIPC_CFG_SRV, tipc_own_addr, tipc_own_addr, |
176 | TIPC_ZONE_SCOPE, 0, tipc_own_addr); | 180 | TIPC_ZONE_SCOPE, 0, tipc_own_addr); |
177 | 181 | ||
178 | pr_info("Started in network mode\n"); | 182 | pr_info("Started in network mode\n"); |
179 | pr_info("Own node address %s, network identity %u\n", | 183 | pr_info("Own node address %s, network identity %u\n", |
180 | tipc_addr_string_fill(addr_string, tipc_own_addr), tipc_net_id); | 184 | tipc_addr_string_fill(addr_string, tipc_own_addr), tipc_net_id); |
185 | return 0; | ||
181 | } | 186 | } |
182 | 187 | ||
183 | void tipc_net_stop(void) | 188 | void tipc_net_stop(void) |
diff --git a/net/tipc/net.h b/net/tipc/net.h index f781cae8df4b..c6c2b46f7c28 100644 --- a/net/tipc/net.h +++ b/net/tipc/net.h | |||
@@ -39,7 +39,7 @@ | |||
39 | 39 | ||
40 | void tipc_net_route_msg(struct sk_buff *buf); | 40 | void tipc_net_route_msg(struct sk_buff *buf); |
41 | 41 | ||
42 | void tipc_net_start(u32 addr); | 42 | int tipc_net_start(u32 addr); |
43 | void tipc_net_stop(void); | 43 | void tipc_net_stop(void); |
44 | 44 | ||
45 | #endif | 45 | #endif |