Protect context switches with a lock in the router