Commit 9c343ea6 authored by Taehee Yoo's avatar Taehee Yoo Committed by Paolo Abeni

amt: remove unnecessary locks

By the previous patch, amt gateway handlers are changed to worked by
a single thread.
So, most locks for gateway are not needed.
So, it removes.

Fixes: cbc21dc1 ("amt: add data plane of amt interface")
Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 30e22a6e
...@@ -577,8 +577,8 @@ static struct sk_buff *amt_build_igmp_gq(struct amt_dev *amt) ...@@ -577,8 +577,8 @@ static struct sk_buff *amt_build_igmp_gq(struct amt_dev *amt)
return skb; return skb;
} }
static void __amt_update_gw_status(struct amt_dev *amt, enum amt_status status, static void amt_update_gw_status(struct amt_dev *amt, enum amt_status status,
bool validate) bool validate)
{ {
if (validate && amt->status >= status) if (validate && amt->status >= status)
return; return;
...@@ -600,14 +600,6 @@ static void __amt_update_relay_status(struct amt_tunnel_list *tunnel, ...@@ -600,14 +600,6 @@ static void __amt_update_relay_status(struct amt_tunnel_list *tunnel,
tunnel->status = status; tunnel->status = status;
} }
static void amt_update_gw_status(struct amt_dev *amt, enum amt_status status,
bool validate)
{
spin_lock_bh(&amt->lock);
__amt_update_gw_status(amt, status, validate);
spin_unlock_bh(&amt->lock);
}
static void amt_update_relay_status(struct amt_tunnel_list *tunnel, static void amt_update_relay_status(struct amt_tunnel_list *tunnel,
enum amt_status status, bool validate) enum amt_status status, bool validate)
{ {
...@@ -700,9 +692,7 @@ static void amt_send_discovery(struct amt_dev *amt) ...@@ -700,9 +692,7 @@ static void amt_send_discovery(struct amt_dev *amt)
if (unlikely(net_xmit_eval(err))) if (unlikely(net_xmit_eval(err)))
amt->dev->stats.tx_errors++; amt->dev->stats.tx_errors++;
spin_lock_bh(&amt->lock); amt_update_gw_status(amt, AMT_STATUS_SENT_DISCOVERY, true);
__amt_update_gw_status(amt, AMT_STATUS_SENT_DISCOVERY, true);
spin_unlock_bh(&amt->lock);
out: out:
rcu_read_unlock(); rcu_read_unlock();
} }
...@@ -937,18 +927,14 @@ static void amt_secret_work(struct work_struct *work) ...@@ -937,18 +927,14 @@ static void amt_secret_work(struct work_struct *work)
static void amt_event_send_discovery(struct amt_dev *amt) static void amt_event_send_discovery(struct amt_dev *amt)
{ {
spin_lock_bh(&amt->lock);
if (amt->status > AMT_STATUS_SENT_DISCOVERY) if (amt->status > AMT_STATUS_SENT_DISCOVERY)
goto out; goto out;
get_random_bytes(&amt->nonce, sizeof(__be32)); get_random_bytes(&amt->nonce, sizeof(__be32));
spin_unlock_bh(&amt->lock);
amt_send_discovery(amt); amt_send_discovery(amt);
spin_lock_bh(&amt->lock);
out: out:
mod_delayed_work(amt_wq, &amt->discovery_wq, mod_delayed_work(amt_wq, &amt->discovery_wq,
msecs_to_jiffies(AMT_DISCOVERY_TIMEOUT)); msecs_to_jiffies(AMT_DISCOVERY_TIMEOUT));
spin_unlock_bh(&amt->lock);
} }
static void amt_discovery_work(struct work_struct *work) static void amt_discovery_work(struct work_struct *work)
...@@ -966,7 +952,6 @@ static void amt_event_send_request(struct amt_dev *amt) ...@@ -966,7 +952,6 @@ static void amt_event_send_request(struct amt_dev *amt)
{ {
u32 exp; u32 exp;
spin_lock_bh(&amt->lock);
if (amt->status < AMT_STATUS_RECEIVED_ADVERTISEMENT) if (amt->status < AMT_STATUS_RECEIVED_ADVERTISEMENT)
goto out; goto out;
...@@ -976,21 +961,18 @@ static void amt_event_send_request(struct amt_dev *amt) ...@@ -976,21 +961,18 @@ static void amt_event_send_request(struct amt_dev *amt)
amt->ready4 = false; amt->ready4 = false;
amt->ready6 = false; amt->ready6 = false;
amt->remote_ip = 0; amt->remote_ip = 0;
__amt_update_gw_status(amt, AMT_STATUS_INIT, false); amt_update_gw_status(amt, AMT_STATUS_INIT, false);
amt->req_cnt = 0; amt->req_cnt = 0;
goto out; goto out;
} }
spin_unlock_bh(&amt->lock);
amt_send_request(amt, false); amt_send_request(amt, false);
amt_send_request(amt, true); amt_send_request(amt, true);
spin_lock_bh(&amt->lock); amt_update_gw_status(amt, AMT_STATUS_SENT_REQUEST, true);
__amt_update_gw_status(amt, AMT_STATUS_SENT_REQUEST, true);
amt->req_cnt++; amt->req_cnt++;
out: out:
exp = min_t(u32, (1 * (1 << amt->req_cnt)), AMT_MAX_REQ_TIMEOUT); exp = min_t(u32, (1 * (1 << amt->req_cnt)), AMT_MAX_REQ_TIMEOUT);
mod_delayed_work(amt_wq, &amt->req_wq, msecs_to_jiffies(exp * 1000)); mod_delayed_work(amt_wq, &amt->req_wq, msecs_to_jiffies(exp * 1000));
spin_unlock_bh(&amt->lock);
} }
static void amt_req_work(struct work_struct *work) static void amt_req_work(struct work_struct *work)
...@@ -2386,12 +2368,10 @@ static bool amt_membership_query_handler(struct amt_dev *amt, ...@@ -2386,12 +2368,10 @@ static bool amt_membership_query_handler(struct amt_dev *amt,
ihv3 = skb_pull(skb, sizeof(*iph) + AMT_IPHDR_OPTS); ihv3 = skb_pull(skb, sizeof(*iph) + AMT_IPHDR_OPTS);
skb_reset_transport_header(skb); skb_reset_transport_header(skb);
skb_push(skb, sizeof(*iph) + AMT_IPHDR_OPTS); skb_push(skb, sizeof(*iph) + AMT_IPHDR_OPTS);
spin_lock_bh(&amt->lock);
amt->ready4 = true; amt->ready4 = true;
amt->mac = amtmq->response_mac; amt->mac = amtmq->response_mac;
amt->req_cnt = 0; amt->req_cnt = 0;
amt->qi = ihv3->qqic; amt->qi = ihv3->qqic;
spin_unlock_bh(&amt->lock);
skb->protocol = htons(ETH_P_IP); skb->protocol = htons(ETH_P_IP);
eth->h_proto = htons(ETH_P_IP); eth->h_proto = htons(ETH_P_IP);
ip_eth_mc_map(iph->daddr, eth->h_dest); ip_eth_mc_map(iph->daddr, eth->h_dest);
...@@ -2411,12 +2391,10 @@ static bool amt_membership_query_handler(struct amt_dev *amt, ...@@ -2411,12 +2391,10 @@ static bool amt_membership_query_handler(struct amt_dev *amt,
mld2q = skb_pull(skb, sizeof(*ip6h) + AMT_IP6HDR_OPTS); mld2q = skb_pull(skb, sizeof(*ip6h) + AMT_IP6HDR_OPTS);
skb_reset_transport_header(skb); skb_reset_transport_header(skb);
skb_push(skb, sizeof(*ip6h) + AMT_IP6HDR_OPTS); skb_push(skb, sizeof(*ip6h) + AMT_IP6HDR_OPTS);
spin_lock_bh(&amt->lock);
amt->ready6 = true; amt->ready6 = true;
amt->mac = amtmq->response_mac; amt->mac = amtmq->response_mac;
amt->req_cnt = 0; amt->req_cnt = 0;
amt->qi = mld2q->mld2q_qqic; amt->qi = mld2q->mld2q_qqic;
spin_unlock_bh(&amt->lock);
skb->protocol = htons(ETH_P_IPV6); skb->protocol = htons(ETH_P_IPV6);
eth->h_proto = htons(ETH_P_IPV6); eth->h_proto = htons(ETH_P_IPV6);
ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest); ipv6_eth_mc_map(&ip6h->daddr, eth->h_dest);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment