Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Generic Config Updater][IPv6] | Generic Config Updater is case sensitive when dealing with IPv6 addresses #11622

Closed
dbarashinvd opened this issue Aug 4, 2022 · 0 comments · Fixed by sonic-net/sonic-utilities#2299
Assignees

Comments

@dbarashinvd
Copy link
Contributor

dbarashinvd commented Aug 4, 2022

Description

Generic Config Updater is case sensitive when dealing with IPv6 addresses

Steps to reproduce the issue:

  1. Config a ipv6 interface and bind ipv6 addresses to it via CLI:

admin@r-bulldog-02:~$ sudo config interface ip add Ethernet12 fc00::1/126 # the address is in lowercase

admin@r-bulldog-02:~$ sudo config interface ip add Ethernet12 FC00::11/126 # the address is in uppercase

admin@r-bulldog-02:~$ show ipv6 interface
Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP


Bridge fe80::8841:bdff:fe6c:242d%Bridge/64 up/down N/A N/A
Ethernet0 fe80::9a03:9bff:fef8:e7c0%Ethernet0/64 up/up N/A N/A
Ethernet4 fe80::9a03:9bff:fef8:e7c0%Ethernet4/64 up/up N/A N/A
Ethernet8 fe80::9a03:9bff:fef8:e7c0%Ethernet8/64 up/up N/A N/A
Ethernet12 fc00::1/126 up/up N/A N/A
fc00::11/126 N/A N/A
fe80::9a03:9bff:fef8:e7c0%Ethernet12/64 N/A N/A
Ethernet14 fe80::9a03:9bff:fef8:e7c0%Ethernet14/64 up/up N/A N/A

......

