rename symbols
Alexander Zubkov
green at qrator.net
Wed Jan 25 21:45:44 CET 2023
Hi,
I did some more experimenting with making aliases from cli. As I
understand, cli has its own "config" structure and memory pool, where its
symbols are allocated. So I need to copy it to the current config, but I
did not find suitable functions for doing that. And I make a copy for
cf_new_symbol. Not sure though, that I did everything right. It would be
great if someone looked at it and gave me some advice.
I split the modifications into two parts: creating aliases in the config
and then creating it in the cli. I think this idea with aliases is not that
ugly. The solution is quite minimal and does not affect anybody who do not
touch aliases. So if somebody wants to be able to do renaming in their
setup - feel free to use/test the patches. And maybe in such form it would
be meaningful to include it into the upstream version, as it is not that
ugly anymore (at least from my point of view). :)
I also not sure wether I need to copy the "scope" field from the reference
symbol or keep it from aliased. I originally kept if from alias symbol and
it worked too, at least with "config"-aliases. Now I'm copying it from the
reference symbol and it also works.
On Tue, Jan 24, 2023 at 9:42 AM Alexander Zubkov <green at qrator.net> wrote:
>
>
> On Tue, Jan 24, 2023 at 8:12 AM Alexander Zubkov <green at qrator.net> wrote:
>
>>
>>
>> On Tue, Jan 24, 2023 at 7:59 AM Ondrej Zajicek <santiago at crfreenet.org>
>> wrote:
>>
>>> On Tue, Jan 24, 2023 at 07:44:47AM +0100, Maria Matejka wrote:
>>> > >Hello
>>> > >
>>> > >I thing that the most elegant way how to handle renaming of objects
>>> > >during reconfiguration is to allow multiple names / aliases. There
>>> could
>>> > >be be more symbols pointing to given object (but the object points
>>> back
>>> > >to its primary name).
>>> > >
>>> > >Reconfiguration to rename objects could be done in two steps - in the
>>> > >first step, the user would add alias for the new name. In the second
>>> step,
>>> > >the old name would be removed.
>>> >
>>> > I think this keeps the problem with protocol restart when the renaming
>>> > of "base name" is done.
>>>
>>> The primary problem of renaming is matching existing objects with
>>> definitions from the new config. If that can be done (by finding
>>> existing objects through aliases), it is just a reconfiguration of
>>> object property, like any other. I.e. implementation problem instead
>>> of conceptual problem.
>>>
>>>
>> Adding aliases is an interesting option. But for example now in
>> protos_commit() it uses WALK_LIST(oc, old->protos), so it walks around old
>> protos first and then searches for a new ones. So it is not enough to add
>> another name pointing to the protocol, you need to search for protocol name
>> and also its aliases in the new protocols, or "invert" walking the lists in
>> all such places.
>> Probably might work if it is done in several steps:
>> 1) name1
>> 2) name1 + alias name2
>> 3) name2 + alias name1
>> 4) name2
>>
>
> I've checked such modifications (in attached patch), and it seems to work
> too. The transition with those several steps goes without protocol
> interruption for changing the names of protocols and tables. The patch adds
> the config statement:
> link <alias> to <symbol>
> It makes "alias" to reference the same entity as "symbol".
>
> In this case the transition process is longer, but less intervention in
> the code is required and it may be less ugly. As a plus, the transition can
> be done without additional CLI commands, only with a series of configs. On
> the other hand you can not do aliases CLI-only for the transition, you need
> them to be present in the new config while it is loading. You can do it in
> CLI for step 1->2, but for 2->3 it will not work. Renaming, though, needed
> intervention in the config too, to extend the symbol buffers.
>
> I also tried to also do a CLI command for aliasing. But it does not work
> in this variant, the new symbol does not appear in the table. Probably it
> is cleaned up after the command finishes. It is strange, because when I
> tried the same for "rename" version like that:
> CF_CLI(RENAME, CF_SYM_KNOWN CF_SYM_UNDEFINED, <sym> <new>, [[Rename
> symbol]])
> Then I just copied the name from the undefined symbol to the known symbol.
> And after that I saw multiple occurence of the name in "show symbols". So I
> thought the undefined one was left in the table. But now when I run "link"
> in the cli, I do not see the new symbol in the table afterwards.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20230125/f31fec51/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alias-symbol-config.patch
Type: text/x-patch
Size: 2534 bytes
Desc: not available
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20230125/f31fec51/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: alias-symbol-cli.patch
Type: text/x-patch
Size: 2963 bytes
Desc: not available
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20230125/f31fec51/attachment-0001.bin>
More information about the Bird-users
mailing list