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

[dhcp-relay] Add dhcp_relay show cli #13614

Merged
merged 6 commits into from
Mar 6, 2023

Conversation

yaqiangz
Copy link
Contributor

@yaqiangz yaqiangz commented Feb 3, 2023

Why I did it

Currently the show and clear cli of dhcp_relayis may cause confusion.

How I did it

  1. Add doc for it: [doc] Add docs for dhcp_relay show/clear cli sonic-utilities#2649
  2. Add dhcp_relay config cli and test cases.
show dhcp_relay ipv4 helper
show dhcp_relay ipv6 destination
show dhcp_relay ipv6 counters
sonic-clear dhcp_relay ipv6 counters

How to verify it

  1. Unit test all passed
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_plugin_registration PASSED [  2%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_dhcp_relay_add_del_with_nonexist_vlanid[ipv4-add] PASSED [  5%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_add_del_dhcp_relay_with_invalid_ip[ipv4-add] PASSED [  7%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_add_del_duplicate_dhcp_relay[ipv4-add] PASSED [ 10%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_dhcp_relay_add_del_with_nonexist_vlanid[ipv4-del] PASSED [ 13%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_add_del_dhcp_relay_with_invalid_ip[ipv4-del] PASSED [ 15%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_add_del_duplicate_dhcp_relay[ipv4-del] PASSED [ 18%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_dhcp_relay_add_del_with_nonexist_vlanid[ipv6-del] PASSED [ 21%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_add_del_dhcp_relay_with_invalid_ip[ipv6-del] PASSED [ 23%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_add_del_duplicate_dhcp_relay[ipv6-del] PASSED [ 26%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_dhcp_relay_add_del_with_nonexist_vlanid[ipv6-add] PASSED [ 28%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_add_del_dhcp_relay_with_invalid_ip[ipv6-add] PASSED [ 31%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_add_del_duplicate_dhcp_relay[ipv6-add] PASSED [ 34%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_add_dhcp_with_exist_ip[ipv6] PASSED [ 36%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_del_nonexist_dhcp_relay[ipv6] PASSED [ 39%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_add_del_dhcp_relay[ipv6] PASSED [ 42%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_add_del_multiple_dhcp_relay[ipv6] PASSED [ 44%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_add_dhcp_with_exist_ip[ipv4] PASSED [ 47%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_del_nonexist_dhcp_relay[ipv4] PASSED [ 50%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_add_del_dhcp_relay[ipv4] PASSED [ 52%]
test_config_dhcp_relay.py::TestConfigDhcpRelay::test_config_add_del_multiple_dhcp_relay[ipv4] PASSED [ 55%]
test_config_vlan_dhcp_relay.py::TestConfigVlanDhcpRelay::test_plugin_registration PASSED [ 57%]
test_config_vlan_dhcp_relay.py::TestConfigVlanDhcpRelay::test_config_vlan_add_dhcp_relay_with_nonexist_vlanid PASSED [ 60%]
test_config_vlan_dhcp_relay.py::TestConfigVlanDhcpRelay::test_config_vlan_add_dhcp_relay_with_invalid_vlanid PASSED [ 63%]
test_config_vlan_dhcp_relay.py::TestConfigVlanDhcpRelay::test_config_vlan_add_dhcp_relay_with_invalid_ip PASSED [ 65%]
test_config_vlan_dhcp_relay.py::TestConfigVlanDhcpRelay::test_config_vlan_add_dhcp_relay_with_exist_ip PASSED [ 68%]
test_config_vlan_dhcp_relay.py::TestConfigVlanDhcpRelay::test_config_vlan_add_del_dhcp_relay_dest PASSED [ 71%]
test_config_vlan_dhcp_relay.py::TestConfigVlanDhcpRelay::test_config_vlan_add_del_dhcpv6_relay_dest PASSED [ 73%]
test_config_vlan_dhcp_relay.py::TestConfigVlanDhcpRelay::test_config_vlan_add_del_multiple_dhcpv6_relay_dest PASSED [ 76%]
test_config_vlan_dhcp_relay.py::TestConfigVlanDhcpRelay::test_config_vlan_remove_nonexist_dhcp_relay_dest PASSED [ 78%]
test_config_vlan_dhcp_relay.py::TestConfigVlanDhcpRelay::test_config_vlan_remove_dhcp_relay_dest_with_nonexist_vlanid PASSED [ 81%]
test_show_dhcp6relay_counters.py::TestDhcp6RelayCounters::test_show_counts PASSED [ 84%]
test_show_dhcp_relay.py::test_plugin_registration PASSED                 [ 86%]
test_show_dhcp_relay.py::test_dhcp_relay_column_output PASSED            [ 89%]
test_show_dhcp_relay.py::test_show_dhcp_relay_0_ipv6_with_header <- ../../../../usr/local/lib/python3.9/dist-packages/pyfakefs/fake_filesystem_unittest.py PASSED [ 92%]
test_show_dhcp_relay.py::test_show_dhcp_relay_1_ipv6_without_header <- ../../../../usr/local/lib/python3.9/dist-packages/pyfakefs/fake_filesystem_unittest.py PASSED [ 94%]
test_show_dhcp_relay.py::test_show_dhcp_relay_2_ipv4_with_header <- ../../../../usr/local/lib/python3.9/dist-packages/pyfakefs/fake_filesystem_unittest.py PASSED [ 97%]
test_show_dhcp_relay.py::test_show_dhcp_relay_3_ipv4_without_header <- ../../../../usr/local/lib/python3.9/dist-packages/pyfakefs/fake_filesystem_unittest.py PASSED [100%]


----------- coverage: platform linux, python 3.9.2-final-0 -----------
Name                                                                                        Stmts   Miss  Cover
---------------------------------------------------------------------------------------------------------------
test_show_dhcp6relay_counters.py                                                               22      2    91%
test_show_dhcp_relay.py                                                                        49      2    96%
test_show_dhcp_relay_counter.py                                                                 9      0   100%
/sonic/dockers/docker-dhcp-relay/cli/show/plugins/show_dhcp_relay.py                          111     23    79%
---------------------------------------------------------------------------------------------------------------
Coverage HTML written to dir htmlcov
Coverage XML written to file coverage.xml
  1. Build image and run cli to verify
admin@bjw-can-720dt-2:~$ show dhcp_relay ipv4 helper
+-------------+----------------------+
|   Interface |   DHCP Relay Address |
+=============+======================+
|    Vlan1000 |            192.0.0.1 |
|             |            192.0.0.2 |
|             |            192.0.0.3 |
|             |            192.0.0.4 |
|             |            192.0.0.5 |
|             |            192.0.0.6 |
|             |            192.0.0.7 |
|             |            192.0.0.8 |
|             |            192.0.0.9 |
|             |           192.0.0.10 |
|             |           192.0.0.11 |
|             |           192.0.0.12 |
|             |           192.0.0.13 |
|             |           192.0.0.14 |
|             |           192.0.0.15 |
|             |           192.0.0.16 |
|             |           192.0.0.17 |
|             |           192.0.0.18 |
|             |           192.0.0.19 |
|             |           192.0.0.20 |
|             |           192.0.0.21 |
|             |           192.0.0.22 |
|             |           192.0.0.23 |
|             |           192.0.0.24 |
|             |           192.0.0.25 |
|             |           192.0.0.26 |
|             |           192.0.0.27 |
|             |           192.0.0.28 |
|             |           192.0.0.29 |
|             |           192.0.0.30 |
|             |           192.0.0.31 |
|             |           192.0.0.32 |
|             |           192.0.0.33 |
|             |           192.0.0.34 |
|             |           192.0.0.35 |
|             |           192.0.0.36 |
|             |           192.0.0.37 |
|             |           192.0.0.38 |
|             |           192.0.0.39 |
|             |           192.0.0.40 |
|             |           192.0.0.41 |
|             |           192.0.0.42 |
|             |           192.0.0.43 |
|             |           192.0.0.44 |
|             |           192.0.0.45 |
|             |           192.0.0.46 |
|             |           192.0.0.47 |
|             |           192.0.0.48 |
+-------------+----------------------+
|    Vlan1001 |          192.168.0.1 |
|             |          192.168.0.2 |
+-------------+----------------------+

admin@bjw-can-720dt-2:~$ show dhcp_relay ipv6 destination
+-------------+----------------------+
|   Interface |   DHCP Relay Address |
+=============+======================+
|    Vlan1000 |         fc02:2000::1 |
|             |         fc02:2000::2 |
|             |         fc02:2000::3 |
|             |         fc02:2000::4 |
+-------------+----------------------+
|    Vlan1001 |         fc02:2000::5 |
|             |         fc02:2000::6 |
+-------------+----------------------+

admin@bjw-can-720dt-2:~$ show dhcp_relay ipv6 counters
       Message Type    Vlan1000
-------------------  ----------
            Unknown           0
            Solicit           0
          Advertise           0
            Request           5
            Confirm           0
              Renew           0
             Rebind           0
              Reply           0
            Release           0
            Decline           0
        Reconfigure           0
Information-Request           0
      Relay-Forward           0
        Relay-Reply           0
          Malformed           0 
admin@bjw-can-720dt-2:~$ sudo sonic-clear dhcp_relay ipv6 counters
admin@bjw-can-720dt-2:~$ show dhcp_relay ipv6 counters
       Message Type    Vlan1000
-------------------  ----------
            Unknown           0
            Solicit           0
          Advertise           0
            Request           0
            Confirm           0
              Renew           0
             Rebind           0
              Reply           0
            Release           0
            Decline           0
        Reconfigure           0
Information-Request           0
      Relay-Forward           0
        Relay-Reply           0
          Malformed           0

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111
  • 202205
  • 202211

Description for the changelog

Ensure to add label/tag for the feature raised. example - PR#2174 under sonic-utilities repo. where, Generic Config and Update feature has been labelled as GCU.

Link to config_db schema for YANG module changes

A picture of a cute animal (not mandatory but encouraged)

@yaqiangz
Copy link
Contributor Author

yaqiangz commented Feb 7, 2023

@jcaiMR @kellyyeh @Blueve Could you please help to review this PR?

@yaqiangz
Copy link
Contributor Author

/azpw run Azure.sonic-buildimage

@mssonicbld
Copy link
Collaborator

/AzurePipelines run Azure.sonic-buildimage

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@yaqiangz
Copy link
Contributor Author

yaqiangz commented Mar 2, 2023

@yxieca Could you please help to do final sign-off to this PR and merge it? Thanks :)

@yxieca yxieca self-requested a review March 3, 2023 17:19
Copy link
Contributor

@yxieca yxieca left a comment

Choose a reason for hiding this comment

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

Why changing IPv6 helper table name?

@yaqiangz
Copy link
Contributor Author

yaqiangz commented Mar 6, 2023

Why changing IPv6 helper table name?

Hi @yxieca, this is not table name in db, it's just test case name. Table name is in line 6, line 22 of mock_config.py ("DHCP_RELAY") which is not changed. Change in line 3 is shown in test results which is in bold below:

test_show_dhcp_relay.py::test_show_dhcp_relay_0_ipv6_with_header <- ../../../../usr/local/lib/python3.9/dist-packages/pyfakefs/fake_filesystem_unittest.py PASSED [ 92%]
test_show_dhcp_relay.py::test_show_dhcp_relay_1_ipv6_without_header <- ../../../../usr/local/lib/python3.9/dist-packages/pyfakefs/fake_filesystem_unittest.py PASSED [ 94%]
test_show_dhcp_relay.py::test_show_dhcp_relay_2_ipv4_with_header <- ../../../../usr/local/lib/python3.9/dist-packages/pyfakefs/fake_filesystem_unittest.py PASSED [ 97%]
test_show_dhcp_relay.py::test_show_dhcp_relay_3_ipv4_without_header <- ../../../../usr/local/lib/python3.9/dist-packages/pyfakefs/fake_filesystem_unittest.py PASSED [100%]

I think such a change is more reasonable and understandable.

@yxieca yxieca merged commit 284ba61 into sonic-net:master Mar 6, 2023
mssonicbld pushed a commit to mssonicbld/sonic-buildimage that referenced this pull request Mar 6, 2023
Why I did it
Currently the show and clear cli of dhcp_relayis may cause confusion.

How I did it
Add doc for it: [doc] Add docs for dhcp_relay show/clear cli sonic-utilities#2649
Add dhcp_relay config cli and test cases.
show dhcp_relay ipv4 helper
show dhcp_relay ipv6 destination
show dhcp_relay ipv6 counters
sonic-clear dhcp_relay ipv6 counters

How to verify it
Unit test all passed
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202205: #14107

mssonicbld pushed a commit that referenced this pull request Mar 7, 2023
Why I did it
Currently the show and clear cli of dhcp_relayis may cause confusion.

How I did it
Add doc for it: [doc] Add docs for dhcp_relay show/clear cli sonic-utilities#2649
Add dhcp_relay config cli and test cases.
show dhcp_relay ipv4 helper
show dhcp_relay ipv6 destination
show dhcp_relay ipv6 counters
sonic-clear dhcp_relay ipv6 counters

How to verify it
Unit test all passed
yaqiangz added a commit to sonic-net/sonic-utilities that referenced this pull request Mar 9, 2023
What I did
Add support for dhcp_relay show cli, consistent with sonic-net/sonic-buildimage#13614

How I did it
Add support for dhcp_relay show cli

How to verify it
1. UT
2. build wheel and install in device

Signed-off-by: Yaqiang Zhu <yaqiangzhu@microsoft.com>
@vivekrnv
Copy link
Contributor

vivekrnv commented Mar 9, 2023

@yaqiangz Any reason we use “helper” for ipv4 and “destination” for ipv6 ?

@yaqiangz
Copy link
Contributor Author

@yaqiangz Any reason we use “helper” for ipv4 and “destination” for ipv6 ?

Helpers are DHCPv4 only concept, DHCPv6 it use relay destination.

xumia pushed a commit to xumia/sonic-buildimage-1 that referenced this pull request Mar 10, 2023
Why I did it
Currently the show and clear cli of dhcp_relayis may cause confusion.

How I did it
Add doc for it: [doc] Add docs for dhcp_relay show/clear cli sonic-utilities#2649
Add dhcp_relay config cli and test cases.
show dhcp_relay ipv4 helper
show dhcp_relay ipv6 destination
show dhcp_relay ipv6 counters
sonic-clear dhcp_relay ipv6 counters

How to verify it
Unit test all passed
@vivekrnv
Copy link
Contributor

@yaqiangz Any reason we use “helper” for ipv4 and “destination” for ipv6 ?

Helpers are DHCPv4 only concept, DHCPv6 it use relay destination.

Thanks, i understand we use this terminology is SONiC. Could you point me towards an RFC or something where this terminology is used/defined. I tried to search but couldn't find it.

@jcaiMR
Copy link
Contributor

jcaiMR commented Mar 16, 2023

@yaqiangz Any reason we use “helper” for ipv4 and “destination” for ipv6 ?

Helpers are DHCPv4 only concept, DHCPv6 it use relay destination.

Thanks, i understand we use this terminology is SONiC. Could you point me towards an RFC or something where this terminology is used/defined. I tried to search but couldn't find it.

helper address is first known as ip helper address (not only for dhcp), it's v4 only concept. Not sure which RFC mentioned it first, it may first mentioned in cisco ios-cli https://www.ciscopress.com/articles/article.asp?p=330807&seqNum=9

mssonicbld pushed a commit to mssonicbld/sonic-buildimage that referenced this pull request Mar 19, 2023
Why I did it
Currently the show and clear cli of dhcp_relayis may cause confusion.

How I did it
Add doc for it: [doc] Add docs for dhcp_relay show/clear cli sonic-utilities#2649
Add dhcp_relay config cli and test cases.
show dhcp_relay ipv4 helper
show dhcp_relay ipv6 destination
show dhcp_relay ipv6 counters
sonic-clear dhcp_relay ipv6 counters

How to verify it
Unit test all passed
@mssonicbld
Copy link
Collaborator

Cherry-pick PR to 202211: #14342

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants