[PATCH v1 10/11] connection: Reorder gateway set/unset operations