[ovs] openvswitch 入门

https://www.sdnlab.com/sdn-guide/14747.html

http://sdnhub.cn/index.php/openv-switch-full-guide/

http://www.rendoumi.com/open-vswitchde-ovs-vsctlming-ling-xiang-jie/

http://www.openvswitch.org/support/dist-docs/ovs-vsctl.8.txt

 

openvswitch完全使用手册:

https://www.cnblogs.com/puremans/p/6562388.html

 

很重要很典型的vxlan设置:

http://docs.openvswitch.org/en/latest/howto/userspace-tunneling/

 

ovs-ofctl 语法

http://www.rendoumi.com/open-vswitchzhong-ovs-ofctlde-xiang-xi-yong-fa/

http://www.openvswitch.org/support/dist-docs/ovs-ofctl.8.txt

摘要:

       priority=value
              The  priority  at  which  a wildcarded entry will match in comparison to others.  value is a number between 0 and 65535, inclusive.  A higher value will match before a lower one.  An exact-
              match entry will always have priority over an entry containing wildcards, so it has an implicit priority value of 65535.  When adding a flow, if the field is not specified, the flow's  pri‐
              ority will default to 32768.

              OpenFlow  leaves  behavior  undefined  when  two or more flows with the same priority can match a single packet.  Some users expect ``sensible'' behavior, such as more specific flows taking
              precedence over less specific flows, but OpenFlow does not specify this and Open vSwitch does not implement it.  Users should therefore take care to use priorities to  ensure  the  behavior
              that they expect.

 

       table=number
              For flow dump commands, limits the flows dumped to those in the table with the given number between 0 and 254.  If not specified (or if 255 is specified as number), then flows in all tables
              are dumped.

 

关键流表

#add bridge and setup tunnel
ovs-vsctl --may-exist add-br br0
ovs-vsctl add-port br0 vxlantarget1 -- set interface vxlantarget1 type=vxlan options:remote_ip=$TARGET_REMOTE_1 options:local_ip=$VXLAN_LOCALIP options:in_key=flow options:out_key=flow 
ovs-vsctl add-port br0 vxlantarget2 -- set interface vxlantarget2 type=vxlan options:remote_ip=$TARGET_REMOTE_2 options:local_ip=$VXLAN_LOCALIP options:in_key=flow options:out_key=flow 
ovs-vsctl add-port br0 vxlanclient1 -- set interface vxlanclient1 type=vxlan options:remote_ip=$CLIENT_REMOTE_1 options:local_ip=$VXLAN_LOCALIP options:in_key=flow options:out_key=flow 
#ovs-vsctl set port veth0-10 tag=20

 

#in
$OVS_OFCTL add-flow br0 "cookie=0x1111,table=0, priority=100, tun_id=$VNI,dl_dst=$NLB_MAC,nw_dst=$NLB_VIP,actions=move:NXM_NX_TUN_ID[0..23]->NXM_NX_REG0[0..23],resubmit(,1)"
$OVS_OFCTL add-flow br0 "cookie=0x2222,table=1, priority=100, actions=move:NXM_NX_REG0[0..23]->NXM_OF_ETH_SRC[24..47],output:$nlbnet1_port"

#out
$OVS_OFCTL add-flow br0 "cookie=0x3333,table=0, priority=100, in_port=$nlbnet1_port,dl_dst=$TARGET_MAC_1,actions=move:NXM_OF_ETH_SRC[24..47]->NXM_NX_TUN_ID[0..23],output:$vxlantarget1_port"

$OVS_OFCTL add-flow br0 "cookie=0x4444,table=0, priority=100, in_port=$nlbnet1_port,dl_dst=$TARGET_MAC_2,actions=move:NXM_OF_ETH_SRC[24..47]->NXM_NX_TUN_ID[0..23],output:$vxlantarget2_port"

 

 

ovs 所有options选项的文档

[root@vrouter1 ~]# man ovs-vswitchd.conf.db
       Each  tunnel  must be uniquely identified by the combination of type, options:remote_ip, options:local_ip, and options:in_key. If two ports are defined that are the same except one has an optional
       identifier and the other does not, the more specific one is matched first. options:in_key is considered more specific than options:local_ip if a port defines  one  and  another  port  defines  the
       other.
。。。 。。。
       options : in_key: optional string
              Optional. The key that received packets must contain, one of:

              ·      0. The tunnel receives packets with no key or with a key of 0. This is equivalent to specifying no options:in_key at all.

              ·      A positive 24-bit (for Geneve, VXLAN, and LISP), 32-bit (for GRE) or 64-bit (for STT) number. The tunnel receives only packets with the specified key.

              ·      The word flow. The tunnel accepts packets with any key. The key will be placed in the tun_id field for matching in the flow table.  The  ovs-ofctl  manual  page  contains  additional
                     information about matching fields in OpenFlow flows.

       options : out_key: optional string
              Optional. The key to be set on outgoing packets, one of:

              ·      0. Packets sent through the tunnel will have no key. This is equivalent to specifying no options:out_key at all.

              ·      A positive 24-bit (for Geneve, VXLAN and LISP), 32-bit (for GRE) or 64-bit (for STT) number. Packets sent through the tunnel will have the specified key.

              ·      The word flow. Packets sent through the tunnel will have the key set using the set_tunnel Nicira OpenFlow vendor extension (0 is used in the absence of an action). The ovs-ofctl man‐
                     ual page contains additional information about the Nicira OpenFlow vendor extensions.

       options : key: optional string
              Optional. Shorthand to set in_key and out_key at the same time.

 

posted on 2018-05-07 18:11  toong  阅读(649)  评论(0编辑  收藏  举报