aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/eth_media.c
diff options
context:
space:
mode:
authorErik Hugne <erik.hugne@ericsson.com>2013-12-06 10:08:00 -0500
committerDavid S. Miller <davem@davemloft.net>2013-12-09 20:30:29 -0500
commit512137eeff00f73a8a62e481a6575f1556cf962c (patch)
treec588e741a1587dc34835871110949ef92b5faab7 /net/tipc/eth_media.c
parentb73e9e3cf06ef8180c75a6bd28cdd1b833d22a3a (diff)
tipc: remove interface state mirroring in bearer
struct 'tipc_bearer' is a generic representation of the underlying media type, and exists in a one-to-one relationship to each interface TIPC is using. The struct contains a 'blocked' flag that mirrors the operational and execution state of the represented interface, and is updated through notification calls from the latter. The users of tipc_bearer are checking this flag before each attempt to send a packet via the interface. This state mirroring serves no purpose in the current code base. TIPC links will not discover a media failure any faster through this mechanism, and in reality the flag only adds overhead at packet sending and reception. Furthermore, the fact that the flag needs to be protected by a spinlock aggregated into tipc_bearer has turned out to cause a serious and completely unnecessary deadlock problem. CPU0 CPU1 ---- ---- Time 0: bearer_disable() link_timeout() Time 1: spin_lock_bh(&b_ptr->lock) tipc_link_push_queue() Time 2: tipc_link_delete() tipc_bearer_blocked(b_ptr) Time 3: k_cancel_timer(&req->timer) spin_lock_bh(&b_ptr->lock) Time 4: del_timer_sync(&req->timer) I.e., del_timer_sync() on CPU0 never returns, because the timer handler on CPU1 is waiting for the bearer lock. We eliminate the 'blocked' flag from struct tipc_bearer, along with all tests on this flag. This not only resolves the deadlock, but also simplifies and speeds up the data path execution of TIPC. It also fits well into our ongoing effort to make the locking policy simpler and more manageable. An effect of this change is that we can get rid of functions such as tipc_bearer_blocked(), tipc_continue() and tipc_block_bearer(). We replace the latter with a new function, tipc_reset_bearer(), which resets all links associated to the bearer immediately after an interface goes down. A user might notice one slight change in link behaviour after this change. When an interface goes down, (e.g. through a NETDEV_DOWN event) all attached links will be reset immediately, instead of leaving it to each link to detect the failure through a timer-driven mechanism. We consider this an improvement, and see no obvious risks with the new behavior. Signed-off-by: Erik Hugne <erik.hugne@ericsson.com> Reviewed-by: Ying Xue <ying.xue@windriver.com> Reviewed-by: Paul Gortmaker <Paul.Gortmaker@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/eth_media.c')
-rw-r--r--net/tipc/eth_media.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/net/tipc/eth_media.c b/net/tipc/eth_media.c
index f80d59f5a161..1e3c33250db3 100644
--- a/net/tipc/eth_media.c
+++ b/net/tipc/eth_media.c
@@ -199,7 +199,6 @@ static int enable_media(struct tipc_bearer *tb_ptr)
199 tb_ptr->bcast_addr.media_id = TIPC_MEDIA_TYPE_ETH; 199 tb_ptr->bcast_addr.media_id = TIPC_MEDIA_TYPE_ETH;
200 tb_ptr->bcast_addr.broadcast = 1; 200 tb_ptr->bcast_addr.broadcast = 1;
201 tb_ptr->mtu = dev->mtu; 201 tb_ptr->mtu = dev->mtu;
202 tb_ptr->blocked = 0;
203 eth_media_addr_set(tb_ptr, &tb_ptr->addr, (char *)dev->dev_addr); 202 eth_media_addr_set(tb_ptr, &tb_ptr->addr, (char *)dev->dev_addr);
204 return 0; 203 return 0;
205} 204}
@@ -263,20 +262,11 @@ static int recv_notification(struct notifier_block *nb, unsigned long evt,
263 switch (evt) { 262 switch (evt) {
264 case NETDEV_CHANGE: 263 case NETDEV_CHANGE:
265 if (netif_carrier_ok(dev)) 264 if (netif_carrier_ok(dev))
266 tipc_continue(eb_ptr->bearer); 265 break;
267 else
268 tipc_block_bearer(eb_ptr->bearer);
269 break;
270 case NETDEV_UP:
271 tipc_continue(eb_ptr->bearer);
272 break;
273 case NETDEV_DOWN: 266 case NETDEV_DOWN:
274 tipc_block_bearer(eb_ptr->bearer);
275 break;
276 case NETDEV_CHANGEMTU: 267 case NETDEV_CHANGEMTU:
277 case NETDEV_CHANGEADDR: 268 case NETDEV_CHANGEADDR:
278 tipc_block_bearer(eb_ptr->bearer); 269 tipc_reset_bearer(eb_ptr->bearer);
279 tipc_continue(eb_ptr->bearer);
280 break; 270 break;
281 case NETDEV_UNREGISTER: 271 case NETDEV_UNREGISTER:
282 case NETDEV_CHANGENAME: 272 case NETDEV_CHANGENAME: