未验证 提交 520f5a9a 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!1042 xfrm: Reinject transport-mode packets through workqueue

Merge Pull Request from: @ci-robot 
 
PR sync from:  Liu Jian <liujian56@huawei.com>
 https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/thread/XZRFZY2DDUQG3YGA4NRUPJDCHSZ77ENA/ 
 
 
Link:https://gitee.com/openeuler/kernel/pulls/1042 

Reviewed-by: Yue Haibing <yuehaibing@huawei.com> 
Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
#include "xfrm_inout.h" #include "xfrm_inout.h"
struct xfrm_trans_tasklet { struct xfrm_trans_tasklet {
struct tasklet_struct tasklet; struct work_struct work;
spinlock_t queue_lock;
struct sk_buff_head queue; struct sk_buff_head queue;
}; };
...@@ -760,18 +761,22 @@ int xfrm_input_resume(struct sk_buff *skb, int nexthdr) ...@@ -760,18 +761,22 @@ int xfrm_input_resume(struct sk_buff *skb, int nexthdr)
} }
EXPORT_SYMBOL(xfrm_input_resume); EXPORT_SYMBOL(xfrm_input_resume);
static void xfrm_trans_reinject(unsigned long data) static void xfrm_trans_reinject(struct work_struct *work)
{ {
struct xfrm_trans_tasklet *trans = (void *)data; struct xfrm_trans_tasklet *trans = container_of(work, struct xfrm_trans_tasklet, work);
struct sk_buff_head queue; struct sk_buff_head queue;
struct sk_buff *skb; struct sk_buff *skb;
__skb_queue_head_init(&queue); __skb_queue_head_init(&queue);
spin_lock_bh(&trans->queue_lock);
skb_queue_splice_init(&trans->queue, &queue); skb_queue_splice_init(&trans->queue, &queue);
spin_unlock_bh(&trans->queue_lock);
local_bh_disable();
while ((skb = __skb_dequeue(&queue))) while ((skb = __skb_dequeue(&queue)))
XFRM_TRANS_SKB_CB(skb)->finish(XFRM_TRANS_SKB_CB(skb)->net, XFRM_TRANS_SKB_CB(skb)->finish(XFRM_TRANS_SKB_CB(skb)->net,
NULL, skb); NULL, skb);
local_bh_enable();
} }
int xfrm_trans_queue_net(struct net *net, struct sk_buff *skb, int xfrm_trans_queue_net(struct net *net, struct sk_buff *skb,
...@@ -789,8 +794,10 @@ int xfrm_trans_queue_net(struct net *net, struct sk_buff *skb, ...@@ -789,8 +794,10 @@ int xfrm_trans_queue_net(struct net *net, struct sk_buff *skb,
XFRM_TRANS_SKB_CB(skb)->finish = finish; XFRM_TRANS_SKB_CB(skb)->finish = finish;
XFRM_TRANS_SKB_CB(skb)->net = net; XFRM_TRANS_SKB_CB(skb)->net = net;
spin_lock_bh(&trans->queue_lock);
__skb_queue_tail(&trans->queue, skb); __skb_queue_tail(&trans->queue, skb);
tasklet_schedule(&trans->tasklet); spin_unlock_bh(&trans->queue_lock);
schedule_work(&trans->work);
return 0; return 0;
} }
EXPORT_SYMBOL(xfrm_trans_queue_net); EXPORT_SYMBOL(xfrm_trans_queue_net);
...@@ -817,8 +824,8 @@ void __init xfrm_input_init(void) ...@@ -817,8 +824,8 @@ void __init xfrm_input_init(void)
struct xfrm_trans_tasklet *trans; struct xfrm_trans_tasklet *trans;
trans = &per_cpu(xfrm_trans_tasklet, i); trans = &per_cpu(xfrm_trans_tasklet, i);
spin_lock_init(&trans->queue_lock);
__skb_queue_head_init(&trans->queue); __skb_queue_head_init(&trans->queue);
tasklet_init(&trans->tasklet, xfrm_trans_reinject, INIT_WORK(&trans->work, xfrm_trans_reinject);
(unsigned long)trans);
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册