func (pipe Pipeline) addFlowEntry(req ofp4.FlowMod) error { tableId := req.TableId() if tableId > ofp4.OFPTT_MAX { return ofp4.MakeErrorMsg( ofp4.OFPET_FLOW_MOD_FAILED, ofp4.OFPFMFC_BAD_TABLE_ID, ) } pipe.lock.Lock() defer pipe.lock.Unlock() var table *flowTable if trial, ok := pipe.flows[tableId]; ok { table = trial } else { table = &flowTable{ lock: &sync.RWMutex{}, feature: makeFlowTableFeature(), } pipe.flows[tableId] = table } return table.addFlowEntry(req, pipe) }