Refactor the netns and ipvrf code so less steps are needed to exec commands in a netns or a VRF context. Also remove some code which became dead. bloat-o-meter output:
$ bloat-o-meter ip.old ip add/remove: 1/4 grow/shrink: 3/4 up/down: 174/-312 (-138) Function old new delta netns_add 971 1058 +87 cmd_exec 207 256 +49 on_netns_exec 32 60 +28 do_switch - 10 +10 netns_restore 69 67 -2 do_ipvrf 811 802 -9 netns_switch 838 822 -16 on_netns_label 45 - -45 do_netns 1226 1180 -46 do_each_netns 57 - -57 on_netns 60 - -60 netns_save 77 - -77 Total: Before=668234, After=668096, chg -0.02% Matteo Croce (3): netns: switch netns in the child when executing commands ip vrf: use hook to change VRF in the child netns: make netns_{save,restore} static include/namespace.h | 2 -- include/utils.h | 6 ++--- ip/ip.c | 1 - ip/ipnetns.c | 56 +++++++++++++++++++++++++++++++++------------ ip/ipvrf.c | 12 ++++++---- lib/exec.c | 7 +++++- lib/namespace.c | 31 ------------------------- lib/utils.c | 27 ---------------------- 8 files changed, 58 insertions(+), 84 deletions(-) -- 2.21.0