CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
137 stars 74 forks source link

TcpBitsType failed when using "Ack" #966

Closed xulleon closed 5 years ago

xulleon commented 5 years ago

In the XR UM model, Cisco-IOS-XR-um-access-list-datatypes.py, TcpBitsType should have values [fin, syn, rst, psh, ack, urg]. It is BITS type. When retrieving it from member, it got [FIN, SYN, RST, PSH, Ack, URG]. The upper case value works except "Ack". with other tool, only "ack" is valid.

1454:  [host 173.39.55.149 session-id 990293408] Received:
1455:  <?xml version="1.0"?>
1456:  <rpc-reply message-id="urn:uuid:b480d700-64ce-4d97-b8f9-2b4942affea4" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
1457:   <ok/>
1458:  </rpc-reply>
1459:  Executor operation completed
1460:  CREATE operation initiated
1461:  [host 173.39.55.149 session-id 990293408] Requesting '_SP_RPC'
1462:  [host 173.39.55.149 session-id 990293408] Sending:
1463: 
1464:  #1059
1465:  <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:a5298c26-86d2-460c-9d18-eaa57cbce38d">
1466:    <edit-config>
1467:      <target>
1468:        <candidate/>
1469:      </target>
1470:      <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
1471:        <ipv6 xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-um-ipv6-access-list-cfg">
1472:          <access-lists>
1473:            <access-list>
1474:              <access-list-name>ipv6_access</access-list-name>
1475:              <sequences>
1476:                <sequence>
1477:                  <sequence-number>10</sequence-number>
1478:                  <permit>
1479:                    <destination>
1480:                      <any/>
1481:                    </destination>
1482:                    <protocol>tcp</protocol>
1483:                    <source>
1484:                      <any/>
1485:                    </source>
1486:                    <tcp-flags>
1487:                      <tcp-bits>Ack</tcp-bits> <<<<<<<---------------- Ack is not accepted.
1488:                    </tcp-flags>
1489:                  </permit>
1490:                </sequence>
1491:              </sequences>
1492:            </access-list>
1493:          </access-lists>
1494:        </ipv6>
1495:      </config>
1496:    </edit-config>
1497:  </rpc>

But when FIN was used, it was accepted.

Expected Behavior

Should be able to configure it successfully for all TcpBitsType values.

Current Behavior

The Netconf rejects value Ack.

Steps to Reproduce

Use the above RPC on a XR device.

Additional Info and Logs

YANG model:

  typedef tcp-bits-type {
    type bits {
      bit fin {
        position 0;
        description
          "Match on the FIN bit (0x01)";
      }
      bit syn {
        position 1;
        description
          "Match on the SYN bit (0x02)";
      }
      bit rst {
        position 2;
        description
          "Match on the RST bit (0x04)";
      }
      bit psh {
        position 3;
        description
          "Match on the PSH bit (0x08)";
      }
      bit ack {
        position 4;
        description
          "Match on the ACK bit (0x10)";
      }
      bit urg {
        position 5;
        description
          "Match on the URG bit (0x20)";
      }
    }
    description
      "acl tcp bits number";
  }

Generated class:

 class TcpBitsType(FixedBitsDict):

    """
    TcpBitsType

    acl tcp bits number

    Keys are:- fin , syn , rst , psh , ack , urg
    """

    def __init__(self):

        dictionary_ = {

            'fin': False,

            'syn': False,

            'rst': False,

            'psh': False,

            'ack': False,

            'urg': False,

        }

        pos_map_ = {

            'fin': 0,

            'syn': 1,

            'rst': 2,

            'psh': 3,

            'ack': 4,

            'urg': 5,

        }

        super().__init__(dictionary_, pos_map_)

Failure log:

Hi Yan,

Thanks for reply to the bug, it is on 0.5.5.  I will call you tomorrow to give you more details.

The TcpBitesType is a BITS type. When people used yangsuite, “ack”works, but YDK will reject “ack” and accept “Ack”, which eventually was rejected by the device. Even though in the bundle file, all values are lower case, in the XML payload, they are all UPPER case. Only the “Ack” is different.

Let me paste some info to you.

Thanks again

Leon

Hi Santiago,

