diff --git a/osdep/BSDEthernetTap.cpp b/osdep/BSDEthernetTap.cpp index 946cf9fc5..efba03147 100644 --- a/osdep/BSDEthernetTap.cpp +++ b/osdep/BSDEthernetTap.cpp @@ -106,6 +106,9 @@ BSDEthernetTap::BSDEthernetTap( if (std::find(devFiles.begin(),devFiles.end(),std::string(tmpdevname)) == devFiles.end()) { long cpid = (long)vfork(); if (cpid == 0) { +#ifdef ZT_TRACE + fprintf(stderr, "DEBUG: ifconfig %s create" ZT_EOL_S, tmpdevname); +#endif ::execl("/sbin/ifconfig","/sbin/ifconfig",tmpdevname,"create",(const char *)0); ::_exit(-1); } else if (cpid > 0) { @@ -117,6 +120,9 @@ BSDEthernetTap::BSDEthernetTap( if (!stat(devpath,&stattmp)) { cpid = (long)vfork(); if (cpid == 0) { +#ifdef ZT_TRACE + fprintf(stderr, "DEBUG: ifconfig %s name %s" ZT_EOL_S, tmpdevname, _dev.c_str()); +#endif ::execl("/sbin/ifconfig","/sbin/ifconfig",tmpdevname,"name",_dev.c_str(),(const char *)0); ::_exit(-1); } else if (cpid > 0) { @@ -163,6 +169,9 @@ BSDEthernetTap::BSDEthernetTap( OSUtils::ztsnprintf(metstr,sizeof(metstr),"%u",_metric); long cpid = (long)vfork(); if (cpid == 0) { +#ifdef ZT_TRACE + fprintf(stderr, "DEBUG: ifconfig %s lladdr %s mtu %s metric %s up" ZT_EOL_S, _dev.c_str(), ethaddr, mtustr, metstr); +#endif ::execl("/sbin/ifconfig","/sbin/ifconfig",_dev.c_str(),"lladdr",ethaddr,"mtu",mtustr,"metric",metstr,"up",(const char *)0); ::_exit(-1); } else if (cpid > 0) { @@ -192,6 +201,9 @@ BSDEthernetTap::~BSDEthernetTap() long cpid = (long)vfork(); if (cpid == 0) { +#ifdef ZT_TRACE + fprintf(stderr, "DEBUG: ifconfig %s destroy" ZT_EOL_S, _dev.c_str()); +#endif ::execl("/sbin/ifconfig","/sbin/ifconfig",_dev.c_str(),"destroy",(const char *)0); ::_exit(-1); } else if (cpid > 0) { @@ -215,6 +227,9 @@ static bool ___removeIp(const std::string &_dev,const InetAddress &ip) long cpid = (long)vfork(); if (cpid == 0) { char ipbuf[64]; +#ifdef ZT_TRACE + fprintf(stderr, "DEBUG: ifconfig %s inet %s -alias" ZT_EOL_S, _dev.c_str(), ip.toIpString(ipbuf)); +#endif execl("/sbin/ifconfig","/sbin/ifconfig",_dev.c_str(),"inet",ip.toIpString(ipbuf),"-alias",(const char *)0); _exit(-1); } else if (cpid > 0) { @@ -245,6 +260,9 @@ bool BSDEthernetTap::addIp(const InetAddress &ip) long cpid = (long)vfork(); if (cpid == 0) { char tmp[128]; +#ifdef ZT_TRACE + fprintf(stderr, "DEBUG: ifconfig %s %s %s alias" ZT_EOL_S, _dev.c_str(), ip.isV4() ? "inet" : "inet6", ip.toString(tmp)); +#endif ::execl("/sbin/ifconfig","/sbin/ifconfig",_dev.c_str(),ip.isV4() ? "inet" : "inet6",ip.toString(tmp),"alias",(const char *)0); ::_exit(-1); } else if (cpid > 0) { @@ -375,6 +393,9 @@ void BSDEthernetTap::setMtu(unsigned int mtu) if (cpid == 0) { char tmp[64]; OSUtils::ztsnprintf(tmp,sizeof(tmp),"%u",mtu); +#ifdef ZT_TRACE + fprintf(stderr, "DEBUG: ifconfig %s mtu %s" ZT_EOL_S, _dev.c_str(), tmp); +#endif execl("/sbin/ifconfig","/sbin/ifconfig",_dev.c_str(),"mtu",tmp,(const char *)0); _exit(-1); } else if (cpid > 0) { diff --git a/osdep/ManagedRoute.cpp b/osdep/ManagedRoute.cpp index 85f2c67c9..83c6d8fb9 100644 --- a/osdep/ManagedRoute.cpp +++ b/osdep/ManagedRoute.cpp @@ -250,14 +250,26 @@ static void _routeCmd(const char *op,const InetAddress &target,const InetAddress char iptmp[64]; if (via) { if ((ifscope)&&(ifscope[0])) { +#ifdef ZT_TRACE + fprintf(stderr, "DEBUG: route %s -ifscope %s %s %s" ZT_EOL_S, ifscope,((target.ss_family == AF_INET6) ? "-inet6" : "-inet"),target.toString(ttmp),via.toIpString(iptmp)); +#endif ::execl(ZT_BSD_ROUTE_CMD,ZT_BSD_ROUTE_CMD,op,"-ifscope",ifscope,((target.ss_family == AF_INET6) ? "-inet6" : "-inet"),target.toString(ttmp),via.toIpString(iptmp),(const char *)0); } else { +#ifdef ZT_TRACE + fprintf(stderr, "DEBUG: route %s %s %s %s" ZT_EOL_S, op,((target.ss_family == AF_INET6) ? "-inet6" : "-inet"),target.toString(ttmp),via.toIpString(iptmp)); +#endif ::execl(ZT_BSD_ROUTE_CMD,ZT_BSD_ROUTE_CMD,op,((target.ss_family == AF_INET6) ? "-inet6" : "-inet"),target.toString(ttmp),via.toIpString(iptmp),(const char *)0); } } else if ((localInterface)&&(localInterface[0])) { if ((ifscope)&&(ifscope[0])) { +#ifdef ZT_TRACE + fprintf(stderr, "DEBUG: route %s -ifscope %s %s %s -interface %s" ZT_EOL_S, op, ifscope,((target.ss_family == AF_INET6) ? "-inet6" : "-inet"),target.toString(ttmp),localInterface); +#endif ::execl(ZT_BSD_ROUTE_CMD,ZT_BSD_ROUTE_CMD,op,"-ifscope",ifscope,((target.ss_family == AF_INET6) ? "-inet6" : "-inet"),target.toString(ttmp),"-interface",localInterface,(const char *)0); } else { +#ifdef ZT_TRACE + fprintf(stderr, "DEBUG: route %s %s %s -interface %s" ZT_EOL_S, op,((target.ss_family == AF_INET6) ? "-inet6" : "-inet"),target.toString(ttmp),localInterface); +#endif ::execl(ZT_BSD_ROUTE_CMD,ZT_BSD_ROUTE_CMD,op,((target.ss_family == AF_INET6) ? "-inet6" : "-inet"),target.toString(ttmp),"-interface",localInterface,(const char *)0); } } @@ -566,4 +578,4 @@ void ManagedRoute::remove() _applied.clear(); } -} // namespace ZeroTier \ No newline at end of file +} // namespace ZeroTier