Skip to content

parse: fix redefinition of gateway(4|6)#460

Merged
daniloegea merged 1 commit intocanonical:mainfrom
daniloegea:fix_gateway46
Apr 19, 2024
Merged

parse: fix redefinition of gateway(4|6)#460
daniloegea merged 1 commit intocanonical:mainfrom
daniloegea:fix_gateway46

Conversation

@daniloegea
Copy link
Contributor

Options gateway4 and gateway6 were not being properly redefined when a merge happens. Redefinition was causing a crash due to an assert in the set_str_if_null macro.

While this assertion helped identifying the merge issue, I believe it's not the best place to keep it so I'm removing it from the macro and making the macro do only what it name suggests it does.

This macro is used in other places but this problem seems to not happen there as far as I can see.

Add a couple of unit test to check the merge is working.

Description

Reproducer:

network:
  ethernets:
    eth0:
      addresses:
        - 192.168.0.1/24
      gateway4: 192.168.0.123
    eth0:
      gateway4: 192.168.0.111
$ netplan generate --root-dir /tmp/fakeroot4

** (generate:190262): WARNING **: 18:08:41.479: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.
**
ERROR:../src/parse.c:1434:handle_gateway4: assertion failed (scalar(node) == npp->current.netdef->gateway4): ("192.168.0.111" == "192.168.0.123")
Bail out! ERROR:../src/parse.c:1434:handle_gateway4: assertion failed (scalar(node) == npp->current.netdef->gateway4): ("192.168.0.111" == "192.168.0.123")

Checklist

  • Runs make check successfully.
  • Retains 100% code coverage (make check-coverage).
  • New/changed keys in YAML format are documented.
  • (Optional) Adds example YAML for new feature.
  • (Optional) Closes an open bug in Launchpad.

Options gateway4 and gateway6 were not being properly redefined when a
merge happens. Redefinition was causing a crash due to an assert in the
set_str_if_null macro.

While this assertion helped identifying the merge issue, I believe it's
not the best place to keep it so I'm removing it from the macro and
making the macro do only what it name suggests it does.

This macro is used in other places but this problem seems to not happen
there as far as I can see.

Add a couple of unit test to check the merge is working.
Copy link
Contributor

@slyon slyon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, lgtm.

@daniloegea daniloegea merged commit a670781 into canonical:main Apr 19, 2024
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 this pull request may close these issues.

2 participants