On Thu, Dec 03, 2009 at 11:50:52PM -0800, patrick keshishian wrote: > On Fri, Dec 04, 2009 at 09:34:31AM +0200, Vladimir Kirillov wrote: > > Hello t...@! > > > > Here's a diff for tun to make it keep record and display the > > pid of tunnel owner process in ifconfig. > > I'm sure it would be a handy feature, hope you'll like it. > [dd] > > @@ -561,6 +566,15 @@ tun_ioctl(struct ifnet *ifp, u_long cmd, > > case SIOCGIFMEDIA: > > case SIOCSIFMEDIA: > > error = ifmedia_ioctl(ifp, ifr, &tp->tun_media, cmd); > > + break; > > + > > + case SIOCGTUNPID: > > + if (tp->tun_proc == NULL) { > > + error = ENOTTY; > > + break; > > + } > > + > > + tunr->tun_pid = tp->tun_proc->p_pid; > > break; > > > Just a personal comment, why not: > > + case SIOCGTUNPID: > + if (tp->tun_proc == NULL) > + error = ENOTTY; > + else > + tunr->tun_pid = tp->tun_proc->p_pid; > break; > > Just so it is more consistent with the rest of the code? >
The main problem with this code is that ENOTTY is the wrong errno to return. ENOTTY has a very specific meaning. -- :wq Claudio