admin@r-bulldog-02:~$ show runningconfiguration all | grep Ethernet12
"Ethernet12": {
"Ethernet12|0": {
"Ethernet12|3-4": {
"Ethernet12": {
"Ethernet12": {
"Ethernet12|0-2": {
"Ethernet12|3-4": {
"Ethernet12|5-6": {
"Ethernet12": "5m",
"Ethernet12": {},
"Ethernet12|fc00::1/126": {},
"Ethernet12|fc00::11/126": {}

SONiC accepts both lowercase and uppercase ipv6 addresses when using CLI, and the uppercase address is converted to lowercase in config db.

  1. Save the config and modify one adderss in config_db.json to uppercase, and reload the config

admin@r-bulldog-02:$ sudo config save -y
Running command: /usr/local/bin/sonic-cfggen -d --print-data > /etc/sonic/config_db.json
admin@r-bulldog-02:
$ sudo vi /etc/sonic/config_db.json # fc00::01/126 is modified to FC00::01/126

admin@r-bulldog-02:~$ sudo config reload -y

Running command: rm -rf /tmp/dropstat-*
Disabling container monitoring ...
Stopping SONiC target ...
Running command: /usr/local/bin/sonic-cfggen -j /etc/sonic/init_cfg.json -j /etc/sonic/config_db.json --write-to-db
Running command: /usr/local/bin/db_migrator.py -o migrate
Running command: /usr/local/bin/sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t /usr/share/sonic/templates/sonic-environment.j2,/etc/sonic/sonic-environment
Restarting SONiC target ...
Enabling container monitoring ...
Reloading Monit configuration ...
Reinitializing monit daemon

admin@r-bulldog-02:~$ show ipv6 interface
Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP


Bridge fe80::c0cf:b0ff:fe28:91b6%Bridge/64 up/down N/A N/A
Ethernet0 fe80::9a03:9bff:fef8:e7c0%Ethernet0/64 up/up N/A N/A
Ethernet4 fe80::9a03:9bff:fef8:e7c0%Ethernet4/64 up/up N/A N/A
Ethernet8 fe80::9a03:9bff:fef8:e7c0%Ethernet8/64 up/up N/A N/A
Ethernet12 fc00::1/126 up/up N/A N/A # the ipv6 addresses are reloaded succefully
fc00::11/126 N/A N/A
fe80::9a03:9bff:fef8:e7c0%Ethernet12/64 N/A N/A

admin@r-bulldog-02:~$ show runningconfiguration interfaces
{
"Ethernet12": {},
"Ethernet12|FC00::11/126": {}, # this one is in uppercase in db
"Ethernet12|fc00::1/126": {} # this one is in lower case, both are valid
}

  1. Create a patch file to remove one ipv6 address from the interface but use the different case from the db

content of /tmp/test.patch file:

[
{
"path": "/INTERFACE/Ethernet12|FC00::1~1126",
"op": "remove"
}
]

  1. Apply the patch, failed because the ipv6 address in the patch is uppercase while is lowercase in db

admin@r-bulldog-02:$ sudo config apply-patch /tmp/test.patch
Patch Applier: Patch application starting.
Patch Applier: Patch: [{"path": "/INTERFACE/Ethernet12|FC00::1
1126", "op": "remove"}]
Patch Applier: Getting current config db.
Patch Applier: Simulating the target full config after applying the patch.
Failed to apply patch
Usage: config apply-patch [OPTIONS] PATCH_FILE_PATH
Try "config apply-patch -h" for help.

Error: can't remove a non-existent object 'Ethernet12|FC00::1/126'

  1. Modify the adderss to lowercase and try again:

admin@r-bulldog-02:$ sudo config apply-patch /tmp/test.patch
Patch Applier: Patch application starting.
Patch Applier: Patch: [{"path": "/INTERFACE/Ethernet12|fc00::1
1126", "op": "remove"}]
Patch Applier: Getting current config db.
Patch Applier: Simulating the target full config after applying the patch.
Patch Applier: Validating target config does not have empty tables, since they do not show up in ConfigDb.
Patch Applier: Sorting patch updates.
sonic_yang(6):Note: Below table(s) have no YANG models: DEFAULT_LOSSLESS_BUFFER_PARAMETER, KDUMP, LOSSLESS_TRAFFIC_PATTERN, SNMP, SNMP_COMMUNITY
sonic_yang(6):Note: Below table(s) have no YANG models: DEFAULT_LOSSLESS_BUFFER_PARAMETER, KDUMP, LOSSLESS_TRAFFIC_PATTERN, SNMP, SNMP_COMMUNITY
sonic_yang(6):Note: Below table(s) have no YANG models: DEFAULT_LOSSLESS_BUFFER_PARAMETER, KDUMP, LOSSLESS_TRAFFIC_PATTERN, SNMP, SNMP_COMMUNITY
Patch Applier: The patch was sorted into 1 change:
Patch Applier: * [{"op": "remove", "path": "/INTERFACE/Ethernet12|fc00::11126"}]
Patch Applier: Applying 1 change in order:
Patch Applier: * [{"op": "remove", "path": "/INTERFACE/Ethernet12|fc00::1
1126"}]
Patch Applier: Verifying patch updates are reflected on ConfigDB.
Patch Applier: Patch application completed.
Patch applied successfully.
admin@r-bulldog-02:~$ show runningconfiguration interface
{
"Ethernet12": {},
"Ethernet12|FC00::11/126": {}
}

Describe the results you received:

apply-patch fails with this error
Error: can't remove a non-existent object 'Ethernet12|FC00::1/126'

Describe the results you expected:

successful apply-patch
Since SONiC accept both uppercase and lowercase ipv6 addresses, the Generric Config Updater should align with the system level design, or the user expirence will not be good, especially the purpose of GCU is to improve user expirence.

Output of show version:

admin@c-anaconda-01:~$ show version

SONiC Software Version: SONiC.HEAD.0-dirty-20220727.101004
Distribution: Debian 11.4
Kernel: 5.10.0-12-2-amd64
Build commit: 4d48e6063
Build date: Wed Jul 27 02:15:44 UTC 2022
Built by: junchao@arc-build-server-2

Platform: x86_64-mlnx_msn3700c-r0
HwSKU: ACS-MSN3700C
ASIC: mellanox
ASIC Count: 1
Serial Number: MT1922X00266
Model Number: MSN3700-CS2FO
Hardware Revision: A4
Uptime: 15:33:09 up 8 days, 13:01,  1 user,  load average: 0.65, 0.83, 0.89
Date: Thu 04 Aug 2022 15:33:09

Docker images:
REPOSITORY                                         TAG                            IMAGE ID       SIZE
docker-orchagent                                   HEAD.0-dirty-20220727.101004   db06e05e21cd   478MB
docker-orchagent                                   latest                         db06e05e21cd   478MB
docker-macsec                                      latest                         e64930203515   462MB
docker-syncd-mlnx                                  HEAD.0-dirty-20220727.101004   659b60c0d4ed   984MB
docker-syncd-mlnx                                  latest                         659b60c0d4ed   984MB
docker-platform-monitor                            HEAD.0-dirty-20220727.101004   55e92f3cfdbb   988MB
docker-platform-monitor                            latest                         55e92f3cfdbb   988MB
docker-dhcp-relay                                  latest                         b824da52cc45   453MB
docker-database                                    HEAD.0-dirty-20220727.101004   d4783556eab1   444MB
docker-database                                    latest                         d4783556eab1   444MB
docker-sonic-telemetry                             HEAD.0-dirty-20220727.101004   0c20b5dfc05f   524MB
docker-sonic-telemetry                             latest                         0c20b5dfc05f   524MB
docker-mux                                         HEAD.0-dirty-20220727.101004   b89573696729   492MB
docker-mux                                         latest                         b89573696729   492MB
docker-router-advertiser                           HEAD.0-dirty-20220727.101004   289528560d7b   444MB
docker-router-advertiser                           latest                         289528560d7b   444MB
docker-fpm-frr                                     HEAD.0-dirty-20220727.101004   e4ce443d0e8e   458MB
docker-fpm-frr                                     latest                         e4ce443d0e8e   458MB
docker-nat                                         HEAD.0-dirty-20220727.101004   a3805611eb0e   431MB
docker-nat                                         latest                         a3805611eb0e   431MB
docker-sflow                                       HEAD.0-dirty-20220727.101004   844f80f51b0d   429MB
docker-sflow                                       latest                         844f80f51b0d   429MB
docker-teamd                                       HEAD.0-dirty-20220727.101004   db46d8e5b4c5   429MB
docker-teamd                                       latest                         db46d8e5b4c5   429MB
docker-snmp                                        HEAD.0-dirty-20220727.101004   ce5698105e30   457MB
docker-snmp                                        latest                         ce5698105e30   457MB
docker-sonic-mgmt-framework                        HEAD.0-dirty-20220727.101004   3caabe97cb97   558MB
docker-sonic-mgmt-framework                        latest                         3caabe97cb97   558MB
docker-lldp                                        HEAD.0-dirty-20220727.101004   b36e1730a9f2   454MB
docker-lldp                                        latest                         b36e1730a9f2   454MB
urm.nvidia.com/sw-nbu-sws-sonic-docker/sonic-wjh   1.3.0-202205-internal-9        17e6c4a62f86   528MB

admin@c-anaconda-01:~$ 

Output of show techsupport:

(paste your output here or download and attach the file here )

Additional information you deem important (e.g. issue happens only occasionally):

liat-grozovik pushed a commit to sonic-net/sonic-utilities that referenced this issue Aug 11, 2022
Fixes sonic-net/sonic-buildimage#11622

- What I did
Convert IPv6 addresses to lowercase in apply-patch for remove op

- How I did it
python regex on 'remove' op in JSON patch input file

- How to verify it
Manual test of created bug, Unit test
yxieca pushed a commit to sonic-net/sonic-utilities that referenced this issue Aug 11, 2022
Fixes sonic-net/sonic-buildimage#11622

- What I did
Convert IPv6 addresses to lowercase in apply-patch for remove op

- How I did it
python regex on 'remove' op in JSON patch input file

- How to verify it
Manual test of created bug, Unit test
preetham-singh pushed a commit to preetham-singh/sonic-utilities that referenced this issue Nov 21, 2022
Fixes sonic-net/sonic-buildimage#11622

- What I did
Convert IPv6 addresses to lowercase in apply-patch for remove op

- How I did it
python regex on 'remove' op in JSON patch input file

- How to verify it
Manual test of created bug, Unit test
qiluo-msft pushed a commit to sonic-net/sonic-utilities that referenced this issue Mar 28, 2023
…2758)

This reverts commit 28b6ba5.


There are some issues when GCU tries to remove the interface IP in some tests, such as add rack test.

In the initial config, the INTERFACE's IPv6 was all loaded in uppercase by default.

    "INTERFACE": {
        "Ethernet68": {},
        "Ethernet68|10.0.0.34/31": {},
        "Ethernet68|FC00::45/126": {},
        "Ethernet72": {},
        "Ethernet72|10.0.0.36/31": {},
        "Ethernet72|FC00::49/126": {},
GCU will never be able to remove that IP because IPv6 was always translated to lowercase due to #2299 . It reported the error can't remove a non-existent object, thus making GCU fail.

#2299  is to deal with this issue: sonic-net/sonic-buildimage#11622.

Although config CLI always translates uppercase to lowercase when adding an IP, the user can have two choices to remove that IP: One is to use config CLI to remove that IP no matter uppercase or lowercase. Another way is to use GCU. In order to use GCU, the user has to check the IP format saved in ConfigDB because GCU operation does differentiate between uppercase and lowercase.
#### What I did
Revert #2299
yxieca pushed a commit to sonic-net/sonic-utilities that referenced this issue Apr 1, 2023
…2758)

This reverts commit 28b6ba5.


There are some issues when GCU tries to remove the interface IP in some tests, such as add rack test.

In the initial config, the INTERFACE's IPv6 was all loaded in uppercase by default.

    "INTERFACE": {
        "Ethernet68": {},
        "Ethernet68|10.0.0.34/31": {},
        "Ethernet68|FC00::45/126": {},
        "Ethernet72": {},
        "Ethernet72|10.0.0.36/31": {},
        "Ethernet72|FC00::49/126": {},
GCU will never be able to remove that IP because IPv6 was always translated to lowercase due to #2299 . It reported the error can't remove a non-existent object, thus making GCU fail.

#2299  is to deal with this issue: sonic-net/sonic-buildimage#11622.

Although config CLI always translates uppercase to lowercase when adding an IP, the user can have two choices to remove that IP: One is to use config CLI to remove that IP no matter uppercase or lowercase. Another way is to use GCU. In order to use GCU, the user has to check the IP format saved in ConfigDB because GCU operation does differentiate between uppercase and lowercase.
#### What I did
Revert #2299
StormLiangMS pushed a commit to sonic-net/sonic-utilities that referenced this issue Apr 8, 2023
…2758)

This reverts commit 28b6ba5.


There are some issues when GCU tries to remove the interface IP in some tests, such as add rack test.

In the initial config, the INTERFACE's IPv6 was all loaded in uppercase by default.

    "INTERFACE": {
        "Ethernet68": {},
        "Ethernet68|10.0.0.34/31": {},
        "Ethernet68|FC00::45/126": {},
        "Ethernet72": {},
        "Ethernet72|10.0.0.36/31": {},
        "Ethernet72|FC00::49/126": {},
GCU will never be able to remove that IP because IPv6 was always translated to lowercase due to #2299 . It reported the error can't remove a non-existent object, thus making GCU fail.

#2299  is to deal with this issue: sonic-net/sonic-buildimage#11622.

Although config CLI always translates uppercase to lowercase when adding an IP, the user can have two choices to remove that IP: One is to use config CLI to remove that IP no matter uppercase or lowercase. Another way is to use GCU. In order to use GCU, the user has to check the IP format saved in ConfigDB because GCU operation does differentiate between uppercase and lowercase.
#### What I did
Revert #2299
malletvapid23 added a commit to malletvapid23/Sonic-Utility that referenced this issue Aug 3, 2023
Fixes sonic-net/sonic-buildimage#11622

- What I did
Convert IPv6 addresses to lowercase in apply-patch for remove op

- How I did it
python regex on 'remove' op in JSON patch input file

- How to verify it
Manual test of created bug, Unit test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant