コード例 #1
0
ファイル: switch.go プロジェクト: yebinMoon/cherry
func (r *L2Switch) OnTopologyChange(finder network.Finder) error {
	r.log.Debug("L2Switch: OnTopologyChange..")

	// We should remove all edges from all switch devices when the network topology is changed.
	// Otherwise, installed flow rules in switches may result in incorrect packet routing based on the previous topology.
	if err := r.removeAllFlows(finder.Devices()); err != nil {
		return err
	}

	return r.BaseProcessor.OnTopologyChange(finder)
}
コード例 #2
0
ファイル: arp.go プロジェクト: yebinMoon/cherry
func (r *ProxyARP) broadcastARPAnnouncement(finder network.Finder, vips []VIP) {
	for _, v := range vips {
		for _, d := range finder.Devices() {
			if err := d.SendARPAnnouncement(v.Address, v.MAC); err != nil {
				r.log.Err(fmt.Sprintf("ProxyARP: failed to broadcast ARP announcement: %v", err))
				continue
			}
		}
		r.log.Info(fmt.Sprintf("ProxyARP: toggled VIP %v to %v", v.Address, v.MAC))
	}
}