kqueue send over unix socket?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

kqueue send over unix socket?

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: [hidden email]
US Mail: 5708 Sabbia Dr, Round Rock, TX 78665-2106
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: kqueue send over unix socket?

Alan Somers-2
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 <[hidden email]> 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: [hidden email]
> US Mail: 5708 Sabbia Dr, Round Rock, TX 78665-2106
> _______________________________________________
> [hidden email] mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "[hidden email]"
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: kqueue send over unix socket?

Konstantin Belousov-3
In reply to this post by Larry Rosenman
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: [hidden email]
> US Mail: 5708 Sabbia Dr, Round Rock, TX 78665-2106
> _______________________________________________
> [hidden email] mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "[hidden email]"
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: kqueue send over unix socket?

Mark Johnston-2
In reply to this post by Larry Rosenman
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.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: kqueue send over unix socket?

Aki Tuomi
In reply to this post by Alan Somers-2
Hi!

I am trying exactly that.

dtrace output gives following

# dtrace -s sendmsg.d -p 61387
dtrace: script 'sendmsg.d' matched 30667 probes
CPU     ID                    FUNCTION: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`0xffffffff80f5891d

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

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

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

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

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


> On 12 March 2019 23:37 Alan Somers <[hidden email]> 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 <[hidden email]> 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: [hidden email]
> > US Mail: 5708 Sabbia Dr, Round Rock, TX 78665-2106
> > _______________________________________________
> > [hidden email] mailing list
> > https://lists.freebsd.org/mailman/listinfo/freebsd-current
> > To unsubscribe, send any mail to "[hidden email]"
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

Re: kqueue send over unix socket?

Jan Bramkamp-2
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?
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "[hidden email]"