summaryrefslogtreecommitdiffstats
path: root/net/mctp/route.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@codeconstruct.com.au>2021-09-29 09:26:05 +0200
committerDavid S. Miller <davem@davemloft.net>2021-09-29 12:00:11 +0200
commitf364dd71d92fe6722fe5d47803be974dc0c40762 (patch)
tree2ca01f13e26cf8d644c0f4e2a544de3c78e3c67f /net/mctp/route.c
parentnet: phy: micrel: Add support for LAN8804 PHY (diff)
downloadlinux-f364dd71d92fe6722fe5d47803be974dc0c40762.tar.xz
linux-f364dd71d92fe6722fe5d47803be974dc0c40762.zip
mctp: Allow MCTP on tun devices
Allowing TUN is useful for testing, to route packets to userspace or to tunnel between machines. Signed-off-by: Matt Johnston <matt@codeconstruct.com.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mctp/route.c')
-rw-r--r--net/mctp/route.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/net/mctp/route.c b/net/mctp/route.c
index 5ca186d53cb0..a953f83ed02b 100644
--- a/net/mctp/route.c
+++ b/net/mctp/route.c
@@ -821,13 +821,18 @@ static int mctp_pkttype_receive(struct sk_buff *skb, struct net_device *dev,
struct net_device *orig_dev)
{
struct net *net = dev_net(dev);
+ struct mctp_dev *mdev;
struct mctp_skb_cb *cb;
struct mctp_route *rt;
struct mctp_hdr *mh;
- /* basic non-data sanity checks */
- if (dev->type != ARPHRD_MCTP)
+ rcu_read_lock();
+ mdev = __mctp_dev_get(dev);
+ rcu_read_unlock();
+ if (!mdev) {
+ /* basic non-data sanity checks */
goto err_drop;
+ }
if (!pskb_may_pull(skb, sizeof(struct mctp_hdr)))
goto err_drop;
@@ -841,9 +846,7 @@ static int mctp_pkttype_receive(struct sk_buff *skb, struct net_device *dev,
goto err_drop;
cb = __mctp_cb(skb);
- rcu_read_lock();
- cb->net = READ_ONCE(__mctp_dev_get(dev)->net);
- rcu_read_unlock();
+ cb->net = READ_ONCE(mdev->net);
rt = mctp_route_lookup(net, cb->net, mh->dest);
if (!rt)