[DHCP] new line symbol in opt_name of extra_dhcp_opt causes dnsmasq to fail

Bug #1943930 reported by Slawek Kaplonski
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
High
Slawek Kaplonski

Bug Description

Bug originally reported by Alex Katz in Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2001626

Description of problem:
The new line symbol (`\n`) can be passed into the opt_name of extra-dhcp-opt with the direct API call. It will cause the dnsmasq process to be in a restart loop.

There is the following stack trace appear in the dhcp-agent.log

 [-] Unable to enable dhcp for ee4beb3e-89e8-4d32-ba99-97f3c7a092e7.: AttributeError: 'NoneType' object has no attribute 'groups'
 Traceback (most recent call last):
   File "/usr/lib/python3.6/site-packages/neutron/agent/dhcp/agent.py", line 208, in call_driver
     getattr(driver, action)(**action_kwargs)
   File "/usr/lib/python3.6/site-packages/neutron/agent/linux/dhcp.py", line 235, in enable
     common_utils.wait_until_true(self._enable, timeout=300)
   File "/usr/lib/python3.6/site-packages/neutron/common/utils.py", line 703, in wait_until_true
     while not predicate():
   File "/usr/lib/python3.6/site-packages/neutron/agent/linux/dhcp.py", line 248, in _enable
     self.spawn_process()
   File "/usr/lib/python3.6/site-packages/neutron/agent/linux/dhcp.py", line 475, in spawn_process
     self._spawn_or_reload_process(reload_with_HUP=False)
   File "/usr/lib/python3.6/site-packages/neutron/agent/linux/dhcp.py", line 484, in _spawn_or_reload_process
     self._output_config_files()
   File "/usr/lib/python3.6/site-packages/neutron/agent/linux/dhcp.py", line 534, in _output_config_files
     self._output_opts_file()
   File "/usr/lib/python3.6/site-packages/neutron/agent/linux/dhcp.py", line 1062, in _output_opts_file
     options += self._generate_opts_per_port(subnet_index_map)
   File "/usr/lib/python3.6/site-packages/neutron/agent/linux/dhcp.py", line 1194, in _generate_opts_per_port
     opt.opt_name, opt.opt_value))
   File "/usr/lib/python3.6/site-packages/neutron/agent/linux/dhcp.py", line 1247, in _format_option
     extra_tag = matches.groups()[0]
 AttributeError: 'NoneType' object has no attribute 'groups'

Example of the API request:

TOK=`openstack token issue -f value -c id`

curl -v -s -X PUT \
    -H "X-Auth-Token: $TOK" \
    -H "Content-Type: application/json" \
    -d '{ "port": { "extra_dhcp_opts": [{ "opt_name": "yyy:test\nanother", "opt_value":"xxx" }]}}' \
    "http://10.0.0.120:9696/v2.0/ports/acf0c1ca-56f8-452c-8b31-51ac25e54ac5"

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/neutron/+/809580

Changed in neutron:
status: Confirmed → In Progress
Changed in neutron:
milestone: none → xena-rc2
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/809580
Committed: https://opendev.org/openstack/neutron/commit/5abd1fb61018e497b369712a0952bb1a18022142
Submitter: "Zuul (22348)"
Branch: master

commit 5abd1fb61018e497b369712a0952bb1a18022142
Author: Slawek Kaplonski <email address hidden>
Date: Fri Sep 17 10:57:18 2021 +0200

    Remove dhcp_extra_opt name after first newline character

    Passing newline as extra dhcp option name to the DHCP agent causes
    issues with configuration of the dnsmasq process for the network.
    This patch removes everything what is after first newline character
    in the dhcp_extra_opt's name before building dnsmasq's config.

    Closes-bug: #1943930
    Change-Id: Iab2832e750ff5ef09c5dcacae4dbff4f9e62bc2d

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/xena)

Fix proposed to branch: stable/xena
Review: https://review.opendev.org/c/openstack/neutron/+/810874

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/wallaby)

Fix proposed to branch: stable/wallaby
Review: https://review.opendev.org/c/openstack/neutron/+/810875

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/victoria)

Fix proposed to branch: stable/victoria
Review: https://review.opendev.org/c/openstack/neutron/+/810876

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/ussuri)

Fix proposed to branch: stable/ussuri
Review: https://review.opendev.org/c/openstack/neutron/+/810877

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/train)

Fix proposed to branch: stable/train
Review: https://review.opendev.org/c/openstack/neutron/+/810878

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/stein)

Fix proposed to branch: stable/stein
Review: https://review.opendev.org/c/openstack/neutron/+/810879

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/rocky)

