sonic-net / sonic-buildimage

Scripts which perform an installable binary image build for SONiC
Other
727 stars 1.39k forks source link

[dhcp6_relay] [counters] dhcpv6 counters are not cleared on clear command #14447

Closed vivekrnv closed 1 year ago

vivekrnv commented 1 year ago

Description

Happening because the sonic-clear only clears data from STATE_DB. It doesn't clear from the internal cache of dhcp6relay

Steps to reproduce the issue:

  1. Setup and send dhcpv6 client requests
  2. show dhcp6relay_counters counts
  3. clear dhcp6relay_counters -- see all zeros
  4. Initiate a dhcpv6 request
  5. show dhcp6relay_counters counts

Describe the results you received:

  1. some counters continue counting from values before clear
root@qa-eth-vt03-3-4600ca1:/home/admin# show dhcp6relay_counters counts
       Message Type    Vlan10
-------------------  --------
            Unknown         0
            Solicit        16
          Advertise        13
            Request        10
            Confirm         0
              Renew       733
             Rebind         1
              Reply       748
            Release         4
            Decline         0
        Reconfigure         4
Information-Request         0
      Relay-Forward       764
        Relay-Reply       765
          Malformed         0

root@qa-eth-vt03-3-4600ca1:/home/admin# clear dhcp6relay_counters 
root@qa-eth-vt03-3-4600ca1:/home/admin# show dhcp6relay_counters counts 
       Message Type    Vlan10
-------------------  --------
            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

<!-- single dhcp client received IP address via dhcp relay -->

root@qa-eth-vt03-3-4600ca1:/home/admin# show dhcp6relay_counters counts 
       Message Type    Vlan10
-------------------  --------
            Unknown         0
            Solicit        20
          Advertise        16
            Request         0
            Confirm         0
              Renew         0
             Rebind         0
              Reply         0
            Release         0
            Decline         0
        Reconfigure         0
Information-Request         0
      Relay-Forward       776
        Relay-Reply       769
          Malformed         0

Describe the results you expected:

  1. real reset to zero and counting starting from zero

Solution:

A potential and easy fix would be to read and increment the value from state_db table instead of maintaining the internal cache. This would add an extra hget call per increase_counter method.

vivekrnv commented 1 year ago

@jcaiMR, @yxieca can you take a look?

jcaiMR commented 1 year ago

Sure, seems the cause is cli clean the counter in state db but dhcp6relay cache still holding the data. There is something need for data sync between memory and db. Will work on a solution.

jcaiMR commented 1 year ago

ETA will be May 30.