[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241203180714.45a2af81@kernel.org>
Date: Tue, 3 Dec 2024 18:07:14 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Donald Hunter <donald.hunter@...il.com>
Cc: netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>, Eric
Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>, Simon
Horman <horms@...nel.org>, Johannes Berg <johannes@...solutions.net>,
linux-wireless@...r.kernel.org, donald.hunter@...hat.com
Subject: Re: [PATCH net-next v1 4/7] tools/net/ynl: accept IP string inputs
On Tue, 3 Dec 2024 13:06:52 +0000 Donald Hunter wrote:
> + def _from_string(self, string, display_hint, type):
Any reason not to pass attr_spec instead of the members one by one?
> + if display_hint in ['ipv4', 'ipv6']:
> + ip = ipaddress.ip_address(string)
> + if type == 'binary':
> + raw = ip.packed
> + else:
> + raw = int(ip)
> + else:
I wonder if we should raise in this case?
Especially if type is binary passing the string back will just blow up
later, right? We could instead rise with a nice clear error message
here.
> + raw = string
> + return raw
Powered by blists - more mailing lists