Fix proposed to branch: stable/rocky
Review: https://review.opendev.org/c/openstack/neutron/+/810853

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/queens)

Fix proposed to branch: stable/queens
Review: https://review.opendev.org/c/openstack/neutron/+/810880

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/xena)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/810874
Committed: https://opendev.org/openstack/neutron/commit/8d6cc1fc574761bcada81e08689e6a16e920e5c3
Submitter: "Zuul (22348)"
Branch: stable/xena

commit 8d6cc1fc574761bcada81e08689e6a16e920e5c3
Author: Slawek Kaplonski <email address hidden>
Date: Fri Sep 17 10:57:18 2021 +0200

    Remove dhcp_extra_opt name after first newline character

    Passing newline as extra dhcp option name to the DHCP agent causes
    issues with configuration of the dnsmasq process for the network.
    This patch removes everything what is after first newline character
    in the dhcp_extra_opt's name before building dnsmasq's config.

    Closes-bug: #1943930
    Change-Id: Iab2832e750ff5ef09c5dcacae4dbff4f9e62bc2d
    (cherry picked from commit 5abd1fb61018e497b369712a0952bb1a18022142)

tags: added: in-stable-xena
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 19.0.0.0rc2

This issue was fixed in the openstack/neutron 19.0.0.0rc2 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/wallaby)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/810875
Committed: https://opendev.org/openstack/neutron/commit/073c5f87e54682284b0d213147af8a8381f3e30a
Submitter: "Zuul (22348)"
Branch: stable/wallaby

commit 073c5f87e54682284b0d213147af8a8381f3e30a
Author: Slawek Kaplonski <email address hidden>
Date: Fri Sep 17 10:57:18 2021 +0200

    Remove dhcp_extra_opt name after first newline character

    Passing newline as extra dhcp option name to the DHCP agent causes
    issues with configuration of the dnsmasq process for the network.
    This patch removes everything what is after first newline character
    in the dhcp_extra_opt's name before building dnsmasq's config.

    Closes-bug: #1943930
    Change-Id: Iab2832e750ff5ef09c5dcacae4dbff4f9e62bc2d
    (cherry picked from commit 5abd1fb61018e497b369712a0952bb1a18022142)

tags: added: in-stable-wallaby
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/rocky)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/810853
Committed: https://opendev.org/openstack/neutron/commit/e3b1022820a0827adb4e20e575d9fcdc36f81d0c
Submitter: "Zuul (22348)"
Branch: stable/rocky

commit e3b1022820a0827adb4e20e575d9fcdc36f81d0c
Author: Slawek Kaplonski <email address hidden>
Date: Fri Sep 17 10:57:18 2021 +0200

    Remove dhcp_extra_opt name after first newline character

    Passing newline as extra dhcp option name to the DHCP agent causes
    issues with configuration of the dnsmasq process for the network.
    This patch removes everything what is after first newline character
    in the dhcp_extra_opt's name before building dnsmasq's config.

    Conflicts:
        neutron/tests/unit/agent/linux/test_dhcp.py

    Closes-bug: #1943930
    Change-Id: Iab2832e750ff5ef09c5dcacae4dbff4f9e62bc2d
    (cherry picked from commit 5abd1fb61018e497b369712a0952bb1a18022142)
    (cherry picked from commit c85abee26de55d4ec37619c2cc691612414546ac)

tags: added: in-stable-rocky
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/ussuri)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/810877
Committed: https://opendev.org/openstack/neutron/commit/41ed4d7f43bc1747416ddf636afd730b22c786d8
Submitter: "Zuul (22348)"
Branch: stable/ussuri

commit 41ed4d7f43bc1747416ddf636afd730b22c786d8
Author: Slawek Kaplonski <email address hidden>
Date: Fri Sep 17 10:57:18 2021 +0200

    Remove dhcp_extra_opt name after first newline character

    Passing newline as extra dhcp option name to the DHCP agent causes
    issues with configuration of the dnsmasq process for the network.
    This patch removes everything what is after first newline character
    in the dhcp_extra_opt's name before building dnsmasq's config.

    Closes-bug: #1943930
    Change-Id: Iab2832e750ff5ef09c5dcacae4dbff4f9e62bc2d
    (cherry picked from commit 5abd1fb61018e497b369712a0952bb1a18022142)

tags: added: in-stable-ussuri
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/victoria)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/810876
Committed: https://opendev.org/openstack/neutron/commit/144f3aa60f9f72efff010adb7f0bf2ad066235ee
Submitter: "Zuul (22348)"
Branch: stable/victoria

