Subject: Re: [PATCH] Phonet: set the pipe handle using setsockopt

From: Rémi Denis-Courmont <[email-masked]>
Date: Wed, 16 Nov 2011 08:30:50 +0200

Le Lundi 14 Novembre 2011 11:36:12 ext Hemant-vilas RAMDASI a écrit :
 > > sockaddr_pn *spn) /* Phonet device ioctl requests */
> > > 
> > >  #ifdef __KERNEL__
> > >  #define SIOCPNGAUTOCONF		(SIOCDEVPRIVATE + 0)
> > > 
> > > +#define SIOPNPIPE_ENABLE	_IO(SIOCPNGAUTOCONF,   1)
> > 
> > Does this even work? I am not an expert on this, but I would think that
> > device-private controls are routed to the network device, not the
> > socket. In
> > any case, it does not seem right.
> 
> Yes, it works. The ioctl is routed to per-socket functions.

Even if it works, sockets are probably not supposed to use the device-private 
ioctl() range, are they?

And why is this inside __KERNEL__ ?

> > > @@ -994,6 +1068,17 @@ static int pep_getsockopt(struct sock *sk, int
> > 
> > level,
> > 
> > > int optname, return -EINVAL;
> > > 
> > >  		break;
> > > 
> > > +	case PNPIPE_ENABLE:
> > > +		if (sk->sk_state == TCP_ESTABLISHED)
> > > +			val = 1;
> > > +		else
> > > +			val = 0;
> > > +		break;
> > 
> > Do you still need this read-only option?
> 
> Yes.

Why and how?

-- 
Rémi Denis-Courmont
http://www.remlab.net/