Commit 68441442 authored by Pieter Jansen van Vuuren's avatar Pieter Jansen van Vuuren Committed by Greg Kroah-Hartman

nfp: flower: add rcu locks when accessing netdev for tunnels

[ Upstream commit cb07d915 ]

Add rcu locks when accessing netdev when processing route request
and tunnel keep alive messages received from hardware.

Fixes: 8e6a9046 ("nfp: flower vxlan neighbour offload")
Fixes: 856f5b13 ("nfp: flower vxlan neighbour keep-alive")
Signed-off-by: default avatarPieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarJohn Hurley <john.hurley@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 356ffdbc
...@@ -168,6 +168,7 @@ void nfp_tunnel_keep_alive(struct nfp_app *app, struct sk_buff *skb) ...@@ -168,6 +168,7 @@ void nfp_tunnel_keep_alive(struct nfp_app *app, struct sk_buff *skb)
return; return;
} }
rcu_read_lock();
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
ipv4_addr = payload->tun_info[i].ipv4; ipv4_addr = payload->tun_info[i].ipv4;
port = be32_to_cpu(payload->tun_info[i].egress_port); port = be32_to_cpu(payload->tun_info[i].egress_port);
...@@ -183,6 +184,7 @@ void nfp_tunnel_keep_alive(struct nfp_app *app, struct sk_buff *skb) ...@@ -183,6 +184,7 @@ void nfp_tunnel_keep_alive(struct nfp_app *app, struct sk_buff *skb)
neigh_event_send(n, NULL); neigh_event_send(n, NULL);
neigh_release(n); neigh_release(n);
} }
rcu_read_unlock();
} }
static int static int
...@@ -366,9 +368,10 @@ void nfp_tunnel_request_route(struct nfp_app *app, struct sk_buff *skb) ...@@ -366,9 +368,10 @@ void nfp_tunnel_request_route(struct nfp_app *app, struct sk_buff *skb)
payload = nfp_flower_cmsg_get_data(skb); payload = nfp_flower_cmsg_get_data(skb);
rcu_read_lock();
netdev = nfp_app_repr_get(app, be32_to_cpu(payload->ingress_port)); netdev = nfp_app_repr_get(app, be32_to_cpu(payload->ingress_port));
if (!netdev) if (!netdev)
goto route_fail_warning; goto fail_rcu_unlock;
flow.daddr = payload->ipv4_addr; flow.daddr = payload->ipv4_addr;
flow.flowi4_proto = IPPROTO_UDP; flow.flowi4_proto = IPPROTO_UDP;
...@@ -378,21 +381,23 @@ void nfp_tunnel_request_route(struct nfp_app *app, struct sk_buff *skb) ...@@ -378,21 +381,23 @@ void nfp_tunnel_request_route(struct nfp_app *app, struct sk_buff *skb)
rt = ip_route_output_key(dev_net(netdev), &flow); rt = ip_route_output_key(dev_net(netdev), &flow);
err = PTR_ERR_OR_ZERO(rt); err = PTR_ERR_OR_ZERO(rt);
if (err) if (err)
goto route_fail_warning; goto fail_rcu_unlock;
#else #else
goto route_fail_warning; goto fail_rcu_unlock;
#endif #endif
/* Get the neighbour entry for the lookup */ /* Get the neighbour entry for the lookup */
n = dst_neigh_lookup(&rt->dst, &flow.daddr); n = dst_neigh_lookup(&rt->dst, &flow.daddr);
ip_rt_put(rt); ip_rt_put(rt);
if (!n) if (!n)
goto route_fail_warning; goto fail_rcu_unlock;
nfp_tun_write_neigh(n->dev, app, &flow, n, GFP_KERNEL); nfp_tun_write_neigh(n->dev, app, &flow, n, GFP_ATOMIC);
neigh_release(n); neigh_release(n);
rcu_read_unlock();
return; return;
route_fail_warning: fail_rcu_unlock:
rcu_read_unlock();
nfp_flower_cmsg_warn(app, "Requested route not found.\n"); nfp_flower_cmsg_warn(app, "Requested route not found.\n");
} }
......
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