提交 f21536d1 编写于 作者: A Allan Stephens 提交者: Paul Gortmaker

tipc: Ensure network address change doesn't impact new port

Re-orders port creation logic so that the initialization of a new
port's message header template occurs while the port list lock is
held. This ensures that a change to the node's network address that
occurs at the same time as the port is being created does not result
in the template identifying the sender using the former network
address. The new approach guarantees that the new port's template is
using the current network address or that it will be updated when
the address changes.
Signed-off-by: NAllan Stephens <allan.stephens@windriver.com>
Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
上级 5eb0a291
...@@ -221,18 +221,25 @@ struct tipc_port *tipc_createport_raw(void *usr_handle, ...@@ -221,18 +221,25 @@ struct tipc_port *tipc_createport_raw(void *usr_handle,
p_ptr->usr_handle = usr_handle; p_ptr->usr_handle = usr_handle;
p_ptr->max_pkt = MAX_PKT_DEFAULT; p_ptr->max_pkt = MAX_PKT_DEFAULT;
p_ptr->ref = ref; p_ptr->ref = ref;
msg = &p_ptr->phdr;
tipc_msg_init(msg, importance, TIPC_NAMED_MSG, NAMED_H_SIZE, 0);
msg_set_origport(msg, ref);
INIT_LIST_HEAD(&p_ptr->wait_list); INIT_LIST_HEAD(&p_ptr->wait_list);
INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list); INIT_LIST_HEAD(&p_ptr->subscription.nodesub_list);
p_ptr->dispatcher = dispatcher; p_ptr->dispatcher = dispatcher;
p_ptr->wakeup = wakeup; p_ptr->wakeup = wakeup;
p_ptr->user_port = NULL; p_ptr->user_port = NULL;
k_init_timer(&p_ptr->timer, (Handler)port_timeout, ref); k_init_timer(&p_ptr->timer, (Handler)port_timeout, ref);
spin_lock_bh(&tipc_port_list_lock);
INIT_LIST_HEAD(&p_ptr->publications); INIT_LIST_HEAD(&p_ptr->publications);
INIT_LIST_HEAD(&p_ptr->port_list); INIT_LIST_HEAD(&p_ptr->port_list);
/*
* Must hold port list lock while initializing message header template
* to ensure a change to node's own network address doesn't result
* in template containing out-dated network address information
*/
spin_lock_bh(&tipc_port_list_lock);
msg = &p_ptr->phdr;
tipc_msg_init(msg, importance, TIPC_NAMED_MSG, NAMED_H_SIZE, 0);
msg_set_origport(msg, ref);
list_add_tail(&p_ptr->port_list, &ports); list_add_tail(&p_ptr->port_list, &ports);
spin_unlock_bh(&tipc_port_list_lock); spin_unlock_bh(&tipc_port_list_lock);
return p_ptr; return p_ptr;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册