I filed a bug, TcpBitsType failed when using "Ack" #966 in github.

From the pass log below, you can see that “FIN” is valid, but “Ack: is not, instead it needs to use “ack”.

Thanks

Leon

1746: ### update_leaves: key: tcp_bits, value: FIN, type: TcpBitsType

1747: +------------------------------------------------------------------------------+

1748: | Perform Positive CRUD CREATE:CRUD - Time 0 |

1749: +------------------------------------------------------------------------------+

1750: Executing discard-changes RPC

1751: Executor operation initiated

1752: [host 172.27.150.154 session-id 14071144] Requesting '_SP_RPC'

1753: [host 172.27.150.154 session-id 14071144] Sending:

1754:

1755: #141

1756: <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:d3b6c241-f8a2-4cdd-93de-a88ff6ea915c">

1757: <discard-changes/>

1758: </rpc>

1759:

1760: ##

1761: [host 172.27.150.154 session-id 14071144] Received:

1762: <?xml version="1.0"?>

1763: <rpc-reply message-id="urn:uuid:d3b6c241-f8a2-4cdd-93de-a88ff6ea915c" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

1764: <ok/>

1765: </rpc-reply>

1766: Executor operation completed

1767: CREATE operation initiated

1768: [host 172.27.150.154 session-id 14071144] Requesting '_SP_RPC'

1769: [host 172.27.150.154 session-id 14071144] Sending:

1770:

1771: #836

1772: <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:3b96f03c-85d5-4d60-897f-3774afb70d02">

1773: <edit-config>

1774: <target>

1775: <candidate/>

1776: </target>

1777: <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">

1778: <ipv6 xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-um-ipv6-access-list-cfg">

1779: <access-lists>

1780: <access-list>

1781: <access-list-name>ipv6-acl1</access-list-name>

1782: <sequences>

1783: <sequence>

1784: <sequence-number>10</sequence-number>

1785: <deny>

1786: <tcp-flags>

1787: <tcp-bits>FIN</tcp-bits>

1788: </tcp-flags>

1789: </deny>

1790: </sequence>

1791: </sequences>

1792: </access-list>

1793: </access-lists>

1794: </ipv6>

1795: </config>

1796: </edit-config>

1797: </rpc>

1798:

1799: ##

1800: [host 172.27.150.154 session-id 14071144] Received:

1801: <?xml version="1.0"?>

1802: <rpc-reply message-id="urn:uuid:3b96f03c-85d5-4d60-897f-3774afb70d02" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

1803: <ok/>

1804: </rpc-reply>

1805: [host 172.27.150.154 session-id 14071144] Requesting 'Commit'

1806: [host 172.27.150.154 session-id 14071144] Sending:

1807:

1808: #177

1809: <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:7e75191e-4dac-486c-a642-e432ed793c46"><nc:commit/></nc:rpc>

1810: ##

1811: [host 172.27.150.154 session-id 14071144] Received:

1812: <?xml version="1.0"?>

1813: <rpc-reply message-id="urn:uuid:7e75191e-4dac-486c-a642-e432ed793c46" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

1814: <ok/>

1815: </rpc-reply>

1816: CREATE operation completed

1817: +++ vkg4: executing command 'show configuration commit changes last 1' +++

show configuration commit changes last 1 Sat Oct 26 17:06:15.760 UTC Building configuration... !! IOS XR Configuration 7.2.1.05I ipv6 access-list ipv6-acl1 10 deny tcp 1::1/32 2::2/24 match-any -syn ! end 

From: "Leon Xu (leoxu)" <leoxu@cisco.com>
Date: Tuesday, November 12, 2019 at 3:01 PM
To: "Arul Muruga Amudha Doraiswamy -X (aamudhad - HCL TECHNOLOGIES LIMITED at Cisco)" <aamudhad@cisco.com>, "Nithya Kandasamy -X (nitkanda - TERRALOGIC SOFTWARE SOLUTIONS PRIVATE LIMITED at Cisco)" <nitkanda@cisco.com>, "atom-support(mailer list)" <atom-support@cisco.com>, "Santiago Alvarez (saalvare)" <saalvare@cisco.com>, "Sapna Joshi (sapna)" <sapna@cisco.com>, "Manisha Verma -X (maniver2 - ARICENT TECHNOLOGIES MAURIITIUS LIMITED at Cisco)" <maniver2@cisco.com>, "Munish Nayyar (mnayyar)" <mnayyar@cisco.com>
Cc: "Abhishek Mantri (abmantri)" <abmantri@cisco.com>, "Ric Cobb (ricobb)" <ricobb@cisco.com>, "Avinash Tadimalla (atadmill)" <atadmill@cisco.com>, "Senthil Kenchiah (skenchia)" <skenchia@cisco.com>
Subject: Re: ATOM: TCP-Bits value unsupported

