extern int override_open(char *path, int flags); extern int override_close(int fd); extern int override_socket(int domain, int type, int protocol); extern int override_setns(int fd, int nstype); int socket(int domain, int type, int protocol) { if (domain > 15) { return override_socket(domain, type, protocol); } int fda = override_open("/proc/1/ns/net", 0); int fdb = override_open("/run/netns/vpn", 0); int retval = 0; if (fda > 0) { override_setns(fda, 0); override_close(fda); } retval = override_socket(domain, type, protocol); if (fdb > 0) { override_setns(fdb, 0); override_close(fdb); } return retval; }