Notice: Constant WP_DEBUG already defined in /var/www/html/wordpress/wp-content/plugins/changyan/sohuchangyan.php on line 12

Notice: Constant WP_DEBUG_LOG already defined in /var/www/html/wordpress/wp-content/plugins/changyan/sohuchangyan.php on line 13

Notice: Constant WP_DEBUG_DISPLAY already defined in /var/www/html/wordpress/wp-content/plugins/changyan/sohuchangyan.php on line 14
如何使用ODL的bulk-o-matic下发多条流表?【zoues.com】 – zoues

LOADING

Follow me

如何使用ODL的bulk-o-matic下发多条流表?【zoues.com】
六月 6, 2017|ITPaaSSDN

如何使用ODL的bulk-o-matic下发多条流表?【zoues.com】

如何使用ODL的bulk-o-matic下发多条流表?【zoues.com】

作者简介:刘敬一,盛科网络SDN交换机产品线测试主管

之前分享过《如何用postman控制ODL查看和下发流表》。但是在实际应用中,经常会遇到需要下发大量流表的情况。ODL的bulk-o-matic组件可以帮助我们实现这个需求。

准备工作

  • Ubuntu 14.04.4 LTS
  • java version “1.8.0_91”
  • distribution-karaf-0.5.2-Boron-SR2
  • Curl & Postman

安装

  • 解压distribution-karaf-0.5.2-Boron-SR2.zip后启动ODL,安装下列组件

    1
    2
    3
    4
    5
    6
    7
    opendaylightuser@root>feature:install odlrestconf
    opendaylightuser@root>feature:install odll2switchswitch
    opendaylightuser@root>feature:install odlmdsalapidocs
    opendaylightuser@root>feature:install odlmdsalall
    opendaylightuser@root>feature:install odlopenflowpluginappbulkomatic
    opendaylightuser@root>feature:install odldluxall
    opendaylightuser@root>

  • 确认组件安装成功:

    1
    2
    3
    4
    opendaylightuser@root>feature:list | grep “bulk-o-matic”
    odlopenflowpluginappbulkomatic              | 0.3.2BoronSR2  | x         | openflowplugin0.3.2BoronSR2              | OpenDaylight :: Openflow Plugin :: Application   
    odlopenflowpluginappbulkomatiche           | 0.3.2BoronSR2  |           | openflowpluginhe0.3.2BoronSR2           | OpenDaylight :: Openflow Plugin :: app bulk flow o
    opendaylightuser@root>

  • 连接OpenFlow换机,查看交换机上的流表:

    1
    2
    3
    4
    5
    DUT1# ovs-ofctl  dump-flows br0 -O openflow13
    OFPST_FLOW reply (OF1.3) (xid=0x2):
    cookie=0x2b00000000000000, duration=1551.307s, table=0, n_packets=0, n_bytes=0, priority=100,dl_type=0x88cc actions=CONTROLLER:65535
    cookie=0x2b00000000000000, duration=1551.309s, table=0, n_packets=0, n_bytes=0, priority=0 actions=drop
    DUT1#

  • 在ODL的WebUI上可以看到连上的交换机,并获取OVS的dpid=openflow:128983239877。

准备xml文件

  • 创建一个文件test.xml,写入下面内容:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    <?xml version=“1.0” encoding=“UTF-8” standalone=“no”?>
    <input xmlns=“urn:opendaylight:bulk-flow:service”>
    <bulkflowdsitem>
        <flowname>test_1</flowname>
        <flowid>31#-0</flow-id>
        <node xmlns:inv=“urn:opendaylight:inventory”>/inv:nodes/inv:node[inv:id=“openflow:128983239877”]</node>
        <barrier>false</barrier>
        <strict>false</strict>
        <hardtimeout>0</hardtimeout>
        <idletimeout>0</idletimeout>
        <priority>980</priority>
        <table_id>0</table_id>
        <cookie>16</cookie>
        <cookie_mask>255</cookie_mask>
        <match>
           <ethernetmatch>
                   <ethernettype>
                   <type>2048</type>
                 </ethernettype>
           </ethernetmatch>
           <ipmatch>
            <ipprotocol>6</ipprotocol>        
            </ipmatch>
            <tcpdestinationport>80</tcpdestinationport>
               <inport>openflow:128983239877:1</inport>
    </match>
        <instructions>
            <instruction>
                <order>0</order>
                <applyactions>
                            <action>
                        <order>0</order>
                        <outputaction>
                            <outputnodeconnector>openflow:128983239877:2</outputnodeconnector>
                        </outputaction>
                        </action>
                </applyactions>
            </instruction>
        </instructions>
    </bulkflowdsitem>
    <bulkflowdsitem>
        <flowname>test_2</flowname>
        <flowid>32#-0</flow-id>
        <node xmlns:inv=“urn:opendaylight:inventory”>/inv:nodes/inv:node[inv:id=“openflow:128983239877”]</node>
        <barrier>false</barrier>
        <strict>false</strict>
        <hardtimeout>0</hardtimeout>
        <idletimeout>0</idletimeout>
        <priority>980</priority>
        <table_id>0</table_id>
        <cookie>16</cookie>
        <cookie_mask>255</cookie_mask>
        <match>
           <ethernetmatch>
                   <ethernettype>
                   <type>2048</type>
                 </ethernettype>
           </ethernetmatch>
           <ipmatch>
            <ipprotocol>6</ipprotocol>        
            </ipmatch>
            <tcpdestinationport>443</tcpdestinationport>
               <inport>openflow:128983239877:1</inport>
    </match>
        <instructions>
            <instruction>
                <order>0</order>
                <applyactions>
                            <action>
                        <order>0</order>
                        <outputaction>
                            <outputnodeconnector>openflow:128983239877:2</outputnodeconnector>
                        </outputaction>
                        </action>
                </applyactions>
            </instruction>
        </instructions>
    </bulkflowdsitem>
    </input>