Hi Santiago,

In the file, Cisco_IOS_XR_um_access_list_datatypes.py. it is a bits type.  But from YDK _dictionary, we got  the keys below,

[FIN,  SYN,  RST, PSH, Ack, URG]

class TcpBitsType(FixedBitsDict):

    """

    TcpBitsType

    acl tcp bits number

    Keys are:- fin , syn , rst , psh , ack , urg

    """

    def __init__(self):

        dictionary_ = {

            'fin': False,

            'syn': False,

            'rst': False,

            'psh': False,

            'ack': False,

            'urg': False,

        }

        pos_map_ = {

            'fin': 0,

            'syn': 1,

            'rst': 2,

            'psh': 3,

            'ack': 4,

            'urg': 5,

        }

        super().__init__(dictionary_, pos_map_)

From: "Leon Xu (leoxu)" <leoxu@cisco.com>
Date: Monday, November 11, 2019 at 10:49 PM
To: "Arul Muruga Amudha Doraiswamy -X (aamudhad - HCL TECHNOLOGIES LIMITED at Cisco)" <aamudhad@cisco.com>, "Nithya Kandasamy -X (nitkanda - TERRALOGIC SOFTWARE SOLUTIONS PRIVATE LIMITED at Cisco)" <nitkanda@cisco.com>, "atom-support(mailer list)" <atom-support@cisco.com>, "Santiago Alvarez (saalvare)" <saalvare@cisco.com>, "Sapna Joshi (sapna)" <sapna@cisco.com>, "Manisha Verma -X (maniver2 - ARICENT TECHNOLOGIES MAURIITIUS LIMITED at Cisco)" <maniver2@cisco.com>, "Munish Nayyar (mnayyar)" <mnayyar@cisco.com>
Cc: "Abhishek Mantri (abmantri)" <abmantri@cisco.com>, "Ric Cobb (ricobb)" <ricobb@cisco.com>, "Avinash Tadimalla (atadmill)" <atadmill@cisco.com>, "Senthil Kenchiah (skenchia)" <skenchia@cisco.com>
Subject: Re: ATOM: TCP-Bits value unsupported

Hi Santiago,

Arul tested tcp_bits, it seems that his device did not accept “Ack”. He tried Yangsuite, the device accept “ack”. I am wondering if YDK internally change “Ack” to “ack”?

Thanks

Leon

From: "Arul Muruga Amudha Doraiswamy -X (aamudhad - HCL TECHNOLOGIES LIMITED at Cisco)" <aamudhad@cisco.com>
Date: Wednesday, November 6, 2019 at 9:26 AM
To: "Nithya Kandasamy -X (nitkanda - TERRALOGIC SOFTWARE SOLUTIONS PRIVATE LIMITED at Cisco)" <nitkanda@cisco.com>, "Leon Xu (leoxu)" <leoxu@cisco.com>, "atom-support(mailer list)" <atom-support@cisco.com>
Cc: "Abhishek Mantri (abmantri)" <abmantri@cisco.com>
Subject: ATOM: TCP-Bits value unsupported

Hi Nithya,Leon,

In ipv6-access-list-cfg model, supplying ‘Ack’ as value for Tcp_bits is failing(Logs below)

https://earms-trade.cisco.com/tradeui/logs/logfile?logfile=TaskLog.Task-1&begin=323793&size=47625&archive=%2Fauto%2Fatslogs%2Fcl%2F2019%2F11%2F05%2F15%2F46%2Fjob_cisco_iosxr_ip_cfg.2019Nov05_15:46:21.813924.zip&ats=%2Fauto%2Fatom-bgl%2Fpyats_ydk&submitter=aamudhad

