960-ipmonitor-fix-ip-monitor-can-t-work-when-NET_NS-is-n.patch 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. From c44003f7e7254ac972eaa1b22a686471ea4ce2d7 Mon Sep 17 00:00:00 2001
  2. From: Liping Zhang <liping.zhang@spreadtrum.com>
  3. Date: Tue, 20 Sep 2016 02:09:02 -0700
  4. Subject: [PATCH] ipmonitor: fix ip monitor can't work when NET_NS is not
  5. enabled
  6. In ip monitor, netns_map_init will check getnsid is supported or not.
  7. But when /proc/self/ns/net does not exist, we just print out error
  8. messages and exit. So user cannot use ip monitor anymore when
  9. CONFIG_NET_NS is disabled:
  10. # ip monitor
  11. open("/proc/self/ns/net"): No such file or directory
  12. If open "/proc/self/ns/net" failed, set have_rtnl_getnsid to false.
  13. Fixes: d652ccbf8195 ("netns: allow to dump and monitor nsid")
  14. Signed-off-by: Liping Zhang <liping.zhang@spreadtrum.com>
  15. Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
  16. ---
  17. ip/ipnetns.c | 4 ++--
  18. 1 file changed, 2 insertions(+), 2 deletions(-)
  19. --- a/ip/ipnetns.c
  20. +++ b/ip/ipnetns.c
  21. @@ -73,8 +73,8 @@ static int ipnetns_have_nsid(void)
  22. fd = open("/proc/self/ns/net", O_RDONLY);
  23. if (fd < 0) {
  24. - perror("open(\"/proc/self/ns/net\")");
  25. - exit(1);
  26. + have_rtnl_getnsid = 0;
  27. + return 0;
  28. }
  29. addattr32(&req.n, 1024, NETNSA_FD, fd);