Re: kqueue send over unix socket?

2019-03-13 Thread Jan Bramkamp
On 12.03.19 22:52, Aki Tuomi wrote:
> Hi!
> 
> I am trying exactly that.

As others have already stated kqueue file descriptors can leave the
process that created them (neither through file descriptor passing nor
through inheritance). Can you tell us why you want to send the kqueue
file descriptor to an other process? What do you want to accomplish?
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: kqueue send over unix socket?

2019-03-12 Thread Aki Tuomi
Hi!

I am trying exactly that.

dtrace output gives following

# dtrace -s sendmsg.d -p 61387
dtrace: script 'sendmsg.d' matched 30667 probes
CPU IDFUNCTION:NAME
  0  16637 uipc_send:return 
  kernel`sosend_generic+0x556
  kernel`kern_sendit+0x296
  kernel`sendit+0x19e
  kernel`sys_sendmsg+0x61
  kernel`amd64_syscall+0xa38
  kernel`0x80f5891d

  0  35794sosend_generic:return 
  kernel`kern_sendit+0x296
  kernel`sendit+0x19e
  kernel`sys_sendmsg+0x61
  kernel`amd64_syscall+0xa38
  kernel`0x80f5891d

  0  32432   kern_sendit:return 
  kernel`sendit+0x19e
  kernel`sys_sendmsg+0x61
  kernel`amd64_syscall+0xa38
  kernel`0x80f5891d

  0  55533  free:return 
  kernel`sendit+0x1b0
  kernel`sys_sendmsg+0x61
  kernel`amd64_syscall+0xa38
  kernel`0x80f5891d

  0  16604sendit:return 
  kernel`sys_sendmsg+0x61
  kernel`amd64_syscall+0xa38
  kernel`0x80f5891d

  0  30776   sys_sendmsg:return 
  kernel`amd64_syscall+0xa38
  kernel`0x80f5891d


> On 12 March 2019 23:37 Alan Somers  wrote:
> 
>  
> Is he trying to send the kqueue file descriptor itself using sendmsg
> with SCM_RIGHTS?  It sounds like kqueues cannot be sent over unix
> sockets; not every file type necessarily can.  But if you want to know
> the nitty-gritty details, just run this:
> dtrace -i 'fbt:::return /arg1 == 45/ {stack();}' -c "my_program
> my_options" and that will usually tell you the exact function that set
> the error.
> 
> If the output is too large, then you can filter it by writing a D
> program like this:
> 
> #sendmsg.d
> fbt:kernel:sys_sendmsg:entry
> {
> this->trigger = 1;
> }
> fbt:::return
> / this->trigger == 1 && arg1 == 45 /
> {
> stack();
> }
> fbt:kernel:sys_sendmsg:return
> {
> this->trigger = 0;
> }
> 
> dtrace -s sendmsg.d -c "my_program my_options"
> 
> Hope that helps.
> -Alan
> 
> On Tue, Mar 12, 2019 at 3:22 PM Larry Rosenman  wrote:
> >
> > I'm working with Aki Tuomi of Dovecot and he asks:
> >
> > I tried to ask if you could ask from some Kernel hacker why I cannot
> > send kqueue() fd over unix socket, I get "Operation not supported".
> >
> > Can anyone help me?
> >
> >
> >
> > --
> > Larry Rosenman http://www.lerctr.org/~ler
> > Phone: +1 214-642-9640 E-Mail: l...@lerctr.org
> > US Mail: 5708 Sabbia Dr, Round Rock, TX 78665-2106
> > ___
> > freebsd-current@freebsd.org mailing list
> > https://lists.freebsd.org/mailman/listinfo/freebsd-current
> > To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: kqueue send over unix socket?

2019-03-12 Thread Mark Johnston
On Tue, Mar 12, 2019 at 04:10:19PM -0500, Larry Rosenman wrote:
> I'm working with Aki Tuomi of Dovecot and he asks:
> 
> I tried to ask if you could ask from some Kernel hacker why I cannot 
> send kqueue() fd over unix socket, I get "Operation not supported".
> 
> Can anyone help me?

What exactly do you want to know?  Events registered on a kqueue may
contain state associated with the process that registered them.  For
example, the identifier for some events is a file descriptor, but
different processes generally don't share their file descriptor tables.
Note that kqueue descriptors are not inherited by the child of a fork()
either.
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: kqueue send over unix socket?

2019-03-12 Thread Konstantin Belousov
On Tue, Mar 12, 2019 at 04:10:19PM -0500, Larry Rosenman wrote:
> I'm working with Aki Tuomi of Dovecot and he asks:
> 
> I tried to ask if you could ask from some Kernel hacker why I cannot 
> send kqueue() fd over unix socket, I get "Operation not supported".
Right, because sending kqfd to other process does not make sense.
For the same reason kqueue filedescriptors are closed on fork.

Issue is that kqueue operates on file descriptors, it stores events
and names them by fd you use for registration.  So all registered
events names become meaningless when process operates on different
file descriptor table, which happens after fork() or if kqfd is
passed over unix socket to other process.

Technically this occurs because kqueue file ops structure does not
specify DFLAG_PASSABLE.

> 
> Can anyone help me?
> 
> 
> 
> -- 
> Larry Rosenman http://www.lerctr.org/~ler
> Phone: +1 214-642-9640 E-Mail: l...@lerctr.org
> US Mail: 5708 Sabbia Dr, Round Rock, TX 78665-2106
> ___
> freebsd-current@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: kqueue send over unix socket?

2019-03-12 Thread Alan Somers
Is he trying to send the kqueue file descriptor itself using sendmsg
with SCM_RIGHTS?  It sounds like kqueues cannot be sent over unix
sockets; not every file type necessarily can.  But if you want to know
the nitty-gritty details, just run this:
dtrace -i 'fbt:::return /arg1 == 45/ {stack();}' -c "my_program
my_options" and that will usually tell you the exact function that set
the error.

If the output is too large, then you can filter it by writing a D
program like this:

#sendmsg.d
fbt:kernel:sys_sendmsg:entry
{
this->trigger = 1;
}
fbt:::return
/ this->trigger == 1 && arg1 == 45 /
{
stack();
}
fbt:kernel:sys_sendmsg:return
{
this->trigger = 0;
}

dtrace -s sendmsg.d -c "my_program my_options"

Hope that helps.
-Alan

On Tue, Mar 12, 2019 at 3:22 PM Larry Rosenman  wrote:
>
> I'm working with Aki Tuomi of Dovecot and he asks:
>
> I tried to ask if you could ask from some Kernel hacker why I cannot
> send kqueue() fd over unix socket, I get "Operation not supported".
>
> Can anyone help me?
>
>
>
> --
> Larry Rosenman http://www.lerctr.org/~ler
> Phone: +1 214-642-9640 E-Mail: l...@lerctr.org
> US Mail: 5708 Sabbia Dr, Round Rock, TX 78665-2106
> ___
> freebsd-current@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


kqueue send over unix socket?

2019-03-12 Thread Larry Rosenman

I'm working with Aki Tuomi of Dovecot and he asks:

I tried to ask if you could ask from some Kernel hacker why I cannot 
send kqueue() fd over unix socket, I get "Operation not supported".


Can anyone help me?



--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 214-642-9640 E-Mail: l...@lerctr.org
US Mail: 5708 Sabbia Dr, Round Rock, TX 78665-2106
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"