mbox series

[net-next,v2,0/2] support SO_PRIORITY cmsg

Message ID 20241102125136.5030-1-annaemesenyiri@gmail.com (mailing list archive)
Headers show
Series support SO_PRIORITY cmsg | expand

Message

Anna Nyiri Nov. 2, 2024, 12:51 p.m. UTC
The changes introduce a new helper function,
`sk_set_prio_allowed`, which centralizes the logic for validating
priority settings. This series adds support for the `SO_PRIORITY`
control message, allowing user-space applications to set socket
priority via control messages (cmsg).

Patch Overview:
Patch 1/2: Introduces `sk_set_prio_allowed` helper function.
Patch 2/2: Implements support for setting `SO_PRIORITY` via control
messages.

v2:
- Suggested by Willem de Bruijn <willemdebruijn.kernel@gmail.com>
  introduce "sk_set_prio_allowed" helper to check priority setting
  capability
- drop new fields and change sockcm_cookie::priority from "char" to
  "u32" to match with sk_buff::priority
- cork->tos value check before priority setting
  moved from __ip_make_skb() to ip_setup_cork()
- rebased on net-next

v1:
https://lore.kernel.org/all/20241029144142.31382-1-annaemesenyiri@gmail.com/

Anna Emese Nyiri (2):
  Introduce sk_set_prio_allowed helper function
  support SO_PRIORITY cmsg

 include/net/inet_sock.h |  2 +-
 include/net/ip.h        |  3 ++-
 include/net/sock.h      |  4 +++-
 net/can/raw.c           |  2 +-
 net/core/sock.c         | 19 ++++++++++++++++---
 net/ipv4/ip_output.c    |  7 +++++--
 net/ipv4/raw.c          |  2 +-
 net/ipv6/ip6_output.c   |  3 ++-
 net/ipv6/raw.c          |  2 +-
 net/packet/af_packet.c  |  2 +-
 10 files changed, 33 insertions(+), 13 deletions(-)

Comments

Jakub Kicinski Nov. 3, 2024, 3:41 p.m. UTC | #1
On Sat,  2 Nov 2024 13:51:34 +0100 Anna Emese Nyiri wrote:
> The changes introduce a new helper function,
> `sk_set_prio_allowed`, which centralizes the logic for validating
> priority settings. This series adds support for the `SO_PRIORITY`
> control message, allowing user-space applications to set socket
> priority via control messages (cmsg).

Could be a flake but it seems to break this test:
  tools/testing/selftests/net/fq_band_pktlimit.sh
with
  # unexpected drop count at 3
please double check if you see this failure.
Ido Schimmel Nov. 3, 2024, 4:25 p.m. UTC | #2
On Sat, Nov 02, 2024 at 01:51:34PM +0100, Anna Emese Nyiri wrote:
> The changes introduce a new helper function,
> `sk_set_prio_allowed`, which centralizes the logic for validating
> priority settings. This series adds support for the `SO_PRIORITY`
> control message, allowing user-space applications to set socket
> priority via control messages (cmsg).
> 
> Patch Overview:
> Patch 1/2: Introduces `sk_set_prio_allowed` helper function.
> Patch 2/2: Implements support for setting `SO_PRIORITY` via control
> messages.
> 
> v2:
> - Suggested by Willem de Bruijn <willemdebruijn.kernel@gmail.com>
>   introduce "sk_set_prio_allowed" helper to check priority setting
>   capability
> - drop new fields and change sockcm_cookie::priority from "char" to
>   "u32" to match with sk_buff::priority
> - cork->tos value check before priority setting
>   moved from __ip_make_skb() to ip_setup_cork()
> - rebased on net-next
> 
> v1:
> https://lore.kernel.org/all/20241029144142.31382-1-annaemesenyiri@gmail.com/
> 
> Anna Emese Nyiri (2):
>   Introduce sk_set_prio_allowed helper function
>   support SO_PRIORITY cmsg
> 
>  include/net/inet_sock.h |  2 +-
>  include/net/ip.h        |  3 ++-
>  include/net/sock.h      |  4 +++-
>  net/can/raw.c           |  2 +-
>  net/core/sock.c         | 19 ++++++++++++++++---
>  net/ipv4/ip_output.c    |  7 +++++--
>  net/ipv4/raw.c          |  2 +-
>  net/ipv6/ip6_output.c   |  3 ++-
>  net/ipv6/raw.c          |  2 +-
>  net/packet/af_packet.c  |  2 +-
>  10 files changed, 33 insertions(+), 13 deletions(-)

