summaryrefslogtreecommitdiff
path: root/block/blk-map.c
diff options
context:
space:
mode:
authorDavid Wei <dw@davidwei.uk>2024-02-29 02:22:50 +0300
committerDavid S. Miller <davem@davemloft.net>2024-03-01 13:43:10 +0300
commit9eb95228a74163e26d338913a5d61e571ea45307 (patch)
treed448094213dc66c7f6cda7048491ec7348f1d4fc /block/blk-map.c
parentf532957d76de89b8ee2545cb6ad5265e1701d0ba (diff)
downloadlinux-9eb95228a74163e26d338913a5d61e571ea45307.tar.xz
netdevsim: forward skbs from one connected port to another
Forward skbs sent from one netdevsim port to its connected netdevsim port using dev_forward_skb, in a spirit similar to veth. Add a tx_dropped variable to struct netdevsim, tracking the number of skbs that could not be forwarded using dev_forward_skb(). The xmit() function accessing the peer ptr is protected by an RCU read critical section. The rcu_read_lock() is functionally redundant as since v5.0 all softirqs are implicitly RCU read critical sections; but it is useful for human readers. If another CPU is concurrently in nsim_destroy(), then it will first set the peer ptr to NULL. This does not affect any existing readers that dereferenced a non-NULL peer. Then, in unregister_netdevice(), there is a synchronize_rcu() before the netdev is actually unregistered and freed. This ensures that any readers i.e. xmit() that got a non-NULL peer will complete before the netdev is freed. Any readers after the RCU_INIT_POINTER() but before synchronize_rcu() will dereference NULL, making it safe. The codepath to nsim_destroy() and nsim_create() takes both the newly added nsim_dev_list_lock and rtnl_lock. This makes it safe with concurrent calls to linking two netdevsims together. Signed-off-by: David Wei <dw@davidwei.uk> Reviewed-by: Maciek Machnikowski <maciek@machnikowski.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'block/blk-map.c')
0 files changed, 0 insertions, 0 deletions