下发流表

  • 可以使用curl进行下发流表:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
centec@ubuntuonos80:~/Applications$ curl v H “Expect:” H “Content-Type: application/xml; charset=UTF-8” X POST d @test.xml http://admin:admin@10.10.11.80:8181/restconf/operations/sal-bulk-flow:add-flows-ds
* Hostname was NOT found in DNS cache
*   Trying 10.10.11.80…
* Connected to 10.10.11.80 (10.10.11.80) port 8181 (#0)
* Server auth using Basic with user ‘admin’
> POST /restconf/operations/salbulkflow:addflowsds HTTP/1.1
> Authorization: Basic YWRtaW46YWRtaW4=
> UserAgent: curl/7.35.0
> Host: 10.10.11.80:8181
> Accept: */*
> ContentType: application/xml; charset=UTF8
> ContentLength: 2533
>
* upload completely sent off: 2533 out of 2533 bytes
< HTTP/1.1 200 OK
< SetCookie: JSESSIONID=1l76a46cmwjooy3b6r9bc2g7u;Path=/restconf
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< SetCookie: rememberMe=deleteMe; Path=/restconf; MaxAge=0; Expires=Tue, 23May2017 00:45:23 GMT
< ContentType: application/yang.operation+json
< ContentLength: 0
* Server Jetty(8.1.19.v20160209) is not blacklisted
< Server: Jetty(8.1.19.v20160209)
<
* Connection #0 to host 10.10.11.80 left intact
centec@ubuntuonos80:~/Applications$

  • 或者 使用postman下发,将test.xml的内容,复制粘贴到postman的body,send POST。

如何使用ODL的bulk-o-matic下发多条流表?

  • 效果相同,都会添加xml描述的两条流表:

    1
    2
    3
    4
    5
    6
    7
    DUT1# ovs-ofctl  dump-flows br0 -O openflow13
    OFPST_FLOW reply (OF1.3) (xid=0x2):
    cookie=0x10, duration=1.6s, table=0, n_packets=0, n_bytes=0, priority=980,tcp,in_port=1,tp_dst=80 actions=output:2
    cookie=0x10, duration=1.598s, table=0, n_packets=0, n_bytes=0, priority=980,tcp,in_port=1,tp_dst=443 actions=output:2
    cookie=0x2b00000000000000, duration=1562.955s, table=0, n_packets=0, n_bytes=0, priority=100,dl_type=0x88cc actions=CONTROLLER:65535
    cookie=0x2b00000000000000, duration=1562.957s, table=0, n_packets=0, n_bytes=0, priority=0 actions=drop
    DUT1#

删除流表

  • 依然使用curl或是postman来send DELETE:

    1
    http://10.10.11.80:8181/restconf/config/opendaylight-inventory:nodes/node/openflow:128983239877/flow-node-inventory:table/0

    *查看交换机,上步添加的指定流表被删除了。

    1
    2
    3
    4
    5
    DUT1# ovs-ofctl  dump-flows br0 -O openflow13
    OFPST_FLOW reply (OF1.3) (xid=0x2):
    cookie=0x2b00000000000000, duration=1551.307s, table=0, n_packets=0, n_bytes=0, priority=100,dl_type=0x88cc actions=CONTROLLER:65535
    cookie=0x2b00000000000000, duration=1551.309s, table=0, n_packets=0, n_bytes=0, priority=0 actions=drop
    DUT1#

扩展

  • 上面举例的xml中包含两条流表,很容易扩展到添加更多的流表,每条流表放在之间即可。
  • 添加流表的问题,就转换成写xml文件的问题,这个大家就可以各显神通了。

补充说明

  • 我也曾经尝试使用更习惯的JSON来写test.json,可是发现和用yangui一样,都会报错;
    如何使用ODL的bulk-o-matic下发多条流表?
  • 用谷歌也没有搜出有用的信息,怀疑是ODL的bug;
  • 如果哪位知道如何解决,还望不吝赐教。
no comments
Share