rename symbols

Alexander Zubkov green at qrator.net
Mon Jan 23 22:51:26 CET 2023


Hi all,

Some weird idea. I'm not sure it needs to be in the mainstream version, but
somebody might find it helpful.

For example I may want to refactor the naming scheme for protocols/tables
in my bird config. But when I apply the new config with the new names, such
renamed protocols will be recreated or restarted, which may be undesired.
So if I could rename protocols/tables in advance and then load the new
config, I can hope than no changes would be found and the there would be no
interruptions.

The attached patch solves the problem, by introducing such changes:

To rename some symbol one can use cli command:
rename <old_symbol> "<new_name>"
The new name is in the form of the string, because symbol form requires
symbol to be created. I tried to use CF_SYM_UNDEFINED for the second
parameter. It works somehow, but leaves duplicate symbols in the table. If
there is some way to clean them after it, it could be more visually
pleasing option.

The other problem is that a symbol has the fixed buffer for the name bound
by its length. And one would not be able to rename it to a new name that is
longer. But to overcome that, I add a field to a symbol to remember the
length of the allocated buffer and allow the buffer to be bigger. This can
be controlled by config option:
symbols min <len>
Which sets minum length that will fit the buffer. But as symbols are
allocated while reading the config, you need to place this configuration
option to the top of your config, i.e. before all the symbols you want to
rename.

So you can load the old config with the old names and this option added, it
will allocate bigger buffers for the symbols. Then you can rename your
symbols to the new ones. And finally load the new config with the new names.

Of course you need the bird version with this patch applied in advace to do
the trick. :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20230123/01368eb1/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rename-symbol.patch
Type: text/x-patch
Size: 4520 bytes
Desc: not available
URL: <http://trubka.network.cz/pipermail/bird-users/attachments/20230123/01368eb1/attachment.bin>


More information about the Bird-users mailing list