Please consider adding a selftest for this feature. Willem already
extended tools/testing/selftests/net/cmsg_sender.c so that it could be
used to set SO_PRIORITY via setsockopt. You can extend it to set
SO_PRIORITY via cmsg and then use it in a test like
tools/testing/selftests/net/cmsg_so_mark.sh is doing for SO_MARK.
Anna Nyiri Nov. 5, 2024, 2:34 p.m. UTC | #3
Ido Schimmel <idosch@idosch.org> ezt írta (időpont: 2024. nov. 3., V, 17:25):
>
> On Sat, Nov 02, 2024 at 01:51:34PM +0100, Anna Emese Nyiri wrote:
> > The changes introduce a new helper function,
> > `sk_set_prio_allowed`, which centralizes the logic for validating
> > priority settings. This series adds support for the `SO_PRIORITY`
> > control message, allowing user-space applications to set socket
> > priority via control messages (cmsg).
> >
> > Patch Overview:
> > Patch 1/2: Introduces `sk_set_prio_allowed` helper function.
> > Patch 2/2: Implements support for setting `SO_PRIORITY` via control
> > messages.
> >
> > v2:
> > - Suggested by Willem de Bruijn <willemdebruijn.kernel@gmail.com>
> >   introduce "sk_set_prio_allowed" helper to check priority setting
> >   capability
> > - drop new fields and change sockcm_cookie::priority from "char" to
> >   "u32" to match with sk_buff::priority
> > - cork->tos value check before priority setting
> >   moved from __ip_make_skb() to ip_setup_cork()
> > - rebased on net-next
> >
> > v1:
> > https://lore.kernel.org/all/20241029144142.31382-1-annaemesenyiri@gmail.com/
> >
> > Anna Emese Nyiri (2):
> >   Introduce sk_set_prio_allowed helper function
> >   support SO_PRIORITY cmsg
> >
> >  include/net/inet_sock.h |  2 +-
> >  include/net/ip.h        |  3 ++-
> >  include/net/sock.h      |  4 +++-
> >  net/can/raw.c           |  2 +-
> >  net/core/sock.c         | 19 ++++++++++++++++---
> >  net/ipv4/ip_output.c    |  7 +++++--
> >  net/ipv4/raw.c          |  2 +-
> >  net/ipv6/ip6_output.c   |  3 ++-
> >  net/ipv6/raw.c          |  2 +-
> >  net/packet/af_packet.c  |  2 +-
> >  10 files changed, 33 insertions(+), 13 deletions(-)
>
> Please consider adding a selftest for this feature. Willem already
> extended tools/testing/selftests/net/cmsg_sender.c so that it could be
> used to set SO_PRIORITY via setsockopt. You can extend it to set
> SO_PRIORITY via cmsg and then use it in a test like
> tools/testing/selftests/net/cmsg_so_mark.sh is doing for SO_MARK.

Of course, I will send the test. However, I would first like to
clarify which option I should assign in cmsg_sender for setting
priority via cmsg. The -P option is already used for setting priority
with setsockopt(), and -p is used to specify the protocol.
Willem de Bruijn Nov. 5, 2024, 3:01 p.m. UTC | #4
Anna Nyiri wrote:
> Ido Schimmel <idosch@idosch.org> ezt írta (időpont: 2024. nov. 3., V, 17:25):
> >
> > On Sat, Nov 02, 2024 at 01:51:34PM +0100, Anna Emese Nyiri wrote:
> > > The changes introduce a new helper function,
> > > `sk_set_prio_allowed`, which centralizes the logic for validating
> > > priority settings. This series adds support for the `SO_PRIORITY`
> > > control message, allowing user-space applications to set socket
> > > priority via control messages (cmsg).
> > >
> > > Patch Overview:
> > > Patch 1/2: Introduces `sk_set_prio_allowed` helper function.
> > > Patch 2/2: Implements support for setting `SO_PRIORITY` via control
> > > messages.
> > >
> > > v2:
> > > - Suggested by Willem de Bruijn <willemdebruijn.kernel@gmail.com>
> > >   introduce "sk_set_prio_allowed" helper to check priority setting
> > >   capability
> > > - drop new fields and change sockcm_cookie::priority from "char" to
> > >   "u32" to match with sk_buff::priority
> > > - cork->tos value check before priority setting
> > >   moved from __ip_make_skb() to ip_setup_cork()
> > > - rebased on net-next
> > >
> > > v1:
> > > https://lore.kernel.org/all/20241029144142.31382-1-annaemesenyiri@gmail.com/
> > >
> > > Anna Emese Nyiri (2):
> > >   Introduce sk_set_prio_allowed helper function
> > >   support SO_PRIORITY cmsg
> > >
> > >  include/net/inet_sock.h |  2 +-
> > >  include/net/ip.h        |  3 ++-
> > >  include/net/sock.h      |  4 +++-
> > >  net/can/raw.c           |  2 +-
> > >  net/core/sock.c         | 19 ++++++++++++++++---
> > >  net/ipv4/ip_output.c    |  7 +++++--
> > >  net/ipv4/raw.c          |  2 +-
> > >  net/ipv6/ip6_output.c   |  3 ++-
> > >  net/ipv6/raw.c          |  2 +-
> > >  net/packet/af_packet.c  |  2 +-
> > >  10 files changed, 33 insertions(+), 13 deletions(-)
> >
> > Please consider adding a selftest for this feature. Willem already
> > extended tools/testing/selftests/net/cmsg_sender.c so that it could be
> > used to set SO_PRIORITY via setsockopt. You can extend it to set
> > SO_PRIORITY via cmsg and then use it in a test like
> > tools/testing/selftests/net/cmsg_so_mark.sh is doing for SO_MARK.
> 
> Of course, I will send the test. However, I would first like to
> clarify which option I should assign in cmsg_sender for setting
> priority via cmsg. The -P option is already used for setting priority
> with setsockopt(), and -p is used to specify the protocol.

Thanks for adding test coverage.

If all the Ps are taken, use Q. It's a rare letter, and happens to be
the next. In the end, whatever is available.