Message ID | 20230911103407.1393149-1-leitao@debian.org (mailing list archive) |
---|---|
Headers | show |
Series | io_uring: Initial support for {s,g}etsockopt commands | expand |
Breno Leitao <leitao@debian.org> writes: > Create a new flag to track if the operation is running compat mode. > This basically check the context->compat and pass it to the issue_flags, > so, it could be queried later in the callbacks. > > Signed-off-by: Breno Leitao <leitao@debian.org> Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de> > --- > include/linux/io_uring.h | 1 + > io_uring/uring_cmd.c | 2 ++ > 2 files changed, 3 insertions(+) > > diff --git a/include/linux/io_uring.h b/include/linux/io_uring.h > index 106cdc55ff3b..bc53b35966ed 100644 > --- a/include/linux/io_uring.h > +++ b/include/linux/io_uring.h > @@ -20,6 +20,7 @@ enum io_uring_cmd_flags { > IO_URING_F_SQE128 = (1 << 8), > IO_URING_F_CQE32 = (1 << 9), > IO_URING_F_IOPOLL = (1 << 10), > + IO_URING_F_COMPAT = (1 << 11), > }; > > struct io_uring_cmd { > diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c > index 537795fddc87..60f843a357e0 100644 > --- a/io_uring/uring_cmd.c > +++ b/io_uring/uring_cmd.c > @@ -128,6 +128,8 @@ int io_uring_cmd(struct io_kiocb *req, unsigned int issue_flags) > issue_flags |= IO_URING_F_SQE128; > if (ctx->flags & IORING_SETUP_CQE32) > issue_flags |= IO_URING_F_CQE32; > + if (ctx->compat) > + issue_flags |= IO_URING_F_COMPAT; > if (ctx->flags & IORING_SETUP_IOPOLL) { > if (!file->f_op->uring_cmd_iopoll) > return -EOPNOTSUPP;
Breno Leitao <leitao@debian.org> writes: > Protect io_uring_cmd_sock() to be called if CONFIG_NET is not set. If > network is not enabled, but io_uring is, then we want to return > -EOPNOTSUPP for any possible socket operation. > > This is helpful because io_uring_cmd_sock() can now call functions that > only exits if CONFIG_NET is enabled without having #ifdef CONFIG_NET > inside the function itself. > > Signed-off-by: Breno Leitao <leitao@debian.org> > --- > io_uring/uring_cmd.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c > index 60f843a357e0..a7d6a7d112b7 100644 > --- a/io_uring/uring_cmd.c > +++ b/io_uring/uring_cmd.c > @@ -167,6 +167,7 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, > } > EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed); > > +#if defined(CONFIG_NET) > int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) > { > struct socket *sock = cmd->file->private_data; > @@ -193,3 +194,10 @@ int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) > } > } > EXPORT_SYMBOL_GPL(io_uring_cmd_sock); > +#else > +int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) > +{ > + return -EOPNOTSUPP; > +} > +#endif > + Is net/socket.c even built without CONFIG_NET? if not, you don't even need the alternative EOPNOTSUPP implementation.
On Mon, Sep 11, 2023 at 11:53:58AM -0400, Gabriel Krisman Bertazi wrote: > Breno Leitao <leitao@debian.org> writes: > > > Protect io_uring_cmd_sock() to be called if CONFIG_NET is not set. If > > network is not enabled, but io_uring is, then we want to return > > -EOPNOTSUPP for any possible socket operation. > > > > This is helpful because io_uring_cmd_sock() can now call functions that > > only exits if CONFIG_NET is enabled without having #ifdef CONFIG_NET > > inside the function itself. > > > > Signed-off-by: Breno Leitao <leitao@debian.org> > > --- > > io_uring/uring_cmd.c | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c > > index 60f843a357e0..a7d6a7d112b7 100644 > > --- a/io_uring/uring_cmd.c > > +++ b/io_uring/uring_cmd.c > > @@ -167,6 +167,7 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, > > } > > EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed); > > > > +#if defined(CONFIG_NET) > > int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) > > { > > struct socket *sock = cmd->file->private_data; > > @@ -193,3 +194,10 @@ int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) > > } > > } > > EXPORT_SYMBOL_GPL(io_uring_cmd_sock); > > +#else > > +int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) > > +{ > > + return -EOPNOTSUPP; > > +} > > +#endif > > + > > Is net/socket.c even built without CONFIG_NET? if not, you don't even need > the alternative EOPNOTSUPP implementation. It seems so. net/socket.o is part of obj-y: https://github.com/torvalds/linux/blob/master/net/Makefile#L9
Breno Leitao <leitao@debian.org> writes: > On Mon, Sep 11, 2023 at 11:53:58AM -0400, Gabriel Krisman Bertazi wrote: >> Breno Leitao <leitao@debian.org> writes: >> >> > Protect io_uring_cmd_sock() to be called if CONFIG_NET is not set. If >> > network is not enabled, but io_uring is, then we want to return >> > -EOPNOTSUPP for any possible socket operation. >> > >> > This is helpful because io_uring_cmd_sock() can now call functions that >> > only exits if CONFIG_NET is enabled without having #ifdef CONFIG_NET >> > inside the function itself. >> > >> > Signed-off-by: Breno Leitao <leitao@debian.org> >> > --- >> > io_uring/uring_cmd.c | 8 ++++++++ >> > 1 file changed, 8 insertions(+) >> > >> > diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c >> > index 60f843a357e0..a7d6a7d112b7 100644 >> > --- a/io_uring/uring_cmd.c >> > +++ b/io_uring/uring_cmd.c >> > @@ -167,6 +167,7 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, >> > } >> > EXPORT_SYMBOL_GPL(io_uring_cmd_import_fixed); >> > >> > +#if defined(CONFIG_NET) >> > int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) >> > { >> > struct socket *sock = cmd->file->private_data; >> > @@ -193,3 +194,10 @@ int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) >> > } >> > } >> > EXPORT_SYMBOL_GPL(io_uring_cmd_sock); >> > +#else >> > +int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) >> > +{ >> > + return -EOPNOTSUPP; >> > +} >> > +#endif >> > + >> >> Is net/socket.c even built without CONFIG_NET? if not, you don't even need >> the alternative EOPNOTSUPP implementation. > > It seems so. net/socket.o is part of obj-y: > > https://github.com/torvalds/linux/blob/master/net/Makefile#L9 Yes. But also: [0:cartola linux]$ grep 'net/' Kbuild obj-$(CONFIG_NET) += net/ I doubled checked and it should build fine without it. Technically, you also want to also guard the declaration in the header file, IMO, even if it compiles fine. Also, there is an extra blank line warning when applying the patch but, surprisingly, checkpatch.pl seems to miss it.