Subject: Re: [PATCH net 4/5] tools: ynl: support listening on all nsids

From: Jakub Kicinski <[email-masked]>
Date: Tue, 19 May 2026 17:11:15 -0700

On Fri, 15 May 2026 22:19:23 +0200 Ilya Maximets wrote:
> +    def ntf_listen_all_nsid(self):

doc-string needed

> +        self.sock.setsockopt(Netlink.SOL_NETLINK,
> +                             Netlink.NETLINK_LISTEN_ALL_NSID, 1)
> +
> +    @staticmethod
> +    def _decode_nsid(ancdata):
> +        for cmsg_level, cmsg_type, cmsg_data in ancdata:
> +            if (cmsg_level == Netlink.SOL_NETLINK and
> +                    cmsg_type == Netlink.NETLINK_LISTEN_ALL_NSID):
> +                nsid = struct.unpack('i', cmsg_data)[0]
> +                if nsid >= 0:
> +                    return nsid
> +                return None
> +        return None
> +
>      def set_recv_dbg(self, enabled):
>          self._recv_dbg = enabled
>  
> @@ -1235,7 +1251,7 @@ class YnlFamily(SpecFamily):
>                              f" when parsing '{attr_spec['name']}'")
>          return raw
>  
> -    def handle_ntf(self, decoded):
> +    def handle_ntf(self, decoded, nsid=None):
>          msg = {}
>          if self.include_raw:
>              msg['raw'] = decoded
> @@ -1246,15 +1262,20 @@ class YnlFamily(SpecFamily):
>  
>          msg['name'] = op['name']
>          msg['msg'] = attrs
> +        if nsid is not None:
> +            msg['nsid'] = nsid
>          self.async_msg_queue.put(msg)
>  
>      def check_ntf(self):
>          while True:
>              try:
> -                reply = self.sock.recv(self._recv_size, socket.MSG_DONTWAIT)
> +                reply, ancdata, _, _ = self.sock.recvmsg(self._recv_size,
> +                                                         4096,
> +                                                         socket.MSG_DONTWAIT)

please add a helper method (_recvmsg()?) that only takes flags
and doesn't return flags or addr since neither caller cares