From: Shuah Khan <skhan@linuxfoundation.org>
To: Antonio Quartulli <antonio@openvpn.net>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
openvpn-devel@lists.sourceforge.net,
linux-kselftest@vger.kernel.org,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Donald Hunter <donald.hunter@gmail.com>,
Shuah Khan <shuah@kernel.org>,
sd@queasysnail.net, ryazanov.s.a@gmail.com,
Andrew Lunn <andrew@lunn.ch>,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: [PATCH net-next v9 23/23] testing/selftest: add test tool and scripts for ovpn module
Date: Thu, 17 Oct 2024 15:40:51 -0600 [thread overview]
Message-ID: <9837c95a-2366-4733-b26a-9bfd27261f56@linuxfoundation.org> (raw)
In-Reply-To: <12609df3-4459-4d86-a505-e4f2daccff93@openvpn.net>
On 10/17/24 05:27, Antonio Quartulli wrote:
> On 16/10/2024 23:14, Shuah Khan wrote:
>> On 10/15/24 19:03, Antonio Quartulli wrote:
>>> The ovpn-cli tool can be compiled and used as selftest for the ovpn
>>> kernel module.
>>>
>>> It implements the netlink API and can thus be integrated in any
>>> script for more automated testing.
>>>
>>> Along with the tool, 2 scripts are added that perform basic
>>> functionality tests by means of network namespaces.
>>>
>>> The scripts can be performed in sequence by running run.sh
>>>
>>> Cc: shuah@kernel.org
>>> Cc: linux-kselftest@vger.kernel.org
>>> Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
>>
>> I almost gave my Reviewed-by when I saw the very long argument parsing
>> in the main() - please see comment below under main().
>>
>> Let's simply the logic using getopt() - it is way too long and
>> complex.
>
> Shuan,
>
> while looking into this I got the feeling that getopt() may not be the right tool for this parser.
>
> The ovpn-cli tool doesn't truly excpect "options" with their arguments on the command line, but it rather takes a "command" followed by command-specific arguments/modifiers. More like the 'ip' tool (from iproute2).
>
> The large if/else block is checking for the specified command.
> Moreover commands are *mutually exclusive*.
>
> Converting this logic to getopt() seems quite complicated as I'd need to:
> * keep track of the first specified command (which may be in any position)
> * prevent other commands to be thrown on the command line
> * come up with an option for each command-specific argument (and make sure only those required by the specified command are present)
>
Thank for looking into it. I would like to make a suggestion to
add a parse() routine and move this logic there instead of making
the main() very long. It will be easier to read the code as well.
> Are you sure this is the right path to follow?
>
> The 'ip' tool also implements something similar after all.
>
Sometimes argument parsing takes on life as new options get
added. It starts out as a couple if else conditionals and
expands - when I see a long argument parsing code, I like
to pause and ask the question. Sounds like you case is more
complex.
thanks,
-- Shuah
next prev parent reply other threads:[~2024-10-17 21:40 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-16 1:03 [PATCH net-next v9 00/23] Introducing OpenVPN Data Channel Offload Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 01/23] netlink: add NLA_POLICY_MAX_LEN macro Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 02/23] net: introduce OpenVPN Data Channel Offload (ovpn) Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 03/23] ovpn: add basic netlink support Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 04/23] ovpn: add basic interface creation/destruction/management routines Antonio Quartulli
2024-10-16 8:27 ` Jiri Pirko
2024-10-16 14:24 ` Antonio Quartulli
2024-10-17 6:39 ` Jiri Pirko
2024-10-16 1:03 ` [PATCH net-next v9 05/23] ovpn: keep carrier always on Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 06/23] ovpn: introduce the ovpn_peer object Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 07/23] ovpn: introduce the ovpn_socket object Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 08/23] ovpn: implement basic TX path (UDP) Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 09/23] ovpn: implement basic RX " Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 10/23] ovpn: implement packet processing Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 11/23] ovpn: store tunnel and transport statistics Antonio Quartulli
2024-10-19 11:38 ` kernel test robot
2024-10-16 1:03 ` [PATCH net-next v9 12/23] ovpn: implement TCP transport Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 13/23] ovpn: implement multi-peer support Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 14/23] ovpn: implement peer lookup logic Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 15/23] ovpn: implement keepalive mechanism Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 16/23] ovpn: add support for updating local UDP endpoint Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 17/23] ovpn: add support for peer floating Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 18/23] ovpn: implement peer add/dump/delete via netlink Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 19/23] ovpn: implement key add/del/swap " Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 20/23] ovpn: kill key and notify userspace in case of IV exhaustion Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 21/23] ovpn: notify userspace when a peer is deleted Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 22/23] ovpn: add basic ethtool support Antonio Quartulli
2024-10-16 1:03 ` [PATCH net-next v9 23/23] testing/selftest: add test tool and scripts for ovpn module Antonio Quartulli
2024-10-16 21:14 ` Shuah Khan
2024-10-17 7:56 ` Antonio Quartulli
2024-10-17 11:27 ` Antonio Quartulli
2024-10-17 21:40 ` Shuah Khan [this message]
2024-10-18 8:20 ` Antonio Quartulli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9837c95a-2366-4733-b26a-9bfd27261f56@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=andrew@lunn.ch \
--cc=antonio@openvpn.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=openvpn-devel@lists.sourceforge.net \
--cc=pabeni@redhat.com \
--cc=ryazanov.s.a@gmail.com \
--cc=sd@queasysnail.net \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox