[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAD4GDZzZrJATP9qTe235RYytfAEm+ByeucR11g+ixWMXvGnVQQ@mail.gmail.com>
Date: Mon, 4 Mar 2024 15:57:57 +0000
From: Donald Hunter <donald.hunter@...il.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: davem@...emloft.net, netdev@...r.kernel.org, edumazet@...gle.com,
pabeni@...hat.com, jiri@...nulli.us
Subject: Re: [PATCH net-next 2/4] tools: ynl: allow setting recv() size
On Mon, 4 Mar 2024 at 14:58, Jakub Kicinski <kuba@...nel.org> wrote:
>
> On Mon, 4 Mar 2024 13:38:51 +0000 Donald Hunter wrote:
> > > class YnlFamily(SpecFamily):
> > > - def __init__(self, def_path, schema=None, process_unknown=False):
> > > + def __init__(self, def_path, schema=None, process_unknown=False,
> > > + recv_size=131072):
> >
> > An aside: what is the reason for choosing a 128k receive buffer? If I
> > remember correctly, netlink messages are capped at 32k.
>
> Attributes, not messages, right? But large messages are relatively
> rare, this is to make dump use fewer syscalls. Dump can give us multiple
> message on each recv().
I did mean messages:
https://elixir.bootlin.com/linux/latest/source/net/netlink/af_netlink.c#L1958
For rt_link I see ~21 messages per recv():
./tools/net/ynl/cli.py \
--spec Documentation/netlink/specs/rt_link.yaml \
--dump getlink --dbg-small-recv 131072 > /dev/null
Recv: read 3260 bytes, 2 messages
nl_len = 1432 (1416) nl_flags = 0x2 nl_type = 16
nl_len = 1828 (1812) nl_flags = 0x2 nl_type = 16
Recv: read 31180 bytes, 21 messages
...
Recv: read 31712 bytes, 22 messages
...
> > > super().__init__(def_path, schema)
> > >
> > > self.include_raw = False
> > > @@ -423,6 +428,16 @@ genl_family_name_to_id = None
> > > self.async_msg_ids = set()
> > > self.async_msg_queue = []
> > >
> > > + # Note that netlink will use conservative (min) message size for
> > > + # the first dump recv() on the socket, our setting will only matter
> >
> > I'm curious, why does it behave like this?
>
> Dump is initiated inside a send() system call, so that we can
> validate arguments and return any init errors directly.
> That means we don't know what buf size will be used by subsequent
> recv()s when we produce the first message :(
Ah, makes sense.
Powered by blists - more mailing lists