[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <9119ef86-b274-4ab0-b67c-c798314fbd12@orange.com>
Date: Wed, 11 Jun 2025 18:42:48 +0200
From: alexandre.ferrieux@...nge.com
To: Daniel Borkmann <daniel@...earbox.net>,
Alexandre Ferrieux <alexandre.ferrieux@...il.com>
Cc: Linux Kernel Network Developers <netdev@...r.kernel.org>,
Nicolas Dichtel <nicolas.dichtel@...nd.com>,
Nikolay Aleksandrov <razor@...ckwall.org>
Subject: Re: [BUG iproute2] Netkit unusable in batch mode
Hi Daniel,
On 6/11/25 16:07, Daniel Borkmann wrote:
>
>> Is there a scenario where
>> netkit_parse_opt() is called several times in a single command, but in a
>> stateful manner ?
>
> This was basically because we call into iplink_parse() after "peer" to gather settings
> for the peer similar to link_veth.c modulo that netkit has mode/policy/scrub settings
> and we only want them to be present once for a single 'link add' call. Might be better
> to just reset the above before the 'goto out_ok' after parsing peer. Could you cook a
> patch for that instead?
Ah, I see... Recursion instead of iteration; that's elegant until you need
stateful code :} To be honest, to me it's rather an anti-idiom (coming from
veth) to be fixed rather than repeated...
Anyway, I did as you suggest, but my hand is unsteady as the code lacks symmetry
and though I tried to reset "data" properly, I'm not sure I did. Please review.
-----
diff --git a/ip/iplink_netkit.c b/ip/iplink_netkit.c
index 818da119..25957316 100644
--- a/ip/iplink_netkit.c
+++ b/ip/iplink_netkit.c
@@ -125,6 +125,8 @@ static int netkit_parse_opt(struct link_util *lu, int argc,
char **argv,
return err;
if (type)
duparg("type", argv[err]);
+ seen_peer = false;
+ seen_mode = false;
goto out_ok;
}
fprintf(stderr, "%s: unknown option \"%s\"?\n",
@@ -146,6 +148,7 @@ out_ok:
ifm->ifi_flags = ifi_flags;
ifm->ifi_change = ifi_change;
ifm->ifi_index = ifi_index;
+ data = NULL;
return 0;
}
____________________________________________________________________________________________________________
Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.
This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.
Powered by blists - more mailing lists