commit 144f3aa60f9f72efff010adb7f0bf2ad066235ee
Author: Slawek Kaplonski <email address hidden>
Date: Fri Sep 17 10:57:18 2021 +0200

    Remove dhcp_extra_opt name after first newline character

    Passing newline as extra dhcp option name to the DHCP agent causes
    issues with configuration of the dnsmasq process for the network.
    This patch removes everything what is after first newline character
    in the dhcp_extra_opt's name before building dnsmasq's config.

    Closes-bug: #1943930
    Change-Id: Iab2832e750ff5ef09c5dcacae4dbff4f9e62bc2d
    (cherry picked from commit 5abd1fb61018e497b369712a0952bb1a18022142)

tags: added: in-stable-victoria
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/queens)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/810880
Committed: https://opendev.org/openstack/neutron/commit/53320288425f0ef9971173074a20bba66ff493f1
Submitter: "Zuul (22348)"
Branch: stable/queens

commit 53320288425f0ef9971173074a20bba66ff493f1
Author: Slawek Kaplonski <email address hidden>
Date: Fri Sep 17 10:57:18 2021 +0200

    Remove dhcp_extra_opt name after first newline character

    Passing newline as extra dhcp option name to the DHCP agent causes
    issues with configuration of the dnsmasq process for the network.
    This patch removes everything what is after first newline character
    in the dhcp_extra_opt's name before building dnsmasq's config.

    Conflicts:
        neutron/tests/unit/agent/linux/test_dhcp.py

    Closes-bug: #1943930
    Change-Id: Iab2832e750ff5ef09c5dcacae4dbff4f9e62bc2d
    (cherry picked from commit 5abd1fb61018e497b369712a0952bb1a18022142)
    (cherry picked from commit c85abee26de55d4ec37619c2cc691612414546ac)

tags: added: in-stable-queens
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/stein)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/810879
Committed: https://opendev.org/openstack/neutron/commit/c85abee26de55d4ec37619c2cc691612414546ac
Submitter: "Zuul (22348)"
Branch: stable/stein

commit c85abee26de55d4ec37619c2cc691612414546ac
Author: Slawek Kaplonski <email address hidden>
Date: Fri Sep 17 10:57:18 2021 +0200

    Remove dhcp_extra_opt name after first newline character

    Passing newline as extra dhcp option name to the DHCP agent causes
    issues with configuration of the dnsmasq process for the network.
    This patch removes everything what is after first newline character
    in the dhcp_extra_opt's name before building dnsmasq's config.

    Closes-bug: #1943930
    Change-Id: Iab2832e750ff5ef09c5dcacae4dbff4f9e62bc2d
    (cherry picked from commit 5abd1fb61018e497b369712a0952bb1a18022142)

tags: added: in-stable-stein
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/train)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/810878
Committed: https://opendev.org/openstack/neutron/commit/07d594434015686e094599e6a0f2038e82a2fe34
Submitter: "Zuul (22348)"
Branch: stable/train

commit 07d594434015686e094599e6a0f2038e82a2fe34
Author: Slawek Kaplonski <email address hidden>
Date: Fri Sep 17 10:57:18 2021 +0200

    Remove dhcp_extra_opt name after first newline character

    Passing newline as extra dhcp option name to the DHCP agent causes
    issues with configuration of the dnsmasq process for the network.
    This patch removes everything what is after first newline character
    in the dhcp_extra_opt's name before building dnsmasq's config.

    Depends-On: https://review.opendev.org/c/openstack/neutron-tempest-plugin/+/815518
    Closes-bug: #1943930
    Change-Id: Iab2832e750ff5ef09c5dcacae4dbff4f9e62bc2d
    (cherry picked from commit 5abd1fb61018e497b369712a0952bb1a18022142)

tags: added: in-stable-train
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 16.4.2

This issue was fixed in the openstack/neutron 16.4.2 release.

tags: added: neutron-proactive-backport-potential
tags: removed: neutron-proactive-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 17.3.0

This issue was fixed in the openstack/neutron 17.3.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 18.2.0

This issue was fixed in the openstack/neutron 18.2.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 20.0.0.0rc1

This issue was fixed in the openstack/neutron 20.0.0.0rc1 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron queens-eol

This issue was fixed in the openstack/neutron queens-eol release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron rocky-eol

This issue was fixed in the openstack/neutron rocky-eol release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron stein-eol

This issue was fixed in the openstack/neutron stein-eol release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron train-eol

This issue was fixed in the openstack/neutron train-eol release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.