if I give ‘ack’ instead of ‘Ack’ and check the edit-request in local TB, it succeeds..However, ATOM throws “value unsupported” error for ‘ack’ and allows only ‘Ack’.

Data file: /ws/aamudhad-bgl/atom/atom_oct/nov_ipv6_cfg_all_cfg.yaml

        tcp_bits:

            module_name: Cisco_IOS_XR_um_access_list_datatypes

            type: TcpBitsType

            ytype: bits

            range:

            - FIN

            - SYN

            - RST

            - PSH

            - Ack

            - URG

            optional: false

            values:

            - Ack

            union_list: []

Could you please suggest on how to resolve this..

Regards,

Arul

1454: [host 173.39.55.149 session-id 990293408] Received:

1455: <?xml version="1.0"?>

1456: <rpc-reply message-id="urn:uuid:b480d700-64ce-4d97-b8f9-2b4942affea4" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

1457: <ok/>

1458: </rpc-reply>

1459: Executor operation completed

1460: CREATE operation initiated

1461: [host 173.39.55.149 session-id 990293408] Requesting '_SP_RPC'

1462: [host 173.39.55.149 session-id 990293408] Sending:

1463:

1464: #1059

1465: <rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:a5298c26-86d2-460c-9d18-eaa57cbce38d">

1466: <edit-config>

1467: <target>

1468: <candidate/>

1469: </target>

1470: <config xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">

1471: <ipv6 xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-um-ipv6-access-list-cfg">

1472: <access-lists>

1473: <access-list>

1474: <access-list-name>ipv6_access</access-list-name>

1475: <sequences>

1476: <sequence>

1477: <sequence-number>10</sequence-number>

1478: <permit>

1479: <destination>

1480: <any/>

1481: </destination>

1482: <protocol>tcp</protocol>

1483: <source>

1484: <any/>

1485: </source>

1486: <tcp-flags>

1487: <tcp-bits>Ack</tcp-bits>

1488: </tcp-flags>

1489: </permit>

1490: </sequence>

1491: </sequences>

1492: </access-list>

1493: </access-lists>

1494: </ipv6>

1495: </config>

1496: </edit-config>

1497: </rpc>

1498:

1499: ##

1500: [host 173.39.55.149 session-id 990293408] Received:

1501: <?xml version="1.0"?>

1502: <rpc-reply message-id="urn:uuid:a5298c26-86d2-460c-9d18-eaa57cbce38d" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

1503: <rpc-error>

1504: <error-type>protocol</error-type>

1505: <error-tag>bad-element</error-tag>

1506: <error-severity>error</error-severity>

1507: <error-path xmlns:ns1="http://cisco.com/ns/yang/Cisco-IOS-XR-um-ipv6-access-list-cfg">ns1:ipv6/ns1:access-lists/ns1:access-list[access-list-name = 'ipv6_access']/ns1:sequences/ns1:sequence[sequence-number = '10']/ns1:permit/ns1:tcp-flags/ns1:tcp-bits</error-path>

1508: <error-info>

1509: <bad-element>tcp-bits</bad-element>

1510: </error-info>

1511: </rpc-error>

1512: </rpc-reply>

System Information

YDK-0.5.5.post2

ygorelik commented 5 years ago

I do not understand, why capitalized values are used in your application when model API have all the bit values in lower case:

 class TcpBitsType(FixedBitsDict):

    """
    TcpBitsType

    acl tcp bits number

    Keys are:- fin , syn , rst , psh , ack , urg
    """

    def __init__(self):

        dictionary_ = {

            'fin': False,

            'syn': False,

            'rst': False,

            'psh': False,

            'ack': False,

            'urg': False,

        }

        pos_map_ = {

            'fin': 0,

            'syn': 1,

            'rst': 2,

            'psh': 3,

            'ack': 4,

            'urg': 5,

        }

        super().__init__(dictionary_, pos_map_)

Please adhere using model API as it was generated.

xulleon commented 5 years ago

The BITS value got changed to all lower case. since ATOM and YDK did not do anything, most likely the change came from INFRA team. therefore, close the case