ovs vtep 源码Tunnel_Ip
Tunnel_Ip
def setup(): br_list = ovs_vsctl("list-br").split() if (ps_name not in br_list): ovs.util.ovs_fatal(0, "couldn't find OVS bridge %s" % ps_name, vlog) global ps_type ps_type = ovs_vsctl("get Bridge %s datapath_type" % ps_name).strip('"') call_prog("vtep-ctl", ["set", "physical_switch", ps_name, 'description="OVS VTEP Emulator"']) tunnel_ips = vtep_ctl("get physical_switch %s tunnel_ips" % ps_name).strip('[]"').split(", ") if len(tunnel_ips) != 1 or not tunnel_ips[0]: ovs.util.ovs_fatal(0, "exactly one 'tunnel_ips' should be set", vlog) global Tunnel_Ip Tunnel_Ip = tunnel_ips[0]
[root@kunpeng82 scripts]# vtep-ctl get physical_switch br0 tunnel_ips ["192.168.16.81"] [root@kunpeng82 scripts]#
class Logical_Switch(object): def setup_ls(self): if ps_type: ovs_vsctl("--may-exist add-br %s -- set Bridge %s datapath_type=%s" % (self.short_name, self.short_name, ps_type)) else: ovs_vsctl("--may-exist add-br %s" % self.short_name) ovs_vsctl("br-set-external-id %s vtep_logical_switch true" % self.short_name) ovs_vsctl("br-set-external-id %s logical_switch_name %s" % (self.short_name, self.name)) vtep_ctl("clear-local-macs %s" % self.name) vtep_ctl("add-mcast-local %s unknown-dst %s" % (self.name, Tunnel_Ip)) 每个loggis swtich 的多播 ovs_ofctl("del-flows %s" % self.short_name) ovs_ofctl("add-flow %s priority=0,action=drop" % self.short_name)
[root@kunpeng82 scripts]# vtep-ctl list-local-macs ls2 ucast-mac-local mcast-mac-local unknown-dst -> vxlan_over_ipv4/192.168.16.81 [root@kunpeng82 scripts]# vtep-ctl list-local-macs ls0 ucast-mac-local mcast-mac-local unknown-dst -> vxlan_over_ipv4/192.168.16.81 [root@kunpeng82 scripts]#