// startIML starts the MAC listener. func (b *Bridge) startIML() { // use openflow to redirect arp and icmp6 traffic to the local tap filters := []string{ "dl_type=0x0806,actions=local,normal", "dl_type=0x86dd,nw_proto=58,icmp_type=135,actions=local,normal", } for _, filter := range filters { if err := addOpenflow(b.Name, filter); err != nil { log.Error("cannot start ip learner on bridge: %v", err) return } } iml, err := ipmac.NewLearner(b.Name) if err != nil { log.Error("cannot start ip learner on bridge: %v", err) return } b.iml = iml }
func (b *bridge) startIML() error { if b.iml != nil { return nil } // use openflow to redirect arp and icmp6 traffic to the local tap var sOut bytes.Buffer var sErr bytes.Buffer p := process("openflow") cmd := &exec.Cmd{ Path: p, Args: []string{ p, "add-flow", b.Name, "dl_type=0x0806,actions=local,normal", }, Env: nil, Dir: "", Stdout: &sOut, Stderr: &sErr, } log.Debug("adding arp flow with cmd: %v", cmd) ovsLock.Lock() err := cmd.Run() ovsLock.Unlock() if err != nil { e := fmt.Errorf("openflow: %v: %v", err, sErr.String()) return e } cmd = &exec.Cmd{ Path: p, Args: []string{ p, "add-flow", b.Name, "dl_type=0x86dd,nw_proto=58,icmp_type=135,actions=local,normal", }, Env: nil, Dir: "", Stdout: &sOut, Stderr: &sErr, } log.Debug("adding icmp6 ND flow with cmd: %v", cmd) ovsLock.Lock() err = cmd.Run() ovsLock.Unlock() if err != nil { e := fmt.Errorf("openflow: %v: %v", err, sErr.String()) return e } iml, err := ipmac.NewLearner(b.Name) if err != nil { return fmt.Errorf("cannot start ip learner on bridge: %v", err) } b.Lock.Lock() b.iml = iml b.Lock.Unlock() return nil }